| 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 template("android_lint") { |
| 15 jar_path = invoker.jar_path |
| 16 android_manifest = invoker.android_manifest |
| 17 java_files = invoker.java_files |
| 18 base_path = "$target_gen_dir/$target_name" |
| 19 |
| 20 action(target_name) { |
| 21 script = "//build/android/gyp/lint.py" |
| 22 result_path = base_path + "/result.xml" |
| 23 config_path = base_path + "/config.xml" |
| 24 suppressions_file = "//build/android/lint/suppressions.xml" |
| 25 inputs = [ |
| 26 suppressions_file, |
| 27 android_manifest, |
| 28 jar_path, |
| 29 ] + java_files |
| 30 |
| 31 outputs = [ |
| 32 config_path, |
| 33 result_path |
| 34 ] |
| 35 |
| 36 rebased_java_files = rebase_path(java_files, root_build_dir) |
| 37 |
| 38 args = [ |
| 39 "--lint-path=$rebased_android_sdk_root/tools/lint", |
| 40 "--config-path", rebase_path(suppressions_file, root_build_dir), |
| 41 "--manifest-path", rebase_path(android_manifest, root_build_dir), |
| 42 "--product-dir=.", |
| 43 "--jar-path", rebase_path(jar_path, root_build_dir), |
| 44 "--processed-config-path", rebase_path(config_path, root_build_dir), |
| 45 "--result-path", rebase_path(result_path, root_build_dir), |
| 46 "--java-files=$rebased_java_files", |
| 47 "--enable", |
| 48 ] |
| 49 } |
| 50 } |
| 51 |
| 14 | 52 |
| 15 # Write the target's .build_config file. This is a json file that contains a | 53 # Write the target's .build_config file. This is a json file that contains a |
| 16 # dictionary of information about how to build this target (things that | 54 # dictionary of information about how to build this target (things that |
| 17 # require knowledge about this target's dependencies and cannot be calculated | 55 # require knowledge about this target's dependencies and cannot be calculated |
| 18 # at gn-time). There is a special syntax to add a value in that dictionary to | 56 # at gn-time). There is a special syntax to add a value in that dictionary to |
| 19 # an action/action_foreachs args: | 57 # an action/action_foreachs args: |
| 20 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) | 58 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) |
| 21 # At runtime, such an arg will be replaced by the value in the build_config. | 59 # At runtime, such an arg will be replaced by the value in the build_config. |
| 22 # See build/android/gyp/write_build_config.py and | 60 # See build/android/gyp/write_build_config.py and |
| 23 # build/android/gyp/util/build_utils.py:ExpandFileArgs | 61 # build/android/gyp/util/build_utils.py:ExpandFileArgs |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 # Compiles and jars a set of java files. | 335 # Compiles and jars a set of java files. |
| 298 # | 336 # |
| 299 # Outputs: | 337 # Outputs: |
| 300 # $jar_path.jar | 338 # $jar_path.jar |
| 301 # $jar_path.jar.TOC | 339 # $jar_path.jar.TOC |
| 302 # | 340 # |
| 303 # Variables | 341 # Variables |
| 304 # java_files: List of .java files to compile. | 342 # java_files: List of .java files to compile. |
| 305 # java_deps: List of java dependencies. These should all have a .jar output | 343 # java_deps: List of java dependencies. These should all have a .jar output |
| 306 # at "${target_gen_dir}/${target_name}.jar. | 344 # at "${target_gen_dir}/${target_name}.jar. |
| 307 # chromium_code: If 1, enable extra warnings. | 345 # chromium_code: If true, enable extra warnings. |
| 308 # srcjar_deps: List of srcjar dependencies. The .java files contained in the | 346 # srcjar_deps: List of srcjar dependencies. The .java files contained in the |
| 309 # dependencies srcjar outputs will be compiled and added to the output jar. | 347 # dependencies srcjar outputs will be compiled and added to the output jar. |
| 310 # jar_path: Use this to explicitly set the output jar path. Defaults to | 348 # jar_path: Use this to explicitly set the output jar path. Defaults to |
| 311 # "${target_gen_dir}/${target_name}.jar. | 349 # "${target_gen_dir}/${target_name}.jar. |
| 312 template("java_library") { | 350 template("java_library") { |
| 313 assert(defined(invoker.java_files)) | 351 assert(defined(invoker.java_files)) |
| 314 assert(defined(invoker.build_config)) | 352 assert(defined(invoker.build_config)) |
| 315 assert(defined(invoker.jar_path)) | 353 assert(defined(invoker.jar_path)) |
| 316 | 354 |
| 317 java_files = invoker.java_files | 355 java_files = invoker.java_files |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 # Dexes the output jar for inclusion in an APK. | 450 # Dexes the output jar for inclusion in an APK. |
| 413 template("android_java_library") { | 451 template("android_java_library") { |
| 414 assert(defined(invoker.java_files)) | 452 assert(defined(invoker.java_files)) |
| 415 assert(defined(invoker.build_config)) | 453 assert(defined(invoker.build_config)) |
| 416 assert(defined(invoker.jar_path)) | 454 assert(defined(invoker.jar_path)) |
| 417 assert(defined(invoker.dex_path)) | 455 assert(defined(invoker.dex_path)) |
| 418 | 456 |
| 419 _jar_path = invoker.jar_path | 457 _jar_path = invoker.jar_path |
| 420 _dex_path = invoker.dex_path | 458 _dex_path = invoker.dex_path |
| 421 | 459 |
| 460 _android_manifest = "//build/android/AndroidManifest.xml" |
| 461 if (defined(invoker.android_manifest)) { |
| 462 _android_manifest = invoker.android_manifest |
| 463 } |
| 464 assert(_android_manifest != "") |
| 465 |
| 466 _final_deps = [] |
| 467 |
| 422 java_library("${target_name}__java_library") { | 468 java_library("${target_name}__java_library") { |
| 423 jar_path = _jar_path | 469 jar_path = _jar_path |
| 424 if (defined(invoker.jar_excluded_patterns)) { | 470 if (defined(invoker.jar_excluded_patterns)) { |
| 425 jar_excluded_patterns = invoker.jar_excluded_patterns | 471 jar_excluded_patterns = invoker.jar_excluded_patterns |
| 426 } | 472 } |
| 427 build_config = invoker.build_config | 473 build_config = invoker.build_config |
| 428 java_files = invoker.java_files | 474 java_files = invoker.java_files |
| 429 | 475 |
| 430 if (defined(invoker.srcjar_deps)) { | 476 if (defined(invoker.srcjar_deps)) { |
| 431 srcjar_deps = invoker.srcjar_deps | 477 srcjar_deps = invoker.srcjar_deps |
| 432 } | 478 } |
| 433 } | 479 } |
| 434 | 480 |
| 435 # TODO(cjhopman): lint | 481 if (defined(invoker.chromium_code) && invoker.chromium_code) { |
| 436 | 482 _final_deps += [ ":${target_name}__lint" ] |
| 483 android_lint("${target_name}__lint") { |
| 484 android_manifest = _android_manifest |
| 485 jar_path = _jar_path |
| 486 java_files = invoker.java_files |
| 487 } |
| 488 } |
| 437 | 489 |
| 438 dex("${target_name}__dex") { | 490 dex("${target_name}__dex") { |
| 439 sources = [_jar_path] | 491 sources = [_jar_path] |
| 440 output = _dex_path | 492 output = _dex_path |
| 441 } | 493 } |
| 442 | 494 |
| 443 group(target_name) { | 495 group(target_name) { |
| 444 deps = [ | 496 deps = [ |
| 445 ":${target_name}__java_library", | 497 ":${target_name}__java_library", |
| 446 ":${target_name}__dex", | 498 ":${target_name}__dex", |
| 447 ] | 499 ] + _final_deps |
| 448 } | 500 } |
| 449 } | 501 } |
| 450 | 502 |
| 451 | 503 |
| 452 # Runs process_resources.py | 504 # Runs process_resources.py |
| 453 template("process_resources") { | 505 template("process_resources") { |
| 454 zip_path = invoker.zip_path | 506 zip_path = invoker.zip_path |
| 455 srcjar_path = invoker.srcjar_path | 507 srcjar_path = invoker.srcjar_path |
| 456 build_config = invoker.build_config | 508 build_config = invoker.build_config |
| 457 resource_dirs = invoker.resource_dirs | 509 resource_dirs = invoker.resource_dirs |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 "--dest", rebase_path(invoker.dest, root_build_dir), | 597 "--dest", rebase_path(invoker.dest, root_build_dir), |
| 546 ] | 598 ] |
| 547 if (defined(invoker.args)) { | 599 if (defined(invoker.args)) { |
| 548 args += invoker.args | 600 args += invoker.args |
| 549 } | 601 } |
| 550 if (defined(invoker.clear_dir) && invoker.clear_dir) { | 602 if (defined(invoker.clear_dir) && invoker.clear_dir) { |
| 551 args += ["--clear"] | 603 args += ["--clear"] |
| 552 } | 604 } |
| 553 } | 605 } |
| 554 } | 606 } |
| OLD | NEW |