-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[rfc] Allow repository rules to lazily declare environment variable deps #20787
[rfc] Allow repository rules to lazily declare environment variable deps #20787
Conversation
I reviewed the test failures, and they don't appear to be related to my changes. I don't think my change introduced thread/synchronization bugs, but I need to defer to the experts.
|
Thanks for the PR! I'll take a look in a minute. Anyhow the test failures are definitely unrelated; see #20790 |
...ava/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java
Outdated
Show resolved
Hide resolved
...ava/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java
Show resolved
Hide resolved
...ava/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkBaseExternalContext.java
Outdated
Show resolved
Hide resolved
...java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryFunction.java
Outdated
Show resolved
Hide resolved
This commit adds a new repository context method, `getenv`, which allows Starlark repository rule implementations to lazily declare environment variable dependencies. This is intended to allow repository rules to establish dependencies on environment variables whose names aren't known in advance. This is work towards bazelbuild#19511. Notes ===== - I don't speak Java, so expect funny smells and copypasta. - `rctx.getenv` behaves similarly to Python's `os.getenv`. - `rctx.getenv` is to environment variables what `rctx.path(Label)` is to files. Future work =========== - Implement bzlmod support.
04f5939
to
7202924
Compare
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.
thanks!
@bazel-io flag |
@bazel-io fork 7.1.0 |
…riable deps (#20944) This commit adds a new repository context method, `getenv`, which allows Starlark repository rule implementations to lazily declare environment variable dependencies. This is intended to allow repository rules to establish dependencies on environment variables whose names aren't known in advance. This is work towards #19511. Notes ===== - I don't speak Java, so expect funny smells and copypasta. - `rctx.getenv` behaves similarly to Python's `os.getenv`. - `rctx.getenv` is to environment variables what `rctx.path(Label)` is to files. Future work =========== - Implement bzlmod support. RELNOTES: Added a new method `repository_ctx.getenv`, which allows Starlark repository rules to declare environment variable dependencies during the fetch, instead of upfront using `repository_rule.environ`. Closes #20787. Commit c230e39 PiperOrigin-RevId: 599568358 Change-Id: I2c1948cd23643d28bf1d41e9baaf98a902112cc7 Co-authored-by: Ryan Beasley <beasleyr@vmware.com>
What happens if one downgrades the Bazel version in an existing output base from one that supports the |
@lberki Just to make sure I understand correctly, the With that, consider the following sequence of events:
If the user downgrades Bazel to an older version, they'll have to revert their repository rule definition (because Does that sound right? Am I missing anything? |
No, you are not missing anything -- I didn't realize in my (very literal) fever dream that resulted in the above comment that |
This commit adds a new repository context method,
getenv
, which allows Starlark repository rule implementations to lazily declare environment variable dependencies. This is intended to allow repository rules to establish dependencies on environment variables whose names aren't known in advance.This is work towards #19511.
Notes
rctx.getenv
behaves similarly to Python'sos.getenv
.rctx.getenv
is to environment variables whatrctx.path(Label)
is to files.Future work