Skip to content
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

Add stamp attribute to pkg_tar (in the style of cc_binary(stamp=-1,0,1) #288

Merged
merged 19 commits into from
May 6, 2021

Conversation

aiuto
Copy link
Collaborator

@aiuto aiuto commented Feb 4, 2021

Part 1 of #287 This is not pretty, because Bazel does not make --stamp available directly

  • add a config setting to mimic --stamp: private_stamp_detect
  • add the stamp attribute to pkg_tar
  • use combination of stamp & private_stamp_detect to invoke stamping
  • this uses an undocumented feature to get to bazel-out/volatile-status.txt
    • that is bad in theory
    • In practice Bazel will eventually have admit the cat is out of the bag and document the files.

Future work:

  • implement for all 4 package types.
  • contain a test where a stamped package is used from a workspace that includes rules_pkg.

RELNOTES: Add stamp to pkg_tar.

This is hack upon hack, because Bazel does not make --stamp available directly

- add a config setting to mimic --stamp.
  - This should be available directly from starlark ctx
  - use the setting to pass a flag to the packager to stamp
- have a genrule to copy volatile-status.txt
  We need this because the packagers can not read it otherwise.
  - genrule has the 'stamp' attribute, which makes bazel-out/volatile-status.txt availble to it
  - we can copy it to a new place that other rules can see
  - This is tedious and not portable, bazel should make it available diretly.
- have pkg_tar implicitly depend on the status file
  - if the builder gets the flag, read the status file to get a time.

But actually using the time is not implemented.
@aiuto aiuto added P3 An issue that we are not working on but will review quarterly WIP labels Feb 4, 2021
@aiuto aiuto changed the title Demonstrate how to make --stamp work Add stamp attribute to pkg_tar May 3, 2021
@aiuto aiuto changed the title Add stamp attribute to pkg_tar Add stamp attribute to pkg_tar (in the style of cc_binary(stamp=-1,0,1) May 3, 2021
@aiuto aiuto added P2 An issue that should be worked on when time is available and removed WIP P3 An issue that we are not working on but will review quarterly labels May 3, 2021
@aiuto aiuto requested a review from nacl May 3, 2021 21:57
@aiuto
Copy link
Collaborator Author

aiuto commented May 3, 2021

@nacl This is ready now. It's not as ugly as I thought it would be.

Copy link
Collaborator

@nacl nacl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- not particularly ugly, other than the private_stamp_detect attribute.

Most comments other than about private_stamp_detect are mostly nits and documentation suggestions.

Also needs a rebase/merge against main.

examples/time_stamping/BUILD Show resolved Hide resolved
examples/time_stamping/WORKSPACE Outdated Show resolved Hide resolved
examples/time_stamping/readme.md Show resolved Hide resolved
examples/time_stamping/readme.md Show resolved Hide resolved
pkg/private/build_info.py Outdated Show resolved Hide resolved
pkg/pkg.bzl Show resolved Hide resolved
pkg/tests/stamp_test.py Show resolved Hide resolved
pkg/tests/stamp_test.py Show resolved Hide resolved
pkg/tests/stamp_test.py Show resolved Hide resolved
pkg/tests/BUILD Show resolved Hide resolved
@aiuto aiuto added P1 An issue that must be resolved. Must have an assignee and removed P2 An issue that should be worked on when time is available labels May 6, 2021
@aiuto aiuto merged commit 1b031fd into bazelbuild:main May 6, 2021
@aiuto aiuto deleted the stamp branch May 6, 2021 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 An issue that must be resolved. Must have an assignee
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants