[iOS] Build universal gen_snapshots for iOS (flutter/engine#54009)
This merges the macOS and iOS rules for creating the `gen_snapshot_arm64` and `gen_snapshot_x64` used to build for iOS devices, as well as for iOS simulators on both arm64 hosts (`gen_snapshot_arm64`) and x64 hosts (`gen_snapshot_x64`). The macOS rules have already been updated to generate universal binaries for each of these that can be run on both Apple Silicon and Intel Mac hosts. This also updates `create_full_ios_framework.py` to bundle the newly-generated universal gen_snapshot binaries and produce the artifacts.zip archive that is uploaded via the build config in `mac_ios_engine.json`. The `create_arm_gen_snapshot` rule remains until I'm 100% convinced it's not used for macOS host Android target builds. Issue: https://github.com/flutter/flutter/issues/101138 Issue: https://github.com/flutter/flutter/issues/69157 This is stacked on top of https://github.com/flutter/engine/pull/54008. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -117,6 +117,7 @@
|
||||
"ninja": {
|
||||
"config": "ci/ios_debug",
|
||||
"targets": [
|
||||
"flutter/lib/snapshot:generate_snapshot_bins",
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework"
|
||||
]
|
||||
},
|
||||
@@ -161,8 +162,8 @@
|
||||
"ninja": {
|
||||
"config": "ci/ios_profile",
|
||||
"targets": [
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework",
|
||||
"flutter/lib/snapshot:generate_snapshot_bin"
|
||||
"flutter/lib/snapshot:generate_snapshot_bins",
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework"
|
||||
]
|
||||
},
|
||||
"postsubmit_overrides": {
|
||||
@@ -206,8 +207,8 @@
|
||||
"ninja": {
|
||||
"config": "ci/ios_release",
|
||||
"targets": [
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework",
|
||||
"flutter/lib/snapshot:generate_snapshot_bin"
|
||||
"flutter/lib/snapshot:generate_snapshot_bins",
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework"
|
||||
]
|
||||
},
|
||||
"postsubmit_overrides": {
|
||||
@@ -349,6 +350,7 @@
|
||||
"ninja": {
|
||||
"config": "ci/ios_debug_extension_safe",
|
||||
"targets": [
|
||||
"flutter/lib/snapshot:generate_snapshot_bins",
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework"
|
||||
]
|
||||
},
|
||||
@@ -395,8 +397,8 @@
|
||||
"ninja": {
|
||||
"config": "ci/ios_profile_extension_safe",
|
||||
"targets": [
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework",
|
||||
"flutter/lib/snapshot:generate_snapshot_bin"
|
||||
"flutter/lib/snapshot:generate_snapshot_bins",
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework"
|
||||
]
|
||||
},
|
||||
"postsubmit_overrides": {
|
||||
@@ -442,8 +444,8 @@
|
||||
"ninja": {
|
||||
"config": "ci/ios_release_extension_safe",
|
||||
"targets": [
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework",
|
||||
"flutter/lib/snapshot:generate_snapshot_bin"
|
||||
"flutter/lib/snapshot:generate_snapshot_bins",
|
||||
"flutter/shell/platform/darwin/ios:flutter_framework"
|
||||
]
|
||||
},
|
||||
"postsubmit_overrides": {
|
||||
|
||||
@@ -33,7 +33,7 @@ group("generate_snapshot_bins") {
|
||||
#
|
||||
# For macOS target builds: needed for both target CPUs (arm64, x64).
|
||||
# For iOS, Android target builds: all AOT target CPUs are arm/arm64.
|
||||
if (host_os == "mac" && target_os == "mac") {
|
||||
if (host_os == "mac" && (target_os == "mac" || target_os == "ios")) {
|
||||
deps += [ ":create_macos_gen_snapshots" ]
|
||||
} else if (host_os == "mac" &&
|
||||
(target_cpu == "arm" || target_cpu == "arm64")) {
|
||||
@@ -184,17 +184,16 @@ if (host_os == "mac" && target_os != "mac" &&
|
||||
# to `gen_snapshot_arm64` or `gen_snapshot_x64` depending on the target
|
||||
# platform.
|
||||
#
|
||||
# This target is used for builds targeting macOS.
|
||||
if (host_os == "mac" && target_os == "mac") {
|
||||
# This target is used for builds targeting iOS and macOS.
|
||||
if (host_os == "mac" && (target_os == "mac" || target_os == "ios")) {
|
||||
template("build_mac_gen_snapshot") {
|
||||
assert(defined(invoker.host_arch))
|
||||
host_cpu = invoker.host_arch
|
||||
|
||||
build_toolchain = "//build/toolchain/mac:clang_$host_cpu"
|
||||
if (host_cpu == target_cpu) {
|
||||
gen_snapshot_target_name = "gen_snapshot"
|
||||
if (target_os == "mac" && host_cpu == target_cpu) {
|
||||
gen_snapshot_target_name = "gen_snapshot_host_targeting_host"
|
||||
} else {
|
||||
gen_snapshot_target_name = "gen_snapshot"
|
||||
}
|
||||
gen_snapshot_target =
|
||||
"$dart_src/runtime/bin:$gen_snapshot_target_name($build_toolchain)"
|
||||
|
||||
@@ -230,21 +230,20 @@ def process_framework(args, dst, framework, framework_binary):
|
||||
|
||||
def generate_gen_snapshot(dst, x64_out_dir, arm64_out_dir):
|
||||
if x64_out_dir:
|
||||
_generate_gen_snapshot(x64_out_dir, os.path.join(dst, 'gen_snapshot_x64'))
|
||||
x64_path = os.path.join(x64_out_dir, 'gen_snapshot_x64')
|
||||
_generate_gen_snapshot(x64_path, os.path.join(dst, 'gen_snapshot_x64'))
|
||||
|
||||
if arm64_out_dir:
|
||||
_generate_gen_snapshot(
|
||||
os.path.join(arm64_out_dir, 'clang_x64'), os.path.join(dst, 'gen_snapshot_arm64')
|
||||
)
|
||||
arm64_path = os.path.join(arm64_out_dir, 'gen_snapshot_arm64')
|
||||
_generate_gen_snapshot(arm64_path, os.path.join(dst, 'gen_snapshot_arm64'))
|
||||
|
||||
|
||||
def _generate_gen_snapshot(directory, destination):
|
||||
gen_snapshot_dir = os.path.join(directory, 'gen_snapshot')
|
||||
if not os.path.isfile(gen_snapshot_dir):
|
||||
print('Cannot find gen_snapshot at %s' % gen_snapshot_dir)
|
||||
def _generate_gen_snapshot(gen_snapshot_path, destination):
|
||||
if not os.path.isfile(gen_snapshot_path):
|
||||
print('Cannot find gen_snapshot at %s' % gen_snapshot_path)
|
||||
sys.exit(1)
|
||||
|
||||
subprocess.check_call(['xcrun', 'bitcode_strip', '-r', gen_snapshot_dir, '-o', destination])
|
||||
subprocess.check_call(['xcrun', 'bitcode_strip', '-r', gen_snapshot_path, '-o', destination])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user