Merge pull request #2538 from chinmaygarde/master

The dynamic services SDK produces a fat Mach binary of x64 and arm64 variants.
This commit is contained in:
Chinmay Garde 2016-03-22 12:11:29 -07:00
commit 030acb9114
2 changed files with 102 additions and 1 deletions

View File

@ -29,7 +29,7 @@ source_set("embedder") {
]
}
static_library("sdk_lib") {
static_library("sdk_lib_single_arch") {
output_name = "FlutterServices"
complete_static_lib = true
@ -48,3 +48,52 @@ static_library("sdk_lib") {
"//mojo/public/platform/native:system",
]
}
group("sdk_lib") {
action("generate_fat_binary") {
stamp_file = "$root_out_dir/dynamic_service_dylib_lipo"
script = "//sky/tools/lipo.py"
device_target = ":sdk_lib_single_arch(//build/toolchain/mac:ios_clang_arm)"
sim_target = ":sdk_lib_single_arch(//build/toolchain/mac:clang_x64)"
device_binary = "$root_build_dir/obj/sky/services/dynamic/libFlutterServices.a"
sim_binary = "$root_build_dir/clang_x64/obj/sky/services/dynamic/libFlutterServices.a"
fat_binary = "$root_out_dir/FlutterServicesIOS.a"
inputs = [
device_binary,
sim_binary,
]
outputs = [
stamp_file,
fat_binary,
]
args = [
"--stamp",
rebase_path(stamp_file),
"--path",
rebase_path(device_binary),
"--path",
rebase_path(sim_binary),
"--output",
rebase_path(fat_binary),
]
deps = [
"$device_target",
"$sim_target",
]
}
deps = []
if (is_ios) {
deps += [
":generate_fat_binary",
]
}
}

52
sky/tools/lipo.py Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env python
# Copyright 2015 The Chromium 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 subprocess
import sys
import os
def MakeStamp(stamp_path):
dir_name = os.path.dirname(stamp_path)
if not os.path.isdir(dir_name):
os.makedirs()
with open(stamp_path, 'a'):
os.utime(stamp_path, None)
def main():
parser = argparse.ArgumentParser(
description='Creates a FAT Mach binary')
parser.add_argument('--path', action='append', dest='paths',
default=[], help='The path to a Mach binary')
parser.add_argument('--output', type=str)
parser.add_argument('--stamp', type=str)
args = parser.parse_args()
cmd = [
'/usr/bin/env',
'xcrun',
'lipo',
]
cmd.extend(args.paths)
cmd.extend([
'-create',
'-output',
args.output,
])
subprocess.check_call(cmd)
MakeStamp(args.stamp)
if __name__ == '__main__':
sys.exit(main())