diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/apple/AppleConfiguration.java | 90 |
1 files changed, 51 insertions, 39 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 752bf64e48..cc77b96018 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 @@ -233,62 +233,74 @@ public class AppleConfiguration extends BuildConfiguration.Fragment { * Returns a map of environment variables (derived from configuration) that should be propagated * for actions pertaining to the given apple platform. Keys are variable names and values are * their corresponding values. + * + * @deprecated use {@link #appleTargetPlatformEnv(ApplePlatform, DottedVersion) instead)}. */ + @Deprecated @SkylarkCallable( - name = "target_apple_env", - doc = "Returns a <code>dict</code> of environment variables that should be set for actions " - + "that build targets of the given Apple platform type. For example, this dictionary " - + "contains variables that denote the platform name and SDK version with which to " - + "build. The keys are variable names and the values are their corresponding values.") + name = "target_apple_env", + doc = + "Returns a <code>dict</code> of environment variables that should be set for actions " + + "that build targets of the given Apple platform type. For example, this dictionary " + + "contains variables that denote the platform name and SDK version with which to " + + "build. The keys are variable names and the values are their corresponding values." + ) + // Bug tracking the removal of this method: https://github.com/bazelbuild/bazel/issues/3424 public ImmutableMap<String, String> getTargetAppleEnvironment(ApplePlatform platform) { - ImmutableMap.Builder<String, String> mapBuilder = ImmutableMap.builder(); - mapBuilder.putAll(appleTargetPlatformEnv(platform)); - return mapBuilder.build(); + return appleTargetPlatformEnv(platform, getSdkVersionForPlatform(platform)); + } + + /** + * Returns a map of environment variables (derived from configuration) that should be propagated + * for actions pertaining to building applications for apple platforms. These environment + * variables are needed to use apple toolkits. Keys are variable names and values are their + * corresponding values. + */ + public static ImmutableMap <String, String> appleTargetPlatformEnv( + ApplePlatform platform, DottedVersion sdkVersion) { + ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); + + builder + .put(AppleConfiguration.APPLE_SDK_VERSION_ENV_NAME, + sdkVersion.toStringWithMinimumComponents(2)) + .put(AppleConfiguration.APPLE_SDK_PLATFORM_ENV_NAME, + platform.getNameInPlist()); + + return builder.build(); } /** * Returns a map of environment variables that should be propagated for actions that build on an * apple host system. These environment variables are needed by the apple toolchain. Keys are * variable names and values are their corresponding values. + * + * @deprecated use {@link #getXcodeVersionEnv(DottedVersion)} instead}. */ @SkylarkCallable( - name = "apple_host_system_env", - doc = "Returns a <a href='dict.html'>dict</a> of environment variables that should be set " - + "for actions that need to run build tools on an Apple host system, such as the version " - + "of Xcode that should be used. The keys are variable names and the values are their " - + "corresponding values.") + name = "apple_host_system_env", + doc = + "Returns a <a href='dict.html'>dict</a> of environment variables that should be set " + + "for actions that need to run build tools on an Apple host system, such as the " + + "version of Xcode that should be used. The keys are variable names and the values " + + "are their corresponding values." + ) + @Deprecated + // Bug tracking the removal of this method: https://github.com/bazelbuild/bazel/issues/3424 public ImmutableMap<String, String> getAppleHostSystemEnv() { - if (xcodeVersion != null) { - return getXcodeVersionEnv(xcodeVersion); - } else { - return ImmutableMap.of(); - } + return getXcodeVersionEnv(xcodeVersion); } /** - * Returns a map of environment variables that should be propagated for actions that require - * a version of xcode to be explicitly declared. Keys are variable names and values are their - * corresponding values. - */ - public ImmutableMap<String, String> getXcodeVersionEnv(DottedVersion xcodeVersion) { - return ImmutableMap.of(AppleConfiguration.XCODE_VERSION_ENV_NAME, xcodeVersion.toString()); - } - - /** - * Returns a map of environment variables (derived from configuration) that should be propagated - * for actions pertaining to building applications for apple platforms. These environment - * variables are needed to use apple toolkits. Keys are variable names and values are their + * Returns a map of environment variables that should be propagated for actions that require a + * version of xcode to be explicitly declared. Keys are variable names and values are their * corresponding values. */ - public Map<String, String> appleTargetPlatformEnv(ApplePlatform platform) { - ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); - - String sdkVersion = getSdkVersionForPlatform(platform).toStringWithMinimumComponents(2); - builder - .put(AppleConfiguration.APPLE_SDK_VERSION_ENV_NAME, sdkVersion) - .put(AppleConfiguration.APPLE_SDK_PLATFORM_ENV_NAME, platform.getNameInPlist()); - - return builder.build(); + public static ImmutableMap<String, String> getXcodeVersionEnv(DottedVersion xcodeVersion) { + if (xcodeVersion != null) { + return ImmutableMap.of(AppleConfiguration.XCODE_VERSION_ENV_NAME, xcodeVersion.toString()); + } else { + return ImmutableMap.of(); + } } /** |