summaryrefslogtreecommitdiff
path: root/build_extra/rust/get_version_hash.py
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2018-08-26 06:17:02 +0200
committerBert Belder <bertbelder@gmail.com>2018-08-26 19:22:37 +0200
commit224cfc8c74133a6b4fe6c9e96a90925ebaf066aa (patch)
tree6a02023ba3a2a1205a84858f3f1aa8bf903450a5 /build_extra/rust/get_version_hash.py
parentdfcde3e1eecc03a97d9e395ee9e61b7e03f1354d (diff)
build: fix rust temp file conflicts during parallel build
Diffstat (limited to 'build_extra/rust/get_version_hash.py')
-rw-r--r--build_extra/rust/get_version_hash.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/build_extra/rust/get_version_hash.py b/build_extra/rust/get_version_hash.py
new file mode 100644
index 000000000..7d37cbf9b
--- /dev/null
+++ b/build_extra/rust/get_version_hash.py
@@ -0,0 +1,14 @@
+# Copyright 2018 the Deno authors. All rights reserved. MIT license.
+
+# This script computes the sha256sum of the first command line argument, and
+# writes a few hex digits of it to stdout. It is used by rust.gni to derive a
+# unique string (without dots/special characters) from a crate version number.
+
+from hashlib import sha256
+import sys
+
+if len(sys.argv) != 2:
+ raise Exception('Expected exactly one argument.')
+
+hash = sha256(sys.argv[1]).hexdigest()
+sys.stdout.write(hash[0:8])