Skip to content

Commit

Permalink
Set --xcode_version_config=@bazel_tools//tools/objc:host_xcodes by de…
Browse files Browse the repository at this point in the history
…fault in

and delete the reference to Constants.TOOLS_REPOSITORY in AppleCommandLineOptions.

--
MOS_MIGRATED_REVID=120918479
  • Loading branch information
lfpino authored and kchodorow committed Apr 27, 2016
1 parent bb2230f commit d1f8477
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public static void setup(ConfiguredRuleClassProvider.Builder builder) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
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;
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -139,13 +138,6 @@ public DefaultProvisioningProfileConverter() {
+ "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) {
Expand All @@ -154,27 +146,27 @@ private Platform getPlatform() {
}
return Platform.forIosArch(iosCpu);
}

@Override
public void addAllLabels(Multimap<String, Label> labelMap) {
if (getPlatform() == Platform.IOS_DEVICE) {
labelMap.put("default_provisioning_profile", defaultProvisioningProfile);
}
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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand All @@ -44,19 +45,19 @@
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
Expand Down Expand Up @@ -181,19 +182,31 @@ public XcodeprojBuildSetting apply(String key) {
});
}

/**
* 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) {
Expand All @@ -203,7 +216,7 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
.checkConstraints()
.direct_compile_time_input()
.cfg(HOST)
.value(XCODE_CONFIG_LABEL))
.value(new XcodeConfigLabel(toolsRepository)))
.build();
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public AspectDefinition getDefinition(AspectParameters aspectParameters) {
.checkConstraints()
.direct_compile_time_input()
.cfg(HOST)
.value(AppleToolchain.RequiresXcodeConfigRule.XCODE_CONFIG_LABEL));
.value(new AppleToolchain.XcodeConfigLabel(toolsRepository)));
return addAdditionalAttributes(builder).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public AspectDefinition getDefinition(AspectParameters aspectParameters) {
.checkConstraints()
.direct_compile_time_input()
.cfg(HOST)
.value(AppleToolchain.RequiresXcodeConfigRule.XCODE_CONFIG_LABEL))
.value(new AppleToolchain.XcodeConfigLabel(toolsRepository)))
.build();
}

Expand Down

0 comments on commit d1f8477

Please sign in to comment.