Reputation: 177
I hope this is a simple question :) In bazel, I can select a config_setting
by specifying --define K=V
passed from the command line. How can I create a library in my BUILD.bazel that "sets" this config_setting
without the need to specify it from command line?
Upvotes: 3
Views: 5021
Reputation: 12000
Some rules have an env
argument, so you can do f.e.:
sh_binary(
name = "target",
...
env = {
"K": "V"
}
)
Upvotes: 1
Reputation: 1329
Defaults for flags can be set a .bazelrc file, for example:
build --define=VERSION=0.0.0-PLACEHOLDER
build --define=FOO=1
You can also have configuration sets too:
build:bar --define=VERSION=0.0.0-PLACEHOLDER
build:bar --define=FOO=1
The above would only become active when passing the --config=bar
flag.
Flags passed on the command line will take precedence over those in the .bazelrc
file.
It's worth mentioning though, that changing define values will cause bazel to analyze everything again, which depending on the graph may take some time, but only affected actions will be executed.
Upvotes: 1