Skip to content

Commit

Permalink
C++: Remove AbstractCcLinkParamsStore from providers.
Browse files Browse the repository at this point in the history
3 providers had AbstractCcLinkParamsStore as a class field, now they wrap
CcLinkingInfo instead.

RELNOTES:none
PiperOrigin-RevId: 205821081
  • Loading branch information
oquenchil authored and Copybara-Service committed Jul 24, 2018
1 parent 7fdd49c commit 6f19151
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,16 @@ private static void addTransitiveInfoProviders(
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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. */
Expand Down Expand Up @@ -110,6 +111,16 @@ protected CcLinkingInfo createInstanceFromSkylark(
}
};

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.
Expand Down Expand Up @@ -158,8 +169,7 @@ public static CcLinkingInfo merge(Collection<CcLinkingInfo> ccLinkingInfos) {
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();
Expand Down

0 comments on commit 6f19151

Please sign in to comment.