Propagate graph_node_aspect over a computed default attribute Set computed default to deps only when we need to propagate graph_node aspect. This change makes it possible to collapse cc_binary and cc_test into a single rule. PiperOrigin-RevId: 574139119 Change-Id: I58f54c87487387cf63658cde96f61a03a5e49876
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl index ac47fdc..e5168d4 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
@@ -14,11 +14,12 @@ """cc_binary Starlark implementation replacing native""" -load(":common/cc/semantics.bzl", "semantics") -load(":common/cc/cc_shared_library.bzl", "GraphNodeInfo", "add_unused_dynamic_deps", "build_exports_map_from_only_dynamic_deps", "build_link_once_static_libs_map", "merge_cc_shared_library_infos", "separate_static_and_dynamic_link_libraries", "sort_linker_inputs", "throw_linked_but_not_exported_errors") +load(":common/cc/cc_binary_attrs.bzl", "cc_binary_attrs") +load(":common/cc/cc_common.bzl", "cc_common") load(":common/cc/cc_helper.bzl", "cc_helper", "linker_mode") load(":common/cc/cc_info.bzl", "CcInfo") -load(":common/cc/cc_common.bzl", "cc_common") +load(":common/cc/cc_shared_library.bzl", "GraphNodeInfo", "add_unused_dynamic_deps", "build_exports_map_from_only_dynamic_deps", "build_link_once_static_libs_map", "merge_cc_shared_library_infos", "separate_static_and_dynamic_link_libraries", "sort_linker_inputs", "throw_linked_but_not_exported_errors") +load(":common/cc/semantics.bzl", "semantics") DebugPackageInfo = _builtins.toplevel.DebugPackageInfo cc_internal = _builtins.internal.cc_internal @@ -340,7 +341,7 @@ static_linker_inputs = [] linker_inputs = cc_linking_context.linker_inputs.to_list() - all_deps = ctx.attr.deps + semantics.get_cc_runtimes(ctx, _is_link_shared(ctx)) + all_deps = ctx.attr._deps_analyzed_by_graph_structure_aspect graph_structure_aspect_nodes = [dep[GraphNodeInfo] for dep in all_deps if GraphNodeInfo in dep] can_be_linked_dynamically = {} @@ -910,20 +911,18 @@ return providers -def make_cc_binary(cc_binary_attrs, **kwargs): - return rule( - implementation = _impl, - attrs = cc_binary_attrs, - outputs = { - "stripped_binary": "%{name}.stripped", - "dwp_file": "%{name}.dwp", - }, - fragments = ["cpp"] + semantics.additional_fragments(), - exec_groups = { - "cpp_link": exec_group(toolchains = cc_helper.use_cpp_toolchain()), - }, - toolchains = cc_helper.use_cpp_toolchain() + - semantics.get_runtimes_toolchain(), - executable = True, - **kwargs - ) +cc_binary = rule( + implementation = _impl, + attrs = cc_binary_attrs, + outputs = { + "stripped_binary": "%{name}.stripped", + "dwp_file": "%{name}.dwp", + }, + fragments = ["cpp"] + semantics.additional_fragments(), + exec_groups = { + "cpp_link": exec_group(toolchains = cc_helper.use_cpp_toolchain()), + }, + toolchains = cc_helper.use_cpp_toolchain() + + semantics.get_runtimes_toolchain(), + executable = True, +)
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary_attrs.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary_attrs.bzl index 5b1f6d1..e2eb792 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary_attrs.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_binary_attrs.bzl
@@ -15,13 +15,13 @@ """Attributes for cc_binary. """ -load(":common/cc/semantics.bzl", "semantics") -load(":common/cc/cc_shared_library.bzl", "CcSharedLibraryInfo", "graph_structure_aspect") load(":common/cc/cc_info.bzl", "CcInfo") +load(":common/cc/cc_shared_library.bzl", "dynamic_deps_attrs") +load(":common/cc/semantics.bzl", "semantics") cc_internal = _builtins.internal.cc_internal -cc_binary_attrs_with_aspects = { +cc_binary_attrs = { "srcs": attr.label_list( flags = ["DIRECT_COMPILE_TIME_INPUT"], allow_files = True, @@ -54,26 +54,19 @@ allow_rules = semantics.ALLOWED_RULES_IN_DEPS + semantics.ALLOWED_RULES_WITH_WARNINGS_IN_DEPS, flags = ["SKIP_ANALYSIS_TIME_FILETYPE_CHECK"], providers = [CcInfo], - aspects = [graph_structure_aspect], - ), - "dynamic_deps": attr.label_list( - allow_files = False, - providers = [CcSharedLibraryInfo], ), "malloc": attr.label( default = Label("@" + semantics.get_repo() + "//tools/cpp:malloc"), allow_files = False, providers = [CcInfo], - aspects = [graph_structure_aspect], + allow_rules = ["cc_library"], ), "_default_malloc": attr.label( default = configuration_field(fragment = "cpp", name = "custom_malloc"), - aspects = [graph_structure_aspect], ), "link_extra_lib": attr.label( default = Label("@" + semantics.get_repo() + "//tools/cpp:link_extra_lib"), providers = [CcInfo], - aspects = [graph_structure_aspect], ), "stamp": attr.int( values = [-1, 0, 1], @@ -98,25 +91,6 @@ "_use_auto_exec_groups": attr.bool(default = True), } -cc_binary_attrs_with_aspects.update(semantics.get_distribs_attr()) -cc_binary_attrs_with_aspects.update(semantics.get_loose_mode_in_hdrs_check_allowed_attr()) - -# Update attributes to contain no aspect implementation. -cc_binary_attrs_without_aspects = dict(cc_binary_attrs_with_aspects) -cc_binary_attrs_without_aspects["deps"] = attr.label_list( - allow_files = semantics.ALLOWED_FILES_IN_DEPS, - allow_rules = semantics.ALLOWED_RULES_IN_DEPS + semantics.ALLOWED_RULES_WITH_WARNINGS_IN_DEPS, - flags = ["SKIP_ANALYSIS_TIME_FILETYPE_CHECK"], - providers = [CcInfo], -) -cc_binary_attrs_without_aspects["malloc"] = attr.label( - default = Label("@" + semantics.get_repo() + "//tools/cpp:malloc"), - allow_files = False, - allow_rules = ["cc_library"], -) -cc_binary_attrs_without_aspects["_default_malloc"] = attr.label( - default = configuration_field(fragment = "cpp", name = "custom_malloc"), -) -cc_binary_attrs_without_aspects["link_extra_lib"] = attr.label( - default = Label("@" + semantics.get_repo() + "//tools/cpp:link_extra_lib"), -) +cc_binary_attrs.update(dynamic_deps_attrs) +cc_binary_attrs.update(semantics.get_distribs_attr()) +cc_binary_attrs.update(semantics.get_loose_mode_in_hdrs_check_allowed_attr())
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary_with_aspects.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary_with_aspects.bzl deleted file mode 100644 index bb172f7..0000000 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary_with_aspects.bzl +++ /dev/null
@@ -1,24 +0,0 @@ -# Copyright 2022 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. - -"""Exports cc_binary variant with aspects. - -If dynamic_deps attribute is specified we need to propagate -aspects. -""" - -load(":common/cc/cc_binary.bzl", "make_cc_binary") -load(":common/cc/cc_binary_attrs.bzl", "cc_binary_attrs_with_aspects") - -cc_binary = make_cc_binary(cc_binary_attrs_with_aspects)
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary_without_aspects.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary_without_aspects.bzl deleted file mode 100644 index 5470e32..0000000 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary_without_aspects.bzl +++ /dev/null
@@ -1,24 +0,0 @@ -# Copyright 2022 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. - -"""Exports cc_binary variant without aspects. - -If dynamic_deps attribute is not specified we do not propagate -aspects. -""" - -load(":common/cc/cc_binary.bzl", "make_cc_binary") -load(":common/cc/cc_binary_attrs.bzl", "cc_binary_attrs_without_aspects") - -cc_binary = make_cc_binary(cc_binary_attrs_without_aspects)
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary_wrapper.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary_wrapper.bzl deleted file mode 100644 index 35c1005..0000000 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary_wrapper.bzl +++ /dev/null
@@ -1,30 +0,0 @@ -# Copyright 2022 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. - -"""Macro encapsulating cc_binary rule implementation. - -This is to avoid propagating aspect on certain attributes in case -dynamic_deps attribute is not specified. -""" - -load(":common/cc/cc_binary_with_aspects.bzl", cc_binary_with_aspects = "cc_binary") -load(":common/cc/cc_binary_without_aspects.bzl", cc_binary_without_aspects = "cc_binary") -load(":common/cc/cc_helper.bzl", "cc_helper") - -def cc_binary(**kwargs): - # Propagate an aspect if dynamic_deps attribute is specified. - if "dynamic_deps" in kwargs and cc_helper.is_non_empty_list_or_select(kwargs["dynamic_deps"], "dynamic_deps"): - cc_binary_with_aspects(**kwargs) - else: - cc_binary_without_aspects(**kwargs)
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl index 405c33b..c838a76 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl
@@ -355,14 +355,6 @@ ) return def_file -def _is_non_empty_list_or_select(value, attr): - if type(value) == "list": - return len(value) > 0 - elif type(value) == "select": - return True - else: - fail("Only select or list is valid for {} attr".format(attr)) - CC_SOURCE = [".cc", ".cpp", ".cxx", ".c++", ".C", ".cu", ".cl"] C_SOURCE = [".c"] OBJC_SOURCE = [".m"] @@ -1241,7 +1233,6 @@ get_copts = _get_copts, get_expanded_env = _get_expanded_env, has_target_constraints = _has_target_constraints, - is_non_empty_list_or_select = _is_non_empty_list_or_select, expand_make_variables_for_copts = _expand_make_variables_for_copts, build_linking_context_from_libraries = _build_linking_context_from_libraries, is_stamping_enabled = _is_stamping_enabled,
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl index 3661767..65e1e00 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl
@@ -840,6 +840,31 @@ fragments = ["cpp"] + semantics.additional_fragments(), ) +def _deps_analyzed_by_graph_structure_aspect(dynamic_deps, linkshared, deps, malloc, link_extra_lib): + if not dynamic_deps: + return [] + + # Propagate an aspect if dynamic_deps attribute is specified. + all_deps = [] + all_deps.extend(deps) + + if not linkshared: + all_deps.append(link_extra_lib) + all_deps.append(malloc) + return all_deps + +dynamic_deps_attrs = { + "dynamic_deps": attr.label_list( + allow_files = False, + providers = [CcSharedLibraryInfo], + ), + "_deps_analyzed_by_graph_structure_aspect": attr.label_list( + providers = [CcInfo], + aspects = [graph_structure_aspect], + default = _deps_analyzed_by_graph_structure_aspect, + ), +} + for_testing_dont_use_check_if_target_under_path = _check_if_target_under_path merge_cc_shared_library_infos = _merge_cc_shared_library_infos build_link_once_static_libs_map = _build_link_once_static_libs_map
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl index 22c6fdaf..4c3b413 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_test.bzl
@@ -15,7 +15,7 @@ """cc_test Starlark implementation.""" load(":common/cc/cc_binary.bzl", "cc_binary_impl") -load(":common/cc/cc_binary_attrs.bzl", "cc_binary_attrs_with_aspects", "cc_binary_attrs_without_aspects") +load(":common/cc/cc_binary_attrs.bzl", "cc_binary_attrs") load(":common/cc/cc_helper.bzl", "cc_helper") load(":common/cc/semantics.bzl", "semantics") load(":common/paths.bzl", "paths") @@ -77,58 +77,43 @@ providers.extend(test_providers) return providers -def make_cc_test(with_aspects = False): - """Makes one of the cc_test rule variants. +_cc_test_attrs = dict(cc_binary_attrs) - This function shall only be used internally in CC ruleset. +# Update cc_test defaults: +_cc_test_attrs.update( + _is_test = attr.bool(default = True), + _apple_constraints = attr.label_list( + default = [ + "@" + paths.join(semantics.get_platforms_root(), "os:ios"), + "@" + paths.join(semantics.get_platforms_root(), "os:macos"), + "@" + paths.join(semantics.get_platforms_root(), "os:tvos"), + "@" + paths.join(semantics.get_platforms_root(), "os:watchos"), + ], + ), + # Starlark tests don't get `env_inherit` by default. + env_inherit = attr.string_list(), + stamp = attr.int(values = [-1, 0, 1], default = 0), + linkstatic = attr.bool(default = False), +) +_cc_test_attrs.update(semantics.get_test_malloc_attr()) +_cc_test_attrs.update(semantics.get_coverage_attrs()) - Args: - with_aspects: Attaches graph_structure_aspect to `deps` attribute and - implicit deps. - Returns: - A cc_test rule class. - """ - _cc_test_attrs = None - if with_aspects: - _cc_test_attrs = dict(cc_binary_attrs_with_aspects) - else: - _cc_test_attrs = dict(cc_binary_attrs_without_aspects) - - # Update cc_test defaults: - _cc_test_attrs.update( - _is_test = attr.bool(default = True), - _apple_constraints = attr.label_list( - default = [ - "@" + paths.join(semantics.get_platforms_root(), "os:ios"), - "@" + paths.join(semantics.get_platforms_root(), "os:macos"), - "@" + paths.join(semantics.get_platforms_root(), "os:tvos"), - "@" + paths.join(semantics.get_platforms_root(), "os:watchos"), - ], - ), - # Starlark tests don't get `env_inherit` by default. - env_inherit = attr.string_list(), - stamp = attr.int(values = [-1, 0, 1], default = 0), - linkstatic = attr.bool(default = False), - ) - _cc_test_attrs.update(semantics.get_test_malloc_attr()) - _cc_test_attrs.update(semantics.get_coverage_attrs()) - - return rule( - implementation = _impl, - attrs = _cc_test_attrs, - outputs = { - # TODO(b/198254254): Handle case for windows. - "stripped_binary": "%{name}.stripped", - "dwp_file": "%{name}.dwp", - }, - fragments = ["cpp", "coverage"] + semantics.additional_fragments(), - exec_groups = { - "cpp_link": exec_group(toolchains = cc_helper.use_cpp_toolchain()), - # testing.ExecutionInfo defaults to an exec_group of "test". - "test": exec_group(toolchains = [config_common.toolchain_type(_CC_TEST_TOOLCHAIN_TYPE, mandatory = False)]), - }, - toolchains = [] + - cc_helper.use_cpp_toolchain() + - semantics.get_runtimes_toolchain(), - test = True, - ) +cc_test = rule( + implementation = _impl, + attrs = _cc_test_attrs, + outputs = { + # TODO(b/198254254): Handle case for windows. + "stripped_binary": "%{name}.stripped", + "dwp_file": "%{name}.dwp", + }, + fragments = ["cpp", "coverage"] + semantics.additional_fragments(), + exec_groups = { + "cpp_link": exec_group(toolchains = cc_helper.use_cpp_toolchain()), + # testing.ExecutionInfo defaults to an exec_group of "test". + "test": exec_group(toolchains = [config_common.toolchain_type(_CC_TEST_TOOLCHAIN_TYPE, mandatory = False)]), + }, + toolchains = [] + + cc_helper.use_cpp_toolchain() + + semantics.get_runtimes_toolchain(), + test = True, +)
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_test_with_aspects.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_test_with_aspects.bzl deleted file mode 100644 index 074519b..0000000 --- a/src/main/starlark/builtins_bzl/common/cc/cc_test_with_aspects.bzl +++ /dev/null
@@ -1,19 +0,0 @@ -# Copyright 2022 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. - -"""cc_test Starlark implementation.""" - -load(":common/cc/cc_test.bzl", "make_cc_test") - -cc_test = make_cc_test(with_aspects = True)
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_test_without_aspects.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_test_without_aspects.bzl deleted file mode 100644 index c63ddd3..0000000 --- a/src/main/starlark/builtins_bzl/common/cc/cc_test_without_aspects.bzl +++ /dev/null
@@ -1,19 +0,0 @@ -# Copyright 2022 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. - -"""cc_test Starlark implementation.""" - -load(":common/cc/cc_test.bzl", "make_cc_test") - -cc_test = make_cc_test(with_aspects = False)
diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_test_wrapper.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_test_wrapper.bzl index d8f35bb..3dda190 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_test_wrapper.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_test_wrapper.bzl
@@ -14,17 +14,13 @@ """cc_test Starlark implementation.""" -load(":common/cc/cc_helper.bzl", "cc_helper") -load(":common/cc/cc_test_with_aspects.bzl", _cc_test_with_aspects = "cc_test") -load(":common/cc/cc_test_without_aspects.bzl", _cc_test_without_aspects = "cc_test") +load(":common/cc/cc_test.bzl", _cc_test = "cc_test") load(":common/cc/semantics.bzl", "semantics") def cc_test(**kwargs): """Entry point for cc_test rules. - This avoids propagating aspects on certain attributes if dynamic_deps attribute is unset. - - It also serves to detect if the `linkstatic` attribute was explicitly set or not. + It serves to detect if the `linkstatic` attribute was explicitly set or not. This is to workaround a deficiency in Starlark attributes. (See: https://github.com/bazelbuild/bazel/issues/14434) @@ -35,8 +31,4 @@ if "linkstatic" not in kwargs: kwargs["linkstatic"] = semantics.get_linkstatic_default_for_test() - # Propagate an aspect if dynamic_deps attribute is specified. - if "dynamic_deps" in kwargs and cc_helper.is_non_empty_list_or_select(kwargs["dynamic_deps"], "dynamic_deps"): - _cc_test_with_aspects(**kwargs) - else: - _cc_test_without_aspects(**kwargs) + _cc_test(**kwargs)
diff --git a/src/main/starlark/builtins_bzl/common/exports.bzl b/src/main/starlark/builtins_bzl/common/exports.bzl index 3244105..4b6fa03 100755 --- a/src/main/starlark/builtins_bzl/common/exports.bzl +++ b/src/main/starlark/builtins_bzl/common/exports.bzl
@@ -14,7 +14,7 @@ """Exported builtins symbols that are not specific to OSS Bazel.""" -load("@_builtins//:common/cc/cc_binary_wrapper.bzl", "cc_binary") +load("@_builtins//:common/cc/cc_binary.bzl", "cc_binary") load("@_builtins//:common/cc/cc_common.bzl", "cc_common") load("@_builtins//:common/cc/cc_compilation_helper.bzl", "cc_compilation_helper") load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
diff --git a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkIntegrationTest.java index 84592d1..c2f72a4 100644 --- a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkIntegrationTest.java +++ b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkIntegrationTest.java
@@ -223,7 +223,6 @@ @Test public void testMacroHasGeneratorAttributes() throws Exception { - setBuildLanguageOptions("--experimental_builtins_injection_override=+cc_binary"); scratch.file( "test/starlark/extension.bzl", "def _impl(ctx):", @@ -242,9 +241,7 @@ " native_macro_rule = 'native_macro')", "macro_rule(name = 'macro_target')", "no_macro_rule(name = 'no_macro_target')", - "native_macro_rule(name = 'native_macro_target')", - "cc_binary(name = 'cc_target', deps = ['cc_dep'])", - "cc_library(name = 'cc_dep')"); + "native_macro_rule(name = 'native_macro_target')"); Rule withMacro = getRuleForTarget("macro_target"); assertThat(withMacro.getAttr("generator_name")).isEqualTo("macro_target"); @@ -261,12 +258,6 @@ assertThat(nativeMacro.getAttr("generator_name")).isEqualTo("native_macro_target"); assertThat(nativeMacro.getAttr("generator_function")).isEqualTo("native_macro"); assertThat(nativeMacro.getAttr("generator_location")).isEqualTo("test/starlark/BUILD:5:18"); - - // Starlark version of cc_binary is created by a wrapper macro. - Rule ccTarget = getRuleForTarget("cc_target"); - assertThat(ccTarget.getAttr("generator_name")).isEqualTo("cc_target"); - assertThat(ccTarget.getAttr("generator_function")).isEqualTo("cc_binary"); - assertThat(ccTarget.getAttr("generator_location")).isEqualTo("test/starlark/BUILD:6:10"); } @Test