Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

[ios] use python script to generate extension safe frameworks and code sign them #45781

Merged
merged 7 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so i moved the Flutter.framework for extension_safe into the responding existing zips. In below python change
For example
debug extension_safe Flutter.framework is now moved under ios-debug/extension_safe

"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')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I created a new subfolder under dst, extension safe frameworks are all moved into this subfolder.

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')):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We explictly put the Flutter.dsym in a standalone zip file. So I thought we should do the same for extension safe dsym to keep it consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I think this is what is misleading. I don't think the zip file location mattered, they are not really useful here, they are later uploaded to a destination determined in the mac_ios_engine.json. After my change, both Flutter.dsym and extension_safe_Flutter.dsym are uploaded to ios/release, where Flutter.dsym used to be.

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