diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/GraphNodeAspect.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/GraphNodeAspect.java index 0f333392b6b373..8b906e42bbd313 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/GraphNodeAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/GraphNodeAspect.java @@ -50,6 +50,8 @@ public AspectParameters apply(Rule rule) { : null; } }; + private static final ImmutableList CC_DEPS_ATTRIBUTES = + ImmutableList.of("deps", "implementation_deps"); @Override public AspectDefinition getDefinition(AspectParameters aspectParameters) { @@ -67,9 +69,12 @@ public ConfiguredAspect create( RepositoryName toolsRepository) throws ActionConflictException, InterruptedException { ImmutableList.Builder children = ImmutableList.builder(); - if (ruleContext.attributes().has("deps")) { - children.addAll( - AnalysisUtils.getProviders(ruleContext.getPrerequisites("deps"), GraphNodeInfo.class)); + for (String depsAttribute : CC_DEPS_ATTRIBUTES) { + if (ruleContext.attributes().has(depsAttribute)) { + children.addAll( + AnalysisUtils.getProviders( + ruleContext.getPrerequisites(depsAttribute), GraphNodeInfo.class)); + } } return new ConfiguredAspect.Builder(ruleContext) .addProvider( diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test index 39dcd2053cbfd7..025a08f2dd26ec 100644 --- a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test +++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test @@ -90,6 +90,7 @@ cc_shared_library( "a_suffix", ], static_deps = [ + "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:implementation_dep", "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:qux", "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:qux2", "//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:prebuilt", @@ -110,6 +111,12 @@ cc_library( hdrs = ["preloaded_dep.h"], ) +cc_library( + name = "implementation_dep", + srcs = ["implementation_dep.cc"], + hdrs = ["implementation_dep.h"], +) + cc_library( name = "foo", srcs = [ @@ -124,6 +131,7 @@ cc_library( "//src/conditions:linux": ["IS_LINUX"], "//conditions:default": [], }), + implementation_deps = ["implementation_dep"], deps = [ "preloaded_dep", "bar", diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/cc_shared_library_integration_test.sh b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/cc_shared_library_integration_test.sh index a6b480bff2d95d..cc62155f972501 100755 --- a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/cc_shared_library_integration_test.sh +++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/cc_shared_library_integration_test.sh @@ -48,6 +48,7 @@ function test_shared_library_symbols() { check_symbol_absent "$symbols" "_Z3quxv" check_symbol_absent "$symbols" "_Z4bar3v" check_symbol_absent "$symbols" "_Z4bar4v" + check_symbol_absent "$symbols" "_Z18implementation_depv" } function test_shared_library_user_link_flags() { diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/foo.cc b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/foo.cc index cc9c8da410e740..c87ca093e33023 100644 --- a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/foo.cc +++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/foo.cc @@ -15,12 +15,14 @@ #include "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/baz.h" #include "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/direct_so_file_cc_lib.h" #include "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/direct_so_file_cc_lib2.h" +#include "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.h" #include "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/preloaded_dep.h" #include "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/qux.h" int foo() { bar(); baz(); + implementation_dep(); qux(); #ifdef IS_LINUX direct_so_file_cc_lib(); diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.cc b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.cc new file mode 100644 index 00000000000000..4297573f2fcfdb --- /dev/null +++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.cc @@ -0,0 +1,16 @@ +// Copyright 2016 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. +#include "src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.h" + +int implementation_dep() { return 43; } diff --git a/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.h b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.h new file mode 100644 index 00000000000000..2ca3acf740b0f6 --- /dev/null +++ b/src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/implementation_dep.h @@ -0,0 +1,19 @@ +// Copyright 2016 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. +#ifndef EXAMPLES_TEST_CC_SHARED_LIBRARY_IMPLEMENTATION_DEP_H_ +#define EXAMPLES_TEST_CC_SHARED_LIBRARY_IMPLEMENTATION_DEP_H_ + +int implementation_dep(); + +#endif // EXAMPLES_TEST_CC_SHARED_LIBRARY_IMPLEMENTATION_DEP_H_ diff --git a/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh b/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh index 005d6792899833..d72467296f42c9 100755 --- a/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh +++ b/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh @@ -73,7 +73,8 @@ EOF --experimental_link_static_libraries_once \ --experimental_enable_target_export_check --experimental_cc_shared_library \ --experimental_builtins_injection_override=+cc_binary \ + --experimental_cc_implementation_deps \ //src/main/starlark/tests/builtins_bzl/cc/... || fail "expected success" } -run_suite "cc_* built starlark test" \ No newline at end of file +run_suite "cc_* built starlark test"