compiler_config_setting.bzl 964 B

1234567891011121314151617181920212223
  1. """Creates config_setting that allows selecting based on 'compiler' value."""
  2. def create_compiler_config_setting(name, value, visibility = None):
  3. # The "do_not_use_tools_cpp_compiler_present" attribute exists to
  4. # distinguish between older versions of Bazel that do not support
  5. # "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do.
  6. # In the future, the only way to select on the compiler will be through
  7. # flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
  8. # be removed.
  9. if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
  10. native.config_setting(
  11. name = name,
  12. flag_values = {
  13. "@bazel_tools//tools/cpp:compiler": value,
  14. },
  15. visibility = visibility,
  16. )
  17. else:
  18. native.config_setting(
  19. name = name,
  20. values = {"compiler": value},
  21. visibility = visibility,
  22. )