Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit abf9369

Browse files
authored
Basic structure for flutter_jit_runner far (#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
1 parent 3c76b90 commit abf9369

File tree

4 files changed

+262
-33
lines changed

4 files changed

+262
-33
lines changed

shell/platform/fuchsia/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (using_fuchsia_sdk) {
88
group("fuchsia") {
99
deps = [
1010
"dart",
11-
"flutter",
11+
"flutter:flutter_jit_runner",
1212
]
1313
}
1414
}

shell/platform/fuchsia/flutter/BUILD.gn

Lines changed: 141 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,45 @@
55
assert(is_fuchsia)
66

77
import("//build/fuchsia/sdk.gni")
8+
import("$flutter_root/shell/gpu/gpu.gni")
9+
import("$flutter_root/tools/fuchsia/package_dir.gni")
810

9-
if (using_fuchsia_sdk) {
10-
executable("flutter") {
11-
output_name = "flutter_runner"
11+
shell_gpu_configuration("fuchsia_gpu_configuration") {
12+
enable_software = false
13+
enable_gl = false
14+
enable_vulkan = true
15+
enable_metal = false
16+
}
17+
18+
# Builds a flutter_runner
19+
#
20+
# Parameters:
21+
#
22+
# output_name (required):
23+
# The name of the resulting binary.
24+
#
25+
# extra_deps (required):
26+
# Any additional dependencies.
27+
# extra_defines (optional):
28+
# Any additional preprocessor defines.
29+
template("flutter_runner") {
30+
assert(defined(invoker.output_name), "flutter_runner must define output_name")
31+
assert(defined(invoker.extra_deps), "flutter_runner must define extra_deps")
32+
33+
invoker_output_name = invoker.output_name
34+
extra_deps = invoker.extra_deps
35+
36+
extra_defines = []
37+
if (defined(invoker.extra_defines)) {
38+
extra_defines += invoker.extra_defines
39+
}
40+
41+
executable(target_name) {
42+
output_name = invoker_output_name
43+
44+
defines = extra_defines
45+
46+
libs = []
1247

1348
sources = [
1449
"component.cc",
@@ -57,35 +92,109 @@ if (using_fuchsia_sdk) {
5792
]
5893

5994
deps = [
60-
"$flutter_root/common",
61-
"$flutter_root/flow",
62-
"$flutter_root/fml",
63-
"$flutter_root/lib/ui",
64-
"$flutter_root/runtime",
65-
"$flutter_root/runtime:libdart",
66-
"$flutter_root/shell/common",
67-
"$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia",
68-
"$flutter_root/shell/platform/fuchsia/dart-pkg/zircon",
69-
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils",
70-
"$flutter_root/vulkan",
71-
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
72-
"$fuchsia_sdk_root/fidl:fuchsia.images",
73-
"$fuchsia_sdk_root/fidl:fuchsia.io",
74-
"$fuchsia_sdk_root/fidl:fuchsia.modular",
75-
"$fuchsia_sdk_root/fidl:fuchsia.sys",
76-
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
77-
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
78-
"$fuchsia_sdk_root/pkg:async-cpp",
79-
"$fuchsia_sdk_root/pkg:async-loop",
80-
"$fuchsia_sdk_root/pkg:async-loop-cpp",
81-
"$fuchsia_sdk_root/pkg:fdio",
82-
"$fuchsia_sdk_root/pkg:fidl_cpp",
83-
"$fuchsia_sdk_root/pkg:scenic_cpp",
84-
"$fuchsia_sdk_root/pkg:syslog",
85-
"$fuchsia_sdk_root/pkg:zx",
86-
"$fuchsia_sdk_root/pkg/lib/sys/cpp",
87-
"$fuchsia_sdk_root/pkg/lib/vfs/cpp",
88-
"//third_party/tonic",
95+
":fuchsia_gpu_configuration",
96+
"$flutter_root/common",
97+
"$flutter_root/flow",
98+
"$flutter_root/fml",
99+
"$flutter_root/lib/ui",
100+
"$flutter_root/runtime",
101+
"$flutter_root/runtime:libdart",
102+
"$flutter_root/shell/common",
103+
"$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia",
104+
"$flutter_root/shell/platform/fuchsia/dart-pkg/zircon",
105+
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils",
106+
"$flutter_root/vulkan",
107+
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
108+
"$fuchsia_sdk_root/fidl:fuchsia.images",
109+
"$fuchsia_sdk_root/fidl:fuchsia.io",
110+
"$fuchsia_sdk_root/fidl:fuchsia.modular",
111+
"$fuchsia_sdk_root/fidl:fuchsia.sys",
112+
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
113+
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
114+
"$fuchsia_sdk_root/pkg:async-cpp",
115+
"$fuchsia_sdk_root/pkg:async-loop",
116+
"$fuchsia_sdk_root/pkg:async-loop-cpp",
117+
"$fuchsia_sdk_root/pkg:fdio",
118+
"$fuchsia_sdk_root/pkg:fidl_cpp",
119+
"$fuchsia_sdk_root/pkg:scenic_cpp",
120+
"$fuchsia_sdk_root/pkg:syslog",
121+
"$fuchsia_sdk_root/pkg:zx",
122+
"$fuchsia_sdk_root/pkg/lib/sys/cpp",
123+
"$fuchsia_sdk_root/pkg/lib/vfs/cpp",
124+
"//third_party/tonic",
125+
] + extra_deps
126+
127+
# The flags below are needed so that Dart's CPU profiler can walk the
128+
# C++ stack.
129+
cflags = [ "-fno-omit-frame-pointer" ]
130+
}
131+
}
132+
133+
# Things that explicitly being excluded:
134+
# 1. flutter_profile flag.
135+
# 2. Injecting flutter tool specific stuff.
136+
# 3. Product mode is going to be false for now.
137+
# 4. Kernel snapshot: framework and product.
138+
# 5. Observatoory stuff.
139+
# 6. Profiler symbols.
140+
# 7. framework and product!! (_framework snapshots and dilp files.)
141+
# 8. CMX files are also ignored.
142+
143+
flutter_runner("jit") {
144+
output_name = "flutter_jit_runner"
145+
146+
extra_deps = [ "$flutter_root/runtime:libdart" ]
147+
}
148+
149+
template("jit_runner") {
150+
product_suffix = ""
151+
152+
if (defined(invoker.product) && invoker.product) {
153+
product_suffix = "product"
154+
}
155+
156+
package_dir(target_name) {
157+
snapshot_gen_dir = "$root_build_dir/gen/flutter/lib/snapshot"
158+
159+
deps = [
160+
":jit${product_suffix}",
161+
"$flutter_root/lib/snapshot:generate_snapshot_bin",
162+
]
163+
164+
binary = "flutter_jit${product_suffix}_runner"
165+
166+
resources = [
167+
{
168+
path = rebase_path(
169+
"$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}.bin")
170+
dest = "vm_snapshot_data.bin"
171+
},
172+
{
173+
path = rebase_path(
174+
"$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}.bin")
175+
dest = "vm_snapshot_instructions.bin"
176+
},
177+
{
178+
path = rebase_path(
179+
"$snapshot_gen_dir/isolate_snapshot${product_suffix}.bin")
180+
dest = "isolate_core_snapshot_data.bin"
181+
},
182+
{
183+
path = rebase_path(
184+
"$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}.bin")
185+
dest = "isolate_core_snapshot_instructions.bin"
186+
},
187+
]
188+
189+
meta = [
190+
{
191+
path = rebase_path("meta/flutter_jit${product_suffix}_runner.cmx")
192+
dest = "flutter_jit${product_suffix}_runner.cmx"
193+
},
89194
]
90195
}
91196
}
197+
198+
jit_runner("flutter_jit_runner") {
199+
product = false
200+
}

tools/fuchsia/copy_path.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2013 The Flutter Authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
""" Gather all the fuchsia artifacts to a destination directory.
7+
"""
8+
9+
import argparse
10+
import errno
11+
import json
12+
import os
13+
import platform
14+
import shutil
15+
import subprocess
16+
import sys
17+
18+
19+
def EnsureParentExists(path):
20+
dir_name, _ = os.path.split(path)
21+
if not os.path.exists(dir_name):
22+
os.makedirs(dir_name)
23+
24+
25+
def SameStat(s1, s2):
26+
return s1.st_ino == s2.st_ino and s1.st_dev == s2.st_dev
27+
28+
29+
def SameFile(f1, f2):
30+
if not os.path.exists(f2):
31+
return False
32+
s1 = os.stat(f1)
33+
s2 = os.stat(f2)
34+
return SameStat(s1, s2)
35+
36+
37+
def CopyPath(src, dst):
38+
try:
39+
EnsureParentExists(dst)
40+
shutil.copytree(src, dst)
41+
except OSError as exc:
42+
if exc.errno == errno.ENOTDIR:
43+
if not SameFile(src, dst):
44+
shutil.copy(src, dst)
45+
else:
46+
raise
47+
48+
49+
def main():
50+
parser = argparse.ArgumentParser()
51+
52+
parser.add_argument(
53+
'--file-list', dest='file_list', action='store', required=True)
54+
55+
args = parser.parse_args()
56+
57+
files = open(args.file_list, 'r')
58+
files_to_copy = files.read().split()
59+
num_files = len(files_to_copy) / 2
60+
61+
for i in range(num_files):
62+
CopyPath(files_to_copy[i], files_to_copy[num_files + i])
63+
64+
return 0
65+
66+
67+
if __name__ == '__main__':
68+
sys.exit(main())

tools/fuchsia/package_dir.gni

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
# Creates a package dir that we will them use pm to package.
6+
#
7+
# This currently ignores the CMX files and does minimal validation.
8+
template("package_dir") {
9+
assert(defined(invoker.binary), "package must define binary")
10+
11+
pkg_target_name = target_name
12+
pkg = {
13+
package_version = "0" # placeholder
14+
forward_variables_from(invoker,
15+
[
16+
"binary",
17+
"deps",
18+
"meta",
19+
"resources",
20+
])
21+
if (!defined(package_name)) {
22+
package_name = pkg_target_name
23+
}
24+
if (!defined(meta)) {
25+
meta = []
26+
}
27+
if (!defined(deps)) {
28+
deps = []
29+
}
30+
if (!defined(resources)) {
31+
resources = []
32+
}
33+
}
34+
35+
far_base_dir = "$root_out_dir/${pkg_target_name}_far"
36+
37+
copy_sources = [ "$root_out_dir/${invoker.binary}" ]
38+
copy_outputs = [ "$far_base_dir/app/bin" ]
39+
40+
foreach(res, pkg.resources) {
41+
copy_sources += [ res.path ]
42+
copy_outputs += [ "$far_base_dir/data/${res.dest}" ]
43+
}
44+
45+
action(target_name) {
46+
script = "$flutter_root/tools/fuchsia/copy_path.py"
47+
response_file_contents = rebase_path(copy_sources + copy_outputs)
48+
deps = pkg.deps
49+
args = [ "--file-list={{response_file_name}}" ]
50+
outputs = copy_outputs
51+
}
52+
}

0 commit comments

Comments
 (0)