Skip to content

Commit f3fe5b3

Browse files
committed
Fix action_env for ipa post processor
1 parent 55cf5c2 commit f3fe5b3

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

apple/internal/codesigning_support.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ def _post_process_and_sign_archive_action(
575575
codesign_inputs,
576576
codesignopts,
577577
entitlements = None,
578+
env = None,
578579
features,
579580
frameworks_path,
580581
input_archive,
@@ -597,6 +598,7 @@ def _post_process_and_sign_archive_action(
597598
codesign_inputs: Extra inputs needed for the `codesign` tool.
598599
codesignopts: Extra options to pass to the `codesign` tool.
599600
entitlements: Optional file representing the entitlements to sign with.
601+
env: Environment variables. Typically from `ctx.configuration.default_shell_env`.
600602
features: List of features enabled by the user. Typically from `ctx.features`.
601603
frameworks_path: The Frameworks path relative to the archive.
602604
input_archive: The `File` representing the archive containing the bundle
@@ -719,6 +721,7 @@ def _post_process_and_sign_archive_action(
719721
actions = actions,
720722
apple_fragment = platform_prerequisites.apple_fragment,
721723
arguments = arguments,
724+
env = env,
722725
executable = process_and_sign_expanded_template,
723726
execution_requirements = execution_requirements,
724727
inputs = depset(
@@ -735,6 +738,7 @@ def _post_process_and_sign_archive_action(
735738
else:
736739
actions.run(
737740
arguments = arguments,
741+
env = env,
738742
executable = process_and_sign_expanded_template,
739743
inputs = input_files,
740744
mnemonic = mnemonic,

apple/internal/ios_rules.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ def _ios_application_impl(ctx):
433433
codesign_inputs = ctx.files.codesign_inputs,
434434
codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx),
435435
entitlements = entitlements.codesigning,
436+
env = ctx.configuration.default_shell_env,
436437
features = features,
437438
ipa_post_processor = ctx.executable.ipa_post_processor,
438439
partials = processor_partials,
@@ -727,6 +728,7 @@ def _ios_app_clip_impl(ctx):
727728
codesign_inputs = ctx.files.codesign_inputs,
728729
codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx),
729730
entitlements = entitlements.codesigning,
731+
env = ctx.configuration.default_shell_env,
730732
features = features,
731733
ipa_post_processor = ctx.executable.ipa_post_processor,
732734
partials = processor_partials,
@@ -1028,6 +1030,7 @@ def _ios_framework_impl(ctx):
10281030
bundle_name = bundle_name,
10291031
codesign_inputs = ctx.files.codesign_inputs,
10301032
codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx),
1033+
env = ctx.configuration.default_shell_env,
10311034
features = features,
10321035
ipa_post_processor = ctx.executable.ipa_post_processor,
10331036
partials = processor_partials,
@@ -1312,6 +1315,7 @@ def _ios_extension_impl(ctx):
13121315
codesign_inputs = ctx.files.codesign_inputs,
13131316
codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx),
13141317
entitlements = entitlements.codesigning,
1318+
env = ctx.configuration.default_shell_env,
13151319
features = features,
13161320
ipa_post_processor = ctx.executable.ipa_post_processor,
13171321
partials = processor_partials,
@@ -1581,6 +1585,7 @@ def _ios_dynamic_framework_impl(ctx):
15811585
bundle_extension = bundle_extension,
15821586
bundle_name = bundle_name,
15831587
codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx),
1588+
env = ctx.configuration.default_shell_env,
15841589
features = features,
15851590
ipa_post_processor = ctx.executable.ipa_post_processor,
15861591
partials = processor_partials,
@@ -1757,6 +1762,7 @@ def _ios_static_framework_impl(ctx):
17571762
bundle_name = bundle_name,
17581763
codesign_inputs = ctx.files.codesign_inputs,
17591764
codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx),
1765+
env = ctx.configuration.default_shell_env,
17601766
features = features,
17611767
ipa_post_processor = ctx.executable.ipa_post_processor,
17621768
partials = processor_partials,
@@ -1959,6 +1965,7 @@ def _ios_imessage_application_impl(ctx):
19591965
bundle_extension = bundle_extension,
19601966
bundle_name = bundle_name,
19611967
entitlements = entitlements.codesigning,
1968+
env = ctx.configuration.default_shell_env,
19621969
features = features,
19631970
ipa_post_processor = ctx.executable.ipa_post_processor,
19641971
partials = processor_partials,
@@ -2212,6 +2219,7 @@ def _ios_imessage_extension_impl(ctx):
22122219
codesign_inputs = ctx.files.codesign_inputs,
22132220
codesignopts = codesigning_support.codesignopts_from_rule_ctx(ctx),
22142221
entitlements = entitlements.codesigning,
2222+
env = ctx.configuration.default_shell_env,
22152223
features = features,
22162224
ipa_post_processor = ctx.executable.ipa_post_processor,
22172225
partials = processor_partials,
@@ -2413,6 +2421,7 @@ def _ios_sticker_pack_extension_impl(ctx):
24132421
bundle_extension = bundle_extension,
24142422
bundle_name = bundle_name,
24152423
entitlements = entitlements.codesigning,
2424+
env = ctx.configuration.default_shell_env,
24162425
features = features,
24172426
ipa_post_processor = ctx.executable.ipa_post_processor,
24182427
partials = processor_partials,

