-
Notifications
You must be signed in to change notification settings - Fork 221
Extend pkg_tar rule with stamp_mtime attribute #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Define workspace status command for stamp_mtime attribute in pkg_tar rule | ||
| test --workspace_status_command=./tests/workspace_status.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,12 +90,28 @@ def _pkg_tar_impl(ctx): | |
| "--owner=" + ctx.attr.owner, | ||
| "--owner_name=" + ctx.attr.ownername, | ||
| ] | ||
| stamp_inputs = [] | ||
| if ctx.attr.mtime != _DEFAULT_MTIME: | ||
| if ctx.attr.portable_mtime: | ||
| fail("You may not set both mtime and portable_mtime") | ||
| if ctx.attr.stamp_mtime: | ||
| fail("You may not set both mtime and stamp_mtime") | ||
| args.append("--mtime=%d" % ctx.attr.mtime) | ||
| if ctx.attr.portable_mtime: | ||
| if ctx.attr.stamp_mtime: | ||
| fail("You may not set both portable_mtime and stamp_mtime") | ||
| args.append("--mtime=portable") | ||
| if ctx.attr.stamp_mtime: | ||
| # Only ctx.version_file for file volatile-status.txt is needed | ||
| # because change of key/value should not invalid existing build | ||
| stamp_inputs += [ctx.version_file] | ||
| stamp_mtime_strip = ctx.attr.stamp_mtime.strip() | ||
| if not stamp_mtime_strip.startswith("{") or not stamp_mtime_strip.endswith("}"): | ||
| fail("You set stamp_mtime, but this doesn't contain a valid key variable") | ||
|
Comment on lines
+108
to
+110
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just use BUILD_STAMP. We don't need the flexibility to let the user set an arbitrary variable out of the volatile status file. This adds complexity that no one asked for. |
||
| # Add mtime with stamped mtime variable | ||
| args.append("--mtime=%s" % stamp_mtime_strip) | ||
| # Add volatile-status.txt file as argument | ||
| args.append("--workspace_status_file=%s" % ctx.version_file.path) | ||
|
|
||
| # Add runfiles if requested | ||
| file_inputs = [] | ||
|
|
@@ -162,7 +178,7 @@ def _pkg_tar_impl(ctx): | |
| ctx.actions.run( | ||
| mnemonic = "PackageTar", | ||
| progress_message = "Writing: %s" % output_file.path, | ||
| inputs = file_inputs + ctx.files.deps + files, | ||
| inputs = file_inputs + ctx.files.deps + files + stamp_inputs, | ||
| executable = ctx.executable.build_tar, | ||
| arguments = ["@" + arg_file.path], | ||
| outputs = [output_file], | ||
|
|
@@ -322,6 +338,7 @@ pkg_tar_impl = rule( | |
| "modes": attr.string_dict(), | ||
| "mtime": attr.int(default = _DEFAULT_MTIME), | ||
| "portable_mtime": attr.bool(default = True), | ||
| "stamp_mtime": attr.string(), | ||
| "owner": attr.string(default = "0.0"), | ||
| "ownername": attr.string(default = "."), | ||
| "owners": attr.string_dict(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| STAMP_MTIME 946684741 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env bash | ||
| stamp_mtime=946684741 # 1999-12-31, 23:58:01 | ||
| cat << EOF | ||
| STAMP_MTIME ${stamp_mtime} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be BUILD_TIMESTAMP |
||
| EOF | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this using a different name than BUILD_TIMESTAMP?
But really, this should be a bool. Either stamp the time found in BUILD_TIMESTAMP or use the portable time.