diff options
author | 2015-08-27 02:56:38 +0000 | |
---|---|---|
committer | 2015-08-27 14:45:10 +0000 | |
commit | 47107aad33695a040b0f771f0c09d66874c4d533 (patch) | |
tree | 43076cea086361d82530313cef193d97d9ebd760 /src/main/java/com/google/devtools/build | |
parent | 2e243a6e5ec029035e6d2d19ec4403ed9f5e8a33 (diff) |
Distinguish between user-supplied ios_cpu and the default, and don't propagate the default to the XCode project control.
--
MOS_MIGRATED_REVID=101644957
Diffstat (limited to 'src/main/java/com/google/devtools/build')
3 files changed, 47 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java index 047fd3c7d9..550aaea0a5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java @@ -15,6 +15,8 @@ package com.google.devtools.build.lib.rules.objc; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Optional; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelConverter; @@ -58,10 +60,11 @@ public class ObjcCommandLineOptions extends FragmentOptions { + "on the machine the simulator will be run on.") public String iosSimulatorDevice; + // TODO(bazel-team): Consider using optional for values like these. @Option(name = "ios_cpu", - defaultValue = DEFAULT_IOS_CPU, + defaultValue = "", category = "build", - help = "Specifies to target CPU of iOS compilation.") + help = "The target CPU for iOS compilation.") public String iosCpu; @Option(name = "xcode_options", @@ -179,13 +182,33 @@ public class ObjcCommandLineOptions extends FragmentOptions { } } + /** + * Returns the value of the ios_cpu flag, or a default value if none was specified. + */ + public String getIosCpu() { + if ("".equals(iosCpu)) { + return DEFAULT_IOS_CPU; + } else { + return iosCpu; + } + } + + /** + * Returns the value of the ios_cpu flag, if it was specified. + * This is to distinguish between the default cpu used by the build tools and the cpu explicitly + * requested by user configuration. + */ + public Optional<String> getConfiguredIosCpu() { + return Strings.isNullOrEmpty(iosCpu) ? Optional.<String>absent() : Optional.of(iosCpu); + } + private Platform getPlatform() { for (String architecture : iosMultiCpus) { if (Platform.forArch(architecture) == Platform.DEVICE) { return Platform.DEVICE; } } - return Platform.forArch(iosCpu); + return Platform.forArch(getIosCpu()); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java index 8741f6784a..7f450114e1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.objc; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.BlazeDirectories; @@ -53,6 +54,7 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { private final String iosSimulatorVersion; private final String iosSimulatorDevice; private final String iosCpu; + private final Optional<String> configuredIosCpu; private final String xcodeOptions; private final boolean generateDebugSymbols; private final boolean runMemleaks; @@ -84,7 +86,9 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { Preconditions.checkNotNull(objcOptions.iosSimulatorDevice, "iosSimulatorDevice"); this.iosSimulatorVersion = Preconditions.checkNotNull(objcOptions.iosSimulatorVersion, "iosSimulatorVersion"); - this.iosCpu = Preconditions.checkNotNull(objcOptions.iosCpu, "iosCpu"); + this.iosCpu = Preconditions.checkNotNull(objcOptions.getIosCpu(), "iosCpu"); + this.configuredIosCpu = + Preconditions.checkNotNull(objcOptions.getConfiguredIosCpu(), "configuredIosCpu"); this.xcodeOptions = Preconditions.checkNotNull(objcOptions.xcodeOptions, "xcodeOptions"); this.generateDebugSymbols = objcOptions.generateDebugSymbols; this.runMemleaks = objcOptions.runMemleaks; @@ -126,11 +130,22 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { return iosSimulatorVersion; } + /** + * Returns the ios_cpu value to use. + */ public String getIosCpu() { return iosCpu; } /** + * Returns the ios_cpu value set by the configuration (that is, by a command-line flag + * or by an ios_multi_cpu split configuration), if it is present. + */ + public Optional<String> getConfiguredIosCpu() { + return configuredIosCpu; + } + + /** * Returns the platform of the configuration for the current bundle, based on configured * architectures (for example, {@code i386} maps to {@link Platform#SIMULATOR}). * diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java index 45f9726009..d0015fcd70 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java @@ -234,7 +234,11 @@ public final class XcodeSupport { List<String> multiCpus = objcConfiguration.getIosMultiCpus(); if (multiCpus.isEmpty()) { - builder.addCpuArchitecture(objcConfiguration.getIosCpu()); + // Only add a CPU architecture if one was explicitly configured. + // Otherwise, the XCode generation tools will supply a default for XCode. + if (objcConfiguration.getConfiguredIosCpu().isPresent()) { + builder.addCpuArchitecture(objcConfiguration.getConfiguredIosCpu().get()); + } } else { builder.addAllCpuArchitecture(multiCpus); } |