Rollback of commit 368cc56fb2baa3e21be4acdd2410a4ce8245de93.

*** Reason for rollback ***

Broke builds that use apple_genrule.

*** Original change description ***

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=126205606
diff --git a/tools/build_defs/apple/shared.bzl b/tools/build_defs/apple/shared.bzl
index 6118fd7..976911b 100644
--- a/tools/build_defs/apple/shared.bzl
+++ b/tools/build_defs/apple/shared.bzl
@@ -47,11 +47,6 @@
 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=[...],...)
   """
@@ -59,22 +54,21 @@
   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)