buildbuddy-io / buildbuddy-toolchain

Bazel toolchains for BuildBuddy RBE
MIT License
12 stars 12 forks source link

Add environment variable override for external_cc #13

Closed tempoz closed 10 months ago

tempoz commented 10 months ago

In order to be able to control this behavior via flags, we must support an environment variable override. At the stage where repository_rules can be called, the workspace loading stage, you are not allowed to use config_setting or select, so even if the end user of this repo were to make a flag or a build_setting that depended on an environment variable, they still could not change the value of external_cc without directly modifying their WORKSPACE or an imported .bzl file.

To that end, we introduce the BUILDBUDDY_TOOLCHAIN_OVERRIDE_USE_EXTERNAL_CC environment variable. Set it to 1 to enable external_cc, or 0 to disable it. As the name suggests, if it exists, it will override any value passed into the repository rule.

siggisim commented 10 months ago

This feels like kind of random / arbitrary complexity to be adding to our toolchain. All this is doing is choosing a platform, which is like 9 lines of code and can be defined outside of this toolchain: https://www.buildbuddy.io/docs/rbe-platforms#using-a-custom-docker-image

I also don't really like the idea of having to set random environment variables to modify toolchain behavior.

siggisim commented 10 months ago

I think even https://github.com/buildbuddy-io/buildbuddy-toolchain/commit/a88ae46d4a9ae0043f3c79a28ffa91831b7ebed5 might have been a mistake, since a custom platform can just be defined in the repo instead.