blob: f4d1f7b9ef4ab888208cb0030bd9c0dff87679b6 [file] [log] [blame]
scentini664f9272018-08-28 14:10:46 +02001"""Creates config_setting that allows selecting based on 'compiler' value."""
2
Yannicf0cb9cd2020-02-13 22:04:14 +01003def create_compiler_config_setting(name, value, visibility = None):
scentini664f9272018-08-28 14:10:46 +02004 # The "do_not_use_tools_cpp_compiler_present" attribute exists to
5 # distinguish between older versions of Bazel that do not support
6 # "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do.
7 # In the future, the only way to select on the compiler will be through
8 # flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
9 # be removed.
10 if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
11 native.config_setting(
12 name = name,
13 flag_values = {
14 "@bazel_tools//tools/cpp:compiler": value,
15 },
Yannicf0cb9cd2020-02-13 22:04:14 +010016 visibility = visibility,
scentini664f9272018-08-28 14:10:46 +020017 )
18 else:
19 native.config_setting(
20 name = name,
21 values = {"compiler": value},
Yannicf0cb9cd2020-02-13 22:04:14 +010022 visibility = visibility,
scentini664f9272018-08-28 14:10:46 +020023 )