aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/apple
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2018-07-26 07:44:33 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-26 07:45:49 -0700
commit74146fdbcc4eb0463e64588a764b22e253a405ac (patch)
treef37bc5ac2ae707274f1bd3fbb4a8f90682980c70 /src/main/java/com/google/devtools/build/lib/rules/apple
parent676e0cd86b51e37cfa710e456b22853914c1cf0a (diff)
Add a flag to make Apple rules not share C++ compile actions.
This is accomplished by: - Setting the APPLE_CROSSTOOL configuration distinguisher in AppleCrosstoolTransition - Doing nothing in AppleCrosstoolTransition in case we are already in an Apple configuration so that funky use cases like a binary having a dependency on a swift_library both directly and through an objc_library work - Adding the "apl-" prefix to the output directory name in APPLE_CROSSTOOL configurations Plus a few minor cleanups: - Removed some unused methods - Nopped out --enable_apple_crosstool_transition if the new flag is set - Nopped out --target_uses_apple_crosstool if the new flag is set These latter reduce the possible space of Apple configurations, thus making the code a bit more comprehensible. RELNOTES: None. PiperOrigin-RevId: 206157413
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/apple')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java39
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java31
2 files changed, 20 insertions, 50 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
index 5a2ff9d259..af55552e95 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
@@ -15,7 +15,6 @@
package com.google.devtools.build.lib.rules.apple;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.DefaultLabelConverter;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelConverter;
@@ -333,6 +332,16 @@ public class AppleCommandLineOptions extends FragmentOptions {
public boolean enableAppleCrosstoolTransition;
@Option(
+ name = "apple_crosstool_in_output_directory_name",
+ defaultValue = "false",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
+ metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
+ help = "If true, all Apple configurations have a different output directory than non-Apple "
+ + "ones")
+ public boolean appleCrosstoolInOutputDirectoryName;
+
+ @Option(
name = "target_uses_apple_crosstool",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
@@ -358,34 +367,6 @@ public class AppleCommandLineOptions extends FragmentOptions {
}
/**
- * Returns the architecture implied by these options.
- *
- * <p>In contexts in which a configuration instance is present, prefer {@link
- * AppleConfiguration#getSingleArchitecture}.
- */
- public String getSingleArchitecture() {
- if (!Strings.isNullOrEmpty(appleSplitCpu)) {
- return appleSplitCpu;
- }
- switch (applePlatformType) {
- case IOS:
- if (!iosMultiCpus.isEmpty()) {
- return iosMultiCpus.get(0);
- } else {
- return iosCpu;
- }
- case WATCHOS:
- return watchosCpus.get(0);
- case TVOS:
- return tvosCpus.get(0);
- case MACOS:
- return macosCpus.get(0);
- default:
- throw new IllegalArgumentException("Unhandled platform type " + applePlatformType);
- }
- }
-
- /**
* Represents the Apple Bitcode mode for compilation steps.
*
* <p>Bitcode is an intermediate representation of a compiled program. For many platforms, Apple
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
index 22333bb41a..530e62ad5c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java
@@ -383,24 +383,18 @@ public class AppleConfiguration extends BuildConfiguration.Fragment
return xcodeConfigLabel;
}
- /**
- * Returns the unique identifier distinguishing configurations that are otherwise the same.
- *
- * <p>Use this value for situations in which two configurations create two outputs that are the
- * same but are not collapsed due to their different configuration owners.
- */
- public ConfigurationDistinguisher getConfigurationDistinguisher() {
- return configurationDistinguisher;
- }
-
private boolean shouldDistinguishOutputDirectory() {
- if (configurationDistinguisher == ConfigurationDistinguisher.UNKNOWN) {
- return false;
- } else if (configurationDistinguisher == ConfigurationDistinguisher.APPLE_CROSSTOOL
- && isAppleCrosstoolEnabled()) {
- return false;
+ if (options.appleCrosstoolInOutputDirectoryName) {
+ return configurationDistinguisher != ConfigurationDistinguisher.UNKNOWN;
} else {
- return true;
+ if (configurationDistinguisher == ConfigurationDistinguisher.UNKNOWN) {
+ return false;
+ } else if (configurationDistinguisher == ConfigurationDistinguisher.APPLE_CROSSTOOL
+ && enableAppleCrosstool) {
+ return false;
+ } else {
+ return true;
+ }
}
}
@@ -439,11 +433,6 @@ public class AppleConfiguration extends BuildConfiguration.Fragment
return objcProviderFromLinked;
}
- /** Returns true if {@link AppleCrosstoolTransition} should be applied to every apple rule. */
- public boolean isAppleCrosstoolEnabled() {
- return enableAppleCrosstool;
- }
-
@Override
public boolean equals(Object obj) {
if (this == obj) {