From cab65ff6f2a81bac81af781f77cf6c2ed023ce8f Mon Sep 17 00:00:00 2001 From: hlopko Date: Fri, 10 May 2019 07:22:06 -0700 Subject: [PATCH] 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. RELNOTES: None. PiperOrigin-RevId: 247606592 --- src/test/shell/bazel/cc_api_rules.bzl | 2 ++ tools/cpp/cc_flags_supplier.bzl | 1 + tools/cpp/cc_flags_supplier_lib.bzl | 1 + 3 files changed, 4 insertions(+) diff --git a/src/test/shell/bazel/cc_api_rules.bzl b/src/test/shell/bazel/cc_api_rules.bzl index 201b0a75f498f4..87d99496b69511 100644 --- a/src/test/shell/bazel/cc_api_rules.bzl +++ b/src/test/shell/bazel/cc_api_rules.bzl @@ -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, @@ -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, diff --git a/tools/cpp/cc_flags_supplier.bzl b/tools/cpp/cc_flags_supplier.bzl index 418aa288a0986c..af01c185225516 100644 --- a/tools/cpp/cc_flags_supplier.bzl +++ b/tools/cpp/cc_flags_supplier.bzl @@ -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"], ) diff --git a/tools/cpp/cc_flags_supplier_lib.bzl b/tools/cpp/cc_flags_supplier_lib.bzl index a179fbf5313cb1..042ecef940353d 100644 --- a/tools/cpp/cc_flags_supplier_lib.bzl +++ b/tools/cpp/cc_flags_supplier_lib.bzl @@ -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,