From 1e98421ca1de2b1875a2d3f05181cb5d74e31a71 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Thu, 5 Nov 2015 12:57:36 -0800 Subject: [PATCH] GN rules for the precompilation SDK --- sky/build/sky_precompilation_sdk.gni | 86 ++++++++++++++++++++++++++++ sky/engine/bindings/bindings.gni | 28 ++++----- sky/shell/BUILD.gn | 9 +-- 3 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 sky/build/sky_precompilation_sdk.gni diff --git a/sky/build/sky_precompilation_sdk.gni b/sky/build/sky_precompilation_sdk.gni new file mode 100644 index 00000000000..806ae3b7656 --- /dev/null +++ b/sky/build/sky_precompilation_sdk.gni @@ -0,0 +1,86 @@ +# 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("//sky/engine/bindings/bindings.gni") + +template("sky_precompilation_sdk") { + assert(is_ios, "The precompilation SDK is only supported for iOS targets") + + assert(defined(invoker.sdk_name), "The SDK name must be defined") + + sdk_name = invoker.sdk_name + sdk_dir = "$root_out_dir/$sdk_name" + + snapshotter_copy_gen_target_name = target_name + "_copy_snapshotter" + copy(snapshotter_copy_gen_target_name) { + snapshotter_target = "//dart/runtime/bin:gen_snapshot($dart_host_toolchain)" + snapshotter_directory = get_label_info(snapshotter_target, "root_out_dir") + snapshotter_name = get_label_info(snapshotter_target, "name") + + sources = [ "$snapshotter_directory/$snapshotter_name" ] + outputs = [ "$sdk_dir/Tools/Snapshotter" ] + + deps = [ snapshotter_target ] + } + + copy("embedder_entry_points") { + sources = [ "//sky/engine/bindings/dart_vm_entry_points.txt" ] + outputs = [ "$sdk_dir/Tools/EmbedderEntryPoints" ] + } + + copy("precompilation_xcode_scripts") { + sources = [ + "//sky/build/SnapshotterInvoke", + "//sky/build/PackagerInvoke", + ] + outputs = [ "$sdk_dir/Tools/{{source_file_part}}" ] + } + + copy("copy_sdk_xcode_harness") { + sources = [ + "//sky/build/sdk_xcode_harness/FlutterApplication", + "//sky/build/sdk_xcode_harness/FlutterApplication.xcodeproj", + "//sky/build/sdk_xcode_harness/Runner", + ] + outputs = [ "$sdk_dir/{{source_file_part}}" ] + } + + executable_gen_target_name = target_name + "_runner" + executable(executable_gen_target_name) { + libs = [ + "UIKit.framework", + "AVFoundation.framework", + "QuartzCore.framework", + "OpenGLES.framework", + ] + deps = [ "//sky/shell:ios_scaffolding" ] + } + + copy_runner_gen_target_name = target_name + "_copy_runner" + copy(copy_runner_gen_target_name) { + sources = [ "$root_out_dir/$executable_gen_target_name" ] + outputs = [ "$sdk_dir/RunnerResources/FlutterRunner" ] + + deps = [ ":$executable_gen_target_name" ] + } + + copy_data_gen_target_name = target_name + "_copy_data" + copy(copy_data_gen_target_name) { + set_sources_assignment_filter([]) + sources = [ "//third_party/icu/android/icudtl.dat" ] + outputs = [ "$sdk_dir/RunnerResources/{{source_file_part}}" ] + set_sources_assignment_filter(sources_assignment_filter) + } + + group(target_name) { + deps = [ + ":$snapshotter_copy_gen_target_name", + ":embedder_entry_points", + ":$copy_runner_gen_target_name", + ":$copy_data_gen_target_name", + ":precompilation_xcode_scripts", + ":copy_sdk_xcode_harness", + ] + } +} diff --git a/sky/engine/bindings/bindings.gni b/sky/engine/bindings/bindings.gni index f6cd013d872..5aebe5797e8 100644 --- a/sky/engine/bindings/bindings.gni +++ b/sky/engine/bindings/bindings.gni @@ -49,26 +49,26 @@ idl_compiler_files = [ "scripts/v8_utilities.py", ] +dart_host_toolchain = host_toolchain +if (target_os == "ios" && !use_ios_simulator) { + # During precompilation, a 64 bit Dart VM cannot generate code for a 32 bit + # architecture (and vice-versa). The snapshotter that is running on the host + # needs to know about the target architecture and built accordingly. + if (target_cpu == "arm") { + dart_host_toolchain = "//build/toolchain/mac:clang_i386" + } else if (target_cpu == "arm64") { + dart_host_toolchain = "//build/toolchain/mac:clang_x64" + } else { + assert(false, "Unknown active architecture on iOS") + } +} + template("dart_precompile") { assert(defined(invoker.dart_package_root), "The dart package root must be defined") assert(defined(invoker.dart_script), "The dart script must be specified") - dart_host_toolchain = host_toolchain - if (target_os == "ios" && !use_ios_simulator) { - # During precompilation, a 64 bit Dart VM cannot generate code for a 32 bit - # architecture (and vice-versa). The snapshotter that is running on the host - # needs to know about the target architecture and built accordingly. - if (target_cpu == "arm") { - dart_host_toolchain = "//build/toolchain/mac:clang_i386" - } else if (target_cpu == "arm64") { - dart_host_toolchain = "//build/toolchain/mac:clang_x64" - } else { - assert(false, "Unknown active architecture on iOS") - } - } - vm_isolate_snapshot_name = target_name + "_vm_isolate.bin" vm_isolate_snapshot = "$target_gen_dir/$vm_isolate_snapshot_name" isolate_snapshot_name = target_name + "_isolate.bin" diff --git a/sky/shell/BUILD.gn b/sky/shell/BUILD.gn index 6c316431a47..34bbaf88fee 100644 --- a/sky/shell/BUILD.gn +++ b/sky/shell/BUILD.gn @@ -189,6 +189,7 @@ if (is_android) { } else if (is_ios) { import("//build/config/ios/rules.gni") import("//build/config/ios/ios_sdk.gni") + import("//sky/build/sky_precompilation_sdk.gni") source_set("ios_scaffolding") { sources = [ @@ -220,9 +221,8 @@ if (is_android) { ] } - group("shell") { - # iOS only supports application bundles with a precompiled instruction - # buffer. There is not Shell target for the same. + sky_precompilation_sdk("shell") { + sdk_name = "SkySDK" } } else if (is_linux) { executable("shell") { @@ -269,9 +269,6 @@ if (is_android) { app_name = "SkyShell" info_plist = "mac/Info.plist" - # entitlements_path = "" - # code_signing_identity = "" - xibs = [ "mac/sky_mac.xib" ] resource_copy_mac("sky_resources") {