forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flutter_app.gni
124 lines (105 loc) · 3.31 KB
/
flutter_app.gni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Copyright 2016 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.
assert(is_fuchsia)
import("//build/dart/dart_package.gni")
# Defines a Flutter application
#
# Parameters
#
# main_dart (required)
# Name of the Dart file containing the main function.
#
# package_name (optional)
# Name of the Dart package.
#
# output_name (optional)
# Name of output to generate. Defaults to $target_name.flx.
#
# deps (optional)
# List of Dart packages the application depends on.
template("flutter_app") {
assert(defined(invoker.main_dart), "Must define main_dart")
dart_package_name = target_name + "_dart_package"
dart_package(dart_package_name) {
forward_variables_from(invoker, [ "deps", "source_dir" ])
if (defined(invoker.package_name)) {
package_name = invoker.package_name
} else {
infer_package_name = true
}
}
if (defined(invoker.output_name)) {
bundle_name = invoker.output_name
} else {
bundle_name = "${target_name}.flx"
}
flutter_snapshot_label = "//flutter/snapshotter($host_toolchain)"
flutter_snapshot_dir = get_label_info(flutter_snapshot_label, "root_out_dir")
flutter_snapshot = "$flutter_snapshot_dir/sky_snapshot"
dart_binary_label = "//dart/runtime/bin:dart_no_observatory($host_toolchain)"
dart_binary_dir = get_label_info(dart_binary_label, "root_out_dir")
dart_binary = "$dart_binary_dir/dart_no_observatory"
flutter_root = "//lib/flutter"
flutter_tools_label = "$flutter_root/packages/flutter_tools"
flutter_tools_gen_dir = get_label_info(flutter_tools_label, "target_gen_dir")
flutter_tools_name = get_label_info(flutter_tools_label, "name")
flutter_tools_packages = "$flutter_tools_gen_dir/$flutter_tools_name.packages"
flutter_tools_main = "$flutter_tools_label/bin/fuchsia_builder.dart"
dot_packages = "$target_gen_dir/$dart_package_name.packages"
bundle_path = "$root_out_dir/$bundle_name"
snapshot_path = "$target_gen_dir/${target_name}_snapshot.bin"
depfile_path = "${snapshot_path}.d"
main_dart = invoker.main_dart
action(target_name) {
depfile = depfile_path
inputs = [
main_dart,
]
outputs = [
bundle_path,
snapshot_path,
]
if (defined(invoker.sources)) {
sources = invoker.sources
}
script = "//flutter/build/package.py"
args = [
"--root",
rebase_path(dart_binary_dir),
"--flutter-root",
rebase_path(flutter_root),
"--dart",
rebase_path(dart_binary),
"--flutter-tools-packages",
rebase_path(flutter_tools_packages),
"--flutter-tools-main",
rebase_path(flutter_tools_main),
"--snapshotter-path",
rebase_path(flutter_snapshot),
"--working-dir",
rebase_path("$target_gen_dir/build"),
"--app-dir",
rebase_path("."),
"--main-dart",
rebase_path(main_dart),
"--packages",
rebase_path(dot_packages),
"--output-file",
rebase_path(bundle_path),
"--snapshot",
rebase_path(snapshot_path),
"--depfile",
rebase_path(depfile_path),
]
deps = [
":$dart_package_name",
dart_binary_label,
flutter_snapshot_label,
flutter_tools_label,
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
}