C++: Removes more usages of CcLinkParamsStore.
The class can probably deleted compeletely with one more CL.
RELNOTES:none
PiperOrigin-RevId: 211821693
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCcLinkParamsProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCcLinkParamsProvider.java
index 2b9ba89..cbcf101 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCcLinkParamsProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCcLinkParamsProvider.java
@@ -14,12 +14,9 @@
package com.google.devtools.build.lib.rules.android;
-import com.google.common.base.Function;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.packages.BuiltinProvider;
import com.google.devtools.build.lib.packages.NativeInfo;
-import com.google.devtools.build.lib.rules.cpp.AbstractCcLinkParamsStore;
import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidCcLinkParamsProviderApi;
import com.google.devtools.build.lib.syntax.EvalException;
@@ -43,12 +40,6 @@
return ccLinkingInfo;
}
- public static final Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> TO_LINK_PARAMS =
- (TransitiveInfoCollection input) -> {
- AndroidCcLinkParamsProvider provider = input.get(AndroidCcLinkParamsProvider.PROVIDER);
- return provider == null ? null : provider.getLinkParams().getCcLinkParamsStore();
- };
-
/** Provider class for {@link AndroidCcLinkParamsProvider} objects. */
public static class Provider extends BuiltinProvider<AndroidCcLinkParamsProvider>
implements AndroidCcLinkParamsProviderApi.Provider<CcLinkingInfo> {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java
index dc94c49..2b96fdd 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java
@@ -248,13 +248,13 @@
nonCodeInputs);
}
- public boolean add(AbstractCcLinkParamsStore store) {
+ public boolean add(CcLinkingInfo ccLinkingInfo) {
Preconditions.checkState(linkingStaticallyLinkSharedSet);
- if (store != null) {
- CcLinkParams args = store.get(linkingStatically, linkShared);
+ if (ccLinkingInfo != null) {
+ CcLinkParams args = ccLinkingInfo.getCcLinkParams(linkingStatically, linkShared);
addTransitiveArgs(args);
}
- return store != null;
+ return ccLinkingInfo != null;
}
/**
@@ -275,10 +275,8 @@
*/
public Builder addTransitiveTarget(TransitiveInfoCollection target) {
CcLinkingInfo ccLinkingInfo = target.get(CcLinkingInfo.PROVIDER);
- CcLinkParamsStore ccLinkParamsStore =
- ccLinkingInfo == null ? null : ccLinkingInfo.getCcLinkParamsStore();
- if (ccLinkParamsStore != null) {
- add(ccLinkParamsStore);
+ if (ccLinkingInfo != null) {
+ add(ccLinkingInfo);
}
return this;
}
@@ -291,14 +289,13 @@
@SafeVarargs
public final Builder addTransitiveTarget(
TransitiveInfoCollection target,
- Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> firstMapping,
+ Function<TransitiveInfoCollection, CcLinkingInfo> firstMapping,
@SuppressWarnings("unchecked") // Java arrays don't preserve generic arguments.
- Function<TransitiveInfoCollection, AbstractCcLinkParamsStore>... remainingMappings) {
+ Function<TransitiveInfoCollection, CcLinkingInfo>... remainingMappings) {
if (add(firstMapping.apply(target))) {
return this;
}
- for (Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> mapping :
- remainingMappings) {
+ for (Function<TransitiveInfoCollection, CcLinkingInfo> mapping : remainingMappings) {
if (add(mapping.apply(target))) {
return this;
}
@@ -314,9 +311,9 @@
@SafeVarargs
public final Builder addTransitiveTargets(
Iterable<? extends TransitiveInfoCollection> targets,
- Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> firstMapping,
+ Function<TransitiveInfoCollection, CcLinkingInfo> firstMapping,
@SuppressWarnings("unchecked") // Java arrays don't preserve generic arguments.
- Function<TransitiveInfoCollection, AbstractCcLinkParamsStore>... remainingMappings) {
+ Function<TransitiveInfoCollection, CcLinkingInfo>... remainingMappings) {
for (TransitiveInfoCollection target : targets) {
addTransitiveTarget(target, firstMapping, remainingMappings);
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParamsStore.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParamsStore.java
index c1d2d9a..15e3400 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParamsStore.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParamsStore.java
@@ -27,30 +27,26 @@
public final class CcLinkParamsStore extends AbstractCcLinkParamsStore {
public static final ObjectCodec<com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore> CODEC =
new CcLinkParamsStore_AutoCodec();
- public static final Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> TO_LINK_PARAMS =
+ public static final Function<TransitiveInfoCollection, CcLinkingInfo> TO_LINK_PARAMS =
input -> {
// ... then try Skylark.
- CcLinkingInfo provider = input.get(CcLinkingInfo.PROVIDER);
- return provider == null ? null : provider.getCcLinkParamsStore();
+ return input.get(CcLinkingInfo.PROVIDER);
};
@AutoCodec
@VisibleForSerialization
static class CcLinkParamsInfoCollection extends AbstractCcLinkParamsStore {
- private final Iterable<com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore>
- ccLinkParamStores;
+ private final Iterable<CcLinkingInfo> ccLinkingInfos;
- CcLinkParamsInfoCollection(
- Iterable<com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore> ccLinkParamStores) {
- this.ccLinkParamStores = ccLinkParamStores;
+ CcLinkParamsInfoCollection(Iterable<CcLinkingInfo> ccLinkingInfos) {
+ this.ccLinkingInfos = ccLinkingInfos;
}
@Override
protected void collect(
CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) {
- for (com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore ccLinkParamsStore :
- ccLinkParamStores) {
- builder.add(ccLinkParamsStore);
+ for (CcLinkingInfo ccLinkingInfo : ccLinkingInfos) {
+ builder.add(ccLinkingInfo);
}
}
}
@@ -77,7 +73,7 @@
}
public static com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore merge(
- final Iterable<com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore> providers) {
+ final Iterable<CcLinkingInfo> providers) {
return new com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore(
new CcLinkParamsInfoCollection(providers));
}
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 66a8a4e..81b361d 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
@@ -117,11 +117,7 @@
super(PROVIDER);
this.ccLinkParamsStore = ccLinkParamsStore;
}
-
- public CcLinkParamsStore getCcLinkParamsStore() {
- return ccLinkParamsStore;
- }
-
+
@Override
public CcLinkParams getStaticModeParamsForDynamicLibrary() {
return ccLinkParamsStore.get(/* linkingStatically= */ true, /* linkShared= */ true);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java
index eeec948..de5d8ed 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java
@@ -44,12 +44,10 @@
public NestedSet<Artifact> getLibraries() {
NestedSetBuilder<Artifact> libs = NestedSetBuilder.linkOrder();
CcLinkingInfo ccLinkingInfo = getInfo().get(CcLinkingInfo.PROVIDER);
- CcLinkParamsStore ccLinkParams =
- ccLinkingInfo == null ? null : ccLinkingInfo.getCcLinkParamsStore();
- if (ccLinkParams == null) {
+ if (ccLinkingInfo == null) {
return libs.build();
}
- for (LinkerInput lib : ccLinkParams.getCcLinkParams(true, false).getLibraries()) {
+ for (LinkerInput lib : ccLinkingInfo.getStaticModeParamsForExecutable().getLibraries()) {
libs.add(lib.getArtifact());
}
return libs.build();
@@ -58,12 +56,10 @@
@Override
public ImmutableList<String> getLinkopts() {
CcLinkingInfo ccLinkingInfo = getInfo().get(CcLinkingInfo.PROVIDER);
- CcLinkParamsStore ccLinkParams =
- ccLinkingInfo == null ? null : ccLinkingInfo.getCcLinkParamsStore();
- if (ccLinkParams == null) {
+ if (ccLinkingInfo == null) {
return ImmutableList.of();
}
- return ccLinkParams.getCcLinkParams(true, false).flattenedLinkopts();
+ return ccLinkingInfo.getStaticModeParamsForExecutable().flattenedLinkopts();
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
index 477a9ef..3232c4d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
@@ -397,26 +397,22 @@
final Function<TransitiveInfoCollection, Runfiles> runfilesForLinkingDynamically =
input -> {
CcLinkingInfo provider = input.get(CcLinkingInfo.PROVIDER);
- CcLinkParamsStore ccLinkParamsStore =
- provider == null ? null : provider.getCcLinkParamsStore();
- return ccLinkParamsStore == null
+ return provider == null
? Runfiles.EMPTY
: new Runfiles.Builder(ruleContext.getWorkspaceName())
.addTransitiveArtifacts(
- ccLinkParamsStore.get(false, false).getDynamicLibrariesForRuntime())
+ provider.getDynamicModeParamsForExecutable().getDynamicLibrariesForRuntime())
.build();
};
final Function<TransitiveInfoCollection, Runfiles> runfilesForLinkingStatically =
input -> {
CcLinkingInfo provider = input.get(CcLinkingInfo.PROVIDER);
- CcLinkParamsStore ccLinkParamsStore =
- provider == null ? null : provider.getCcLinkParamsStore();
- return ccLinkParamsStore == null
+ return provider == null
? Runfiles.EMPTY
: new Runfiles.Builder(ruleContext.getWorkspaceName())
.addTransitiveArtifacts(
- ccLinkParamsStore.get(true, false).getDynamicLibrariesForRuntime())
+ provider.getStaticModeParamsForExecutable().getDynamicLibrariesForRuntime())
.build();
};
return linkingStatically ? runfilesForLinkingStatically : runfilesForLinkingDynamically;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCcLinkParamsProvider.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCcLinkParamsProvider.java
index 597d788..c808552 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCcLinkParamsProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCcLinkParamsProvider.java
@@ -14,11 +14,8 @@
package com.google.devtools.build.lib.rules.java;
-import com.google.common.base.Function;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
-import com.google.devtools.build.lib.rules.cpp.AbstractCcLinkParamsStore;
import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
@@ -37,10 +34,4 @@
public CcLinkingInfo getCcLinkingInfo() {
return ccLinkingInfo;
}
-
- public static final Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> TO_LINK_PARAMS =
- input -> {
- JavaCcLinkParamsProvider provider = input.getProvider(JavaCcLinkParamsProvider.class);
- return provider == null ? null : provider.getCcLinkingInfo().getCcLinkParamsStore();
- };
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
index a264962..a32866f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
@@ -19,7 +19,7 @@
import static com.google.devtools.build.lib.cmdline.Label.parseAbsoluteUnchecked;
import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
-import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkParamsStore;
+import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkingInfo;
import static com.google.devtools.build.lib.rules.java.proto.StrictDepsUtils.createNonStrictCompilationArgsProvider;
import com.google.common.collect.ImmutableList;
@@ -254,8 +254,8 @@
}
javaProvidersBuilder.add(generatedCompilationArgsProvider);
- javaProvidersBuilder.add(createCcLinkParamsStore(
- ruleContext, aspectCommon.getProtoRuntimeDeps()));
+ javaProvidersBuilder.add(
+ createCcLinkingInfo(ruleContext, aspectCommon.getProtoRuntimeDeps()));
TransitiveInfoProviderMap javaProviders = javaProvidersBuilder.build();
aspect
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java
index cb9be32..9c416ff 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoLibrary.java
@@ -15,7 +15,7 @@
package com.google.devtools.build.lib.rules.java.proto;
import static com.google.devtools.build.lib.collect.nestedset.Order.STABLE_ORDER;
-import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkParamsStore;
+import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkingInfo;
import static com.google.devtools.build.lib.rules.java.proto.StrictDepsUtils.constructJcapFromAspectDeps;
import com.google.common.collect.ImmutableList;
@@ -95,7 +95,7 @@
.addOutputGroup(OutputGroupInfo.DEFAULT, NestedSetBuilder.<Artifact>emptySet(STABLE_ORDER))
.addNativeDeclaredProvider(getJavaLiteRuntimeSpec(ruleContext))
.addNativeDeclaredProvider(javaInfo)
- .addProvider(createCcLinkParamsStore(ruleContext, ImmutableList.of()))
+ .addProvider(createCcLinkingInfo(ruleContext, ImmutableList.of()))
.build();
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
index 131c617..d3867d1 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
@@ -19,7 +19,7 @@
import static com.google.devtools.build.lib.cmdline.Label.parseAbsoluteUnchecked;
import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
-import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkParamsStore;
+import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkingInfo;
import static com.google.devtools.build.lib.rules.java.proto.StrictDepsUtils.createNonStrictCompilationArgsProvider;
import com.google.common.base.Preconditions;
@@ -265,8 +265,8 @@
}
javaProvidersBuilder.add(generatedCompilationArgsProvider);
- javaProvidersBuilder.add(createCcLinkParamsStore(
- ruleContext, aspectCommon.getProtoRuntimeDeps()));
+ javaProvidersBuilder.add(
+ createCcLinkingInfo(ruleContext, aspectCommon.getProtoRuntimeDeps()));
TransitiveInfoProviderMap javaProviders = javaProvidersBuilder.build();
aspect
.addSkylarkTransitiveInfo(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java
index 9e21d34..fd93ede 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoLibrary.java
@@ -16,7 +16,7 @@
import static com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode.TARGET;
import static com.google.devtools.build.lib.collect.nestedset.Order.STABLE_ORDER;
-import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkParamsStore;
+import static com.google.devtools.build.lib.rules.java.proto.JplCcLinkParams.createCcLinkingInfo;
import static com.google.devtools.build.lib.rules.java.proto.StrictDepsUtils.constructJcapFromAspectDeps;
import com.google.common.collect.ImmutableList;
@@ -99,7 +99,7 @@
.addNativeDeclaredProvider(javaInfo);
if (ruleContext.getFragment(JavaConfiguration.class).jplPropagateCcLinkParamsStore()) {
- result.addProvider(createCcLinkParamsStore(ruleContext, ImmutableList.of()));
+ result.addProvider(createCcLinkingInfo(ruleContext, ImmutableList.of()));
}
return result.build();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JplCcLinkParams.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JplCcLinkParams.java
index 09aeecc..ff9ea52 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JplCcLinkParams.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JplCcLinkParams.java
@@ -30,8 +30,8 @@
public class JplCcLinkParams {
/**
- * Creates a CcLinkParamsStore based on 'deps' and an explicit list of proto runtimes, in the
- * context of a java_xxx_proto_library and its aspects.
+ * Creates a CcLinkingInfo based on 'deps' and an explicit list of proto runtimes, in the context
+ * of a java_xxx_proto_library and its aspects.
*
* @param ruleContext used to extract 'deps'. the 'deps' are expected to provide
* JavaProtoLibraryAspectProvider, which is the case when a java_xxx_proto_library rule
@@ -39,7 +39,7 @@
* dependency's aspect node.
* @param protoRuntimes a list of java_library.
*/
- public static JavaCcLinkParamsProvider createCcLinkParamsStore(
+ public static JavaCcLinkParamsProvider createCcLinkingInfo(
final RuleContext ruleContext, final ImmutableList<TransitiveInfoCollection> protoRuntimes) {
List<JavaCcLinkParamsProvider> providers = new ArrayList<>();
for (TransitiveInfoCollection t :
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
index 998971d..6ae72b9 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
@@ -69,7 +69,6 @@
import com.google.devtools.build.lib.rules.cpp.CcCompilationContext;
import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo;
import com.google.devtools.build.lib.rules.cpp.CcLinkParams;
-import com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore;
import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
import com.google.devtools.build.lib.rules.cpp.CppFileTypes;
import com.google.devtools.build.lib.rules.cpp.CppModuleMap;
@@ -169,7 +168,7 @@
private Optional<Artifact> linkedBinary = Optional.absent();
private Optional<Artifact> linkmapFile = Optional.absent();
private Iterable<CcCompilationContext> depCcHeaderProviders = ImmutableList.of();
- private Iterable<CcLinkParamsStore> depCcLinkProviders = ImmutableList.of();
+ private Iterable<CcLinkingInfo> depCcLinkProviders = ImmutableList.of();
/**
* Builder for {@link ObjcCommon} obtaining both attribute data and configuration data from
@@ -258,15 +257,14 @@
ImmutableList.Builder<ObjcProvider> propagatedObjcDeps =
ImmutableList.<ObjcProvider>builder();
ImmutableList.Builder<CcCompilationInfo> cppDeps = ImmutableList.builder();
- ImmutableList.Builder<CcLinkParamsStore> cppDepLinkParams =
- ImmutableList.<CcLinkParamsStore>builder();
+ ImmutableList.Builder<CcLinkingInfo> cppDepLinkParams = ImmutableList.builder();
for (ConfiguredTargetAndData dep : deps) {
ConfiguredTarget depCT = dep.getConfiguredTarget();
addAnyProviders(propagatedObjcDeps, depCT, ObjcProvider.SKYLARK_CONSTRUCTOR);
addAnyProviders(cppDeps, depCT, CcCompilationInfo.PROVIDER);
if (isCcLibrary(dep)) {
- cppDepLinkParams.add(depCT.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore());
+ cppDepLinkParams.add(depCT.get(CcLinkingInfo.PROVIDER));
CcCompilationContext ccCompilationContext =
depCT.get(CcCompilationInfo.PROVIDER).getCcCompilationContext();
addDefines(ccCompilationContext.getDefines());
@@ -452,8 +450,8 @@
objcProvider.addAll(DEFINE, headerProvider.getDefines());
textualHeaders.addAll(headerProvider.getTextualHdrs());
}
- for (CcLinkParamsStore linkProvider : depCcLinkProviders) {
- CcLinkParams params = linkProvider.getCcLinkParams(true, false);
+ for (CcLinkingInfo linkProvider : depCcLinkProviders) {
+ CcLinkParams params = linkProvider.getStaticModeParamsForExecutable();
ImmutableList<String> linkOpts = params.flattenedLinkopts();
ImmutableSet.Builder<SdkFramework> frameworkLinkOpts = new ImmutableSet.Builder<>();
ImmutableList.Builder<String> nonFrameworkLinkOpts = new ImmutableList.Builder<>();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
index d84fe5a..68f4fbd 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProvider.java
@@ -34,7 +34,6 @@
import com.google.devtools.build.lib.packages.BuiltinProvider;
import com.google.devtools.build.lib.packages.Info;
import com.google.devtools.build.lib.packages.NativeProvider.WithLegacySkylarkName;
-import com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore;
import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
import com.google.devtools.build.lib.rules.cpp.CppModuleMap;
import com.google.devtools.build.lib.rules.cpp.LinkerInputs;
@@ -780,16 +779,12 @@
// three possible locations (and may be duplicated!):
// 1. ObjcProvider.LIBRARY
// 2. ObjcProvider.CC_LIBRARY
- // 3. CcLinkParamsStore->LibraryToLink->getArtifact()
+ // 3. CcLinkingInfo->LibraryToLink->getArtifact()
// TODO(cpeyser): Clean up objc-cc interop.
HashSet<PathFragment> avoidLibrariesSet = new HashSet<>();
for (CcLinkingInfo linkProvider : avoidCcProviders) {
- CcLinkParamsStore ccLinkParamsStore = linkProvider.getCcLinkParamsStore();
- if (ccLinkParamsStore == null) {
- continue;
- }
NestedSet<LibraryToLink> librariesToLink =
- ccLinkParamsStore.getCcLinkParams(true, false).getLibraries();
+ linkProvider.getStaticModeParamsForExecutable().getLibraries();
for (LibraryToLink libraryToLink : librariesToLink.toList()) {
avoidLibrariesSet.add(libraryToLink.getArtifact().getRunfilesPath());
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyCcLinkParamsProvider.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyCcLinkParamsProvider.java
index 67be6ae..9936f13 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PyCcLinkParamsProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyCcLinkParamsProvider.java
@@ -13,12 +13,9 @@
// limitations under the License.
package com.google.devtools.build.lib.rules.python;
-import com.google.common.base.Function;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.packages.NativeInfo;
import com.google.devtools.build.lib.packages.NativeProvider;
-import com.google.devtools.build.lib.rules.cpp.AbstractCcLinkParamsStore;
import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
@@ -49,10 +46,4 @@
public CcLinkingInfo getCcLinkingInfo() {
return ccLinkingInfo;
}
-
- public static final Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> TO_LINK_PARAMS =
- input -> {
- PyCcLinkParamsProvider provider = input.get(PyCcLinkParamsProvider.PROVIDER);
- return provider == null ? null : provider.getCcLinkingInfo().getCcLinkParamsStore();
- };
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
index 54462ad..6294613 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java
@@ -117,8 +117,7 @@
assertThat(
emptylib
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .get(/* linkingStatically= */ false, /* linkShared= */ false)
+ .getDynamicModeParamsForExecutable()
.getDynamicLibrariesForRuntime()
.isEmpty())
.isTrue();
@@ -231,8 +230,7 @@
assertThat(
statically
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .get(/* linkingStatically= */ false, /* linkShared= */ false)
+ .getDynamicModeParamsForExecutable()
.getDynamicLibrariesForRuntime()
.isEmpty())
.isTrue();
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java
index 41bdb56..78eff66 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcImportBaseConfiguredTargetTest.java
@@ -142,37 +142,27 @@
"cc_import(name = 'foo', static_library = 'libfoo.a')");
Iterable<Artifact> libraries =
LinkerInputs.toNonSolibArtifacts(
- target
- .get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(false, false)
- .getLibraries());
+ target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForExecutable().getLibraries());
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.a");
libraries =
LinkerInputs.toNonSolibArtifacts(
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(false, true)
+ .getDynamicModeParamsForDynamicLibrary()
.getLibraries());
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.a");
libraries =
LinkerInputs.toNonSolibArtifacts(
+ target.get(CcLinkingInfo.PROVIDER).getStaticModeParamsForExecutable().getLibraries());
+ assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.a");
+
+ libraries =
+ LinkerInputs.toNonSolibArtifacts(
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(true, false)
- .getLibraries());
- assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.a");
-
- libraries =
- LinkerInputs.toNonSolibArtifacts(
- target
- .get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(true, true)
+ .getStaticModeParamsForDynamicLibrary()
.getLibraries());
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.a");
}
@@ -187,31 +177,28 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', shared_library = 'libfoo.so')");
CcLinkParams ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(false, false);
+ target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForExecutable();
Iterable<Artifact> libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
Iterable<Artifact> dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.so");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sa_Cfoo___Ua/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(false, true);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForDynamicLibrary();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.so");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sa_Cfoo___Ua/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(true, false);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getStaticModeParamsForExecutable();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.so");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sa_Cfoo___Ua/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(true, true);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getStaticModeParamsForDynamicLibrary();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.so");
@@ -230,31 +217,28 @@
"cc_import(name = 'foo', shared_library = 'libfoo.so',"
+ " interface_library = 'libfoo.ifso')");
CcLinkParams ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(false, false);
+ target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForExecutable();
Iterable<Artifact> libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
Iterable<Artifact> dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src b/libfoo.ifso");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sb_Cfoo___Ub/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(false, true);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForDynamicLibrary();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src b/libfoo.ifso");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sb_Cfoo___Ub/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(true, false);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getStaticModeParamsForExecutable();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src b/libfoo.ifso");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sb_Cfoo___Ub/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(true, true);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getStaticModeParamsForDynamicLibrary();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src b/libfoo.ifso");
@@ -272,30 +256,27 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', static_library = 'libfoo.a', shared_library = 'libfoo.so')");
CcLinkParams ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(false, false);
+ target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForExecutable();
Iterable<Artifact> libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
Iterable<Artifact> dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.so");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sa_Cfoo___Ua/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(false, true);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForDynamicLibrary();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.so");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime))
.containsExactly("bin _solib_k8/_U_S_Sa_Cfoo___Ua/libfoo.so");
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(true, false);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getStaticModeParamsForExecutable();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.a");
assertThat(artifactsToStrings(dynamicLibrariesForRuntime)).isEmpty();
- ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(true, true);
+ ccLinkParams = target.get(CcLinkingInfo.PROVIDER).getStaticModeParamsForDynamicLibrary();
libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.a");
@@ -313,8 +294,7 @@
LibraryToLink libraryToLink =
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(false, false)
+ .getDynamicModeParamsForExecutable()
.getLibraries()
.toList()
.get(0);
@@ -331,7 +311,7 @@
skylarkImplementationLoadStatement,
"cc_import(name = 'foo', interface_library = 'libfoo.ifso', system_provided = 1)");
CcLinkParams ccLinkParams =
- target.get(CcLinkingInfo.PROVIDER).getCcLinkParamsStore().getCcLinkParams(false, false);
+ target.get(CcLinkingInfo.PROVIDER).getDynamicModeParamsForExecutable();
Iterable<Artifact> libraries = LinkerInputs.toNonSolibArtifacts(ccLinkParams.getLibraries());
Iterable<Artifact> dynamicLibrariesForRuntime = ccLinkParams.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).containsExactly("src a/libfoo.ifso");
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 f630f34..408dc5f 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
@@ -219,8 +219,7 @@
assertThat(
hello
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .get(/* linkingStatically= */ false, /* linkShared= */ false)
+ .getDynamicModeParamsForExecutable()
.getDynamicLibrariesForRuntime())
.containsExactly(implSharedObjectLink);
}
@@ -285,8 +284,7 @@
assertThat(
hello
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .get(/* linkingStatically= */ false, /* linkShared= */ false)
+ .getDynamicModeParamsForExecutable()
.getDynamicLibrariesForRuntime())
.containsExactly(implSharedObjectLink);
}
@@ -297,8 +295,7 @@
assertThat(
hello
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(false, false)
+ .getDynamicModeParamsForExecutable()
.getLinkopts()
.isEmpty())
.isTrue();
@@ -1366,8 +1363,7 @@
LinkerInputs.toNonSolibArtifacts(
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(true, true)
+ .getStaticModeParamsForDynamicLibrary()
.getLibraries());
assertThat(artifactsToStrings(libraries)).contains("bin a/libfoo.a");
}
@@ -1382,8 +1378,7 @@
LinkerInputs.toNonSolibArtifacts(
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(true, true)
+ .getStaticModeParamsForDynamicLibrary()
.getLibraries());
assertThat(artifactsToStrings(libraries)).doesNotContain("bin a/libfoo.a");
assertThat(artifactsToStrings(libraries)).contains("src a/libfoo.so");
@@ -1399,8 +1394,7 @@
LinkerInputs.toNonSolibArtifacts(
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(true, true)
+ .getStaticModeParamsForDynamicLibrary()
.getLibraries());
assertThat(artifactsToStrings(libraries)).doesNotContain("src a/libfoo.so");
assertThat(artifactsToStrings(libraries)).contains("src a/libfoo.lo");
@@ -1418,8 +1412,7 @@
Iterable<Artifact> libraries =
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(false, true)
+ .getDynamicModeParamsForDynamicLibrary()
.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).doesNotContain("bin a/libfoo.ifso");
assertThat(artifactsToStrings(libraries)).contains("bin a/libfoo.so");
@@ -1433,8 +1426,7 @@
Iterable<Artifact> libraries =
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(false, true)
+ .getDynamicModeParamsForDynamicLibrary()
.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).doesNotContain("bin _solib_k8/liba_Slibfoo.ifso");
assertThat(artifactsToStrings(libraries)).contains("bin _solib_k8/liba_Slibfoo.so");
@@ -1449,8 +1441,7 @@
Iterable<Artifact> libraries =
target
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .getCcLinkParams(false, true)
+ .getDynamicModeParamsForDynamicLibrary()
.getDynamicLibrariesForRuntime();
assertThat(artifactsToStrings(libraries)).isEmpty();
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
index 130c5ff..0bc3f0a 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LibraryLinkingTest.java
@@ -111,8 +111,7 @@
Iterables.getOnlyElement(
ccLib
.get(CcLinkingInfo.PROVIDER)
- .getCcLinkParamsStore()
- .get(/* linkingStatically= */ false, /* linkShared= */ false)
+ .getDynamicModeParamsForExecutable()
.getDynamicLibrariesForRuntime());
// This artifact is generated by a SolibSymlinkAction, so we need to go back two levels.
CppLinkAction solibLink =