cc_toolchain_config_features.bzl 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. """Configuration features for other features in a `cc_toolchain_config`.
  5. These features are designed to be used by other features in a
  6. `cc_toolchain_config` that need to configure their behavior in some way. This
  7. can be configuration based on either the target or host of the build, and along
  8. multiple dimensions of each.
  9. """
  10. load(
  11. "@rules_cc//cc:cc_toolchain_config_lib.bzl",
  12. "feature",
  13. )
  14. freebsd_target_feature = feature(name = "freebsd_target")
  15. linux_target_feature = feature(name = "linux_target")
  16. macos_target_feature = feature(name = "macos_target")
  17. windows_target_feature = feature(name = "windows_target")
  18. os_target_features = {
  19. "freebsd": [freebsd_target_feature],
  20. "linux": [linux_target_feature],
  21. "macos": [macos_target_feature],
  22. "windows": [windows_target_feature],
  23. }
  24. def target_os_features(os):
  25. if os not in os_target_features:
  26. fail("Unsupported target OS: %s" % os)
  27. return os_target_features[os]