Created
April 27, 2017 05:00
-
-
Save jayeye/14c91816d10d5b899e1baaaaa9ba4848 to your computer and use it in GitHub Desktop.
stamping with build information. Obviously, replace _slash_ in the filenames with an actual slash!
This file contains hidden or 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
from pprint import pprint | |
import buildinfo | |
pprint(buildinfo.buildinfo) |
This file contains hidden or 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
package(default_visibility = ["//visibility:public"]) | |
genrule( | |
name = "genpybuildinfo", | |
outs = [ | |
"buildinfo.py", | |
], | |
stamp = 1, | |
cmd = "./$(location tools/mkpybuildinfo.sh) > \"$@\"", | |
tools = [ | |
"tools/mkpybuildinfo.sh", | |
], | |
) | |
py_library( | |
name = "buildinfo", | |
srcs = [ | |
":genpybuildinfo", | |
], | |
) | |
# Use this for testing, remove in production! | |
py_binary( | |
name = "bi", | |
srcs = [ | |
"bi.py", | |
], | |
deps = [ | |
":buildinfo", | |
], | |
) |
This file contains hidden or 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
build --workspace_status_command=./tools/mkstamp.sh |
This file contains hidden or 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
#!/bin/sh | |
cat << @EOF | |
_status = ''' | |
$(cat bazel-out/stable-status.txt bazel-out/volatile-status.txt) | |
''' | |
buildinfo = dict() | |
for l in _status.splitlines(): | |
ll = l.strip().split(None, 1) | |
if len(ll) == 2: | |
buildinfo[ll[0]] = ll[1] |
This file contains hidden or 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
#!/bin/sh | |
echo BUILD_DATE $(TZ=Etc/UTC date -Iseconds) | |
echo BUILD_SCM_HASH $(git rev-parse HEAD) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment