aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Cal Peyser <cpeyser@google.com>2017-03-14 14:57:53 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-03-14 19:50:28 +0000
commit6140817ad14fbc2a80c9f6e8556657d5156fb1b1 (patch)
treea33ca703127bb97611f1f4cb0b4e44506fc2c0a2 /src/main
parent37c51ae72c5a23af0cd5325b1592057370f5b650 (diff)
apple_binary scopes link artifacts using child configuration for --experimental_objc_crosstool=all
-- PiperOrigin-RevId: 150066766 MOS_MIGRATED_REVID=150066766
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java21
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java10
4 files changed, 36 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java
index b0183e09e5..e2c04b7608 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java
@@ -189,7 +189,8 @@ public abstract class CcLibrary implements RuleConfiguredTargetFactory {
// which only happens when some rule explicitly depends on the dynamic library.
if (!createDynamicLibrary && !supportsDynamicLinker) {
Artifact solibArtifact =
- CppHelper.getLinuxLinkedArtifact(ruleContext, LinkTargetType.DYNAMIC_LIBRARY);
+ CppHelper.getLinuxLinkedArtifact(
+ ruleContext, ruleContext.getConfiguration(), LinkTargetType.DYNAMIC_LIBRARY);
ruleContext.registerAction(new FailAction(ruleContext.getActionOwner(),
ImmutableList.of(solibArtifact), "Toolchain does not support dynamic linking"));
} else if (!createDynamicLibrary
@@ -200,7 +201,8 @@ public abstract class CcLibrary implements RuleConfiguredTargetFactory {
// generate an .so with. If that's the case, register a fake generating action to prevent
// a "no generating action for this artifact" error.
Artifact solibArtifact =
- CppHelper.getLinuxLinkedArtifact(ruleContext, LinkTargetType.DYNAMIC_LIBRARY);
+ CppHelper.getLinuxLinkedArtifact(
+ ruleContext, ruleContext.getConfiguration(), LinkTargetType.DYNAMIC_LIBRARY);
ruleContext.registerAction(new FailAction(ruleContext.getActionOwner(),
ImmutableList.of(solibArtifact), "configurable \"srcs\" triggers an implicit .so output "
+ "even though there are no sources to compile in this configuration"));
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
index 4151d995c7..f3f2e70026 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibraryHelper.java
@@ -1100,19 +1100,26 @@ public final class CcLibraryHelper {
archiveFile.add(
CppHelper.getLinuxLinkedArtifact(
ruleContext,
+ configuration,
Link.LinkTargetType.ALWAYS_LINK_STATIC_LIBRARY,
linkedArtifactNameSuffix));
} else {
archiveFile.add(
CppHelper.getLinuxLinkedArtifact(
- ruleContext, Link.LinkTargetType.STATIC_LIBRARY, linkedArtifactNameSuffix));
+ ruleContext,
+ configuration,
+ Link.LinkTargetType.STATIC_LIBRARY,
+ linkedArtifactNameSuffix));
}
if (!ruleContext.attributes().get("linkstatic", Type.BOOLEAN)
&& !ccOutputs.isEmpty()) {
dynamicLibrary.add(
CppHelper.getLinuxLinkedArtifact(
- ruleContext, Link.LinkTargetType.DYNAMIC_LIBRARY, linkedArtifactNameSuffix));
+ ruleContext,
+ configuration,
+ Link.LinkTargetType.DYNAMIC_LIBRARY,
+ linkedArtifactNameSuffix));
}
outputGroups.put("archive", archiveFile.build());
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 92df63420e..3134aad034 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
@@ -342,13 +342,23 @@ public class CppHelper {
src.getRoot());
}
- /** Returns the linked artifact for linux. */
- public static Artifact getLinuxLinkedArtifact(RuleContext ruleContext, LinkTargetType linkType) {
- return getLinuxLinkedArtifact(ruleContext, linkType, "");
+ /**
+ * Returns the linked artifact for linux.
+ *
+ * @param ruleContext the ruleContext to be used to scope the artifact
+ * @param config the configuration to be used to scope the artifact
+ * @param linkType the type of artifact, used to determine extension
+ */
+ public static Artifact getLinuxLinkedArtifact(
+ RuleContext ruleContext, BuildConfiguration config, LinkTargetType linkType) {
+ return getLinuxLinkedArtifact(ruleContext, config, linkType, "");
}
/** Returns the linked artifact with the given suffix for linux. */
- public static Artifact getLinuxLinkedArtifact(RuleContext ruleContext, LinkTargetType linkType,
+ public static Artifact getLinuxLinkedArtifact(
+ RuleContext ruleContext,
+ BuildConfiguration config,
+ LinkTargetType linkType,
String linkedArtifactNameSuffix) {
PathFragment name = new PathFragment(ruleContext.getLabel().getName());
if (linkType != LinkTargetType.EXECUTABLE) {
@@ -356,7 +366,8 @@ public class CppHelper {
"lib" + name.getBaseName() + linkedArtifactNameSuffix + linkType.getExtension());
}
- return ruleContext.getBinArtifact(name);
+ return ruleContext.getPackageRelativeArtifact(
+ name, config.getBinDirectory(ruleContext.getRule().getRepository()));
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
index 3d27459a85..bca504c0cf 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
@@ -957,8 +957,9 @@ public final class CppModel {
*/
private Artifact getLinkedArtifact(LinkTargetType linkTargetType) throws RuleErrorException {
Artifact result = null;
- Artifact linuxDefault = CppHelper.getLinuxLinkedArtifact(
- ruleContext, linkTargetType, linkedArtifactNameSuffix);
+ Artifact linuxDefault =
+ CppHelper.getLinuxLinkedArtifact(
+ ruleContext, configuration, linkTargetType, linkedArtifactNameSuffix);
try {
String maybePicName = ruleContext.getLabel().getName() + linkedArtifactNameSuffix;
@@ -1117,7 +1118,10 @@ public final class CppModel {
if (cppConfiguration.useInterfaceSharedObjects() && allowInterfaceSharedObjects) {
soInterface =
CppHelper.getLinuxLinkedArtifact(
- ruleContext, LinkTargetType.INTERFACE_DYNAMIC_LIBRARY, linkedArtifactNameSuffix);
+ ruleContext,
+ configuration,
+ LinkTargetType.INTERFACE_DYNAMIC_LIBRARY,
+ linkedArtifactNameSuffix);
sonameLinkopts = ImmutableList.of("-Wl,-soname=" +
SolibSymlinkAction.getDynamicLibrarySoname(soImpl.getRootRelativePath(), false));
}