Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: mojo/public/dart/rules.gni

Issue 1312183003: dart_pkg cleanups (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/dart/observatory_test/BUILD.gn ('k') | services/dart/dart_apptests/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 # This file has rules for making Dart packages and Dart-based Mojo applications. 5 # This file has rules for making Dart packages and Dart-based Mojo applications.
6 # The entrypoint is the dart_pkg rule. 6 # The entrypoint is the dart_pkg rule.
7 7
8 import("../mojo.gni") 8 import("../mojo.gni")
9 import("//build/module_args/mojo.gni") 9 import("//build/module_args/mojo.gni")
10 import("//build/module_args/dart.gni") 10 import("//build/module_args/dart.gni")
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 sdk_ext_mappings = [] 192 sdk_ext_mappings = []
193 if (defined(invoker.sdk_ext_mappings)) { 193 if (defined(invoker.sdk_ext_mappings)) {
194 sdk_ext_mappings += invoker.sdk_ext_mappings 194 sdk_ext_mappings += invoker.sdk_ext_mappings
195 } 195 }
196 196
197 script = rebase_path("mojo/public/tools/dart_pkg.py", ".", mojo_sdk_root) 197 script = rebase_path("mojo/public/tools/dart_pkg.py", ".", mojo_sdk_root)
198 198
199 entrypoints = [] 199 entrypoints = []
200 if (defined(invoker.apps)) { 200 if (defined(invoker.apps)) {
201 entrypoints += invoker.apps 201 foreach(app, invoker.apps) {
202 entrypoints += [ app[1] ]
203 }
202 } 204 }
203 if (defined(invoker.libs)) { 205 if (defined(invoker.libs)) {
204 entrypoints += invoker.libs 206 entrypoints += invoker.libs
205 } 207 }
206 208
207 sources = entrypoints 209 sources = entrypoints
208 pkg_sources = entrypoints 210 pkg_sources = entrypoints
209 if (defined(invoker.sources)) { 211 if (defined(invoker.sources)) {
210 sources += invoker.sources 212 sources += invoker.sources
211 pkg_sources += invoker.sources 213 pkg_sources += invoker.sources
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 rebase_path(entrypoints) + [ "--mojom-sources" ] + 255 rebase_path(entrypoints) + [ "--mojom-sources" ] +
254 rebase_path(mojom_sources, "", mojo_sdk_root) + 256 rebase_path(mojom_sources, "", mojo_sdk_root) +
255 [ "--sdk-ext-directories" ] + rebase_path(sdk_ext_directory) + 257 [ "--sdk-ext-directories" ] + rebase_path(sdk_ext_directory) +
256 [ "--sdk-ext-files" ] + rebase_path(sdk_ext_files) + 258 [ "--sdk-ext-files" ] + rebase_path(sdk_ext_files) +
257 [ "--sdk-ext-mappings" ] + sdk_ext_mappings 259 [ "--sdk-ext-mappings" ] + sdk_ext_mappings
258 } 260 }
259 } 261 }
260 262
261 # This is the entrypoint for organizing Dart code for Mojo. 263 # This is the entrypoint for organizing Dart code for Mojo.
262 # 264 #
263 # For each file in |apps|, it makes a .mojo Mojo application using the dartx 265 # There should be a one to one mapping between dart_pkg rules and pubspec.yamls.
264 # format as well as an assemblage of the app under $root_gen_dir/part-pkg for 266 #
267 # This build rule will result in a package under $root_gen_dir/dart-pkg/
268 #
269 # The name of the package is taken from the 'pubspec.yaml' file.
270 #
271 # For each app in |apps|, it makes a .mojo Mojo application using the dartx
272 # format as well as an assemblage of the app under $root_gen_dir/dart-pkg for
265 # use in local development. 273 # use in local development.
266 # 274 #
267 # For each file in |libs|, it invokes the Dart analyzer. All other sources go in 275 # For each library in |libs|, it invokes the Dart analyzer on that library. The
268 # |sources|. This should at least contain a 'pubspec.yaml' file. If no |apps| 276 # build will fail if the library is not analyzer clean.
269 # are defined, this rule makes the library package available to applications. 277 #
270 # The name of the package is taken from the 'pubspec.yaml' file. Even if a 278 # All other sources go in |sources|. This should at least contain the
271 # package will not be uploaded to pub, an attempt should be made not to conflict 279 # 'pubspec.yaml' file.
272 # with the names of existing pub packages, for example by using the prefix 280 #
273 # 'mojo_dart_'. 281 # Even if a package will not be uploaded to pub, an attempt should be made not
282 # to conflict with the names of existing pub packages, for example by using the
283 # prefix 'mojo_dart_'.
274 # 284 #
275 # sources 285 # sources
276 # List of non-app and non-lib sources to include in the package. This 286 # List of sources to include in the package. This should at least contain
277 # should at least contain the pubspec.yaml for the package. 287 # the pubspec.yaml for the package.
278 # 288 #
279 # apps (optional) 289 # apps (optional)
280 # List of Mojo application entrypoints containing a main() function. 290 # List of pairs. [mojo_app_name, entrypoint.dart]. Each entrypoint
281 # Each of these entrypoints will result in a .mojo Mojo application. 291 # script must contain a main() function. A .mojo Mojo application will be
282 # See |output_name| for how this application is named. 292 # generated for each application.
283 # 293 #
284 # libs (optional) 294 # libs (optional)
285 # List of package entrypoints to pass to the analyzer. If none are 295 # List of library entrypoints to pass to the analyzer. If none are
286 # defined, the analyzer is not run. 296 # defined, the analyzer is not run.
287 # 297 #
288 # strict (optional) 298 # strict (optional)
289 # If |apps| are specified, |strict| can be set to true to 299 # If |apps| are specified, |strict| can be set to true to
290 # instruct the content handler to run the apps in Dart VM's strict 300 # instruct the content handler to run the apps in Dart VM's strict
291 # compilation mode (with assertions and type-checks, etc.). 301 # compilation mode (with assertions and type-checks, etc.).
292 # 302 #
293 # app_name_override (optional)
294 # When |apps| are specified, this is the prefix to use for the
295 # name of the assembled .mojo file. The target name is used by default.
296 # For each entrypoint, the result is |output_name|_|entrypoint|.mojo. If
297 # the entrypoint is main.dart, the result is simply |output_name|.mojo.
298 #
299 # deps (optional) 303 # deps (optional)
300 # List of other dart_pkg targets for Dart packages imported by this 304 # List of other dart_pkg targets for Dart packages imported by this
301 # dart_pkg, as well as the mojom targets needed by this dart_pkg. 305 # dart_pkg, as well as the mojom targets needed by this dart_pkg.
302 # 306 #
303 # pkg_dir (optional) 307 # pkg_dir (optional)
304 # Directory containing the package sources. This overrides sources and 308 # Directory containing the package sources. This overrides sources and
305 # entrypoints. The analyzer will not be run. 309 # entrypoints. The analyzer will not be run.
306 # 310 #
307 # datadeps (optional) 311 # datadeps (optional)
308 # 312 #
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 360 }
357 if (defined(invoker.sdk_ext_files)) { 361 if (defined(invoker.sdk_ext_files)) {
358 sdk_ext_files = invoker.sdk_ext_files 362 sdk_ext_files = invoker.sdk_ext_files
359 } 363 }
360 if (defined(invoker.sdk_ext_mappings)) { 364 if (defined(invoker.sdk_ext_mappings)) {
361 sdk_ext_mappings = invoker.sdk_ext_mappings 365 sdk_ext_mappings = invoker.sdk_ext_mappings
362 } 366 }
363 } 367 }
364 368
365 if (defined(invoker.apps)) { 369 if (defined(invoker.apps)) {
366 pkg_name = target_name
367 if (defined(invoker.app_name_override)) {
368 pkg_name = invoker.app_name_override
369 }
370 pkg_helper_output_dir = "$root_gen_dir/dart-pkg/${dart_package_name}" 370 pkg_helper_output_dir = "$root_gen_dir/dart-pkg/${dart_package_name}"
371 foreach(entrypoint, invoker.apps) { 371 foreach(app, invoker.apps) {
372 entrypoint_name = get_path_info(entrypoint, "name") 372 app_name = app[0]
373 dartx_target_name = "${pkg_name}_${entrypoint_name}" 373 app_entrypoint = app[1]
374 dartx_output_name = dartx_target_name 374 dartx_output_name = app_name
375 if (entrypoint_name == "main") { 375 dartx_application("${app_name}_dart_app") {
376 dartx_output_name = pkg_name
377 }
378 dartx_application(dartx_target_name) {
379 output_name = dartx_output_name 376 output_name = dartx_output_name
380 main_dart = rebase_path(entrypoint, "", pkg_helper_output_dir) 377 main_dart = rebase_path(app_entrypoint, "", pkg_helper_output_dir)
381 sources = rebase_path(invoker.sources, "", pkg_helper_output_dir) 378 sources = rebase_path(invoker.sources, "", pkg_helper_output_dir)
382 deps = [ 379 deps = [
383 ":$dart_pkg_target_name", 380 ":$dart_pkg_target_name",
384 ] 381 ]
385 deps += invoker.deps 382 deps += invoker.deps
386 if (defined(invoker.strict)) { 383 if (defined(invoker.strict)) {
387 strict = invoker.strict 384 strict = invoker.strict
388 } 385 }
389 } 386 }
390 } 387 }
391 } 388 }
392 389
393 group(target_name) { 390 group(target_name) {
394 deps = [ 391 deps = [
395 ":$dart_pkg_target_name", 392 ":$dart_pkg_target_name",
396 ] 393 ]
397 if (defined(invoker.apps)) { 394 if (defined(invoker.apps)) {
398 pkg_name = target_name 395 foreach(app, invoker.apps) {
399 if (defined(invoker.app_name_override)) { 396 app_name = app[0]
400 pkg_name = invoker.app_name_override 397 dartx_target_name = "${app_name}_dart_app"
401 }
402 foreach(entrypoint, invoker.apps) {
403 entrypoint_name = get_path_info(entrypoint, "name")
404 dartx_target_name = "${pkg_name}_${entrypoint_name}"
405 deps += [ ":$dartx_target_name" ] 398 deps += [ ":$dartx_target_name" ]
406 } 399 }
407 } 400 }
408 } 401 }
409 } 402 }
OLDNEW
« no previous file with comments | « mojo/dart/observatory_test/BUILD.gn ('k') | services/dart/dart_apptests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698