mirror of https://github.com/bazelbuild/rules_cc
Implement provides in rule based toolchain.
BEGIN_PUBLIC Implement provides in rule based toolchain. END_PUBLIC PiperOrigin-RevId: 619082926 Change-Id: I938640981bd10f0e3d41402d211672a45264df1a
This commit is contained in:
parent
61def7a42c
commit
991cdf09a9
|
@ -0,0 +1,29 @@
|
||||||
|
# Copyright 2024 The Bazel Authors. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
"""Rule for mutually exclusive categories in the rule based toolchain."""
|
||||||
|
|
||||||
|
load(":cc_toolchain_info.bzl", "MutuallyExclusiveCategoryInfo")
|
||||||
|
|
||||||
|
def _cc_mutually_exclusive_category_impl(ctx):
|
||||||
|
return [MutuallyExclusiveCategoryInfo(
|
||||||
|
label = ctx.label,
|
||||||
|
name = str(ctx.label),
|
||||||
|
)]
|
||||||
|
|
||||||
|
cc_mutually_exclusive_category = rule(
|
||||||
|
implementation = _cc_mutually_exclusive_category_impl,
|
||||||
|
doc = "A category of features, for which only one can be enabled",
|
||||||
|
attrs = {},
|
||||||
|
provides = [MutuallyExclusiveCategoryInfo],
|
||||||
|
)
|
|
@ -3,6 +3,7 @@ load("//cc/toolchains:args.bzl", "cc_args")
|
||||||
load("//cc/toolchains:feature.bzl", "cc_feature")
|
load("//cc/toolchains:feature.bzl", "cc_feature")
|
||||||
load("//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint")
|
load("//cc/toolchains:feature_constraint.bzl", "cc_feature_constraint")
|
||||||
load("//cc/toolchains:feature_set.bzl", "cc_feature_set")
|
load("//cc/toolchains:feature_set.bzl", "cc_feature_set")
|
||||||
|
load("//cc/toolchains:mutually_exclusive_category.bzl", "cc_mutually_exclusive_category")
|
||||||
load("//cc/toolchains/impl:external_feature.bzl", "cc_external_feature")
|
load("//cc/toolchains/impl:external_feature.bzl", "cc_external_feature")
|
||||||
load("//tests/rule_based_toolchain:analysis_test_suite.bzl", "analysis_test_suite")
|
load("//tests/rule_based_toolchain:analysis_test_suite.bzl", "analysis_test_suite")
|
||||||
load(":features_test.bzl", "TARGETS", "TESTS")
|
load(":features_test.bzl", "TARGETS", "TESTS")
|
||||||
|
@ -59,13 +60,20 @@ util.helper_target(
|
||||||
implies = [":simple"],
|
implies = [":simple"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_mutually_exclusive_category(
|
||||||
|
name = "category",
|
||||||
|
)
|
||||||
|
|
||||||
util.helper_target(
|
util.helper_target(
|
||||||
cc_feature,
|
cc_feature,
|
||||||
name = "mutual_exclusion_feature",
|
name = "mutual_exclusion_feature",
|
||||||
args = [":c_compile"],
|
args = [":c_compile"],
|
||||||
enabled = True,
|
enabled = True,
|
||||||
feature_name = "mutual_exclusion",
|
feature_name = "mutual_exclusion",
|
||||||
mutually_exclusive = [":simple"],
|
mutually_exclusive = [
|
||||||
|
":simple",
|
||||||
|
":category",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
util.helper_target(
|
util.helper_target(
|
||||||
|
|
|
@ -89,6 +89,7 @@ def _feature_collects_mutual_exclusion_test(env, targets):
|
||||||
FeatureInfo,
|
FeatureInfo,
|
||||||
).mutually_exclusive().contains_exactly([
|
).mutually_exclusive().contains_exactly([
|
||||||
targets.simple.label,
|
targets.simple.label,
|
||||||
|
targets.category.label,
|
||||||
])
|
])
|
||||||
|
|
||||||
def _feature_set_collects_features_test(env, targets):
|
def _feature_set_collects_features_test(env, targets):
|
||||||
|
@ -144,17 +145,18 @@ def _feature_can_be_overridden_test(env, targets):
|
||||||
overrides.overrides().some().label().equals(targets.builtin_feature.label)
|
overrides.overrides().some().label().equals(targets.builtin_feature.label)
|
||||||
|
|
||||||
TARGETS = [
|
TARGETS = [
|
||||||
|
":builtin_feature",
|
||||||
":c_compile",
|
":c_compile",
|
||||||
":simple",
|
":category",
|
||||||
":simple2",
|
":direct_constraint",
|
||||||
":feature_set",
|
":feature_set",
|
||||||
":requires",
|
|
||||||
":implies",
|
":implies",
|
||||||
":mutual_exclusion_feature",
|
":mutual_exclusion_feature",
|
||||||
":direct_constraint",
|
|
||||||
":transitive_constraint",
|
|
||||||
":builtin_feature",
|
|
||||||
":overrides",
|
":overrides",
|
||||||
|
":requires",
|
||||||
|
":simple",
|
||||||
|
":simple2",
|
||||||
|
":transitive_constraint",
|
||||||
]
|
]
|
||||||
|
|
||||||
# @unsorted-dict-items
|
# @unsorted-dict-items
|
||||||
|
|
Loading…
Reference in New Issue