Basic structure for flutter_jit_runner far (flutter/engine#10073)

* Basic structure for flutter_jit_runner far

- Added a package_dir gni that copies the dir structure.
- Doesn't support a lot of the existing functionality.
- Added a script to copy paths.

* pick libdart based on flutter mode

* fix licenses
This commit is contained in:
Kaushik Iska 2019-07-23 16:51:50 -07:00 committed by GitHub
parent 78a026650c
commit 27f1cc9865
4 changed files with 262 additions and 33 deletions

View File

@ -8,7 +8,7 @@ if (using_fuchsia_sdk) {
group("fuchsia") {
deps = [
"dart",
"flutter",
"flutter:flutter_jit_runner",
]
}
}

View File

@ -5,10 +5,45 @@
assert(is_fuchsia)
import("//build/fuchsia/sdk.gni")
import("$flutter_root/shell/gpu/gpu.gni")
import("$flutter_root/tools/fuchsia/package_dir.gni")
if (using_fuchsia_sdk) {
executable("flutter") {
output_name = "flutter_runner"
shell_gpu_configuration("fuchsia_gpu_configuration") {
enable_software = false
enable_gl = false
enable_vulkan = true
enable_metal = false
}
# Builds a flutter_runner
#
# Parameters:
#
# output_name (required):
# The name of the resulting binary.
#
# extra_deps (required):
# Any additional dependencies.
# extra_defines (optional):
# Any additional preprocessor defines.
template("flutter_runner") {
assert(defined(invoker.output_name), "flutter_runner must define output_name")
assert(defined(invoker.extra_deps), "flutter_runner must define extra_deps")
invoker_output_name = invoker.output_name
extra_deps = invoker.extra_deps
extra_defines = []
if (defined(invoker.extra_defines)) {
extra_defines += invoker.extra_defines
}
executable(target_name) {
output_name = invoker_output_name
defines = extra_defines
libs = []
sources = [
"component.cc",
@ -57,35 +92,109 @@ if (using_fuchsia_sdk) {
]
deps = [
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/fml",
"$flutter_root/lib/ui",
"$flutter_root/runtime",
"$flutter_root/runtime:libdart",
"$flutter_root/shell/common",
"$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia",
"$flutter_root/shell/platform/fuchsia/dart-pkg/zircon",
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils",
"$flutter_root/vulkan",
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
"$fuchsia_sdk_root/fidl:fuchsia.images",
"$fuchsia_sdk_root/fidl:fuchsia.io",
"$fuchsia_sdk_root/fidl:fuchsia.modular",
"$fuchsia_sdk_root/fidl:fuchsia.sys",
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
"$fuchsia_sdk_root/pkg:async-cpp",
"$fuchsia_sdk_root/pkg:async-loop",
"$fuchsia_sdk_root/pkg:async-loop-cpp",
"$fuchsia_sdk_root/pkg:fdio",
"$fuchsia_sdk_root/pkg:fidl_cpp",
"$fuchsia_sdk_root/pkg:scenic_cpp",
"$fuchsia_sdk_root/pkg:syslog",
"$fuchsia_sdk_root/pkg:zx",
"$fuchsia_sdk_root/pkg/lib/sys/cpp",
"$fuchsia_sdk_root/pkg/lib/vfs/cpp",
"//third_party/tonic",
":fuchsia_gpu_configuration",
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/fml",
"$flutter_root/lib/ui",
"$flutter_root/runtime",
"$flutter_root/runtime:libdart",
"$flutter_root/shell/common",
"$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia",
"$flutter_root/shell/platform/fuchsia/dart-pkg/zircon",
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils",
"$flutter_root/vulkan",
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
"$fuchsia_sdk_root/fidl:fuchsia.images",
"$fuchsia_sdk_root/fidl:fuchsia.io",
"$fuchsia_sdk_root/fidl:fuchsia.modular",
"$fuchsia_sdk_root/fidl:fuchsia.sys",
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
"$fuchsia_sdk_root/pkg:async-cpp",
"$fuchsia_sdk_root/pkg:async-loop",
"$fuchsia_sdk_root/pkg:async-loop-cpp",
"$fuchsia_sdk_root/pkg:fdio",
"$fuchsia_sdk_root/pkg:fidl_cpp",
"$fuchsia_sdk_root/pkg:scenic_cpp",
"$fuchsia_sdk_root/pkg:syslog",
"$fuchsia_sdk_root/pkg:zx",
"$fuchsia_sdk_root/pkg/lib/sys/cpp",
"$fuchsia_sdk_root/pkg/lib/vfs/cpp",
"//third_party/tonic",
] + extra_deps
# The flags below are needed so that Dart's CPU profiler can walk the
# C++ stack.
cflags = [ "-fno-omit-frame-pointer" ]
}
}
# Things that explicitly being excluded:
# 1. flutter_profile flag.
# 2. Injecting flutter tool specific stuff.
# 3. Product mode is going to be false for now.
# 4. Kernel snapshot: framework and product.
# 5. Observatoory stuff.
# 6. Profiler symbols.
# 7. framework and product!! (_framework snapshots and dilp files.)
# 8. CMX files are also ignored.
flutter_runner("jit") {
output_name = "flutter_jit_runner"
extra_deps = [ "$flutter_root/runtime:libdart" ]
}
template("jit_runner") {
product_suffix = ""
if (defined(invoker.product) && invoker.product) {
product_suffix = "product"
}
package_dir(target_name) {
snapshot_gen_dir = "$root_build_dir/gen/flutter/lib/snapshot"
deps = [
":jit${product_suffix}",
"$flutter_root/lib/snapshot:generate_snapshot_bin",
]
binary = "flutter_jit${product_suffix}_runner"
resources = [
{
path = rebase_path(
"$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}.bin")
dest = "vm_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}.bin")
dest = "vm_snapshot_instructions.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot${product_suffix}.bin")
dest = "isolate_core_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}.bin")
dest = "isolate_core_snapshot_instructions.bin"
},
]
meta = [
{
path = rebase_path("meta/flutter_jit${product_suffix}_runner.cmx")
dest = "flutter_jit${product_suffix}_runner.cmx"
},
]
}
}
jit_runner("flutter_jit_runner") {
product = false
}

View File

@ -0,0 +1,68 @@
#!/usr/bin/env python
#
# 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.
""" Gather all the fuchsia artifacts to a destination directory.
"""
import argparse
import errno
import json
import os
import platform
import shutil
import subprocess
import sys
def EnsureParentExists(path):
dir_name, _ = os.path.split(path)
if not os.path.exists(dir_name):
os.makedirs(dir_name)
def SameStat(s1, s2):
return s1.st_ino == s2.st_ino and s1.st_dev == s2.st_dev
def SameFile(f1, f2):
if not os.path.exists(f2):
return False
s1 = os.stat(f1)
s2 = os.stat(f2)
return SameStat(s1, s2)
def CopyPath(src, dst):
try:
EnsureParentExists(dst)
shutil.copytree(src, dst)
except OSError as exc:
if exc.errno == errno.ENOTDIR:
if not SameFile(src, dst):
shutil.copy(src, dst)
else:
raise
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--file-list', dest='file_list', action='store', required=True)
args = parser.parse_args()
files = open(args.file_list, 'r')
files_to_copy = files.read().split()
num_files = len(files_to_copy) / 2
for i in range(num_files):
CopyPath(files_to_copy[i], files_to_copy[num_files + i])
return 0
if __name__ == '__main__':
sys.exit(main())

View File

@ -0,0 +1,52 @@
# 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.
# Creates a package dir that we will them use pm to package.
#
# This currently ignores the CMX files and does minimal validation.
template("package_dir") {
assert(defined(invoker.binary), "package must define binary")
pkg_target_name = target_name
pkg = {
package_version = "0" # placeholder
forward_variables_from(invoker,
[
"binary",
"deps",
"meta",
"resources",
])
if (!defined(package_name)) {
package_name = pkg_target_name
}
if (!defined(meta)) {
meta = []
}
if (!defined(deps)) {
deps = []
}
if (!defined(resources)) {
resources = []
}
}
far_base_dir = "$root_out_dir/${pkg_target_name}_far"
copy_sources = [ "$root_out_dir/${invoker.binary}" ]
copy_outputs = [ "$far_base_dir/app/bin" ]
foreach(res, pkg.resources) {
copy_sources += [ res.path ]
copy_outputs += [ "$far_base_dir/data/${res.dest}" ]
}
action(target_name) {
script = "$flutter_root/tools/fuchsia/copy_path.py"
response_file_contents = rebase_path(copy_sources + copy_outputs)
deps = pkg.deps
args = [ "--file-list={{response_file_name}}" ]
outputs = copy_outputs
}
}