mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
This PR merges the OS-specific Clang flags into the main Clang flags features using feature-based constraints instead of separate features conditionally added. Similarly for libc++. This also move flags to more correctly live in the Clang flag set vs. the libc++ flag set as some of these flags were specific to using libc++. To make this change, the libc++ feature needs to be computed rather than being fixed, as we need to add search paths based on the installed location of LLVM and Clang. All of this only works when the OS-config flags work. The earlier PR adding these had a bug -- _none_ of the OS features would ever be enabled. This didn't result in a problem as the initial use was only to _disable_ flags on the wrong OS. Now that we're enabling flags, we have to get it right by marking all of these as `enabled`.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
# Exceptions. See /LICENSE for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
"""Configuration features for other features in a `cc_toolchain_config`.
|
|
|
|
These features are designed to be used by other features in a
|
|
`cc_toolchain_config` that need to configure their behavior in some way. This
|
|
can be configuration based on either the target or host of the build, and along
|
|
multiple dimensions of each.
|
|
"""
|
|
|
|
load(
|
|
"@rules_cc//cc:cc_toolchain_config_lib.bzl",
|
|
"feature",
|
|
)
|
|
|
|
freebsd_target_feature = feature(name = "freebsd_target", enabled = True)
|
|
linux_target_feature = feature(name = "linux_target", enabled = True)
|
|
macos_target_feature = feature(name = "macos_target", enabled = True)
|
|
windows_target_feature = feature(name = "windows_target", enabled = True)
|
|
|
|
os_target_features = {
|
|
"freebsd": [freebsd_target_feature],
|
|
"linux": [linux_target_feature],
|
|
"macos": [macos_target_feature],
|
|
"windows": [windows_target_feature],
|
|
}
|
|
|
|
def target_os_features(os):
|
|
if os not in os_target_features:
|
|
fail("Unsupported target OS: %s" % os)
|
|
|
|
return os_target_features[os]
|