-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #317 from Zemnmez/version-pipelining
version pipelining
- Loading branch information
Showing
7 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# no output defined here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
def _impl(ctx): | ||
# Create actions to generate the three output files. | ||
# Actions are run only when the corresponding file is requested. | ||
|
||
inputs = ctx.files.srcs | ||
arguments = [ file.path for file in ctx.files.srcs ] | ||
|
||
ctx.actions.run_shell( | ||
outputs = [ctx.outputs.md5], | ||
inputs = inputs, | ||
command = "md5sum $@ > {}".format( ctx.outputs.md5.path), | ||
arguments = arguments, | ||
) | ||
|
||
ctx.actions.run_shell( | ||
outputs = [ctx.outputs.sha1], | ||
inputs = inputs, | ||
command = "sha1sum $@ > {}".format( ctx.outputs.sha1.path), | ||
arguments = arguments, | ||
) | ||
|
||
ctx.actions.run_shell( | ||
outputs = [ctx.outputs.sha256], | ||
inputs = inputs, | ||
command = "sha256sum $@ > {}".format( ctx.outputs.sha256.path), | ||
arguments = arguments, | ||
) | ||
|
||
# By default (if you run `bazel build` on this target, or if you use it as a | ||
# source of another target), only the sha256 is computed. | ||
return DefaultInfo(files = depset([ctx.outputs.sha256])) | ||
|
||
_hashes = rule( | ||
implementation = _impl, | ||
attrs = { | ||
"srcs": attr.label_list(mandatory = True, allow_files = True), | ||
"md5": attr.output(), | ||
"sha1": attr.output(), | ||
"sha256": attr.output(), | ||
}, | ||
) | ||
|
||
def hashes(**kwargs): | ||
name = kwargs["name"] | ||
_hashes( | ||
md5 = "%s.md5" % name, | ||
sha1 = "%s.sha1" % name, | ||
sha256 = "%s.sha256" % name, | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("//bzl/hash:rules.bzl", "hashes") | ||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") | ||
|
||
hashes( | ||
name = "hashes", | ||
srcs = [ "input1.txt", "input2.txt" ] | ||
) | ||
|
||
generated_file_test( | ||
name = "version_concat_test", | ||
generated = ":hashes", | ||
src = "expected.txt" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 bzl/hash/test/input1.txt | ||
486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7 bzl/hash/test/input2.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
world |