aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-06-29 15:41:11 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-06-30 11:40:53 +0000
commit368cc56fb2baa3e21be4acdd2410a4ce8245de93 (patch)
treea2b0f4a8f0546aed78c56353ae3ee4771445f2cf /tools
parente5f3baf0858d86ec266a6ca5c87b9662b30fb8a9 (diff)
Move platform environment from xcrun_action to apple_action.
This change ensures that scripts that don't need to be wrapped with xcrun_action (like actoolwrapper, ibtoolwrapper, and friends, because they internally invoke xcrunwrapper) also have the Xcode version and platform envvars set. RELNOTES: -- MOS_MIGRATED_REVID=126195267
Diffstat (limited to 'tools')
-rw-r--r--tools/build_defs/apple/shared.bzl18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/build_defs/apple/shared.bzl b/tools/build_defs/apple/shared.bzl
index 976911b177..6118fd7926 100644
--- a/tools/build_defs/apple/shared.bzl
+++ b/tools/build_defs/apple/shared.bzl
@@ -47,6 +47,11 @@ def module_cache_path(ctx):
def apple_action(ctx, **kw):
"""Creates an action that only runs on MacOS/Darwin.
+ This function also passes to the action the necessary environment variables
+ that control the Xcode version and platform to build for.
+
+ Rules that use this action must require the "apple" configuration fragment.
+
Call it similar to how you would call ctx.action:
apple_action(ctx, outputs=[...], inputs=[...],...)
"""
@@ -54,21 +59,22 @@ def apple_action(ctx, **kw):
execution_requirements += DARWIN_EXECUTION_REQUIREMENTS
kw['execution_requirements'] = execution_requirements
+ platform = ctx.fragments.apple.ios_cpu_platform()
+ action_env = ctx.fragments.apple.target_apple_env(platform) \
+ + ctx.fragments.apple.apple_host_system_env()
+ kw['env'] = kw.get('env', {}) + action_env
+
ctx.action(**kw)
def xcrun_action(ctx, **kw):
"""Creates an apple action that executes xcrunwrapper.
+ Rules that use this action must require the "apple" configuration fragment.
+
args:
ctx: The context of the rule that owns this action.
This method takes the same keyword arguments as ctx.action, however you don't
need to specify the executable.
"""
- platform = ctx.fragments.apple.ios_cpu_platform()
- action_env = ctx.fragments.apple.target_apple_env(platform) \
- + ctx.fragments.apple.apple_host_system_env()
- env = kw.get('env', {})
- kw['env'] = env + action_env
-
apple_action(ctx, executable=ctx.executable._xcrunwrapper, **kw)