bazelbuild / bazel-skylib

Common useful functions and rules for Bazel
https://bazel.build/
Apache License 2.0
393 stars 180 forks source link

Add `env` and `env_inherit` to `native_binary` and `native_test` #482

Closed redsun82 closed 3 months ago

redsun82 commented 9 months ago

This relies on the RunEnvironmentInfo that was introduced in bazel 5.3.0. To keep the library compatible with previous versions, a new bazel_skylib_globals is added that will provide a None definition of RunEnvironmentInfo if still unavailable.

This is inspired by bazel_features: while using that directly would be easy with bzlmod integration, for the legacy workspace-based integration would suffer, as bazel_skylib_workspace would only be able to bring bazel_features in the workspace, but then one would have to call bazel_features_deps() as well after loading it.

If updating the legacy worksapce integration instructions with the above addition is deemed ok, one could bring that additionally dependency in. Otherwise I just added the necessary code to inspect the version (with the painful external repo workaround) directly in here.

Closes https://github.com/bazelbuild/bazel-skylib/issues/409