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 zipped applications for Dart. | 5 # Rules to generate zipped applications for Dart. |
6 # Rules to generate dart-pkg and dart-pkg/packages. | 6 # Rules to generate dart-pkg and dart-pkg/packages. |
7 | 7 |
8 import("//build/module_args/mojo.gni") | 8 import("//build/module_args/mojo.gni") |
9 | 9 |
10 template("dartzip_package") { | 10 template("dartzip_package") { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 ] | 208 ] |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 # Creates a gen/dart-pkg/package_name directory containing symlinks to package | 212 # Creates a gen/dart-pkg/package_name directory containing symlinks to package |
213 # sources. Also copies any mojom dependencies into lib/mojom. | 213 # sources. Also copies any mojom dependencies into lib/mojom. |
214 # | 214 # |
215 # sources | 215 # sources |
216 # List of sources to include in the package. | 216 # List of sources to include in the package. |
217 # | 217 # |
| 218 # pkg_dir (optional) |
| 219 # Directory containing the package sources. This overrides sources. |
| 220 # |
218 # deps (optional) | 221 # deps (optional) |
219 # Note: this can only contain mojom targets. | 222 # Note: this can only contain mojom targets. |
220 # | 223 # |
221 # datadeps (optional) | 224 # datadeps (optional) |
222 # | 225 # |
223 # sdk_ext_directory (optional) | 226 # sdk_ext_directory (optional) |
224 # Directory containing sdk-ext .dart sources. | 227 # Directory containing sdk-ext .dart sources. |
225 # | 228 # |
226 template("dart_pkg") { | 229 template("dart_pkg") { |
227 pubspec_yaml_path = rebase_path("pubspec.yaml") | 230 if (defined(invoker.pkg_dir)) { |
| 231 pubspec_yaml_path = rebase_path("pubspec.yaml", "", invoker.pkg_dir) |
| 232 } else { |
| 233 pubspec_yaml_path = rebase_path("pubspec.yaml") |
| 234 } |
228 dart_package_name_script = | 235 dart_package_name_script = |
229 rebase_path("mojo/public/tools/dart_package_name.py", ".", mojo_sdk_root) | 236 rebase_path("mojo/public/tools/dart_package_name.py", ".", mojo_sdk_root) |
230 package_name = exec_script(dart_package_name_script, | 237 package_name = exec_script(dart_package_name_script, |
231 [ | 238 [ |
232 "--pubspec", | 239 "--pubspec", |
233 pubspec_yaml_path, | 240 pubspec_yaml_path, |
234 ], | 241 ], |
235 "trim string", | 242 "trim string", |
236 [ pubspec_yaml_path ]) | 243 [ pubspec_yaml_path ]) |
237 | 244 |
238 pkg_directory = rebase_path("$root_gen_dir/dart-pkg") | 245 pkg_directory = rebase_path("$root_gen_dir/dart-pkg") |
239 package_root = rebase_path("$root_gen_dir/dart-pkg/packages") | 246 package_root = rebase_path("$root_gen_dir/dart-pkg/packages") |
240 stamp_file = "$root_gen_dir/dart-pkg/${package_name}.stamp" | 247 stamp_file = "$root_gen_dir/dart-pkg/${package_name}.stamp" |
241 | 248 |
242 assert(defined(invoker.sources)) | 249 assert(defined(invoker.sources) || defined(invoker.pkg_dir)) |
243 | 250 |
244 action(target_name) { | 251 action(target_name) { |
245 deps = [] | 252 deps = [] |
246 if (defined(invoker.deps)) { | 253 if (defined(invoker.deps)) { |
247 deps += invoker.deps | 254 deps += invoker.deps |
248 } | 255 } |
249 | 256 |
250 datadeps = [] | 257 datadeps = [] |
251 if (defined(invoker.datadeps)) { | 258 if (defined(invoker.datadeps)) { |
252 datadeps += invoker.datadeps | 259 datadeps += invoker.datadeps |
(...skipping 16 matching lines...) Expand all Loading... |
269 sdk_ext_directory = [] | 276 sdk_ext_directory = [] |
270 if (defined(invoker.sdk_ext_directory)) { | 277 if (defined(invoker.sdk_ext_directory)) { |
271 sdk_ext_directory += [ invoker.sdk_ext_directory ] | 278 sdk_ext_directory += [ invoker.sdk_ext_directory ] |
272 } | 279 } |
273 | 280 |
274 script = rebase_path("mojo/public/tools/dart_pkg.py", ".", mojo_sdk_root) | 281 script = rebase_path("mojo/public/tools/dart_pkg.py", ".", mojo_sdk_root) |
275 outputs = [ | 282 outputs = [ |
276 stamp_file, | 283 stamp_file, |
277 ] | 284 ] |
278 | 285 |
| 286 if (defined(invoker.sources)) { |
| 287 sources = invoker.sources |
| 288 } else { |
| 289 assert(defined(invoker.pkg_dir)) |
| 290 list_script = rebase_path("build/ls.py", ".", mojo_sdk_root) |
| 291 sources = exec_script(list_script, |
| 292 [ |
| 293 "--target-directory", |
| 294 rebase_path(invoker.pkg_dir), |
| 295 ], |
| 296 "list lines") |
| 297 } |
| 298 |
279 inputs = [ | 299 inputs = [ |
280 list_mojoms_script, | 300 list_mojoms_script, |
281 script, | 301 script, |
282 ] + rebase_path(invoker.sources) | 302 ] + rebase_path(sources) |
283 | 303 |
284 args = [ | 304 args = [ |
285 "--package-name", | 305 "--package-name", |
286 package_name, | 306 package_name, |
287 "--gen-directory", | 307 "--gen-directory", |
288 rebase_path("$root_gen_dir/dart-gen"), | 308 rebase_path("$root_gen_dir/dart-gen"), |
289 "--pkg-directory", | 309 "--pkg-directory", |
290 pkg_directory, | 310 pkg_directory, |
291 "--package-root", | 311 "--package-root", |
292 package_root, | 312 package_root, |
293 "--stamp-file", | 313 "--stamp-file", |
294 rebase_path(stamp_file), | 314 rebase_path(stamp_file), |
295 "--package-sources", | 315 "--package-sources", |
296 ] + rebase_path(invoker.sources) + [ "--mojom-sources" ] + | 316 ] + rebase_path(sources) + [ "--mojom-sources" ] + |
297 rebase_path(mojom_sources, "", mojo_sdk_root) + | 317 rebase_path(mojom_sources, "", mojo_sdk_root) + |
298 [ "--sdk-ext-directories" ] + rebase_path(sdk_ext_directory) | 318 [ "--sdk-ext-directories" ] + rebase_path(sdk_ext_directory) |
299 } | 319 } |
300 } | 320 } |
OLD | NEW |