aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar plf <plf@google.com>2018-08-06 04:52:10 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-06 04:53:58 -0700
commitdb18e6b4c8a7cbb5c19cd1af74da8b7e503d33bf (patch)
tree16c6fc5a03ade87844093cd130b8741e2a75bbf8 /src/main/java/com/google/devtools/build/lib/rules
parentddd14b78958f360bfa23eba7b9d1a0a0f492443e (diff)
C++: Removes calls to setCcLinkparamsStore of CcLinkingInfo.Builder
This is in preparation for deleting CcLinkParamsStore. All remaining calls to the setCcLinkparamsStore method of the CcLinkingInfo builder have been removed. See b/111781390 for details of rollback. RELNOTES:none PiperOrigin-RevId: 207525881
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java74
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingInfo.java113
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java42
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryCcLinkParamsStore.java61
5 files changed, 142 insertions, 161 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 871def83e3..167a44aa92 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
@@ -887,15 +887,14 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory {
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
+ // --noexperimental_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));
+ ccLinkingInfoBuilder
+ .setStaticModeParamsForDynamicLibrary(CcLinkParams.EMPTY)
+ .setStaticModeParamsForExecutable(CcLinkParams.EMPTY)
+ .setDynamicModeParamsForDynamicLibrary(CcLinkParams.EMPTY)
+ .setDynamicModeParamsForExecutable(CcLinkParams.EMPTY);
if (cppConfiguration.enableCcDynamicLibrariesForRuntime()) {
ccLinkingInfoBuilder.setCcDynamicLibrariesForRuntime(
new CcDynamicLibrariesForRuntime(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java
index 2c0e64e638..e5eb997365 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java
@@ -55,6 +55,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import java.util.function.BiFunction;
import javax.annotation.Nullable;
/**
@@ -536,11 +537,45 @@ public final class CcLinkingHelper {
collectDynamicLibrariesForRuntimeArtifacts(
ccLinkingOutputs.getDynamicLibrariesForRuntime()));
}
- CppConfiguration cppConfiguration = ruleContext.getFragment(CppConfiguration.class);
- boolean forcePic = cppConfiguration.forcePic();
- ccLinkingInfoBuilder.setCcLinkParamsStore(
- new CcLinkParamsStore(
- createCcLinkParamsStore(ccLinkingOutputs, ccCompilationContext, forcePic)));
+
+ final CcLinkingOutputs ccLinkingOutputsFinalized = ccLinkingOutputs;
+ BiFunction<Boolean, Boolean, CcLinkParams> createParams =
+ (staticMode, forDynamicLibrary) -> {
+ CcLinkParams.Builder builder = CcLinkParams.builder();
+ builder.addLinkstamps(linkstamps.build(), ccCompilationContext);
+ for (CcLinkingInfo ccLinkingInfo : ccLinkingInfos) {
+ builder.addTransitiveArgs(
+ ccLinkingInfo.getCcLinkParams(
+ /* staticMode= */ staticMode, /* forDynamicLibrary */ forDynamicLibrary));
+ }
+ if (!neverlink) {
+ builder.addLibraries(
+ ccLinkingOutputsFinalized.getPreferredLibraries(
+ staticMode,
+ /*preferPic=*/ forDynamicLibrary
+ || ruleContext.getFragment(CppConfiguration.class).forcePic()));
+ if (!staticMode
+ || (ccLinkingOutputsFinalized.getStaticLibraries().isEmpty()
+ && ccLinkingOutputsFinalized.getPicStaticLibraries().isEmpty())) {
+ builder.addDynamicLibrariesForRuntime(
+ LinkerInputs.toLibraryArtifacts(
+ ccLinkingOutputsFinalized.getDynamicLibrariesForRuntime()));
+ }
+ builder.addLinkOpts(linkopts);
+ builder.addNonCodeInputs(nonCodeLinkerInputs);
+ }
+ return builder.build();
+ };
+
+ ccLinkingInfoBuilder
+ .setStaticModeParamsForDynamicLibrary(
+ createParams.apply(/* staticMode= */ true, /* forDynamicLibrary= */ true))
+ .setStaticModeParamsForExecutable(
+ createParams.apply(/* staticMode= */ true, /* forDynamicLibrary= */ false))
+ .setDynamicModeParamsForDynamicLibrary(
+ createParams.apply(/* staticMode= */ false, /* forDynamicLibrary= */ true))
+ .setDynamicModeParamsForExecutable(
+ createParams.apply(/* staticMode= */ false, /* forDynamicLibrary= */ false));
providers.put(ccLinkingInfoBuilder.build());
return new LinkingInfo(
providers.build(), outputGroups, ccLinkingOutputs, originalLinkingOutputs);
@@ -611,35 +646,6 @@ public final class CcLinkingHelper {
outputGroups.put(DYNAMIC_LIBRARY_OUTPUT_GROUP_NAME, dynamicLibrary.build());
}
- private AbstractCcLinkParamsStore createCcLinkParamsStore(
- final CcLinkingOutputs ccLinkingOutputs,
- final CcCompilationContext ccCompilationContext,
- final boolean forcePic) {
- return new AbstractCcLinkParamsStore() {
- @Override
- protected void collect(
- CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) {
- builder.addLinkstamps(linkstamps.build(), ccCompilationContext);
- for (CcLinkingInfo ccLinkingInfo : ccLinkingInfos) {
- builder.add(ccLinkingInfo.getCcLinkParamsStore());
- }
- if (!neverlink) {
- builder.addLibraries(
- ccLinkingOutputs.getPreferredLibraries(
- linkingStatically, /*preferPic=*/ linkShared || forcePic));
- if (!linkingStatically
- || (ccLinkingOutputs.getStaticLibraries().isEmpty()
- && ccLinkingOutputs.getPicStaticLibraries().isEmpty())) {
- builder.addDynamicLibrariesForRuntime(
- LinkerInputs.toLibraryArtifacts(ccLinkingOutputs.getDynamicLibrariesForRuntime()));
- }
- builder.addLinkOpts(linkopts);
- builder.addNonCodeInputs(nonCodeLinkerInputs);
- }
- }
- };
- }
-
private NestedSet<LinkerInput> collectNativeCcLibraries(CcLinkingOutputs ccLinkingOutputs) {
NestedSetBuilder<LinkerInput> result = NestedSetBuilder.linkOrder();
result.addAll(ccLinkingOutputs.getDynamicLibrariesForLinking());
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 123a824302..e94be13775 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,7 +30,6 @@ 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. */
@@ -93,12 +92,11 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi
throw new EvalException(
loc, "Every CcLinkParams parameter must be passed to CcLinkingInfo.");
}
- ccLinkingInfoBuilder.setCcLinkParamsStore(
- new CcLinkParamsStore(
- staticModeParamsForDynamicLibrary,
- staticModeParamsForExecutable,
- dynamicModeParamsForDynamicLibrary,
- dynamicModeParamsForExecutable));
+ ccLinkingInfoBuilder
+ .setStaticModeParamsForDynamicLibrary(staticModeParamsForDynamicLibrary)
+ .setStaticModeParamsForExecutable(staticModeParamsForExecutable)
+ .setDynamicModeParamsForDynamicLibrary(dynamicModeParamsForDynamicLibrary)
+ .setDynamicModeParamsForExecutable(dynamicModeParamsForExecutable);
// TODO(plf): The CcDynamicLibrariesForRuntime provider can be removed perhaps. Do not
// add to the API until we know for sure. The CcRunfiles provider is already in the API
// at the time of this comment (cl/200184914). Perhaps it can be removed but Skylark rules
@@ -110,12 +108,10 @@ 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))
+ .setStaticModeParamsForDynamicLibrary(CcLinkParams.EMPTY)
+ .setStaticModeParamsForExecutable(CcLinkParams.EMPTY)
+ .setDynamicModeParamsForDynamicLibrary(CcLinkParams.EMPTY)
+ .setDynamicModeParamsForExecutable(CcLinkParams.EMPTY)
.build();
private final CcLinkParamsStore ccLinkParamsStore;
@@ -163,13 +159,26 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi
}
public static CcLinkingInfo merge(Collection<CcLinkingInfo> ccLinkingInfos) {
- CcLinkingInfo.Builder builder = new CcLinkingInfo.Builder();
- builder.setCcLinkParamsStore(
- CcLinkParamsStore.merge(
- Stream.concat(Stream.of(CcLinkingInfo.EMPTY), ccLinkingInfos.stream())
- .map(CcLinkingInfo::getCcLinkParamsStore)
- .collect(ImmutableList.toImmutableList())));
- return builder.build();
+ CcLinkParams.Builder staticModeParamsForDynamicLibraryBuilder = CcLinkParams.builder();
+ CcLinkParams.Builder staticModeParamsForExecutableBuilder = CcLinkParams.builder();
+ CcLinkParams.Builder dynamicModeParamsForDynamicLibraryBuilder = CcLinkParams.builder();
+ CcLinkParams.Builder dynamicModeParamsForExecutableBuilder = CcLinkParams.builder();
+ for (CcLinkingInfo ccLinkingInfo : ccLinkingInfos) {
+ staticModeParamsForDynamicLibraryBuilder.addTransitiveArgs(
+ ccLinkingInfo.getStaticModeParamsForDynamicLibrary());
+ staticModeParamsForExecutableBuilder.addTransitiveArgs(
+ ccLinkingInfo.getStaticModeParamsForExecutable());
+ dynamicModeParamsForDynamicLibraryBuilder.addTransitiveArgs(
+ ccLinkingInfo.getDynamicModeParamsForDynamicLibrary());
+ dynamicModeParamsForExecutableBuilder.addTransitiveArgs(
+ ccLinkingInfo.getDynamicModeParamsForExecutable());
+ }
+ return new CcLinkingInfo.Builder()
+ .setStaticModeParamsForDynamicLibrary(staticModeParamsForDynamicLibraryBuilder.build())
+ .setStaticModeParamsForExecutable(staticModeParamsForExecutableBuilder.build())
+ .setDynamicModeParamsForDynamicLibrary(dynamicModeParamsForDynamicLibraryBuilder.build())
+ .setDynamicModeParamsForExecutable(dynamicModeParamsForExecutableBuilder.build())
+ .build();
}
@Override
@@ -181,9 +190,24 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi
return ccDynamicLibrariesForRuntime;
}
+ public CcLinkParams getCcLinkParams(boolean staticMode, boolean forDynamicLibrary) {
+ if (staticMode) {
+ if (forDynamicLibrary) {
+ return getStaticModeParamsForDynamicLibrary();
+ } else {
+ return getStaticModeParamsForExecutable();
+ }
+ } else {
+ if (forDynamicLibrary) {
+ return getDynamicModeParamsForDynamicLibrary();
+ } else {
+ return getDynamicModeParamsForExecutable();
+ }
+ }
+ }
+
/** A Builder for {@link CcLinkingInfo}. */
public static class Builder {
- CcLinkParamsStore ccLinkParamsStore;
CcLinkParams staticModeParamsForDynamicLibrary;
CcLinkParams staticModeParamsForExecutable;
CcLinkParams dynamicModeParamsForDynamicLibrary;
@@ -195,19 +219,6 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi
return new CcLinkingInfo.Builder();
}
- @Deprecated
- // TODO(b/111781390): Use individual setters for each flavor of CcLinkParams. Not all call sites
- // are being refactored at once. Work in progress.
- public Builder setCcLinkParamsStore(CcLinkParamsStore ccLinkParamsStore) {
- Preconditions.checkState(this.ccLinkParamsStore == null);
- Preconditions.checkState(this.staticModeParamsForDynamicLibrary == null);
- Preconditions.checkState(this.staticModeParamsForExecutable == null);
- Preconditions.checkState(this.dynamicModeParamsForDynamicLibrary == null);
- Preconditions.checkState(this.dynamicModeParamsForExecutable == null);
- this.ccLinkParamsStore = ccLinkParamsStore;
- return this;
- }
-
public Builder setCcRunfiles(CcRunfiles ccRunfiles) {
Preconditions.checkState(this.ccRunfiles == null);
this.ccRunfiles = ccRunfiles;
@@ -222,46 +233,40 @@ public final class CcLinkingInfo extends NativeInfo implements CcLinkingInfoApi
}
public Builder setStaticModeParamsForDynamicLibrary(CcLinkParams ccLinkParams) {
- Preconditions.checkState(
- this.staticModeParamsForDynamicLibrary == null && ccLinkParamsStore == null);
+ Preconditions.checkState(this.staticModeParamsForDynamicLibrary == null);
this.staticModeParamsForDynamicLibrary = ccLinkParams;
return this;
}
public Builder setStaticModeParamsForExecutable(CcLinkParams ccLinkParams) {
- Preconditions.checkState(
- this.staticModeParamsForExecutable == null && ccLinkParamsStore == null);
+ Preconditions.checkState(this.staticModeParamsForExecutable == null);
this.staticModeParamsForExecutable = ccLinkParams;
return this;
}
public Builder setDynamicModeParamsForDynamicLibrary(CcLinkParams ccLinkParams) {
- Preconditions.checkState(
- this.dynamicModeParamsForDynamicLibrary == null && ccLinkParamsStore == null);
+ Preconditions.checkState(this.dynamicModeParamsForDynamicLibrary == null);
this.dynamicModeParamsForDynamicLibrary = ccLinkParams;
return this;
}
public Builder setDynamicModeParamsForExecutable(CcLinkParams ccLinkParams) {
- Preconditions.checkState(
- this.dynamicModeParamsForExecutable == null && ccLinkParamsStore == null);
+ Preconditions.checkState(this.dynamicModeParamsForExecutable == null);
this.dynamicModeParamsForExecutable = ccLinkParams;
return this;
}
public CcLinkingInfo build() {
- if (ccLinkParamsStore == null) {
- Preconditions.checkNotNull(staticModeParamsForDynamicLibrary);
- Preconditions.checkNotNull(staticModeParamsForExecutable);
- Preconditions.checkNotNull(dynamicModeParamsForDynamicLibrary);
- Preconditions.checkNotNull(dynamicModeParamsForExecutable);
- ccLinkParamsStore =
- new CcLinkParamsStore(
- staticModeParamsForDynamicLibrary,
- staticModeParamsForExecutable,
- dynamicModeParamsForDynamicLibrary,
- dynamicModeParamsForExecutable);
- }
+ Preconditions.checkNotNull(staticModeParamsForDynamicLibrary);
+ Preconditions.checkNotNull(staticModeParamsForExecutable);
+ Preconditions.checkNotNull(dynamicModeParamsForDynamicLibrary);
+ Preconditions.checkNotNull(dynamicModeParamsForExecutable);
+ CcLinkParamsStore ccLinkParamsStore =
+ new CcLinkParamsStore(
+ staticModeParamsForDynamicLibrary,
+ staticModeParamsForExecutable,
+ dynamicModeParamsForDynamicLibrary,
+ dynamicModeParamsForExecutable);
return new CcLinkingInfo(ccLinkParamsStore, ccRunfiles, ccDynamicLibrariesForRuntime);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java
index 42741b573b..ff8e381864 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java
@@ -15,6 +15,7 @@
package com.google.devtools.build.lib.rules.objc;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
@@ -24,12 +25,16 @@ import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTa
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesProvider;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
+import com.google.devtools.build.lib.rules.cpp.ArtifactCategory;
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.CcLinkParamsStore;
+import com.google.devtools.build.lib.rules.cpp.CcLinkParams;
import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
+import com.google.devtools.build.lib.rules.cpp.LinkerInputs;
+import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink;
import com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes;
import com.google.devtools.build.lib.syntax.Type;
+import com.google.devtools.build.lib.vfs.FileSystemUtils;
import java.util.Map;
import java.util.TreeMap;
@@ -105,9 +110,14 @@ public class ObjcLibrary implements RuleConfiguredTargetFactory {
CcCompilationInfo.Builder ccCompilationInfoBuilder = CcCompilationInfo.Builder.create();
ccCompilationInfoBuilder.setCcCompilationContext(ccCompilationContext);
- CcLinkingInfo.Builder ccLinkingInfoBuilder = CcLinkingInfo.Builder.create();
- ccLinkingInfoBuilder.setCcLinkParamsStore(
- new CcLinkParamsStore(new ObjcLibraryCcLinkParamsStore(common)));
+ CcLinkParams ccLinkParams = buildCcLinkParams(common);
+ CcLinkingInfo ccLinkingInfo =
+ CcLinkingInfo.Builder.create()
+ .setStaticModeParamsForDynamicLibrary(ccLinkParams)
+ .setStaticModeParamsForExecutable(ccLinkParams)
+ .setDynamicModeParamsForDynamicLibrary(ccLinkParams)
+ .setDynamicModeParamsForExecutable(ccLinkParams)
+ .build();
return ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build())
.addNativeDeclaredProvider(common.getObjcProvider())
@@ -117,11 +127,33 @@ public class ObjcLibrary implements RuleConfiguredTargetFactory {
.addProvider(
InstrumentedFilesProvider.class,
compilationSupport.getInstrumentedFilesProvider(objectFilesCollector.build()))
- .addNativeDeclaredProvider(ccLinkingInfoBuilder.build())
+ .addNativeDeclaredProvider(ccLinkingInfo)
.addOutputGroups(outputGroupCollector)
.build();
}
+ public CcLinkParams buildCcLinkParams(ObjcCommon common) {
+ ImmutableSet.Builder<LibraryToLink> libraries = new ImmutableSet.Builder<>();
+ ObjcProvider objcProvider = common.getObjcProvider();
+ for (Artifact library : objcProvider.get(ObjcProvider.LIBRARY)) {
+ libraries.add(
+ LinkerInputs.opaqueLibraryToLink(
+ library,
+ ArtifactCategory.STATIC_LIBRARY,
+ FileSystemUtils.removeExtension(library.getRootRelativePathString())));
+ }
+ libraries.addAll(objcProvider.get(ObjcProvider.CC_LIBRARY));
+
+ CcLinkParams.Builder builder = CcLinkParams.builder();
+ builder.addLibraries(libraries.build());
+
+ for (SdkFramework sdkFramework : objcProvider.get(ObjcProvider.SDK_FRAMEWORK)) {
+ builder.addLinkOpts(ImmutableList.of("-framework", sdkFramework.getName()));
+ }
+
+ return builder.build();
+ }
+
/** Throws errors or warnings for bad attribute state. */
private static void validateAttributes(RuleContext ruleContext) {
for (String copt : ObjcCommon.getNonCrosstoolCopts(ruleContext)) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryCcLinkParamsStore.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryCcLinkParamsStore.java
deleted file mode 100644
index a97ba8403d..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryCcLinkParamsStore.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2016 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.build.lib.rules.objc;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.rules.cpp.AbstractCcLinkParamsStore;
-import com.google.devtools.build.lib.rules.cpp.ArtifactCategory;
-import com.google.devtools.build.lib.rules.cpp.CcLinkParams;
-import com.google.devtools.build.lib.rules.cpp.LinkerInputs;
-import com.google.devtools.build.lib.rules.cpp.LinkerInputs.LibraryToLink;
-import com.google.devtools.build.lib.vfs.FileSystemUtils;
-
-/**
- * A {@link AbstractCcLinkParamsStore} to be propagated to dependent cc_{library, binary} targets.
- */
-class ObjcLibraryCcLinkParamsStore extends AbstractCcLinkParamsStore {
-
- private final ObjcCommon common;
-
- /**
- * Create a params store.
- *
- * @param common the {@link ObjcCommon} instance for this target.
- */
- public ObjcLibraryCcLinkParamsStore(ObjcCommon common) {
- this.common = common;
- }
-
- @Override
- protected void collect(
- CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) {
- ObjcProvider objcProvider = common.getObjcProvider();
-
- ImmutableSet.Builder<LibraryToLink> libraries = new ImmutableSet.Builder<>();
- for (Artifact library : objcProvider.get(ObjcProvider.LIBRARY)) {
- libraries.add(LinkerInputs.opaqueLibraryToLink(
- library, ArtifactCategory.STATIC_LIBRARY,
- FileSystemUtils.removeExtension(library.getRootRelativePathString())));
- }
- libraries.addAll(objcProvider.get(ObjcProvider.CC_LIBRARY));
- builder.addLibraries(libraries.build());
-
- for (SdkFramework sdkFramework : objcProvider.get(ObjcProvider.SDK_FRAMEWORK)) {
- builder.addLinkOpts(ImmutableList.of("-framework", sdkFramework.getName()));
- }
- }
-} \ No newline at end of file