aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-08-25 04:06:17 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-08-25 12:54:21 +0200
commite2bfb4bb4017b9a50b6e00b84d2fc52856323592 (patch)
tree330f938189fd33b2e5dd6480c5b2fcda32fe85ef /src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
parentb91ef056ce096bfe9f995080264980e418dada80 (diff)
Automated rollback of commit 1af9b1e2238c3b43a2b66233495ecf7b6ef4dcab.
*** Reason for rollback *** Reason for previous rollback was identified as being a memory regression causing some cases to hit java heap limit. Proposal is to increase java heap limit to compensate and just go with the original change. *** Original change description *** Automated rollback of commit 6cfffdf37e11018c7e6e2cabc90440d6d29c819b. PiperOrigin-RevId: 166426608
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java48
1 files changed, 32 insertions, 16 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
index c9716a5902..b787ebcaf5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
@@ -301,6 +301,7 @@ public abstract class CompilationSupport {
protected final IntermediateArtifacts intermediateArtifacts;
protected final boolean useDeps;
protected final Map<String, NestedSet<Artifact>> outputGroupCollector;
+ protected final CcToolchainProvider toolchain;
protected final boolean isTestRule;
protected final boolean usePch;
@@ -324,6 +325,7 @@ public abstract class CompilationSupport {
CompilationAttributes compilationAttributes,
boolean useDeps,
Map<String, NestedSet<Artifact>> outputGroupCollector,
+ CcToolchainProvider toolchain,
boolean isTestRule,
boolean usePch) {
this.ruleContext = ruleContext;
@@ -336,6 +338,18 @@ public abstract class CompilationSupport {
this.isTestRule = isTestRule;
this.outputGroupCollector = outputGroupCollector;
this.usePch = usePch;
+ // TODO(b/62143697): Remove this check once all rules are using the crosstool support.
+ if (ruleContext
+ .attributes()
+ .has(CcToolchain.CC_TOOLCHAIN_DEFAULT_ATTRIBUTE_NAME, BuildType.LABEL)) {
+ if (toolchain == null) {
+ toolchain = CppHelper.getToolchainUsingDefaultCcToolchainAttribute(ruleContext);
+ }
+ this.toolchain = toolchain;
+ } else {
+ // Since the rule context doesn't have a toolchain at all, ignore any provided override.
+ this.toolchain = null;
+ }
}
/** Builder for {@link CompilationSupport} */
@@ -347,6 +361,7 @@ public abstract class CompilationSupport {
private boolean useDeps = true;
private Map<String, NestedSet<Artifact>> outputGroupCollector;
private boolean isObjcLibrary = false;
+ private CcToolchainProvider toolchain;
private boolean isTestRule = false;
private boolean usePch = true;
@@ -423,6 +438,17 @@ public abstract class CompilationSupport {
}
/**
+ * Sets {@link CcToolchainProvider} for the calling target.
+ *
+ * <p>This is needed if it can't correctly be inferred directly from the rule context. Setting
+ * to null causes the default to be used as if this was never called.
+ */
+ public Builder setToolchainProvider(CcToolchainProvider toolchain) {
+ this.toolchain = toolchain;
+ return this;
+ }
+
+ /**
* Returns a {@link CompilationSupport} instance. This is either a {@link
* CrosstoolCompilationSupport} or {@link LegacyCompilationSupport} depending on the value of
* --experimental_objc_crosstool.
@@ -458,6 +484,7 @@ public abstract class CompilationSupport {
compilationAttributes,
useDeps,
outputGroupCollector,
+ toolchain,
isTestRule,
usePch);
} else {
@@ -468,6 +495,7 @@ public abstract class CompilationSupport {
compilationAttributes,
useDeps,
outputGroupCollector,
+ toolchain,
isTestRule,
usePch);
}
@@ -490,7 +518,7 @@ public abstract class CompilationSupport {
objcProvider,
ExtraCompileArgs.NONE,
ImmutableList.<PathFragment>of(),
- maybeGetCcToolchain(),
+ toolchain,
maybeGetFdoSupport());
}
@@ -571,7 +599,7 @@ public abstract class CompilationSupport {
return registerFullyLinkAction(
objcProvider,
outputArchive,
- maybeGetCcToolchain(),
+ toolchain,
maybeGetFdoSupport());
}
@@ -629,7 +657,7 @@ public abstract class CompilationSupport {
objcProvider,
inputArtifacts,
outputArchive,
- maybeGetCcToolchain(),
+ toolchain,
maybeGetFdoSupport());
}
@@ -758,7 +786,7 @@ public abstract class CompilationSupport {
common.getObjcProvider(),
extraCompileArgs,
priorityHeaders,
- maybeGetCcToolchain(),
+ toolchain,
maybeGetFdoSupport());
}
return this;
@@ -1444,18 +1472,6 @@ public abstract class CompilationSupport {
}
@Nullable
- private CcToolchainProvider maybeGetCcToolchain() {
- // TODO(rduan): Remove this check once all rules are using the crosstool support.
- if (ruleContext
- .attributes()
- .has(CcToolchain.CC_TOOLCHAIN_DEFAULT_ATTRIBUTE_NAME, BuildType.LABEL)) {
- return CppHelper.getToolchainUsingDefaultCcToolchainAttribute(ruleContext);
- } else {
- return null;
- }
- }
-
- @Nullable
private FdoSupportProvider maybeGetFdoSupport() {
// TODO(rduan): Remove this check once all rules are using the crosstool support.
if (ruleContext