Skip to content

Commit

Permalink
Add ctx argument to cc_common.configure_features
Browse files Browse the repository at this point in the history
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
#7793, and is part of the effort for
#6516.

If the rule doesn't depend on cpp fragment yet, you will have to add `fragments
=['cpp']` argument to the rule() call.

RELNOTES: None.
PiperOrigin-RevId: 247606592
  • Loading branch information
hlopko authored and copybara-github committed May 10, 2019
1 parent f20f622 commit cab65ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/test/shell/bazel/cc_api_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def _filter_none(input_list):
def _cc_lib_impl(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
Expand Down Expand Up @@ -105,6 +106,7 @@ cc_lib = rule(
def _cc_bin_impl(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
Expand Down
1 change: 1 addition & 0 deletions tools/cpp/cc_flags_supplier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ cc_flags_supplier = rule(
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
},
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
fragments = ["cpp"],
)
1 change: 1 addition & 0 deletions tools/cpp/cc_flags_supplier_lib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def _from_sysroot(cc_toolchain):

def _from_features(ctx, cc_toolchain, action_name):
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
Expand Down

0 comments on commit cab65ff

Please sign in to comment.