Make the Apple Skylark rule be able to fetch environment data from the xcode_config rule in addition to ctx.fragments.apple . Subsequent Bazel versions won't support these methods on ctx.fragments.apple and thus need to be updated. Progress towards https://github.com/bazelbuild/bazel/issues/3424 . RELNOTES: None. PiperOrigin-RevId: 171021097
diff --git a/tools/build_defs/apple/shared.bzl b/tools/build_defs/apple/shared.bzl index 4d62db6..1506edc 100644 --- a/tools/build_defs/apple/shared.bzl +++ b/tools/build_defs/apple/shared.bzl
@@ -74,8 +74,10 @@ """Returns the environment dictionary necessary to use xcrunwrapper.""" platform = ctx.fragments.apple.single_arch_platform - action_env = ctx.fragments.apple.target_apple_env(platform) \ - + ctx.fragments.apple.apple_host_system_env() + environment_supplier = ctx.attr._xcode_config[apple_common.XcodeVersionConfig] + if not hasattr(environment_supplier, "apple_host_system_env"): + environment_supplier = ctx.fragments.apple + action_env = environment_supplier.target_apple_env(platform) + environment_supplier.apple_host_system_env() return action_env