OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
6 | 6 |
7 assert(is_android) | 7 assert(is_android) |
8 | 8 |
9 | 9 |
10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) | 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) |
11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) | 11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) |
12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil
d_dir) | 12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil
d_dir) |
13 | 13 |
| 14 android_sdk_jar = "$android_sdk/android.jar" |
| 15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) |
| 16 |
14 template("android_lint") { | 17 template("android_lint") { |
15 jar_path = invoker.jar_path | 18 jar_path = invoker.jar_path |
16 android_manifest = invoker.android_manifest | 19 android_manifest = invoker.android_manifest |
17 java_files = invoker.java_files | 20 java_files = invoker.java_files |
18 base_path = "$target_gen_dir/$target_name" | 21 base_path = "$target_gen_dir/$target_name" |
19 | 22 |
20 action(target_name) { | 23 action(target_name) { |
21 script = "//build/android/gyp/lint.py" | 24 script = "//build/android/gyp/lint.py" |
22 result_path = base_path + "/result.xml" | 25 result_path = base_path + "/result.xml" |
23 config_path = base_path + "/config.xml" | 26 config_path = base_path + "/config.xml" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 "--key-name", _keystore_name, | 328 "--key-name", _keystore_name, |
326 "--key-passwd", _keystore_password, | 329 "--key-passwd", _keystore_password, |
327 ] | 330 ] |
328 } | 331 } |
329 | 332 |
330 group(target_name) { | 333 group(target_name) { |
331 deps = [":${target_name}__finalize"] | 334 deps = [":${target_name}__finalize"] |
332 } | 335 } |
333 } | 336 } |
334 | 337 |
| 338 template("java_prebuilt") { |
| 339 _input_jar_path = invoker.input_jar_path |
| 340 _output_jar_path = invoker.output_jar_path |
| 341 _jar_toc_path = _output_jar_path + ".TOC" |
| 342 |
| 343 assert(invoker.build_config != "") |
| 344 |
| 345 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
| 346 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar" |
| 347 _proguard_config_path = invoker.proguard_config |
| 348 _build_config = invoker.build_config |
| 349 _rebased_build_config = rebase_path(_build_config, root_build_dir) |
| 350 action("${target_name}__proguard_process") { |
| 351 script = "//build/android/gyp/proguard.py" |
| 352 inputs = [ |
| 353 android_sdk_jar, |
| 354 _proguard_jar_path, |
| 355 _build_config, |
| 356 _input_jar_path, |
| 357 _proguard_config_path, |
| 358 ] |
| 359 depfile = "${target_gen_dir}/${target_name}.d" |
| 360 outputs = [ |
| 361 depfile, |
| 362 _output_jar_path, |
| 363 ] |
| 364 args = [ |
| 365 "--depfile", rebase_path(depfile, root_build_dir), |
| 366 "--proguard-path", rebase_path(_proguard_jar_path, root_build_dir), |
| 367 "--input-path", rebase_path(_input_jar_path, root_build_dir), |
| 368 "--output-path", rebase_path(_output_jar_path, root_build_dir), |
| 369 "--proguard-config", rebase_path(_proguard_config_path, root_build_dir), |
| 370 "--classpath", rebased_android_sdk_jar, |
| 371 "--classpath=@FileArg($_rebased_build_config:javac:classpath)", |
| 372 ] |
| 373 } |
| 374 } else { |
| 375 copy("${target_name}__copy_jar") { |
| 376 sources = [_input_jar_path] |
| 377 outputs = [_output_jar_path] |
| 378 } |
| 379 } |
| 380 |
| 381 action("${target_name}__jar_toc") { |
| 382 script = "//build/android/gyp/jar_toc.py" |
| 383 depfile = "$target_gen_dir/$target_name.d" |
| 384 outputs = [ |
| 385 depfile, |
| 386 _jar_toc_path, |
| 387 _jar_toc_path + ".md5.stamp" |
| 388 ] |
| 389 inputs = [ _output_jar_path ] |
| 390 args = [ |
| 391 "--depfile", rebase_path(depfile, root_build_dir), |
| 392 "--jar-path", rebase_path(_output_jar_path, root_build_dir), |
| 393 "--toc-path", rebase_path(_jar_toc_path, root_build_dir), |
| 394 ] |
| 395 } |
| 396 |
| 397 group(target_name) { |
| 398 deps = [ |
| 399 ":${target_name}__jar_toc" |
| 400 ] |
| 401 } |
| 402 } |
| 403 |
335 # Compiles and jars a set of java files. | 404 # Compiles and jars a set of java files. |
336 # | 405 # |
337 # Outputs: | 406 # Outputs: |
338 # $jar_path.jar | 407 # $jar_path.jar |
339 # $jar_path.jar.TOC | 408 # $jar_path.jar.TOC |
340 # | 409 # |
341 # Variables | 410 # Variables |
342 # java_files: List of .java files to compile. | 411 # java_files: List of .java files to compile. |
343 # java_deps: List of java dependencies. These should all have a .jar output | 412 # java_deps: List of java dependencies. These should all have a .jar output |
344 # at "${target_gen_dir}/${target_name}.jar. | 413 # at "${target_gen_dir}/${target_name}.jar. |
345 # chromium_code: If true, enable extra warnings. | 414 # chromium_code: If true, enable extra warnings. |
346 # srcjar_deps: List of srcjar dependencies. The .java files contained in the | 415 # srcjar_deps: List of srcjar dependencies. The .java files contained in the |
347 # dependencies srcjar outputs will be compiled and added to the output jar. | 416 # dependencies srcjar outputs will be compiled and added to the output jar. |
348 # jar_path: Use this to explicitly set the output jar path. Defaults to | 417 # jar_path: Use this to explicitly set the output jar path. Defaults to |
349 # "${target_gen_dir}/${target_name}.jar. | 418 # "${target_gen_dir}/${target_name}.jar. |
350 template("java_library") { | 419 template("java_library") { |
351 assert(defined(invoker.java_files)) | 420 assert(defined(invoker.java_files)) |
352 assert(defined(invoker.build_config)) | 421 assert(defined(invoker.build_config)) |
353 assert(defined(invoker.jar_path)) | 422 assert(defined(invoker.jar_path)) |
354 | 423 |
355 java_files = invoker.java_files | 424 _java_files = invoker.java_files |
356 jar_path = invoker.jar_path | 425 _final_jar_path = invoker.jar_path |
357 jar_toc_path = jar_path + ".TOC" | 426 _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar" |
358 | 427 |
359 build_config = invoker.build_config | 428 _build_config = invoker.build_config |
360 | 429 |
361 jar_excluded_patterns = [] | 430 _jar_excluded_patterns = [] |
362 if (defined(invoker.jar_excluded_patterns)) { | 431 if (defined(invoker.jar_excluded_patterns)) { |
363 jar_excluded_patterns += invoker.jar_excluded_patterns | 432 _jar_excluded_patterns += invoker.jar_excluded_patterns |
364 } | 433 } |
365 | 434 |
366 chromium_code = false | 435 _chromium_code = false |
367 if (defined(invoker.chromium_code)) { | 436 if (defined(invoker.chromium_code)) { |
368 chromium_code = chromium_code || invoker.chromium_code | 437 _chromium_code = invoker.chromium_code |
369 } | 438 } |
370 | 439 |
371 srcjar_deps = [] | 440 _srcjar_deps = [] |
372 if (defined(invoker.srcjar_deps)) { | 441 if (defined(invoker.srcjar_deps)) { |
373 srcjar_deps += invoker.srcjar_deps | 442 _srcjar_deps += invoker.srcjar_deps |
374 } | 443 } |
375 | 444 |
376 java_srcjars = [] | 445 _java_srcjars = [] |
377 foreach(dep, srcjar_deps) { | 446 foreach(dep, _srcjar_deps) { |
378 dep_gen_dir = get_label_info(dep, "target_gen_dir") | 447 _dep_gen_dir = get_label_info(dep, "target_gen_dir") |
379 dep_name = get_label_info(dep, "name") | 448 _dep_name = get_label_info(dep, "name") |
380 java_srcjars += [ "$dep_gen_dir/$dep_name.srcjar" ] | 449 _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ] |
381 } | 450 } |
382 # Mark srcjar_deps as used. | 451 # Mark srcjar_deps as used. |
383 assert(srcjar_deps == [] || srcjar_deps != []) | 452 assert(_srcjar_deps == [] || true) |
384 | 453 |
385 rebase_jar_path = rebase_path(jar_path, root_build_dir) | 454 _system_jars = [ android_sdk_jar ] |
386 | |
387 system_jars = [ "${android_sdk}/android.jar" ] | |
388 action("${target_name}__javac") { | 455 action("${target_name}__javac") { |
389 script = "//build/android/gyp/javac.py" | 456 script = "//build/android/gyp/javac.py" |
390 depfile = "$target_gen_dir/$target_name.d" | 457 depfile = "$target_gen_dir/$target_name.d" |
391 outputs = [ | 458 outputs = [ |
392 depfile, | 459 depfile, |
393 jar_path, | 460 _intermediate_jar_path, |
394 jar_path + ".md5.stamp" | 461 _intermediate_jar_path + ".md5.stamp" |
395 ] | 462 ] |
396 sources = java_files + java_srcjars | 463 sources = _java_files + _java_srcjars |
397 inputs = system_jars + [ build_config ] | 464 inputs = _system_jars + [ _build_config ] |
398 | 465 |
399 rebase_system_jars = rebase_path(system_jars, root_build_dir) | 466 _rebased_system_jars = rebase_path(_system_jars, root_build_dir) |
400 rebase_java_srcjars = rebase_path(java_srcjars, root_build_dir) | 467 _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir) |
401 rebase_build_config = rebase_path(build_config, root_build_dir) | 468 _rebased_build_config = rebase_path(_build_config, root_build_dir) |
402 rebase_depfile = rebase_path(depfile, root_build_dir) | 469 _rebased_depfile = rebase_path(depfile, root_build_dir) |
| 470 _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir) |
403 args = [ | 471 args = [ |
404 "--depfile=$rebase_depfile", | 472 "--depfile=$_rebased_depfile", |
405 "--classpath=$rebase_system_jars", | 473 "--classpath=$_rebased_system_jars", |
406 "--classpath=@FileArg($rebase_build_config:javac:classpath)", | 474 "--classpath=@FileArg($_rebased_build_config:javac:classpath)", |
407 "--jar-path=$rebase_jar_path", | 475 "--jar-path=$_rebased_jar_path", |
408 "--java-srcjars=$rebase_java_srcjars", | 476 "--java-srcjars=$_rebased_java_srcjars", |
409 "--java-srcjars=@FileArg($rebase_build_config:javac:srcjars)", | 477 "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)", |
410 "--jar-excluded-classes=$jar_excluded_patterns", | 478 "--jar-excluded-classes=$_jar_excluded_patterns", |
411 ] | 479 ] |
412 if (chromium_code) { | 480 if (_chromium_code) { |
413 args += [ "--chromium-code" ] | 481 args += [ "--chromium-code" ] |
414 } | 482 } |
415 | 483 |
416 args += rebase_path(java_files, root_build_dir) | 484 args += rebase_path(_java_files, root_build_dir) |
417 } | 485 } |
418 | 486 |
419 # TODO(cjhopman): proguard | 487 java_prebuilt("${target_name}__finish") { |
420 | 488 build_config = _build_config |
421 rebase_jar_toc_path = rebase_path(jar_toc_path, root_build_dir) | 489 input_jar_path = _intermediate_jar_path |
422 action("${target_name}__jar_toc") { | 490 output_jar_path = _final_jar_path |
423 script = "//build/android/gyp/jar_toc.py" | 491 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
424 depfile = "$target_gen_dir/$target_name.d" | 492 proguard_preprocess = invoker.proguard_preprocess |
425 outputs = [ | 493 proguard_config = invoker.proguard_config |
426 depfile, | 494 } |
427 jar_toc_path, | |
428 jar_toc_path + ".md5.stamp" | |
429 ] | |
430 inputs = [ jar_path ] | |
431 args = [ | |
432 "--depfile", rebase_path(depfile, root_build_dir), | |
433 "--jar-path=${rebase_jar_path}", | |
434 "--toc-path=${rebase_jar_toc_path}", | |
435 ] | |
436 } | 495 } |
437 | 496 |
438 group(target_name) { | 497 group(target_name) { |
439 deps = [ | 498 deps = [ |
440 ":${target_name}__javac", | 499 ":${target_name}__javac", |
441 ":${target_name}__jar_toc", | 500 ":${target_name}__finish", |
442 ] | 501 ] |
443 } | 502 } |
444 } | 503 } |
445 | 504 |
446 | 505 |
447 # This adds Android-specific parts to the java_library template. | 506 # This adds Android-specific parts to the java_library template. |
448 # | 507 # |
449 # Runs Android lint against the compiled java files. | 508 # Runs Android lint against the compiled java files. |
450 # Dexes the output jar for inclusion in an APK. | 509 # Dexes the output jar for inclusion in an APK. |
451 template("android_java_library") { | 510 template("android_java_library") { |
(...skipping 17 matching lines...) Expand all Loading... |
469 jar_path = _jar_path | 528 jar_path = _jar_path |
470 if (defined(invoker.jar_excluded_patterns)) { | 529 if (defined(invoker.jar_excluded_patterns)) { |
471 jar_excluded_patterns = invoker.jar_excluded_patterns | 530 jar_excluded_patterns = invoker.jar_excluded_patterns |
472 } | 531 } |
473 build_config = invoker.build_config | 532 build_config = invoker.build_config |
474 java_files = invoker.java_files | 533 java_files = invoker.java_files |
475 | 534 |
476 if (defined(invoker.srcjar_deps)) { | 535 if (defined(invoker.srcjar_deps)) { |
477 srcjar_deps = invoker.srcjar_deps | 536 srcjar_deps = invoker.srcjar_deps |
478 } | 537 } |
| 538 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
| 539 proguard_preprocess = invoker.proguard_preprocess |
| 540 proguard_config = invoker.proguard_config |
| 541 } |
479 } | 542 } |
480 | 543 |
481 if (defined(invoker.chromium_code) && invoker.chromium_code) { | 544 if (defined(invoker.chromium_code) && invoker.chromium_code) { |
482 _final_deps += [ ":${target_name}__lint" ] | 545 _final_deps += [ ":${target_name}__lint" ] |
483 android_lint("${target_name}__lint") { | 546 android_lint("${target_name}__lint") { |
484 android_manifest = _android_manifest | 547 android_manifest = _android_manifest |
485 jar_path = _jar_path | 548 jar_path = _jar_path |
486 java_files = invoker.java_files | 549 java_files = invoker.java_files |
487 } | 550 } |
488 } | 551 } |
489 | 552 |
490 dex("${target_name}__dex") { | 553 dex("${target_name}__dex") { |
491 sources = [_jar_path] | 554 sources = [_jar_path] |
492 output = _dex_path | 555 output = _dex_path |
493 } | 556 } |
494 | 557 |
495 group(target_name) { | 558 group(target_name) { |
496 deps = [ | 559 deps = [ |
497 ":${target_name}__java_library", | 560 ":${target_name}__java_library", |
498 ":${target_name}__dex", | 561 ":${target_name}__dex", |
499 ] + _final_deps | 562 ] + _final_deps |
500 } | 563 } |
501 } | 564 } |
502 | 565 |
503 | |
504 # Runs process_resources.py | 566 # Runs process_resources.py |
505 template("process_resources") { | 567 template("process_resources") { |
506 zip_path = invoker.zip_path | 568 zip_path = invoker.zip_path |
507 srcjar_path = invoker.srcjar_path | 569 srcjar_path = invoker.srcjar_path |
508 build_config = invoker.build_config | 570 build_config = invoker.build_config |
509 resource_dirs = invoker.resource_dirs | 571 resource_dirs = invoker.resource_dirs |
510 android_manifest = invoker.android_manifest | 572 android_manifest = invoker.android_manifest |
511 | 573 |
512 non_constant_id = true | 574 non_constant_id = true |
513 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { | 575 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 "--dest", rebase_path(invoker.dest, root_build_dir), | 659 "--dest", rebase_path(invoker.dest, root_build_dir), |
598 ] | 660 ] |
599 if (defined(invoker.args)) { | 661 if (defined(invoker.args)) { |
600 args += invoker.args | 662 args += invoker.args |
601 } | 663 } |
602 if (defined(invoker.clear_dir) && invoker.clear_dir) { | 664 if (defined(invoker.clear_dir) && invoker.clear_dir) { |
603 args += ["--clear"] | 665 args += ["--clear"] |
604 } | 666 } |
605 } | 667 } |
606 } | 668 } |
OLD | NEW |