Skip to content

Commit

Permalink
Fix action_env for ipa post processor
Browse files Browse the repository at this point in the history
  • Loading branch information
MIP9 committed Sep 5, 2023
1 parent 55cf5c2 commit 31c218f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions apple/internal/codesigning_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ def _post_process_and_sign_archive_action(
codesign_inputs,
codesignopts,
entitlements = None,
env = None,
features,
frameworks_path,
input_archive,
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions apple/internal/processor.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ def _bundle_post_process_and_sign(
codesign_inputs,
codesignopts,
entitlements,
env,
features,
ipa_post_processor,
output_archive,
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -699,6 +703,7 @@ def _process(
codesign_inputs = [],
codesignopts = [],
entitlements = None,
env = None,
features,
ipa_post_processor,
output_discriminator = None,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions test/ios_application_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ EOF
cat > app/post_processor.sh <<EOF
#!/bin/bash
WORKDIR="\$1"
echo "foo" > "\$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")"
}

Expand Down

0 comments on commit 31c218f

Please sign in to comment.