This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[macOS] Generate universal gen_snapshots #52885
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python3 | ||
cbracken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# Copyright 2013 The Flutter Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import argparse | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
|
||
def canonical_path(path): | ||
"""Returns the canonical path for the input path. | ||
If the input path is not absolute, it is treated as relative to the engine | ||
source tree's buildroot directory.""" | ||
if os.path.isabs(path): | ||
return path | ||
buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..', '..')) | ||
return os.path.join(buildroot_dir, path) | ||
|
||
|
||
def assert_file_exists(binary_path, arch): | ||
if not os.path.isfile(binary_path): | ||
print('Cannot find macOS %s binary at %s' % (arch, binary_path)) | ||
sys.exit(1) | ||
|
||
|
||
def create_universal_binary(in_arm64, in_x64, out): | ||
subprocess.check_call(['lipo', in_arm64, in_x64, '-create', '-output', out]) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description='Creates a universal binary from input arm64, x64 binaries' | ||
) | ||
parser.add_argument('--in-arm64', type=str, required=True) | ||
parser.add_argument('--in-x64', type=str, required=True) | ||
parser.add_argument('--out', type=str, required=True) | ||
args = parser.parse_args() | ||
|
||
in_arm64 = canonical_path(args.in_arm64) | ||
in_x64 = canonical_path(args.in_x64) | ||
out = canonical_path(args.out) | ||
|
||
assert_file_exists(in_arm64, 'arm64') | ||
assert_file_exists(in_x64, 'x64') | ||
create_universal_binary(in_arm64, in_x64, out) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DBC
What's the difference between
create_macos_binary.py
andcreate_macos_gen_snapshots.py
? Do we need both of them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting -- create_macos_gen_snapshots is old and was used for iOS (and is hardcoded full of armv7 stuff); I guess we never cleaned it up?
I'll send out a patch to kill it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_macos_gen_snapshots
is used in the generator which processes the output of the buildsengine/ci/builders/mac_host_engine.json
Line 560 in 7a309e5
To avoid the timeout and because an hour is really quite long to wait for the builds to clear, maybe the snapshots should be created in different builds, and then processed with the generator at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there should be examples of using global generators already in the ios/macos build json files, and I think that can work here if we know how to split the different targets across different builders.