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 import("//build/config/android/internal_rules.gni") | 6 import("//build/config/android/internal_rules.gni") |
7 import("//build/toolchain/toolchain.gni") | 7 import("//build/toolchain/toolchain.gni") |
8 | 8 |
9 assert(is_android) | 9 assert(is_android) |
10 | 10 |
(...skipping 2540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2551 | 2551 |
2552 android_library(target_name) { | 2552 android_library(target_name) { |
2553 chromium_code = false | 2553 chromium_code = false |
2554 java_files = [] | 2554 java_files = [] |
2555 srcjar_deps = [ ":${_template_name}__protoc_java" ] | 2555 srcjar_deps = [ ":${_template_name}__protoc_java" ] |
2556 deps = [ | 2556 deps = [ |
2557 "//third_party/android_protobuf:protobuf_nano_javalib", | 2557 "//third_party/android_protobuf:protobuf_nano_javalib", |
2558 ] | 2558 ] |
2559 } | 2559 } |
2560 } | 2560 } |
2561 | |
2562 # Declare an Android library target for a prebuilt AAR. | |
2563 # | |
2564 # This target creates an Android library containing java code and Android | |
2565 # resources. For libraries without resources, it will not generate | |
2566 # corresponding android_resources targets. | |
2567 # | |
2568 # Variables | |
2569 # aar_path: Path to the AAR. | |
2570 # requires_android: Whether this library must be used for compiling Android. Default to true. (Optional) | |
jbudorick
2016/07/19 13:14:06
nit: this gets the requirement backwards -- requir
Ian Wen
2016/07/19 18:36:48
Talked offline. Added todo. Done.
| |
2571 # | |
2572 # Example | |
2573 # android_aar_prebuilt("foo_java") { | |
2574 # aar_path = "foo.aar" | |
2575 # } | |
2576 template("android_aar_prebuilt") { | |
2577 assert(defined(invoker.aar_path)) | |
2578 _output_path = "${target_gen_dir}/${target_name}" | |
2579 _unpack_target_name = "${target_name}__unpack_aar" | |
2580 | |
2581 # Scan the AAR file and determine the resources and jar files. | |
2582 # Some libraries might not have resources; others might have two jars. | |
2583 _scanned_files = | |
2584 exec_script("//build/android/gyp/aar.py", | |
2585 [ | |
2586 "--input-file", | |
2587 rebase_path(invoker.aar_path, root_build_dir), | |
2588 "--list", | |
2589 ], | |
2590 "scope") | |
2591 | |
2592 action(_unpack_target_name) { | |
2593 script = "//build/android/gyp/aar.py" # Unzips the AAR | |
2594 args = [ | |
2595 "--input-file", | |
2596 rebase_path(invoker.aar_path, root_build_dir), | |
2597 "--output-dir", | |
2598 rebase_path(_output_path, root_build_dir), | |
2599 "--extract", | |
2600 ] | |
2601 inputs = [ | |
2602 invoker.aar_path, | |
2603 ] | |
2604 outputs = [ | |
2605 "${_output_path}/AndroidManifest.xml", | |
2606 ] | |
2607 | |
2608 if (_scanned_files.resources != []) { | |
2609 outputs += [ "${_output_path}/R.txt" ] | |
2610 outputs += get_path_info( | |
2611 rebase_path(_scanned_files.resources, "", _output_path), | |
2612 "abspath") | |
2613 } | |
2614 if (defined(_scanned_files.jars)) { | |
2615 outputs += | |
2616 get_path_info(rebase_path(_scanned_files.jars, "", _output_path), | |
2617 "abspath") | |
2618 } | |
2619 } | |
2620 | |
2621 _sub_target_names = [] | |
2622 | |
2623 # Create android_java_prebuilt targets for jar files. | |
2624 _counter = 0 | |
2625 foreach(jar, _scanned_files.jars) { | |
2626 _counter += 1 | |
2627 _current_target = "${target_name}__jar_$_counter" | |
2628 _sub_target_names += [ ":$_current_target" ] | |
2629 java_prebuilt(_current_target) { | |
2630 forward_variables_from(invoker, | |
2631 [ | |
2632 "deps", | |
2633 "requires_android", | |
2634 ]) | |
2635 if (!defined(deps)) { | |
2636 deps = [] | |
2637 } | |
2638 deps += [ ":$_unpack_target_name" ] | |
2639 if (!defined(requires_android)) { | |
2640 requires_android = true | |
2641 } | |
2642 supports_android = true | |
2643 jar_path = "${_output_path}/$jar" | |
2644 } | |
2645 } | |
2646 | |
2647 # Create the android_resources target for resources. | |
2648 if (_scanned_files.resources != []) { | |
2649 _res_target_name = "${target_name}__res" | |
2650 _sub_target_names += [ ":$_res_target_name" ] | |
2651 android_resources(_res_target_name) { | |
2652 forward_variables_from(invoker, [ "deps" ]) | |
2653 if (!defined(deps)) { | |
2654 deps = [] | |
2655 } | |
2656 deps += [ ":$_unpack_target_name" ] | |
2657 resource_dirs = [] | |
2658 generated_resource_dirs = [ "${_output_path}/res" ] | |
2659 generated_resource_files = | |
2660 rebase_path(_scanned_files.resources, "", _output_path) | |
2661 android_manifest_dep = ":$_unpack_target_name" | |
2662 android_manifest = "${_output_path}/AndroidManifest.xml" | |
2663 v14_skip = true | |
2664 } | |
2665 } | |
2666 | |
2667 java_group(target_name) { | |
2668 deps = _sub_target_names | |
2669 } | |
2670 } | |
2561 } | 2671 } |
OLD | NEW |