Build macOS engine as an xcframework (flutter/engine#50300)
Creates and adds FlutterMacOS.xcframework to out/mac or out/host. Creates and archives FlutterMacOS.xcframework when building mac_host_engine. Archives the xcframework in a new zipped folder at `darwin-x64/framework.zip`, `darwin-x64-profile/framework.zip`, `darwin-x64-release/framework.zip`. The FlutterMacOS.framework is also still archived currently - I thought it'd be better to keep it archived so we don't have to worry about the tool breaking until we're ready to remove it. Part of https://github.com/flutter/flutter/issues/126016. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
committed by
GitHub
parent
2e41a9065a
commit
eaa52fc3e0
@@ -476,6 +476,21 @@
|
||||
"source": "out/release/snapshot/gen_snapshot.zip",
|
||||
"destination": "darwin-x64-release/gen_snapshot.zip",
|
||||
"realm": "production"
|
||||
},
|
||||
{
|
||||
"source": "out/debug/framework/framework.zip",
|
||||
"destination": "darwin-x64/framework.zip",
|
||||
"realm": "production"
|
||||
},
|
||||
{
|
||||
"source": "out/profile/framework/framework.zip",
|
||||
"destination": "darwin-x64-profile/framework.zip",
|
||||
"realm": "production"
|
||||
},
|
||||
{
|
||||
"source": "out/release/framework/framework.zip",
|
||||
"destination": "darwin-x64-release/framework.zip",
|
||||
"realm": "production"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -304,7 +304,17 @@ action("_generate_symlinks") {
|
||||
}
|
||||
}
|
||||
|
||||
group("flutter_framework") {
|
||||
action("flutter_framework") {
|
||||
script = "//flutter/sky/tools/create_xcframework.py"
|
||||
outputs = [ "$root_out_dir/FlutterMacOS.xcframework" ]
|
||||
args = [
|
||||
"--frameworks",
|
||||
rebase_path(_flutter_framework_dir),
|
||||
"--name",
|
||||
"FlutterMacOS",
|
||||
"--location",
|
||||
rebase_path(root_out_dir),
|
||||
]
|
||||
deps = [ ":_generate_symlinks_and_verify_framework_module" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import shutil
|
||||
import sys
|
||||
import os
|
||||
|
||||
from create_xcframework import create_xcframework # pylint: disable=import-error
|
||||
|
||||
buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..', '..'))
|
||||
|
||||
ARCH_SUBPATH = 'mac-arm64' if platform.processor() == 'arm' else 'mac-x64'
|
||||
@@ -23,7 +25,9 @@ out_dir = os.path.join(buildroot_dir, 'out')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Creates FlutterMacOS.framework for macOS')
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Creates FlutterMacOS.framework and FlutterMacOS.xcframework for macOS'
|
||||
)
|
||||
|
||||
parser.add_argument('--dst', type=str, required=True)
|
||||
parser.add_argument('--arm64-out-dir', type=str, required=True)
|
||||
@@ -96,6 +100,10 @@ def main():
|
||||
find_subprocess.wait()
|
||||
xargs_subprocess.wait()
|
||||
|
||||
# Create XCFramework from the arm64 and x64 fat framework.
|
||||
xcframeworks = [fat_framework]
|
||||
create_xcframework(location=dst, name='FlutterMacOS', frameworks=xcframeworks)
|
||||
|
||||
process_framework(dst, args, fat_framework, fat_framework_binary)
|
||||
|
||||
return 0
|
||||
@@ -202,6 +210,32 @@ def process_framework(dst, args, fat_framework, fat_framework_binary):
|
||||
final_dst_path = os.path.join(dst, 'FlutterMacOS.framework.zip')
|
||||
shutil.move(final_src_path, final_dst_path)
|
||||
|
||||
zip_xcframework_archive(dst)
|
||||
|
||||
|
||||
def zip_xcframework_archive(dst):
|
||||
filepath_with_entitlements = ''
|
||||
filepath_without_entitlements = (
|
||||
'FlutterMacOS.xcframework/macos-arm64_x84_64/'
|
||||
'FlutterMacOS.framework/Versions/A/FlutterMacOS'
|
||||
)
|
||||
embed_codesign_configuration(os.path.join(dst, 'entitlements.txt'), filepath_with_entitlements)
|
||||
|
||||
embed_codesign_configuration(
|
||||
os.path.join(dst, 'without_entitlements.txt'), filepath_without_entitlements
|
||||
)
|
||||
|
||||
subprocess.check_call([
|
||||
'zip',
|
||||
'-r',
|
||||
'-y',
|
||||
'framework.zip',
|
||||
'FlutterMacOS.xcframework',
|
||||
'entitlements.txt',
|
||||
'without_entitlements.txt',
|
||||
],
|
||||
cwd=dst)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user