From f8f5f4c5f0dfb9ad42f9bb1cff5e0d2a15b2c757 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Tue, 1 Dec 2020 14:57:58 -0800 Subject: [PATCH 1/2] Generate gen_snapshot_armv7 and gen_snapshot_arm64 --- shell/platform/darwin/ios/BUILD.gn | 26 ++++++++++++++++++++++ sky/tools/create_macos_gen_snapshots.py | 29 +++++++++++++------------ 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 897fe374b5578..f4407ae176dec 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -324,6 +324,29 @@ shared_library("copy_and_verify_framework_module") { ] } +action("create_arm_gen_snapshot") { + output_dir = "$root_out_dir/clang_x64" + script = "//flutter/sky/tools/create_macos_gen_snapshots.py" + visibility = [ ":*" ] + args = [ + "--dst", + rebase_path(output_dir), + ] + if (target_cpu == "arm") { + args += [ + "--armv7-out-dir", + rebase_path("$root_out_dir"), + ] + outputs = [ "$output_dir/gen_snapshot_armv7" ] + } else { + args += [ + "--arm64-out-dir", + rebase_path("$root_out_dir"), + ] + outputs = [ "$output_dir/gen_snapshot_arm64" ] + } +} + group("universal_flutter_framework") { visibility = [ ":*" ] deps = [ @@ -335,6 +358,9 @@ group("universal_flutter_framework") { ":copy_framework_podspec", ":copy_license", ] + if (target_cpu == "arm" || target_cpu == "arm64") { + deps += [ ":create_arm_gen_snapshot" ] + } } action("flutter_framework") { diff --git a/sky/tools/create_macos_gen_snapshots.py b/sky/tools/create_macos_gen_snapshots.py index 1811a951d872c..297c277c8b775 100755 --- a/sky/tools/create_macos_gen_snapshots.py +++ b/sky/tools/create_macos_gen_snapshots.py @@ -13,26 +13,27 @@ def main(): parser = argparse.ArgumentParser(description='Copies architecture-dependent gen_snapshot binaries to output dir') parser.add_argument('--dst', type=str, required=True) - parser.add_argument('--arm64-out-dir', type=str, required=True) - parser.add_argument('--armv7-out-dir', type=str, required=True) + parser.add_argument('--arm64-out-dir', type=str) + parser.add_argument('--armv7-out-dir', type=str) args = parser.parse_args() - arm64_gen_snapshot = os.path.join(args.arm64_out_dir, 'clang_x64', 'gen_snapshot') - armv7_gen_snapshot = os.path.join(args.armv7_out_dir, 'clang_x64', 'gen_snapshot') + if args.arm64_out_dir: + generate_gen_snapshot(args.arm64_out_dir, os.path.join(args.dst, 'gen_snapshot_arm64')) - if not os.path.isfile(arm64_gen_snapshot): - print 'Cannot find x86_64 (arm64) gen_snapshot at', arm64_gen_snapshot - return 1 + if args.armv7_out_dir: + generate_gen_snapshot(args.armv7_out_dir, os.path.join(args.dst, 'gen_snapshot_armv7')) - if not os.path.isfile(armv7_gen_snapshot): - print 'Cannot find i386 (armv7) gen_snapshot at', armv7_gen_snapshot - return 1 - subprocess.check_call(['xcrun', 'bitcode_strip', '-r', armv7_gen_snapshot, - '-o', os.path.join(args.dst, 'gen_snapshot_armv7')]) - subprocess.check_call(['xcrun', 'bitcode_strip', '-r', arm64_gen_snapshot, - '-o', os.path.join(args.dst, 'gen_snapshot_arm64')]) +def generate_gen_snapshot(directory, destination): + gen_snapshot_dir = os.path.join(directory, 'clang_x64', 'gen_snapshot') + if not os.path.isfile(gen_snapshot_dir): + print 'Cannot find gen_snapshot at', gen_snapshot_dir + sys.exit(1) + + subprocess.check_call(['xcrun', 'bitcode_strip', '-r', gen_snapshot_dir, + '-o', destination]) + if __name__ == '__main__': sys.exit(main()) From 6fdd1f59151df7569656128e5a065676dd444ff6 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 2 Dec 2020 10:43:47 -0800 Subject: [PATCH 2/2] Move to snapshot/BUILD.gn --- lib/snapshot/BUILD.gn | 27 +++++++++++++++++++++++++++ shell/platform/darwin/ios/BUILD.gn | 26 -------------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index eb71524900fac..dc281ea7811d8 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -197,6 +197,29 @@ bin_to_linkable("platform_strong_dill_linkable") { executable = false } +action("create_arm_gen_snapshot") { + output_dir = "$root_out_dir/clang_x64" + script = "//flutter/sky/tools/create_macos_gen_snapshots.py" + visibility = [ ":*" ] + args = [ + "--dst", + rebase_path(output_dir), + ] + if (target_cpu == "arm") { + args += [ + "--armv7-out-dir", + rebase_path("$root_out_dir"), + ] + outputs = [ "$output_dir/gen_snapshot_armv7" ] + } else { + args += [ + "--arm64-out-dir", + rebase_path("$root_out_dir"), + ] + outputs = [ "$output_dir/gen_snapshot_arm64" ] + } +} + source_set("snapshot") { deps = [ ":isolate_snapshot_data_linkable", @@ -205,6 +228,10 @@ source_set("snapshot") { ":vm_snapshot_data_linkable", ":vm_snapshot_instructions_linkable", ] + if (host_os == "macos" && (target_cpu == "arm" || target_cpu == "arm64")) { + deps += [ ":create_arm_gen_snapshot" ] + } + sources = get_target_outputs(":isolate_snapshot_data_linkable") + get_target_outputs(":isolate_snapshot_instructions_linkable") + get_target_outputs(":vm_snapshot_data_linkable") + diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index f4407ae176dec..897fe374b5578 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -324,29 +324,6 @@ shared_library("copy_and_verify_framework_module") { ] } -action("create_arm_gen_snapshot") { - output_dir = "$root_out_dir/clang_x64" - script = "//flutter/sky/tools/create_macos_gen_snapshots.py" - visibility = [ ":*" ] - args = [ - "--dst", - rebase_path(output_dir), - ] - if (target_cpu == "arm") { - args += [ - "--armv7-out-dir", - rebase_path("$root_out_dir"), - ] - outputs = [ "$output_dir/gen_snapshot_armv7" ] - } else { - args += [ - "--arm64-out-dir", - rebase_path("$root_out_dir"), - ] - outputs = [ "$output_dir/gen_snapshot_arm64" ] - } -} - group("universal_flutter_framework") { visibility = [ ":*" ] deps = [ @@ -358,9 +335,6 @@ group("universal_flutter_framework") { ":copy_framework_podspec", ":copy_license", ] - if (target_cpu == "arm" || target_cpu == "arm64") { - deps += [ ":create_arm_gen_snapshot" ] - } } action("flutter_framework") {