-
Notifications
You must be signed in to change notification settings - Fork 6k
/
web_sdk.gni
85 lines (71 loc) · 2.5 KB
/
web_sdk.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
# Copyright 2019 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.
import("//flutter/common/config.gni")
import("//third_party/dart/build/dart/dart_action.gni")
dart_sdk_package_config = "//third_party/dart/.dart_tool/package_config.json"
template("sdk_rewriter") {
ui = defined(invoker.ui) && invoker.ui
if (!ui) {
assert(defined(invoker.library_name), "Must pass 'library_name'")
assert(defined(invoker.api_file), "Must pass 'api_file'")
}
assert(defined(invoker.input_dir), "Must pass 'input_dir'")
assert(defined(invoker.output_dir), "Must pass 'output_dir'")
source_dart_files = exec_script("//third_party/dart/tools/list_dart_files.py",
[
"absolute",
rebase_path(invoker.input_dir),
],
"list lines")
if (defined(invoker.exclude_patterns)) {
filtered_files = filter_exclude(source_dart_files, invoker.exclude_patterns)
source_dart_files = []
source_dart_files = filtered_files
}
prebuilt_dart_action(target_name) {
packages = dart_sdk_package_config
pool = "//flutter/build/dart:dart_pool"
script = "//flutter/web_sdk/sdk_rewriter.dart"
inputs = source_dart_files + [ script ]
stamp_location = "$target_gen_dir/$target_name.stamp"
outputs = [
stamp_location,
invoker.output_dir,
]
input_dir = rebase_path(invoker.input_dir)
output_dir = rebase_path(invoker.output_dir)
args = [
"--output-dir=$output_dir",
"--input-dir=$input_dir",
"--stamp",
rebase_path(stamp_location, root_build_dir),
]
if (defined(invoker.is_public) && invoker.is_public) {
args += [ "--public" ]
}
if (ui) {
args += [ "--ui" ]
} else {
library_name = invoker.library_name
api_file = rebase_path(invoker.api_file)
args += [
"--library-name=$library_name",
"--api-file=$api_file",
]
}
foreach(source_file, source_dart_files) {
path = rebase_path(source_file)
args += [ "--source-file=$path" ]
}
}
}
template("web_ui_ui_web_with_output") {
sdk_rewriter(target_name) {
library_name = "ui_web"
is_public = true
api_file = "//flutter/lib/web_ui/lib/ui_web/src/ui_web.dart"
input_dir = "//flutter/lib/web_ui/lib/ui_web/src/ui_web/"
output_dir = invoker.output_dir
}
}