apple/internal/processor.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ def _bundle_post_process_and_sign(
471471
codesign_inputs,
472472
codesignopts,
473473
entitlements,
474+
env,
474475
features,
475476
ipa_post_processor,
476477
output_archive,
@@ -493,6 +494,7 @@ def _bundle_post_process_and_sign(
493494
codesign_inputs: Extra inputs needed for the `codesign` tool.
494495
codesignopts: Extra options to pass to the `codesign` tool.
495496
entitlements: The entitlements file to sign with. Can be `None` if one was not provided.
497+
env: Environment variables. Typically from `ctx.configuration.default_shell_env`.
496498
features: List of features enabled by the user. Typically from `ctx.features`.
497499
ipa_post_processor: A file that acts as a bundle post processing tool. May be `None`.
498500
output_archive: The file representing the final bundled, post-processed and signed archive.
@@ -603,6 +605,7 @@ def _bundle_post_process_and_sign(
603605
codesign_inputs = codesign_inputs,
604606
codesignopts = codesignopts,
605607
entitlements = entitlements,
608+
env = env,
606609
features = features,
607610
frameworks_path = frameworks_path,
608611
input_archive = unprocessed_archive,
@@ -672,6 +675,7 @@ def _bundle_post_process_and_sign(
672675
codesign_inputs = codesign_inputs,
673676
codesignopts = codesignopts,
674677
entitlements = entitlements,
678+
env = env,
675679
features = features,
676680
frameworks_path = embedding_frameworks_path,
677681
input_archive = unprocessed_embedded_archive,
@@ -699,6 +703,7 @@ def _process(
699703
codesign_inputs = [],
700704
codesignopts = [],
701705
entitlements = None,
706+
env = None,
702707
features,
703708
ipa_post_processor,
704709
output_discriminator = None,
@@ -722,6 +727,7 @@ def _process(
722727
codesign_inputs: Extra inputs needed for the `codesign` tool.
723728
codesignopts: Extra options to pass to the `codesign` tool.
724729
entitlements: The entitlements file to sign with. Can be `None` if one was not provided.
730+
env: Environment variables. Typically from `ctx.configuration.default_shell_env`.
725731
features: List of features enabled by the user. Typically from `ctx.features`.
726732
ipa_post_processor: A file that acts as a bundle post processing tool. May be `None`.
727733
output_discriminator: A string to differentiate between different target intermediate files
@@ -762,6 +768,7 @@ def _process(
762768
codesign_inputs = codesign_inputs,
763769
codesignopts = codesignopts,
764770
entitlements = entitlements,
771+
env = env,
765772
features = features,
766773
ipa_post_processor = ipa_post_processor,
767774
output_archive = output_archive,

test/ios_application_test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ EOF
155155
cat > app/post_processor.sh <<EOF
156156
#!/bin/bash
157157
WORKDIR="\$1"
158-
echo "foo" > "\$WORKDIR/Payload/app.app/inserted_by_post_processor.txt"
158+
echo "\$FOO" >> "\$WORKDIR/Payload/app.app/inserted_by_post_processor.txt"
159159
EOF
160160
chmod +x app/post_processor.sh
161161

162-
do_build ios //app:app || fail "Should build"
163-
assert_equals "foo" "$(unzip_single_file "test-bin/app/app.ipa" \
162+
do_build ios --action_env=FOO=bar //app:app || fail "Should build"
163+
assert_equals "bar" "$(unzip_single_file "test-bin/app/app.ipa" \
164164
"Payload/app.app/inserted_by_post_processor.txt")"
165165
}
166166

0 commit comments

Comments
 (0)