diff --git a/apple/internal/codesigning_support.bzl b/apple/internal/codesigning_support.bzl index 3f3af898bb..54a5957b4a 100644 --- a/apple/internal/codesigning_support.bzl +++ b/apple/internal/codesigning_support.bzl @@ -575,6 +575,7 @@ def _post_process_and_sign_archive_action( codesign_inputs, codesignopts, entitlements = None, + env = None, features, frameworks_path, input_archive, @@ -597,6 +598,7 @@ def _post_process_and_sign_archive_action( codesign_inputs: Extra inputs needed for the `codesign` tool. codesignopts: Extra options to pass to the `codesign` tool. entitlements: Optional file representing the entitlements to sign with. + env: Environment variables. Typically from `ctx.configuration.default_shell_env`. features: List of features enabled by the user. Typically from `ctx.features`. frameworks_path: The Frameworks path relative to the archive. input_archive: The `File` representing the archive containing the bundle @@ -719,6 +721,7 @@ def _post_process_and_sign_archive_action( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, arguments = arguments, + env = env, executable = process_and_sign_expanded_template, execution_requirements = execution_requirements, inputs = depset( @@ -735,6 +738,7 @@ def _post_process_and_sign_archive_action( else: actions.run( arguments = arguments, + env = env, executable = process_and_sign_expanded_template, inputs = input_files, mnemonic = mnemonic, diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index 6ccb71aa98..4808de3ed5 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -433,6 +433,7 @@ def _ios_application_impl(ctx): codesign_inputs = ctx.files.codesign_inputs, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), entitlements = entitlements.codesigning, + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -727,6 +728,7 @@ def _ios_app_clip_impl(ctx): codesign_inputs = ctx.files.codesign_inputs, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), entitlements = entitlements.codesigning, + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -1028,6 +1030,7 @@ def _ios_framework_impl(ctx): bundle_name = bundle_name, codesign_inputs = ctx.files.codesign_inputs, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -1312,6 +1315,7 @@ def _ios_extension_impl(ctx): codesign_inputs = ctx.files.codesign_inputs, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), entitlements = entitlements.codesigning, + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -1581,6 +1585,7 @@ def _ios_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -1757,6 +1762,7 @@ def _ios_static_framework_impl(ctx): bundle_name = bundle_name, codesign_inputs = ctx.files.codesign_inputs, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -1959,6 +1965,7 @@ def _ios_imessage_application_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, entitlements = entitlements.codesigning, + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -2212,6 +2219,7 @@ def _ios_imessage_extension_impl(ctx): codesign_inputs = ctx.files.codesign_inputs, codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx), entitlements = entitlements.codesigning, + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, @@ -2413,6 +2421,7 @@ def _ios_sticker_pack_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, entitlements = entitlements.codesigning, + env = ctx.configuration.default_shell_env, features = features, ipa_post_processor = ctx.executable.ipa_post_processor, partials = processor_partials, diff --git a/apple/internal/processor.bzl b/apple/internal/processor.bzl index d0f1d03f49..007ed8d58d 100644 --- a/apple/internal/processor.bzl +++ b/apple/internal/processor.bzl @@ -471,6 +471,7 @@ def _bundle_post_process_and_sign( codesign_inputs, codesignopts, entitlements, + env, features, ipa_post_processor, output_archive, @@ -493,6 +494,7 @@ def _bundle_post_process_and_sign( codesign_inputs: Extra inputs needed for the `codesign` tool. codesignopts: Extra options to pass to the `codesign` tool. entitlements: The entitlements file to sign with. Can be `None` if one was not provided. + env: Environment variables. Typically from `ctx.configuration.default_shell_env`. features: List of features enabled by the user. Typically from `ctx.features`. ipa_post_processor: A file that acts as a bundle post processing tool. May be `None`. output_archive: The file representing the final bundled, post-processed and signed archive. @@ -603,6 +605,7 @@ def _bundle_post_process_and_sign( codesign_inputs = codesign_inputs, codesignopts = codesignopts, entitlements = entitlements, + env = env, features = features, frameworks_path = frameworks_path, input_archive = unprocessed_archive, @@ -672,6 +675,7 @@ def _bundle_post_process_and_sign( codesign_inputs = codesign_inputs, codesignopts = codesignopts, entitlements = entitlements, + env = env, features = features, frameworks_path = embedding_frameworks_path, input_archive = unprocessed_embedded_archive, @@ -699,6 +703,7 @@ def _process( codesign_inputs = [], codesignopts = [], entitlements = None, + env = None, features, ipa_post_processor, output_discriminator = None, @@ -722,6 +727,7 @@ def _process( codesign_inputs: Extra inputs needed for the `codesign` tool. codesignopts: Extra options to pass to the `codesign` tool. entitlements: The entitlements file to sign with. Can be `None` if one was not provided. + env: Environment variables. Typically from `ctx.configuration.default_shell_env`. features: List of features enabled by the user. Typically from `ctx.features`. ipa_post_processor: A file that acts as a bundle post processing tool. May be `None`. output_discriminator: A string to differentiate between different target intermediate files @@ -762,6 +768,7 @@ def _process( codesign_inputs = codesign_inputs, codesignopts = codesignopts, entitlements = entitlements, + env = env, features = features, ipa_post_processor = ipa_post_processor, output_archive = output_archive, diff --git a/test/ios_application_test.sh b/test/ios_application_test.sh index 25ff20bb36..9e69de64b6 100755 --- a/test/ios_application_test.sh +++ b/test/ios_application_test.sh @@ -155,12 +155,12 @@ EOF cat > app/post_processor.sh < "\$WORKDIR/Payload/app.app/inserted_by_post_processor.txt" +echo "\$FOO" >> "\$WORKDIR/Payload/app.app/inserted_by_post_processor.txt" EOF chmod +x app/post_processor.sh - do_build ios //app:app || fail "Should build" - assert_equals "foo" "$(unzip_single_file "test-bin/app/app.ipa" \ + do_build ios --action_env=FOO=bar //app:app || fail "Should build" + assert_equals "bar" "$(unzip_single_file "test-bin/app/app.ipa" \ "Payload/app.app/inserted_by_post_processor.txt")" }