aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolSplitTransition.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java15
-rwxr-xr-xsrc/test/shell/bazel/apple/bazel_objc_test.sh10
5 files changed, 28 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java
index f9268f84fa..696f581150 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java
@@ -114,7 +114,8 @@ public class BazelConfigurationCollection implements ConfigurationCollectionFact
@Override
public BuildConfiguration toplevelConfigurationHook(Target toTarget) {
ImmutableList<String> appleCrosstoolRuleClasses =
- AppleCrosstoolTransition.shouldUseAppleCrosstoolTransition(configuration.getOptions())
+ AppleCrosstoolTransition.appleCrosstoolTransitionIsAppliedForAllObjc(
+ configuration.getOptions())
? AppleConfiguration.APPLE_CROSSTOOL_RULE_CLASSES
: AppleConfiguration.APPLE_CROSSTOOL_RULE_CLASSES_FOR_STATIC_CONFIGS;
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 bba468d3a2..7438c3a52f 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
@@ -278,6 +278,14 @@ public class AppleCommandLineOptions extends FragmentOptions {
)
public boolean enableAppleCrosstoolTransition;
+ @Option(
+ name = "target_uses_apple_crosstool",
+ defaultValue = "false",
+ category = "undocumented",
+ help = "If true, this target uses the apple crosstool. Do not set this flag manually."
+ )
+ public boolean targetUsesAppleCrosstool;
+
private Platform getPlatform() {
for (String architecture : iosMultiCpus) {
if (Platform.forTarget(PlatformType.IOS, architecture) == Platform.IOS_DEVICE) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolSplitTransition.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolSplitTransition.java
index 8e919c088a..89df5b521f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolSplitTransition.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolSplitTransition.java
@@ -48,8 +48,14 @@ public class AppleCrosstoolSplitTransition implements SplitTransition<BuildOptio
@Override
public List<BuildOptions> split(BuildOptions buildOptions) {
BuildOptions result = buildOptions.clone();
- result.get(AppleCommandLineOptions.class).configurationDistinguisher =
- ConfigurationDistinguisher.APPLE_CROSSTOOL;
+
+ if (!AppleCrosstoolTransition.appleCrosstoolTransitionIsAppliedForAllObjc(buildOptions)) {
+ // If the apple crosstool is not applied universally, the apple crosstool distinguisher
+ // is required to prevent artifact collisions. Since AppleCrosstoolTransition is only applied
+ // when the crosstool is applied universally, the distinguisher only needs to be set here.
+ result.get(AppleCommandLineOptions.class).configurationDistinguisher =
+ ConfigurationDistinguisher.APPLE_CROSSTOOL;
+ }
// TODO(b/29355778): Once ios_cpu is retired, introduce another top-level flag (perhaps
// --apple_cpu) for toolchain selection in top-level consuming rules.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java
index 38c79dd84a..59cf36aa98 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleCrosstoolTransition.java
@@ -19,7 +19,6 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.PatchTransition;
import com.google.devtools.build.lib.rules.apple.AppleCommandLineOptions;
-import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher;
import com.google.devtools.build.lib.rules.cpp.CppOptions;
import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode;
@@ -43,14 +42,10 @@ public class AppleCrosstoolTransition implements PatchTransition {
public BuildOptions apply(BuildOptions buildOptions) {
BuildOptions result = buildOptions.clone();
- if (!shouldUseAppleCrosstoolTransition(buildOptions)) {
+ if (!appleCrosstoolTransitionIsAppliedForAllObjc(buildOptions)) {
return buildOptions;
}
- result.get(AppleCommandLineOptions.class).configurationDistinguisher =
- ConfigurationDistinguisher.APPLE_CROSSTOOL;
-
-
// TODO(b/29355778): Once ios_cpu is retired, introduce another top-level flag (perhaps
// --apple_cpu) for toolchain selection in top-level consuming rules.
String cpu = String.format("%s_%s",
@@ -74,7 +69,8 @@ public class AppleCrosstoolTransition implements PatchTransition {
BuildOptions to, String cpu) {
to.get(BuildConfiguration.Options.class).cpu = cpu;
to.get(CppOptions.class).crosstoolTop =
- from.get(AppleCommandLineOptions.class).appleCrosstoolTop;
+ from.get(AppleCommandLineOptions.class).appleCrosstoolTop;
+ to.get(AppleCommandLineOptions.class).targetUsesAppleCrosstool = true;
// --compiler = "compiler" for all OSX toolchains. We do not support asan/tsan, cfi, etc. on
// darwin.
@@ -90,10 +86,9 @@ public class AppleCrosstoolTransition implements PatchTransition {
}
/**
- * Returns true if the given options imply use of AppleCrosstoolTransition for all apple
- * targets.
+ * Returns true if the given options imply use of AppleCrosstoolTransition for all apple targets.
*/
- public static boolean shouldUseAppleCrosstoolTransition(BuildOptions options) {
+ public static boolean appleCrosstoolTransitionIsAppliedForAllObjc(BuildOptions options) {
return (options.get(AppleCommandLineOptions.class).enableAppleCrosstoolTransition
|| options.get(ObjcCommandLineOptions.class).experimentalObjcLibrary
|| options.get(ObjcCommandLineOptions.class).objcCrosstoolMode != ObjcCrosstoolMode.OFF);
diff --git a/src/test/shell/bazel/apple/bazel_objc_test.sh b/src/test/shell/bazel/apple/bazel_objc_test.sh
index 44cd8cd6b0..78dde29446 100755
--- a/src/test/shell/bazel/apple/bazel_objc_test.sh
+++ b/src/test/shell/bazel/apple/bazel_objc_test.sh
@@ -199,17 +199,17 @@ int aFunction() {
}
EOF
- bazel build --verbose_failures --ios_sdk_version=$IOS_SDK_VERSION \
- //objclib:objclib >"$TEST_log" 2>&1 || \
- fail "Should build objc_library"
+ bazel build --verbose_failures --apple_crosstool_transition \
+ --ios_sdk_version=$IOS_SDK_VERSION //objclib:objclib >"$TEST_log" 2>&1 \
+ || fail "Should build objc_library"
# Based on timezones, ar -tv may show the timestamp of the contents as either
# Dec 31 1969 or Jan 1 1970 -- either is fine.
# We would use 'date' here, but the format is slightly different (Jan 1 vs.
# Jan 01).
- ar -tv bazel-out/apl-ios_x86_64-fastbuild/bin/objclib/libobjclib.a \
+ ar -tv bazel-out/ios_x86_64-fastbuild/bin/objclib/libobjclib.a \
| grep "mysrc" | grep "Dec 31" | grep "1969" \
- || ar -tv bazel-out/apl-ios_x86_64-fastbuild/bin/objclib/libobjclib.a \
+ || ar -tv bazel-out/ios_x86_64-fastbuild/bin/objclib/libobjclib.a \
| grep "mysrc" | grep "Jan 1" | grep "1970" || \
fail "Timestamp of contents of archive file should be zero"
}