File tree Expand file tree Collapse file tree
rules/computed_dependencies Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,11 +44,28 @@ def _impl(ctx):
4444
4545 # Compute the hash
4646 out = ctx .outputs .text
47- ctx .actions .run_shell (
47+ hasher = ctx .actions .declare_file (ctx .label .name + "_hasher.py" )
48+ ctx .actions .write (
49+ output = hasher ,
50+ content = """
51+ import hashlib
52+ import sys
53+
54+ with open(sys.argv[1], 'rb') as f:
55+ data = f.read()
56+ md5 = hashlib.md5(data).hexdigest()
57+
58+ with open(sys.argv[2], 'w') as f:
59+ f.write(md5)
60+ """ ,
61+ )
62+
63+ ctx .actions .run (
4864 outputs = [out ],
49- inputs = [processed ],
50- use_default_shell_env = True ,
51- command = "md5sum < %s > %s" % (processed .path , out .path ),
65+ inputs = [processed , hasher ],
66+ executable = "python3" ,
67+ arguments = [hasher .path , processed .path , out .path ],
68+ mnemonic = "ComputeHash" ,
5269 )
5370
5471_md5_sum = rule (
You can’t perform that action at this time.
0 commit comments