diff options
author | Luis Fernando Pino Duque <lpino@google.com> | 2016-04-27 15:36:56 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-04-27 17:11:57 +0000 |
commit | d1f847791e8f039b37407330c9629a5db628869d (patch) | |
tree | 28f1dc7de82a0c95ce3a7cf269c76d2f226c1d66 /src/main/java/com/google/devtools/build/lib | |
parent | bb2230f29bde1314a3846f1a87f18f1c66f458f6 (diff) |
Set --xcode_version_config=@bazel_tools//tools/objc:host_xcodes by default in
and delete the reference to Constants.TOOLS_REPOSITORY in AppleCommandLineOptions.
--
MOS_MIGRATED_REVID=120918479
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
5 files changed, 41 insertions, 36 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java index 8b16abb7f3..84fb20a167 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java @@ -390,7 +390,7 @@ public class BazelRuleClassProvider { builder.addRuleDefinition(new ObjcRuleClasses.WatchExtensionBundleRule()); builder.addRuleDefinition(new ObjcRuleClasses.WatchApplicationBundleRule()); builder.addRuleDefinition(new ObjcRuleClasses.CrosstoolRule()); - builder.addRuleDefinition(new AppleToolchain.RequiresXcodeConfigRule()); + builder.addRuleDefinition(new AppleToolchain.RequiresXcodeConfigRule(TOOLS_REPOSITORY)); builder.addRuleDefinition(new AppleWatch1ExtensionRule()); builder.addRuleDefinition(new AppleWatchExtensionBinaryRule()); builder.addRuleDefinition(new IosApplicationRule()); 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 93e54def4b..9b3090e457 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 @@ -17,8 +17,8 @@ package com.google.devtools.build.lib.rules.apple; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; -import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.DefaultLabelConverter; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelConverter; import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter; @@ -99,19 +99,19 @@ public class AppleCommandLineOptions extends FragmentOptions { help = "Comma-separated list of architectures to build an ios_application with. The result " + "is a universal binary containing all specified architectures.") public List<String> iosMultiCpus; - + @VisibleForTesting static final String DEFAULT_IOS_CPU = "x86_64"; - + @Option(name = "default_ios_provisioning_profile", defaultValue = "", category = "undocumented", converter = DefaultProvisioningProfileConverter.class) public Label defaultProvisioningProfile; - + @Option(name = "xcode_version_config", - defaultValue = "", + defaultValue = "@bazel_tools" + DEFAULT_XCODE_VERSION_CONFIG_LABEL, category = "undocumented", - converter = XcodeVersionConfigConverter.class, + converter = LabelConverter.class, help = "The label of the xcode_config rule to be used for selecting the xcode version " + "in the build configuration") public Label xcodeVersionConfig; @@ -120,8 +120,7 @@ public class AppleCommandLineOptions extends FragmentOptions { * The default label of the build-wide {@code xcode_config} configuration rule. This can be * changed from the default using the {@code xcode_version_config} build flag. */ - static final String DEFAULT_XCODE_VERSION_CONFIG_LABEL = - Constants.TOOLS_REPOSITORY + "//tools/objc:host_xcodes"; + static final String DEFAULT_XCODE_VERSION_CONFIG_LABEL = "//tools/objc:host_xcodes"; /** Converter for --default_ios_provisioning_profile. */ public static class DefaultProvisioningProfileConverter extends DefaultLabelConverter { @@ -139,13 +138,6 @@ public class AppleCommandLineOptions extends FragmentOptions { + "Values: 'none', 'embedded_markers', 'embedded'.") public AppleBitcodeMode appleBitcodeMode; - /** Converter for {@code --xcode_version_config}. */ - public static class XcodeVersionConfigConverter extends DefaultLabelConverter { - public XcodeVersionConfigConverter() { - super(DEFAULT_XCODE_VERSION_CONFIG_LABEL); - } - } - private Platform getPlatform() { for (String architecture : iosMultiCpus) { if (Platform.forIosArch(architecture) == Platform.IOS_DEVICE) { @@ -154,7 +146,7 @@ public class AppleCommandLineOptions extends FragmentOptions { } return Platform.forIosArch(iosCpu); } - + @Override public void addAllLabels(Multimap<String, Label> labelMap) { if (getPlatform() == Platform.IOS_DEVICE) { @@ -162,19 +154,19 @@ public class AppleCommandLineOptions extends FragmentOptions { } labelMap.put("xcode_version_config", xcodeVersionConfig); } - + /** * Represents the Apple Bitcode mode for compilation steps. - * + * * <p>Bitcode is an intermediate representation of a compiled program. For many platforms, * Apple requires app submissions to contain bitcode in order to be uploaded to the app store. - * + * * <p>This is a build-wide value, as bitcode mode needs to be consistent among a target and * its compiled dependencies. */ public enum AppleBitcodeMode { - /** + /** * Do not compile bitcode. */ NONE("none"), diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java index bbe4076bc8..c0fd467687 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleToolchain.java @@ -26,6 +26,7 @@ import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.packages.Attribute.LateBoundLabel; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.Rule; @@ -44,19 +45,19 @@ import com.google.devtools.build.xcode.xcodegen.proto.XcodeGenProtos.XcodeprojBu doc = "Utilities for resolving items from the Apple toolchain." ) public class AppleToolchain { - + // These next two strings are shared secrets with the xcrunwrapper.sh to allow // expansion of DeveloperDir and SDKRoot and runtime, since they aren't known // until compile time on any given build machine. @VisibleForTesting public static final String DEVELOPER_DIR = "__BAZEL_XCODE_DEVELOPER_DIR__"; @VisibleForTesting public static final String SDKROOT_DIR = "__BAZEL_XCODE_SDKROOT__"; - + // These two paths are framework paths relative to SDKROOT. @VisibleForTesting public static final String DEVELOPER_FRAMEWORK_PATH = "/Developer/Library/Frameworks"; @VisibleForTesting public static final String SYSTEM_FRAMEWORK_PATH = "/System/Library/Frameworks"; - + // There is a handy reference to many clang warning flags at // http://nshipster.com/clang-diagnostics/ // There is also a useful narrative for many Xcode settings at @@ -182,18 +183,30 @@ public class AppleToolchain { } /** + * The default label of the build-wide {@code xcode_config} configuration rule. + */ + @Immutable + public static final class XcodeConfigLabel extends LateBoundLabel<BuildConfiguration> { + public XcodeConfigLabel(String toolsRepository) { + super(toolsRepository + AppleCommandLineOptions.DEFAULT_XCODE_VERSION_CONFIG_LABEL, + AppleConfiguration.class); + } + + @Override + public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) { + return configuration.getFragment(AppleConfiguration.class).getXcodeConfigLabel(); + } + } + + /** * Base rule definition to be ancestor for rules which may require an xcode toolchain. */ public static class RequiresXcodeConfigRule implements RuleDefinition { - public static final LateBoundLabel<BuildConfiguration> XCODE_CONFIG_LABEL = - new LateBoundLabel<BuildConfiguration>( - AppleCommandLineOptions.DEFAULT_XCODE_VERSION_CONFIG_LABEL, AppleConfiguration.class) { - @Override - public Label resolve(Rule rule, AttributeMap attributes, - BuildConfiguration configuration) { - return configuration.getFragment(AppleConfiguration.class).getXcodeConfigLabel(); - } - }; + private final String toolsRepository; + + public RequiresXcodeConfigRule(String toolsRepository) { + this.toolsRepository = toolsRepository; + } @Override public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { @@ -203,7 +216,7 @@ public class AppleToolchain { .checkConstraints() .direct_compile_time_input() .cfg(HOST) - .value(XCODE_CONFIG_LABEL)) + .value(new XcodeConfigLabel(toolsRepository))) .build(); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java index f89ac4bc69..2d91d75264 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java @@ -90,7 +90,7 @@ public abstract class AbstractJ2ObjcProtoAspect extends NativeAspectClass .checkConstraints() .direct_compile_time_input() .cfg(HOST) - .value(AppleToolchain.RequiresXcodeConfigRule.XCODE_CONFIG_LABEL)); + .value(new AppleToolchain.XcodeConfigLabel(toolsRepository))); return addAdditionalAttributes(builder).build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java index b8b941a93a..5bce361311 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java @@ -115,7 +115,7 @@ public class J2ObjcAspect extends NativeAspectClass implements ConfiguredAspectF .checkConstraints() .direct_compile_time_input() .cfg(HOST) - .value(AppleToolchain.RequiresXcodeConfigRule.XCODE_CONFIG_LABEL)) + .value(new AppleToolchain.XcodeConfigLabel(toolsRepository))) .build(); } |