diff options
Diffstat (limited to 'src/main/java/com/google/devtools')
13 files changed, 92 insertions, 99 deletions
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 9fc38f0d12..3b9745f8d5 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 @@ -221,45 +221,42 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { } /** - * Gets the single "effective" architecture for the given {@link PlatformType}. Prefer this over - * {@link #getArchitectures(PlatformType)} only in cases if in the context of a rule which - * is only concerned with a single architecture (such as {@code objc_library}, which registers - * single-architecture compile actions. + * Gets the single "effective" architecture for this configuration's {@link PlatformType} (for + * example, "i386" or "arm64"). Prefer this over {@link #getMultiArchitectures(PlatformType)} + * only if in the context of rule logic which is only concerned with a single architecture (such + * as in {@code objc_library}, which registers single-architecture compile actions). * * <p>Single effective architecture is determined using the following rules: * <ol> * <li>If {@code --apple_split_cpu} is set (done via prior configuration transition), then - * that is the effective architecture.</li> - * <li>In the case of iOS, use {@code --ios_cpu}.</li> + * that is the effective architecture.</li> + * <li>If the multi cpus flag (e.g. {@code --ios_multi_cpus}) is set and non-empty, then the first + * such architecture is returned.</li> + * <li>In the case of iOS, use {@code --ios_cpu} for backwards compatibility.</li> * <li>Use the default.</li></ol> - * - * @throws IllegalArgumentException if {@code --apple_platform_type} is set (via prior - * configuration transition) yet does not match {@code platformType} */ - // TODO(cparsons): Support platform types other than iOS. - // TODO(b/28958783): Consider changing this behavior to be more consistent between single and - // multi-arch cases. - public String getSingleArchitecture(PlatformType platformType) { + public String getSingleArchitecture() { if (!Strings.isNullOrEmpty(appleSplitCpu)) { - if (applePlatformType != platformType) { - throw new IllegalArgumentException( - String.format("Expected post-split-transition platform type %s to match input %s ", - applePlatformType, platformType)); - } return appleSplitCpu; } - switch (platformType) { + switch (applePlatformType) { case IOS: - return getIosCpu(); - // TODO(cparsons): Support other platform types. + if (!getIosMultiCpus().isEmpty()) { + return getIosMultiCpus().get(0); + } else { + return getIosCpu(); + } + // TODO(cparsons): Support platform types other than iOS. default: - throw new IllegalArgumentException("Unhandled platform type " + platformType); + throw new IllegalArgumentException("Unhandled platform type " + applePlatformType); } } - + /** * Gets the "effective" architecture(s) for the given {@link PlatformType}. For example, - * "i386" or "arm64". At least one architecture is always returned. + * "i386" or "arm64". At least one architecture is always returned. Prefer this over + * {@link #getSingleArchitecture} in rule logic which may support multiple architectures, such + * as bundling rules. * * <p>Effective architecture(s) is determined using the following rules: * <ol> @@ -273,7 +270,7 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { * @throws IllegalArgumentException if {@code --apple_platform_type} is set (via prior * configuration transition) yet does not match {@code platformType} */ - public List<String> getArchitectures(PlatformType platformType) { + public List<String> getMultiArchitectures(PlatformType platformType) { if (!Strings.isNullOrEmpty(appleSplitCpu)) { if (applePlatformType != platformType) { throw new IllegalArgumentException( @@ -296,39 +293,26 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { } /** - * Gets the current configuration {@link Platform} for the given {@link PlatformType}. Platform - * is determined via a combination between the given platform type and the "effective - * architecture" of this configuration, as returned by {@link #getArchitectures}. If there - * are multiple effective architectures, the first in the list will be used. (This handles - * cases where multiple architectures may be specified, for example via multi-cpu flag, though - * only one can be consumed for the current rule.) Consider {@link #getBundlingPlatform} as an - * alternative, when more than one architecture may be expected. + * Gets the single "effective" platform for this configuration's {@link PlatformType} and + * architecture. Prefer this over {@link #getMultiArchPlatform(PlatformType)} + * only in cases if in the context of rule logic which is only concerned with a single + * architecture (such as in {@code objc_library}, which registers single-architecture compile + * actions). */ - public Platform getPlatform(PlatformType platformType) { - return Platform.forTarget(platformType, getSingleArchitecture(platformType)); + public Platform getSingleArchPlatform() { + return Platform.forTarget(applePlatformType, getSingleArchitecture()); } /** - * Returns the platform of the configuration for the current bundle for {@link PlatformType#IOS} - * platform type, based on configured "effective" architectures (for example, {@code i386} maps - * to {@link Platform#IOS_SIMULATOR}). - * - * <p>Effective architecture(s) are determined via {@link #getArchitectures}. If there are - * multiple effective architectures, then returns {@link Platform#IOS_DEVICE} if any of the - * architectures matches it, otherwise returns {@link Platform#IOS_SIMULATOR}. - * - * <p>Note that this method is similar to, {@link #getPlatform} but different in how it handles - * multiple architecture scenarios. This method should be used for obtaining {@link Platform} in - * contexts where multiple architectures are expected, such as bundling rules. - * - * @throws IllegalArgumentException if the current build options specify architecture(s) with - * no known apple platform + * Gets the current configuration {@link Platform} for the given {@link PlatformType}. Platform + * is determined via a combination between the given platform type and the "effective" + * architectures of this configuration, as returned by {@link #getMultiArchitectures}; if any + * of the supported architectures are of device type, this will return a device platform. + * Otherwise, this will return a simulator platform. */ - // TODO(bazel-team): This method should be enabled to return multiple values once all call sites - // (in particular actool, bundlemerge, momc) have been upgraded to support multiple values. - // TODO(cparsons): Take platform type as input, supporting platforms other than IOS. - public Platform getBundlingPlatform() { - List<String> architectures = getArchitectures(PlatformType.IOS); + // TODO(bazel-team): This should support returning multiple platforms. + public Platform getMultiArchPlatform(PlatformType platformType) { + List<String> architectures = getMultiArchitectures(platformType); for (String arch : architectures) { if (Platform.forTarget(PlatformType.IOS, arch) == Platform.IOS_DEVICE) { return Platform.IOS_DEVICE; @@ -336,18 +320,19 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { } return Platform.IOS_SIMULATOR; } - + /** * Returns the {@link Platform} represented by {@code ios_cpu} (see {@link #getIosCpu}. * (For example, {@code i386} maps to {@link Platform#IOS_SIMULATOR}.) Note that this is not * necessarily the effective platform for all ios actions in the current context: This is * typically the correct platform for implicityly-ios compile and link actions in the current - * context. For effective platform for bundling actions, see {@link #getBundlingPlatform}. + * context. For effective platform for bundling actions, see + * {@link #getMultiArchPlatform(PlatformType)}. */ // TODO(b/28754442): Deprecate for more general skylark-exposed platform retrieval. @SkylarkCallable(name = "ios_cpu_platform", doc = "The platform given by the ios_cpu flag.") public Platform getIosCpuPlatform() { - return getPlatform(PlatformType.IOS); + return Platform.forTarget(PlatformType.IOS, iosCpu); } /** 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 a2bbaa1798..097f24f90d 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 @@ -33,7 +33,6 @@ import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.RuleClass; import com.google.devtools.build.lib.packages.RuleClass.Builder; import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType; -import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.xcode.xcodegen.proto.XcodeGenProtos.XcodeprojBuildSetting; @@ -82,12 +81,11 @@ public class AppleToolchain { .build(); /** - * Returns the platform plist name (for example, iPhoneSimulator) for the platform corresponding - * to the value of {@code --ios_cpu} in the given configuration. + * Returns the platform plist name (for example, iPhoneSimulator) for the single-arch-context + * apple platform specified in the configuration. */ - // TODO(bazel-team): Support non-ios platforms. public static String getPlatformPlistName(AppleConfiguration configuration) { - return configuration.getPlatform(PlatformType.IOS).getNameInPlist(); + return configuration.getSingleArchPlatform().getNameInPlist(); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java index ec64b37603..e7dba73b6c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java @@ -30,7 +30,6 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.packages.Attribute.SplitTransition; import com.google.devtools.build.lib.packages.Attribute.SplitTransitionProvider; import com.google.devtools.build.lib.packages.Rule; -import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory; import com.google.devtools.build.lib.rules.apple.AppleCommandLineOptions; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; @@ -144,11 +143,11 @@ public class AppleBinary implements RuleConfiguredTargetFactory { .registerCombineArchitecturesAction( binariesToLipo.build(), ruleIntermediateArtifacts.combinedArchitectureBinary(), - appleConfiguration.getPlatform(PlatformType.IOS)) + appleConfiguration.getMultiArchPlatform(PlatformType.IOS)) .registerCombineArchitecturesAction( archivesToLipo.build(), ruleContext.getImplicitOutputArtifact(AppleBinaryRule.LIPO_ARCHIVE), - appleConfiguration.getPlatform(PlatformType.IOS)); + appleConfiguration.getMultiArchPlatform(PlatformType.IOS)); RuleConfiguredTargetBuilder targetBuilder = ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java index 7ee2cc8fb6..1f98901f9f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BinaryLinkingTargetFactory.java @@ -32,6 +32,7 @@ import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory. import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.Platform; +import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.lib.rules.objc.CompilationSupport.ExtraLinkArgs; import com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes; import com.google.devtools.build.lib.rules.objc.ProtoSupport.TargetType; @@ -151,7 +152,7 @@ abstract class BinaryLinkingTargetFactory implements RuleConfiguredTargetFactory .validateAttributes(); xcTestAppProvider = Optional.of(releaseBundlingSupport.xcTestAppProvider()); - if (appleConfiguration.getBundlingPlatform() == Platform.IOS_SIMULATOR) { + if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) == Platform.IOS_SIMULATOR) { Artifact runnerScript = intermediateArtifacts.runnerScript(); Artifact ipaFile = ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA); releaseBundlingSupport.registerGenerateRunnerScriptAction(runnerScript, ipaFile); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java index f7a83beeb0..372fe5e1a8 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleMergeControlBytes.java @@ -17,6 +17,7 @@ package com.google.devtools.build.lib.rules.objc; import com.google.common.io.ByteSource; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; +import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos; import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos.Control; @@ -57,7 +58,7 @@ final class BundleMergeControlBytes extends ByteSource { // TODO(bazel-team): Add rule attribute for specifying targeted device family .setMinimumOsVersion(bundling.getMinimumOsVersion().toString()) .setSdkVersion(appleConfiguration.getIosSdkVersion().toString()) - .setPlatform(appleConfiguration.getBundlingPlatform().name()) + .setPlatform(appleConfiguration.getMultiArchPlatform(PlatformType.IOS).name()) .setBundleRoot(bundling.getBundleDir()); if (bundling.getBundleInfoplist().isPresent()) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java index bb816ba2be..66650a2d7c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BundleSupport.java @@ -319,7 +319,8 @@ final class BundleSupport { .add("-XD_MOMC_SDKROOT=" + AppleToolchain.sdkDir()) .add("-XD_MOMC_IOS_TARGET_VERSION=" + bundling.getMinimumOsVersion()) .add("-MOMC_PLATFORMS") - .add(appleConfiguration.getBundlingPlatform().getLowerCaseNameInPlist()) + .add(appleConfiguration.getMultiArchPlatform(PlatformType.IOS) + .getLowerCaseNameInPlist()) .add("-XD_MOMC_TARGET_VERSION=10.6") .add(datamodel.getContainer().getSafePathString()) .build()) @@ -445,7 +446,8 @@ final class BundleSupport { // The next three arguments are positional, i.e. they don't have flags before them. .addPath(zipOutput.getExecPath()) .add("--platform") - .add(appleConfiguration.getBundlingPlatform().getLowerCaseNameInPlist()) + .add(appleConfiguration.getMultiArchPlatform(PlatformType.IOS) + .getLowerCaseNameInPlist()) .addExecPath("--output-partial-info-plist", partialInfoPlist) .add("--minimum-deployment-target") .add(bundling.getMinimumOsVersion().toString()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index 5adaf565a1..ef3d63c013 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -81,7 +81,6 @@ import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.AppleToolchain; import com.google.devtools.build.lib.rules.apple.Platform; -import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.lib.rules.cpp.CppModuleMap; import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction; import com.google.devtools.build.lib.rules.cpp.LinkerInputs; @@ -563,7 +562,7 @@ public final class CompilationSupport { // TODO(bazel-team): Remote private headers from inputs once they're added to the provider. ruleContext.registerAction( ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("ObjcCompile") .setExecutable(xcrunwrapper(ruleContext)) .setCommandLine(commandLine.build()) @@ -693,7 +692,7 @@ public final class CompilationSupport { ruleContext.registerAction( ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("SwiftCompile") .setExecutable(xcrunwrapper(ruleContext)) .setCommandLine(commandLine.build()) @@ -763,7 +762,7 @@ public final class CompilationSupport { commandLine.add(commonFrameworkFlags(objcProvider, appleConfiguration)); ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("SwiftModuleMerge") .setExecutable(xcrunwrapper(ruleContext)) .setCommandLine(commandLine.build()) @@ -794,13 +793,13 @@ public final class CompilationSupport { actions.add(objFilelistAction(context, objFiles, objList)); actions.add(ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("ObjcLink") .setExecutable(libtool(ruleContext)) .setCommandLine(new CustomCommandLine.Builder() .add("-static") .add("-filelist").add(objList.getExecPathString()) - .add("-arch_only").add(appleConfiguration.getSingleArchitecture(PlatformType.IOS)) + .add("-arch_only").add(appleConfiguration.getSingleArchitecture()) .add("-syslibroot").add(AppleToolchain.sdkDir()) .add("-o").add(archive.getExecPathString()) .build()) @@ -834,12 +833,12 @@ public final class CompilationSupport { ImmutableList<Artifact> objcLibraries = objcLibraries(objcProvider); ImmutableList<Artifact> ccLibraries = ccLibraries(objcProvider); ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("ObjcLink") .setExecutable(libtool(ruleContext)) .setCommandLine(new CustomCommandLine.Builder() .add("-static") - .add("-arch_only").add(appleConfiguration.getSingleArchitecture(PlatformType.IOS)) + .add("-arch_only").add(appleConfiguration.getSingleArchitecture()) .add("-syslibroot").add(AppleToolchain.sdkDir()) .add("-o").add(outputArchive.getExecPathString()) .addExecPaths(objcLibraries) @@ -1037,7 +1036,7 @@ public final class CompilationSupport { linkmap); ruleContext.registerAction( ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("ObjcLink") .setShellCommand(ImmutableList.of("/bin/bash", "-c")) .setCommandLine(new SingleArgCommandLine(commandLine)) @@ -1072,7 +1071,7 @@ public final class CompilationSupport { ruleContext.registerAction( ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("ObjcBinarySymbolStrip") .setExecutable(xcrunwrapper(ruleContext)) .setCommandLine(symbolStripCommandLine(stripArgs, binaryToLink, strippedBinary)) @@ -1341,7 +1340,7 @@ public final class CompilationSupport { commandLine, ParameterFile.ParameterFileType.UNQUOTED, ISO_8859_1)); ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder( - ruleContext, appleConfiguration.getPlatform(PlatformType.IOS)) + ruleContext, appleConfiguration.getSingleArchPlatform()) .setMnemonic("DummyPruner") .setExecutable(pruner) .addInput(dummyArchive) @@ -1557,8 +1556,9 @@ public final class CompilationSupport { */ @VisibleForTesting static String swiftTarget(AppleConfiguration configuration) { - return configuration.getSingleArchitecture(PlatformType.IOS) - + "-apple-ios" + configuration.getIosSdkVersion(); + // TODO(bazel-team): Assert the configuration is for an apple platform, or support + // other platform types. + return configuration.getSingleArchitecture() + "-apple-ios" + configuration.getIosSdkVersion(); } /** @@ -1568,7 +1568,7 @@ public final class CompilationSupport { ObjcProvider provider, ObjcConfiguration objcConfiguration, AppleConfiguration appleConfiguration) { ImmutableList.Builder<String> builder = new ImmutableList.Builder<>(); - Platform platform = appleConfiguration.getPlatform(PlatformType.IOS); + Platform platform = appleConfiguration.getSingleArchPlatform(); if (platform == Platform.IOS_SIMULATOR) { builder.add("-mios-simulator-version-min=" + objcConfiguration.getMinimumOs()); } else { @@ -1580,7 +1580,7 @@ public final class CompilationSupport { } return builder - .add("-arch", appleConfiguration.getSingleArchitecture(PlatformType.IOS)) + .add("-arch", appleConfiguration.getSingleArchitecture()) .add("-isysroot", AppleToolchain.sdkDir()) // TODO(bazel-team): Pass framework search paths to Xcodegen. .addAll(commonFrameworkFlags(provider, appleConfiguration)) @@ -1600,7 +1600,7 @@ public final class CompilationSupport { */ static Iterable<String> commonFrameworkNames( ObjcProvider provider, AppleConfiguration appleConfiguration) { - Platform platform = appleConfiguration.getPlatform(PlatformType.IOS); + Platform platform = appleConfiguration.getSingleArchPlatform(); return new ImmutableList.Builder<String>() .add(AppleToolchain.sdkFrameworkDir(platform, appleConfiguration)) @@ -1628,7 +1628,7 @@ public final class CompilationSupport { private static List<String> platformSpecificCompileFlagsForClang( AppleConfiguration configuration) { - switch (configuration.getPlatform(PlatformType.IOS)) { + switch (configuration.getSingleArchPlatform()) { case IOS_DEVICE: return ImmutableList.of(); case IOS_SIMULATOR: diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java index 25d5e475f2..617fd3ece9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java @@ -27,6 +27,7 @@ import com.google.devtools.build.lib.packages.Attribute.SplitTransition; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher; import com.google.devtools.build.lib.rules.apple.Platform; +import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.lib.rules.objc.ObjcProvider.Flag; import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.SplitArchTransition; @@ -81,7 +82,7 @@ public class IosApplication extends ReleaseBundlingTargetFactory { ReleaseBundlingSupport releaseBundlingSupport) throws InterruptedException { // If this is an application built for the simulator, make it runnable. AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - if (appleConfiguration.getBundlingPlatform() == Platform.IOS_SIMULATOR) { + if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) == Platform.IOS_SIMULATOR) { Artifact runnerScript = ObjcRuleClasses.intermediateArtifacts(ruleContext).runnerScript(); Artifact ipaFile = ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA); releaseBundlingSupport.registerGenerateRunnerScriptAction(runnerScript, ipaFile); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index f6a0c938d2..ded917c61c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -1043,7 +1043,8 @@ public class ObjcRuleClasses { Rule rule, AttributeMap attributes, BuildConfiguration configuration) { AppleConfiguration appleConfiguration = configuration.getFragment(AppleConfiguration.class); - if (appleConfiguration.getBundlingPlatform() != Platform.IOS_DEVICE) { + if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) + != Platform.IOS_DEVICE) { return null; } if (rule.isAttributeValueExplicitlySpecified(PROVISIONING_PROFILE_ATTR)) { @@ -1341,7 +1342,8 @@ public class ObjcRuleClasses { BuildConfiguration configuration) { AppleConfiguration appleConfiguration = configuration.getFragment(AppleConfiguration.class); - if (appleConfiguration.getBundlingPlatform() != Platform.IOS_DEVICE) { + if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) + != Platform.IOS_DEVICE) { return null; } if (rule.isAttributeValueExplicitlySpecified( @@ -1524,7 +1526,8 @@ public class ObjcRuleClasses { BuildConfiguration configuration) { AppleConfiguration appleConfiguration = configuration.getFragment(AppleConfiguration.class); - if (appleConfiguration.getBundlingPlatform() != Platform.IOS_DEVICE) { + if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) + != Platform.IOS_DEVICE) { return null; } if (rule.isAttributeValueExplicitlySpecified( diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java index 868303e70a..f67b0a8377 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java @@ -261,7 +261,7 @@ public final class ReleaseBundlingSupport { AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); if (releaseBundling.getProvisioningProfile() == null - && appleConfiguration.getBundlingPlatform() != Platform.IOS_SIMULATOR) { + && appleConfiguration.getMultiArchPlatform(PlatformType.IOS) != Platform.IOS_SIMULATOR) { ruleContext.attributeError(releaseBundling.getProvisioningProfileAttrName(), DEVICE_NO_PROVISIONING_PROFILE); } @@ -373,7 +373,7 @@ public final class ReleaseBundlingSupport { String platformWithVersion = String.format( "%s%s", - configuration.getBundlingPlatform().getLowerCaseNameInPlist(), + configuration.getMultiArchPlatform(PlatformType.IOS).getLowerCaseNameInPlist(), configuration.getIosSdkVersion()); ruleContext.registerAction( ObjcRuleClasses.spawnAppleEnvActionBuilder(ruleContext) @@ -402,7 +402,7 @@ public final class ReleaseBundlingSupport { List<Integer> uiDeviceFamily = TargetDeviceFamily.UI_DEVICE_FAMILY_VALUES.get(bundleSupport.targetDeviceFamilies()); AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - Platform platform = appleConfiguration.getBundlingPlatform(); + Platform platform = appleConfiguration.getMultiArchPlatform(PlatformType.IOS); NSDictionary result = new NSDictionary(); @@ -457,7 +457,7 @@ public final class ReleaseBundlingSupport { } AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - if (appleConfiguration.getBundlingPlatform() == Platform.IOS_DEVICE) { + if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) == Platform.IOS_DEVICE) { processingNeeded = true; registerEntitlementsActions(); actionCommandLine += signingCommandLine(); @@ -766,7 +766,7 @@ public final class ReleaseBundlingSupport { DottedVersion minimumOsVersion) { ImmutableList<BundleableFile> extraBundleFiles; AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); - if (appleConfiguration.getBundlingPlatform() == Platform.IOS_DEVICE) { + if (appleConfiguration.getMultiArchPlatform(PlatformType.IOS) == Platform.IOS_DEVICE) { extraBundleFiles = ImmutableList.of(new BundleableFile( releaseBundling.getProvisioningProfile(), PROVISIONING_PROFILE_BUNDLE_FILE)); } else { @@ -820,7 +820,7 @@ public final class ReleaseBundlingSupport { AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class); new LipoSupport(ruleContext).registerCombineArchitecturesAction(linkedBinaries(), - resultingLinkedBinary, appleConfiguration.getPlatform(PlatformType.IOS)); + resultingLinkedBinary, appleConfiguration.getMultiArchPlatform(PlatformType.IOS)); } private NestedSet<Artifact> linkedBinaries() { diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java index a55c1a0537..ad0d1912c8 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/WatchApplicationSupport.java @@ -47,6 +47,7 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher; import com.google.devtools.build.lib.rules.apple.Platform; +import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.lib.rules.objc.ReleaseBundlingSupport.LinkedBinary; import com.google.devtools.build.lib.rules.objc.WatchUtils.WatchOSVersion; import com.google.devtools.build.lib.syntax.Type; @@ -153,7 +154,8 @@ final class WatchApplicationSupport { * {@code TargetDeviceFamily.WATCH}. */ private ImmutableSet<TargetDeviceFamily> families() { - Platform platform = ruleContext.getFragment(AppleConfiguration.class).getBundlingPlatform(); + Platform platform = + ruleContext.getFragment(AppleConfiguration.class).getMultiArchPlatform(PlatformType.IOS); if (platform == Platform.IOS_DEVICE) { return ImmutableSet.of(TargetDeviceFamily.WATCH); } else { @@ -207,7 +209,7 @@ final class WatchApplicationSupport { Joiner.on(" ").join(ImmutableList.of("_WatchKitStub", bundleName)))); ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(ruleContext, - ruleContext.getFragment(AppleConfiguration.class).getBundlingPlatform()) + ruleContext.getFragment(AppleConfiguration.class).getMultiArchPlatform(PlatformType.IOS)) .setProgressMessage( "Copying WatchKit binary and stub resource: " + ruleContext.getLabel()) .setShellCommand(ImmutableList.of("/bin/bash", "-c", Joiner.on(" ").join(command))) diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java b/src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java index e8abe97212..4909c2553c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/WatchUtils.java @@ -24,6 +24,7 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; import com.google.devtools.build.lib.rules.apple.DottedVersion; +import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.xcode.xcodegen.proto.XcodeGenProtos.XcodeprojBuildSetting; /** @@ -140,7 +141,7 @@ final class WatchUtils { watchKitSupportDirName)); ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(ruleContext, - ruleContext.getFragment(AppleConfiguration.class).getBundlingPlatform()) + ruleContext.getFragment(AppleConfiguration.class).getMultiArchPlatform(PlatformType.IOS)) .setProgressMessage("Copying Watchkit support to app bundle") .setShellCommand(ImmutableList.of("/bin/bash", "-c", Joiner.on(" ").join(command))) .addOutput(watchSupportZip) 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 61ac5a6af3..4719bfce58 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 @@ -272,7 +272,7 @@ public final class XcodeSupport { this.project = project; this.pbxproj = pbxproj; this.workspaceRoot = objcConfiguration.getXcodeWorkspaceRoot(); - this.appleCpus = appleConfiguration.getArchitectures(PlatformType.IOS); + this.appleCpus = appleConfiguration.getMultiArchitectures(PlatformType.IOS); this.minimumOs = objcConfiguration.getMinimumOs().toString(); this.generateDebugSymbols = objcConfiguration.generateDebugSymbols() || objcConfiguration.generateDsym(); |