diff options
author | 2018-07-25 01:53:49 -0700 | |
---|---|---|
committer | 2018-07-25 01:54:51 -0700 | |
commit | 024ca68015578b6d03b738db895d761ccdb0768d (patch) | |
tree | ff7cbc4e93ff1f1929ba7bb3d0afae0ca565d6a5 /src/main/java/com/google/devtools/build/lib/rules/cpp | |
parent | fac9b3b47f241b1aab51e552b551146985ad833a (diff) |
C++: Remove AbstractCcLinkParamsStore from providers.
3 providers had AbstractCcLinkParamsStore as a class field, now they wrap
CcLinkingInfo instead.
This is being rolled forward, first try caused a NullPointerException in
go_wrap_cc rules that had the attribute use_default_import set to False.
GoWrapCcConfiguredTargetTest now has a go_wrap_cc rule that has this attribute
set to false and fails with the previous version of this CL.
RELNOTES:none
PiperOrigin-RevId: 205959266
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java | 10 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java | 14 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java index 36aca5f7df..871def83e3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java @@ -886,6 +886,16 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { ccCompilationInfoBuilder.setCcCompilationContext(ccCompilationContext); CcLinkingInfo.Builder ccLinkingInfoBuilder = CcLinkingInfo.Builder.create(); + // TODO(b/111289526): Remove CcLinkingInfo provider from cc_binary as soon as the flag + // --experimental_enable_cc_dynlibs_for_runtime is flipped. An empty CcLinkParamsStore is not + // needed, but here we set it to avoid a null pointer exception in places where we're expecting + // it. In the future CcLinkParamsStore will be obligatory. + ccLinkingInfoBuilder.setCcLinkParamsStore( + new CcLinkParamsStore( + /* staticModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY, + /* staticModeParamsForExecutable= */ CcLinkParams.EMPTY, + /* dynamicModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY, + /* dynamicModeParamsForExecutable= */ CcLinkParams.EMPTY)); if (cppConfiguration.enableCcDynamicLibrariesForRuntime()) { ccLinkingInfoBuilder.setCcDynamicLibrariesForRuntime( new CcDynamicLibrariesForRuntime( diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java index 21494f7765..a8a27515af 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java @@ -30,6 +30,7 @@ import com.google.devtools.build.lib.syntax.FunctionSignature; import com.google.devtools.build.lib.syntax.Runtime; import com.google.devtools.build.lib.syntax.SkylarkType; import java.util.Collection; +import java.util.stream.Stream; import javax.annotation.Nullable; /** Wrapper for every C++ linking provider. */ @@ -110,6 +111,16 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi } }; + public static final CcLinkingInfo EMPTY = + CcLinkingInfo.Builder.create() + .setCcLinkParamsStore( + new CcLinkParamsStore( + /* staticModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY, + /* staticModeParamsForExecutable= */ CcLinkParams.EMPTY, + /* dynamicModeParamsForDynamicLibrary= */ CcLinkParams.EMPTY, + /* dynamicModeParamsForExecutable= */ CcLinkParams.EMPTY)) + .build(); + private final CcLinkParamsStore ccLinkParamsStore; // TODO(b/111289526): These providers are not useful. All the information they provide can be // obtained from CcLinkParams. CcRunfiles is already dead code and can be removed. @@ -158,8 +169,7 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi CcLinkingInfo.Builder builder = new CcLinkingInfo.Builder(); builder.setCcLinkParamsStore( CcLinkParamsStore.merge( - ccLinkingInfos - .stream() + Stream.concat(Stream.of(CcLinkingInfo.EMPTY), ccLinkingInfos.stream()) .map(CcLinkingInfo::getCcLinkParamsStore) .collect(ImmutableList.toImmutableList()))); return builder.build(); |