aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp
diff options
context:
space:
mode:
authorGravatar plf <plf@google.com>2018-07-24 06:48:05 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-24 06:49:23 -0700
commit6f1915114ec7af104a2649a454cc1519ce7806bf (patch)
tree7e938436d4ddc385c45b72a0b4c0ed85fe1a76bf /src/main/java/com/google/devtools/build/lib/rules/cpp
parent7fdd49c22b24ba1a5c119e20b6a73c979103de44 (diff)
C++: Remove AbstractCcLinkParamsStore from providers.
3 providers had AbstractCcLinkParamsStore as a class field, now they wrap CcLinkingInfo instead. RELNOTES:none PiperOrigin-RevId: 205821081
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.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java14
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();