OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Rules to generate python packaged applications for Dart | 5 # Rules to generate zipped applications for Dart. |
| 6 # Rules to generate dart-pkg and dart-pkg/packages. |
6 | 7 |
7 import("//build/module_args/mojo.gni") | 8 import("//build/module_args/mojo.gni") |
8 | 9 |
9 template("dart_package") { | 10 template("dartzip_package") { |
10 package_target_name = "$target_name" | 11 package_target_name = "$target_name" |
11 package_output = "$target_out_dir/$target_name.dartzip" | 12 package_output = "$target_out_dir/$target_name.dartzip" |
12 | 13 |
13 if (defined(invoker.uses_pub) && invoker.uses_pub) { | 14 if (defined(invoker.uses_pub) && invoker.uses_pub) { |
14 # Repackage all dependencies pulled in via "pub get" in a dartzip file. | 15 # Repackage all dependencies pulled in via "pub get" in a dartzip file. |
15 action("${package_target_name}_repackage") { | 16 action("${package_target_name}_repackage") { |
16 target_dir = get_label_info(":$target_name", "dir") | 17 target_dir = get_label_info(":$target_name", "dir") |
17 script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_sdk_root) | 18 script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_sdk_root) |
18 | 19 |
| 20 package_name = "$package_target_name" |
| 21 if (defined(invoker.package_name_override)) { |
| 22 package_name = invoker.package_name_override |
| 23 } |
| 24 |
19 # Get a list of the files in packages/ as inputs. | 25 # Get a list of the files in packages/ as inputs. |
20 list_packages_contents_script = | 26 list_packages_contents_script = |
21 rebase_path("mojo/public/tools/dart_list_packages_contents.py", | 27 rebase_path("mojo/public/tools/dart_list_packages_contents.py", |
22 ".", | 28 ".", |
23 mojo_sdk_root) | 29 mojo_sdk_root) |
24 rebase_target_dir = rebase_path(target_dir, root_build_dir) | 30 rebase_target_dir = rebase_path(target_dir, root_build_dir) |
25 inputs = exec_script(list_packages_contents_script, | 31 inputs = exec_script(list_packages_contents_script, |
26 [ | 32 [ |
27 "--target-directory", | 33 "--target-directory", |
28 rebase_target_dir, | 34 rebase_target_dir, |
| 35 "--package-name", |
| 36 package_name, |
29 ], | 37 ], |
30 "list lines", | 38 "list lines", |
31 [ target_dir + "/pubspec.lock" ]) | 39 [ target_dir + "/pubspec.lock" ]) |
32 | 40 |
33 # Zip up all the pulled-in files relative to their location in the | 41 # Zip up all the pulled-in files relative to their location in the |
34 # packages dir. | 42 # packages dir. |
35 output = "$target_out_dir/$target_name.dartzip" | 43 output = "$target_out_dir/$target_name.dartzip" |
36 outputs = [ | 44 outputs = [ |
37 output, | 45 output, |
38 ] | 46 ] |
39 rebase_base_dir = rebase_target_dir + "/packages" | 47 rebase_base_dir = rebase_target_dir |
40 rebase_inputs = rebase_path(inputs, root_build_dir) | 48 rebase_inputs = rebase_path(inputs, root_build_dir) |
41 rebase_output = rebase_path(output, root_build_dir) | 49 rebase_output = rebase_path(output, root_build_dir) |
42 args = [ | 50 args = [ |
43 "--base-dir=$rebase_base_dir", | 51 "--base-dir=$rebase_base_dir", |
44 "--inputs=$rebase_inputs", | 52 "--inputs=$rebase_inputs", |
45 "--output=$rebase_output", | 53 "--output=$rebase_output", |
46 ] | 54 ] |
47 } | 55 } |
48 } | 56 } |
49 | 57 |
50 action("${package_target_name}_package") { | 58 action("${package_target_name}_package") { |
51 script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_sdk_root) | 59 script = |
| 60 rebase_path("mojo/public/tools/dart_package.py", ".", mojo_sdk_root) |
52 | 61 |
53 inputs = invoker.sources | 62 inputs = invoker.sources |
54 | 63 |
55 deps = [] | 64 deps = [] |
56 zip_inputs = [] | 65 zip_inputs = [] |
57 | 66 |
58 if (defined(invoker.uses_pub) && invoker.uses_pub) { | 67 if (defined(invoker.uses_pub) && invoker.uses_pub) { |
59 deps += [ ":${package_target_name}_repackage" ] | 68 deps += [ ":${package_target_name}_repackage" ] |
60 } | 69 } |
61 | 70 |
(...skipping 17 matching lines...) Expand all Loading... |
79 | 88 |
80 rebase_base_dir = | 89 rebase_base_dir = |
81 rebase_path(get_label_info(":$package_target_name", "dir"), | 90 rebase_path(get_label_info(":$package_target_name", "dir"), |
82 root_build_dir) | 91 root_build_dir) |
83 if (defined(invoker.base_dir)) { | 92 if (defined(invoker.base_dir)) { |
84 rebase_base_dir = invoker.base_dir | 93 rebase_base_dir = invoker.base_dir |
85 } | 94 } |
86 rebase_inputs = rebase_path(inputs, root_build_dir) | 95 rebase_inputs = rebase_path(inputs, root_build_dir) |
87 rebase_zip_inputs = rebase_path(zip_inputs, root_build_dir) | 96 rebase_zip_inputs = rebase_path(zip_inputs, root_build_dir) |
88 rebase_output = rebase_path(output, root_build_dir) | 97 rebase_output = rebase_path(output, root_build_dir) |
| 98 |
89 args = [ | 99 args = [ |
90 "--base-dir=$rebase_base_dir", | 100 "--base-dir=$rebase_base_dir", |
91 "--inputs=$rebase_inputs", | 101 "--inputs=$rebase_inputs", |
92 "--zip-inputs=$rebase_zip_inputs", | 102 "--zip-inputs=$rebase_zip_inputs", |
93 "--output=$rebase_output", | 103 "--output=$rebase_output", |
94 ] | 104 ] |
95 } | 105 } |
96 | 106 |
97 action(target_name) { | 107 action(target_name) { |
98 script = | 108 script = |
99 rebase_path("mojo/public/tools/dart_analyze.py", ".", mojo_sdk_root) | 109 rebase_path("mojo/public/tools/dart_analyze.py", ".", mojo_sdk_root) |
100 | 110 |
101 sources = [ | 111 sources = [ |
102 package_output, | 112 package_output, |
103 ] | 113 ] |
104 | 114 |
105 args = [ | 115 args = [ |
106 rebase_path(package_output), | 116 rebase_path(package_output), |
107 rebase_path("$target_gen_dir/${package_target_name}_analyze.stamp"), | 117 rebase_path("$target_gen_dir/${package_target_name}_analyze.stamp"), |
108 "--no-hints", | 118 "--no-hints", |
109 "--url-mapping=dart:mojo.io,/" + | 119 "--url-mapping=dart:mojo.io,/" + |
110 rebase_path("mojo/public/dart/io.dart", "/", mojo_sdk_root), | 120 rebase_path("mojo/public/dart/lib/io.dart", "/", mojo_sdk_root), |
111 ] | 121 ] |
112 | 122 |
113 deps = [ | 123 deps = [ |
114 ":${package_target_name}_package", | 124 ":${package_target_name}_package", |
115 ] | 125 ] |
116 if (defined(invoker.deps)) { | 126 if (defined(invoker.deps)) { |
117 deps += invoker.deps | 127 deps += invoker.deps |
118 } | 128 } |
119 | 129 |
120 if (defined(invoker.datadeps)) { | 130 if (defined(invoker.datadeps)) { |
121 datadeps = invoker.datadeps | 131 datadeps = invoker.datadeps |
122 } | 132 } |
123 | 133 |
124 outputs = [ | 134 outputs = [ |
125 "$target_gen_dir/${package_target_name}_analyze.stamp", | 135 "$target_gen_dir/${package_target_name}_analyze.stamp", |
126 ] | 136 ] |
127 } | 137 } |
128 } | 138 } |
129 | 139 |
130 # Use this template to generate a .mojo dart application. One of the source | 140 # Use this template to generate a .mojo dart application. One of the source |
131 # files should be named main.dart and contain a main function as the | 141 # files should be named main.dart and contain a main function as the |
132 # entry point. Dependencies of dart_packaged_application targets should be | 142 # entry point. Dependencies of dart_packaged_application targets should be |
133 # either mojom targets (and specified using the mojom_deps variable) or | 143 # either mojom targets (and specified using the mojom_deps variable) or |
134 # dart_package targets. | 144 # dartzip_package targets. |
135 template("dart_packaged_application") { | 145 template("dartzip_packaged_application") { |
136 package_name = "${target_name}_package" | 146 package_name = "${target_name}_package" |
137 package_output = "$target_out_dir/$package_name.dartzip" | 147 package_output = "$target_out_dir/$package_name.dartzip" |
138 | 148 |
139 if (defined(invoker.output_name)) { | 149 if (defined(invoker.output_name)) { |
140 mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo" | 150 mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo" |
141 } else { | 151 } else { |
142 mojo_output = "$root_out_dir/" + target_name + ".mojo" | 152 mojo_output = "$root_out_dir/" + target_name + ".mojo" |
143 } | 153 } |
144 | 154 |
145 dart_package(package_name) { | 155 dartzip_package(package_name) { |
146 sources = invoker.sources | 156 sources = invoker.sources |
147 if (defined(invoker.deps)) { | 157 if (defined(invoker.deps)) { |
148 deps = invoker.deps | 158 deps = invoker.deps |
149 } | 159 } |
150 if (defined(invoker.uses_pub)) { | 160 if (defined(invoker.uses_pub)) { |
151 uses_pub = invoker.uses_pub | 161 uses_pub = invoker.uses_pub |
152 } | 162 } |
153 if (defined(invoker.mojom_deps)) { | 163 if (defined(invoker.mojom_deps)) { |
154 mojom_deps = invoker.mojom_deps | 164 mojom_deps = invoker.mojom_deps |
155 } | 165 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 201 |
192 rebase_input = rebase_path(input, root_build_dir) | 202 rebase_input = rebase_path(input, root_build_dir) |
193 rebase_output = rebase_path(output, root_build_dir) | 203 rebase_output = rebase_path(output, root_build_dir) |
194 args = [ | 204 args = [ |
195 "--input=$rebase_input", | 205 "--input=$rebase_input", |
196 "--output=$rebase_output", | 206 "--output=$rebase_output", |
197 "--line=$line", | 207 "--line=$line", |
198 ] | 208 ] |
199 } | 209 } |
200 } | 210 } |
| 211 |
| 212 # Creates a gen/dart-pkg/package_name directory containing symlinks to package |
| 213 # sources. Also copies any mojom dependencies into lib/mojom. |
| 214 # |
| 215 # sources |
| 216 # List of sources to include in the package. |
| 217 # |
| 218 # deps (optional) |
| 219 # Note: this can contain only other mojom targets. |
| 220 # |
| 221 # datadeps (optional) |
| 222 # |
| 223 template("dart_pkg") { |
| 224 pubspec_yaml_path = rebase_path("pubspec.yaml") |
| 225 dart_package_name_script = |
| 226 rebase_path("mojo/public/tools/dart_package_name.py", ".", mojo_sdk_root) |
| 227 package_name = exec_script(dart_package_name_script, |
| 228 [ |
| 229 "--pubspec", |
| 230 pubspec_yaml_path, |
| 231 ], |
| 232 "trim string", |
| 233 [ pubspec_yaml_path ]) |
| 234 |
| 235 pkg_directory = rebase_path("$root_gen_dir/dart-pkg") |
| 236 package_root = rebase_path("$root_gen_dir/dart-pkg/packages") |
| 237 stamp_file = "$root_gen_dir/dart-pkg/${package_name}.stamp" |
| 238 |
| 239 assert(defined(invoker.sources)) |
| 240 |
| 241 action(target_name) { |
| 242 deps = [] |
| 243 if (defined(invoker.deps)) { |
| 244 deps += invoker.deps |
| 245 } |
| 246 |
| 247 datadeps = [] |
| 248 if (defined(invoker.datadeps)) { |
| 249 datadeps += invoker.datadeps |
| 250 } |
| 251 |
| 252 list_mojoms_script = rebase_path("mojo/public/tools/dart_list_mojoms.py", |
| 253 ".", |
| 254 mojo_sdk_root) |
| 255 mojom_sources = [] |
| 256 foreach(d, deps) { |
| 257 root_prefix = rebase_path(".", "", mojo_sdk_root) |
| 258 source_directory = rebase_path(get_label_info(d, "dir")) |
| 259 mojom_sources += exec_script(list_mojoms_script, |
| 260 [ |
| 261 source_directory, |
| 262 root_prefix, |
| 263 ], |
| 264 "list lines") |
| 265 } |
| 266 |
| 267 script = rebase_path("mojo/public/tools/dart_pkg.py", ".", mojo_sdk_root) |
| 268 outputs = [ |
| 269 stamp_file, |
| 270 ] |
| 271 |
| 272 inputs = [ |
| 273 list_mojoms_script, |
| 274 script |
| 275 ] + rebase_path(invoker.sources) |
| 276 |
| 277 args = [ |
| 278 "--package-name", |
| 279 package_name, |
| 280 "--gen-directory", |
| 281 rebase_path("$root_gen_dir/dart-gen"), |
| 282 "--pkg-directory", |
| 283 pkg_directory, |
| 284 "--package-root", |
| 285 package_root, |
| 286 "--stamp-file", |
| 287 rebase_path(stamp_file), |
| 288 "--package-sources", |
| 289 ] + rebase_path(invoker.sources) + [ "--mojom-sources" ] + |
| 290 rebase_path(mojom_sources, "", mojo_sdk_root) |
| 291 } |
| 292 } |
OLD | NEW |