Our product can be built with a large number of variants, it is both different platforms but also many variants for test.
We have started to use transitions to be able to test all variants with a single "bazel test ..."
Now we have realized that all targets are built in a separated output trees for each transitions.
The documentation also mention a TODO regarding the problem.
Are there any plans for reducing the number of built targets when using transitions?
Here is an example with how we see the problem.
The rule example() use a transition where the bool flag "c1" is set to true or false.
Two targets are created, it is only the "bin" target that is actually using the build setting but all common code is built into two separated output trees one for "c1" = True, and one for "c1" = False.
load("@rules_cc//cc:defs.bzl", "cc_binary")
load(":test.bzl", "example")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
cc_binary(
name = "bin",
srcs = ["application.c"],
copts = select({
":c1==True": ["-DC1_APP"],
"//conditions:default": [],
}),
deps = ["//transitions/common"],
)
config_setting(
name = "c1==True",
flag_values = {":c1": "True"},
)
bool_flag(
name = "c1",
build_setting_default = True,
)
example(
name = "app",
c1 = False,
input = ":bin",
)
example(
name = "c1_app",
c1 = True,
input = ":bin",
)