From 0c1d09e4dce4c3251c2be2c70d4575ec65b1d9d3 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 2 Nov 2021 08:32:17 -0700 Subject: [PATCH] Propagate --experimental_cc_implementation_deps to host config RELNOTES: n/a PiperOrigin-RevId: 407089786 --- .../build/lib/rules/cpp/CppOptions.java | 1 + .../cpp/CcLibraryConfiguredTargetTest.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index e6968df2b90d1e..ee1bd0453f18d5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -1142,6 +1142,7 @@ public FragmentOptions getHost() { host.experimentalLinkStaticLibrariesOnce = experimentalLinkStaticLibrariesOnce; host.experimentalEnableTargetExportCheck = experimentalEnableTargetExportCheck; host.experimentalCcSharedLibraryDebug = experimentalCcSharedLibraryDebug; + host.experimentalCcImplementationDeps = experimentalCcImplementationDeps; host.coptList = coptListBuilder.addAll(hostCoptList).build(); host.cxxoptList = cxxoptListBuilder.addAll(hostCxxoptList).build(); diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java index 52410942c51984..12e7f8846d655e 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java @@ -1991,6 +1991,37 @@ public void testImplementationDepsLinkingContextIsPropagated() throws Exception .contains("bin foo/libimplementation_dep.a"); } + @Test + public void testImplementationDepsConfigurationHostSucceeds() throws Exception { + useConfiguration("--experimental_cc_implementation_deps"); + scratch.file( + "foo/BUILD", + "cc_binary(", + " name = 'bin',", + " srcs = ['bin.cc'],", + " deps = ['lib'],", + ")", + "cc_library(", + " name = 'lib',", + " srcs = ['lib.cc'],", + " deps = ['public_dep'],", + ")", + "cc_library(", + " name = 'public_dep',", + " srcs = ['public_dep.cc'],", + " hdrs = ['public_dep.h'],", + " implementation_deps = ['implementation_dep'],", + ")", + "cc_library(", + " name = 'implementation_dep',", + " srcs = ['implementation_dep.cc'],", + " hdrs = ['implementation_dep.h'],", + ")"); + + getHostConfiguredTarget("//foo:bin"); + assertDoesNotContainEvent("requires --experimental_cc_implementation_deps"); + } + @Test public void testImplementationDepsFailsWithoutFlag() throws Exception { scratch.file(