mirror of https://github.com/bazelbuild/rules_cc
Add ctx argument to cc_common.configure_features
In order to migrate C++ rules to platforms, we need the access to the C++ configuration fragment in Starlark APIs. All existing APIs have already access to it, but cc_common.configure_features doesn't. This change adds a ctx argument to configure_features. This is the migration needed for https://github.com/bazelbuild/bazel/issues/7793, and is part of the effort for https://github.com/bazelbuild/bazel/issues/6516. If the rule doesn't depend on cpp fragment yet, you will have to add `fragments =['cpp']` argument to the rule() call. Note that this behavior is only available in Bazel 0.25 (to be released this month). RELNOTES: None. PiperOrigin-RevId: 247171967
This commit is contained in:
parent
f678ef5279
commit
b308aae57f
|
@ -24,6 +24,7 @@ def _my_c_archive_impl(ctx):
|
||||||
output_file = ctx.actions.declare_file(ctx.label.name + ".a")
|
output_file = ctx.actions.declare_file(ctx.label.name + ".a")
|
||||||
|
|
||||||
feature_configuration = cc_common.configure_features(
|
feature_configuration = cc_common.configure_features(
|
||||||
|
ctx = ctx,
|
||||||
cc_toolchain = cc_toolchain,
|
cc_toolchain = cc_toolchain,
|
||||||
requested_features = ctx.features,
|
requested_features = ctx.features,
|
||||||
unsupported_features = ctx.disabled_features,
|
unsupported_features = ctx.disabled_features,
|
||||||
|
@ -90,4 +91,5 @@ my_c_archive = rule(
|
||||||
"deps": attr.label_list(providers = [CcInfo]),
|
"deps": attr.label_list(providers = [CcInfo]),
|
||||||
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
|
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
|
||||||
},
|
},
|
||||||
|
fragments = ["cpp"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,6 +28,7 @@ def _my_c_compile_impl(ctx):
|
||||||
source_file = ctx.file.src
|
source_file = ctx.file.src
|
||||||
output_file = ctx.actions.declare_file(ctx.label.name + ".o")
|
output_file = ctx.actions.declare_file(ctx.label.name + ".o")
|
||||||
feature_configuration = cc_common.configure_features(
|
feature_configuration = cc_common.configure_features(
|
||||||
|
ctx = ctx,
|
||||||
cc_toolchain = cc_toolchain,
|
cc_toolchain = cc_toolchain,
|
||||||
requested_features = ctx.features,
|
requested_features = ctx.features,
|
||||||
unsupported_features = DISABLED_FEATURES + ctx.disabled_features,
|
unsupported_features = DISABLED_FEATURES + ctx.disabled_features,
|
||||||
|
|
Loading…
Reference in New Issue