diff options
author | 2016-08-25 18:24:21 +0000 | |
---|---|---|
committer | 2016-08-25 20:21:05 +0000 | |
commit | a6595116da5fb80554496cd69e4ab74b93c7b1e4 (patch) | |
tree | b6232635c4a2f61e331f1bf55ea2862a799a8c24 /src/main/java/com/google/devtools/build/lib/rules/apple | |
parent | deae15aa89df6a2aaaf602e2689123fe45b9ef5f (diff) |
Expose PlatformType and supporting methods to Skylark.
--
MOS_MIGRATED_REVID=131311014
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/apple')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java | 44 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java | 16 |
2 files changed, 40 insertions, 20 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 712def6f81..c1d2248eef 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 @@ -229,19 +229,29 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { /** * 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). + * 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>If {@code --apple_split_cpu} is set (done via prior configuration transition), then that is + * the effective architecture. * <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> + * such architecture is returned. + * <li>In the case of iOS, use {@code --ios_cpu} for backwards compatibility. + * <li>Use the default. + * </ol> */ + @SkylarkCallable( + name = "single_arch_cpu", + structField = true, + doc = + "The single \"effective\" architecture for this configuration (e.g. i386 or arm64) " + + "in the context of rule logic which is only concerned with a single architecture " + + "(such as in objc_library, which registers single-architecture compile actions). " + ) public String getSingleArchitecture() { if (!Strings.isNullOrEmpty(appleSplitCpu)) { return appleSplitCpu; @@ -304,14 +314,18 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { /** * 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). + * 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). */ - @SkylarkCallable(name = "single_arch_platform", doc = "The platform of the current" - + " configuration. This should only be invoked in a context where only a single architecture" - + " may be supported; consider mutli_arch_platform for other cases.") + @SkylarkCallable( + name = "single_arch_platform", + doc = + "The platform of the current configuration. This should only be invoked in a context where " + + "only a single architecture may be supported; consider mutli_arch_platform for other " + + "cases.", + structField = true + ) public Platform getSingleArchPlatform() { return Platform.forTarget(applePlatformType, getSingleArchitecture()); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java b/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java index 987c4fd0ef..98f6deb740 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java +++ b/src/main/java/com/google/devtools/build/lib/rules/apple/Platform.java @@ -19,10 +19,8 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.util.Preconditions; - import java.util.Locale; import java.util.Set; - import javax.annotation.Nullable; /** An enum that can be used to distinguish between various apple platforms. */ @@ -60,9 +58,12 @@ public enum Platform { this.platformType = platformType; } - /** - * Returns the platform type of this platform. - */ + /** Returns the platform type of this platform. */ + @SkylarkCallable( + name = "platform_type", + doc = "Returns the platform type of this platform.", + structField = true + ) public PlatformType getType() { return platformType; } @@ -142,6 +143,11 @@ public enum Platform { * type (for example, watchOS) together with a cpu value (for example, armv7). */ // TODO(cparsons): Use these values in static retrieval methods in this class. + @SkylarkModule( + name = "platform_type", + category = SkylarkModuleCategory.NONE, + doc = "Describes Apple platform \"type\", such as iOS, tvOS, macOS etc." + ) public enum PlatformType { IOS, WATCHOS, |