Skip to content

Commit

Permalink
[ios] use python script to generate extension safe frameworks and cod…
Browse files Browse the repository at this point in the history
…e sign them (#45781)

Generates the fat framework for extension safe variants and add them to the code sign list.

Also reverts part of #45664 where the variants are uploaded in separate archive. Now with this change, the extension safe is inside a "extension_safe" folder under existing archive. 

fixes flutter/flutter#124291

The destination folder after this change:
- An extension_safe folder is added, which includes the extension safe Flutter.frameworks and dsym
- The artifacts.zip now includes the `extension_safe` except the dysm
- A extension_safe_Flutter.dsym.zip is created (under ios/release/) , which includes the extension_safe/Flutter.dsym

<img width="508" alt="Screenshot 2023-09-13 at 3 26 23 PM" src="https://github.com/flutter/engine/assets/3756895/84901ef1-af89-413f-94c7-74ed0aa36da6">

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
Chris Yang authored and harryterkelsen committed Oct 23, 2023
1 parent 59d9a5b commit 00e9b5e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 65 deletions.
66 changes: 2 additions & 64 deletions ci/builders/mac_ios_engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,53 +289,6 @@
"script": "flutter/sky/tools/create_full_ios_framework.py",
"language": "python3"
},
{
"name": "Debug-ios-Flutter-Extension-Safe.xcframework",
"parameters": [
"--dst",
"out/debug_extension_safe",
"--arm64-out-dir",
"out/ios_debug_extension_safe",
"--simulator-x64-out-dir",
"out/ios_debug_sim_extension_safe",
"--simulator-arm64-out-dir",
"out/ios_debug_sim_arm64_extension_safe"
],
"script": "flutter/sky/tools/create_full_ios_framework.py",
"language": "python3"
},
{
"name": "Profile-ios-Flutter-Extension-Safe.xcframework",
"parameters": [
"--dst",
"out/profile_extension_safe",
"--arm64-out-dir",
"out/ios_profile_extension_safe",
"--simulator-x64-out-dir",
"out/ios_debug_sim_extension_safe",
"--simulator-arm64-out-dir",
"out/ios_debug_sim_arm64_extension_safe"
],
"script": "flutter/sky/tools/create_full_ios_framework.py",
"language": "python3"
},
{
"name": "Release-ios-Flutter-Extension-Safe.xcframework",
"parameters": [
"--dst",
"out/release_extension_safe",
"--arm64-out-dir",
"out/ios_release_extension_safe",
"--simulator-x64-out-dir",
"out/ios_debug_sim_extension_safe",
"--simulator-arm64-out-dir",
"out/ios_debug_sim_arm64_extension_safe",
"--dsym",
"--strip"
],
"script": "flutter/sky/tools/create_full_ios_framework.py",
"language": "python3"
},
{
"name": "Release-macos-gen-snapshots",
"parameters": [
Expand Down Expand Up @@ -379,23 +332,8 @@
"realm": "production"
},
{
"source": "out/debug_extension_safe/artifacts.zip",
"destination": "ios-extension-safe/artifacts.zip",
"realm": "production"
},
{
"source": "out/profile_extension_safe/artifacts.zip",
"destination": "ios-profile-extension-safe/artifacts.zip",
"realm": "production"
},
{
"source": "out/release_extension_safe/artifacts.zip",
"destination": "ios-release-extension-safe/artifacts.zip",
"realm": "production"
},
{
"source": "out/release_extension_safe/Flutter.dSYM.zip",
"destination": "ios-release-extension-safe/Flutter.dSYM.zip",
"source": "out/release/extension_safe_Flutter.dSYM.zip",
"destination": "ios-release/extension_safe_Flutter.dSYM.zip",
"realm": "production"
}
]
Expand Down
52 changes: 51 additions & 1 deletion sky/tools/create_full_ios_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,49 @@ def main():
args, dst, framework, arm64_framework, simulator_framework,
simulator_x64_framework, simulator_arm64_framework
)

extension_safe_dst = os.path.join(dst, 'extension_safe')
create_extension_safe_framework(
args, extension_safe_dst, '%s_extension_safe' % arm64_out_dir,
'%s_extension_safe' % simulator_x64_out_dir,
'%s_extension_safe' % simulator_arm64_out_dir
)

generate_gen_snapshot(args, dst, x64_out_dir, arm64_out_dir)
zip_archive(dst)
return 0

def create_extension_safe_framework( # pylint: disable=too-many-arguments
args, dst, arm64_out_dir, simulator_x64_out_dir, simulator_arm64_out_dir
):
framework = os.path.join(dst, 'Flutter.framework')
simulator_framework = os.path.join(dst, 'sim', 'Flutter.framework')
arm64_framework = os.path.join(arm64_out_dir, 'Flutter.framework')
simulator_x64_framework = os.path.join(
simulator_x64_out_dir, 'Flutter.framework'
)
simulator_arm64_framework = os.path.join(
simulator_arm64_out_dir, 'Flutter.framework'
)

if not os.path.isdir(arm64_framework):
print(
'Cannot find extension safe iOS arm64 Framework at %s' % arm64_framework
)
return 1

if not os.path.isdir(simulator_x64_framework):
print(
'Cannot find extension safe iOS x64 simulator Framework at %s' %
simulator_x64_framework
)
return 1

create_framework(
args, dst, framework, arm64_framework, simulator_framework,
simulator_x64_framework, simulator_arm64_framework
)
return 0

def create_framework( # pylint: disable=too-many-arguments
args, dst, framework, arm64_framework, simulator_framework,
Expand Down Expand Up @@ -173,7 +212,9 @@ def zip_archive(dst):
ios_file_with_entitlements = ['gen_snapshot_arm64']
ios_file_without_entitlements = [
'Flutter.xcframework/ios-arm64/Flutter.framework/Flutter',
'Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter'
'Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter',
'extension_safe/Flutter.xcframework/ios-arm64/Flutter.framework/Flutter',
'extension_safe/Flutter.xcframework/ios-arm64_x86_64-simulator/Flutter.framework/Flutter'
]
embed_codesign_configuration(
os.path.join(dst, 'entitlements.txt'), ios_file_with_entitlements
Expand All @@ -192,12 +233,21 @@ def zip_archive(dst):
'Flutter.xcframework',
'entitlements.txt',
'without_entitlements.txt',
'extension_safe/Flutter.framework',
'extension_safe/Flutter.xcframework',
'extension_safe/sim',
],
cwd=dst)
if os.path.exists(os.path.join(dst, 'Flutter.dSYM')):
subprocess.check_call(['zip', '-r', 'Flutter.dSYM.zip', 'Flutter.dSYM'],
cwd=dst)

if os.path.exists(os.path.join(dst, 'extension_safe', 'Flutter.dSYM')):
subprocess.check_call([
'zip', '-r', 'extension_safe_Flutter.dSYM.zip', 'Flutter.dSYM'
],
cwd=dst)


def process_framework(args, dst, framework, framework_binary):
if args.dsym:
Expand Down

0 comments on commit 00e9b5e

Please sign in to comment.