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 # TODO(jbudorick@): remove this arguments after crbug.com/522043 is fixed. |
| 2571 # requires_android: Whether this target can only be used for compiling Andro
id related targets. |
| 2572 # |
| 2573 # Example |
| 2574 # android_aar_prebuilt("foo_java") { |
| 2575 # aar_path = "foo.aar" |
| 2576 # } |
| 2577 template("android_aar_prebuilt") { |
| 2578 assert(defined(invoker.aar_path)) |
| 2579 _output_path = "${target_gen_dir}/${target_name}" |
| 2580 _unpack_target_name = "${target_name}__unpack_aar" |
| 2581 |
| 2582 # Scan the AAR file and determine the resources and jar files. |
| 2583 # Some libraries might not have resources; others might have two jars. |
| 2584 _scanned_files = |
| 2585 exec_script("//build/android/gyp/aar.py", |
| 2586 [ |
| 2587 "--input-file", |
| 2588 rebase_path(invoker.aar_path, root_build_dir), |
| 2589 "--list", |
| 2590 ], |
| 2591 "scope") |
| 2592 |
| 2593 action(_unpack_target_name) { |
| 2594 script = "//build/android/gyp/aar.py" # Unzips the AAR |
| 2595 args = [ |
| 2596 "--input-file", |
| 2597 rebase_path(invoker.aar_path, root_build_dir), |
| 2598 "--output-dir", |
| 2599 rebase_path(_output_path, root_build_dir), |
| 2600 "--extract", |
| 2601 ] |
| 2602 inputs = [ |
| 2603 invoker.aar_path, |
| 2604 ] |
| 2605 outputs = [ |
| 2606 "${_output_path}/AndroidManifest.xml", |
| 2607 ] |
| 2608 |
| 2609 if (_scanned_files.resources != []) { |
| 2610 outputs += [ "${_output_path}/R.txt" ] |
| 2611 outputs += get_path_info( |
| 2612 rebase_path(_scanned_files.resources, "", _output_path), |
| 2613 "abspath") |
| 2614 } |
| 2615 if (defined(_scanned_files.jars)) { |
| 2616 outputs += |
| 2617 get_path_info(rebase_path(_scanned_files.jars, "", _output_path), |
| 2618 "abspath") |
| 2619 } |
| 2620 } |
| 2621 |
| 2622 _sub_target_names = [] |
| 2623 |
| 2624 # Create android_java_prebuilt targets for jar files. |
| 2625 _counter = 0 |
| 2626 foreach(jar, _scanned_files.jars) { |
| 2627 _counter += 1 |
| 2628 _current_target = "${target_name}__jar_$_counter" |
| 2629 _sub_target_names += [ ":$_current_target" ] |
| 2630 java_prebuilt(_current_target) { |
| 2631 forward_variables_from(invoker, |
| 2632 [ |
| 2633 "deps", |
| 2634 "requires_android", |
| 2635 ]) |
| 2636 if (!defined(deps)) { |
| 2637 deps = [] |
| 2638 } |
| 2639 deps += [ ":$_unpack_target_name" ] |
| 2640 if (!defined(requires_android)) { |
| 2641 requires_android = true |
| 2642 } |
| 2643 supports_android = true |
| 2644 jar_path = "${_output_path}/$jar" |
| 2645 } |
| 2646 } |
| 2647 |
| 2648 # Create the android_resources target for resources. |
| 2649 if (_scanned_files.resources != []) { |
| 2650 _res_target_name = "${target_name}__res" |
| 2651 _sub_target_names += [ ":$_res_target_name" ] |
| 2652 android_resources(_res_target_name) { |
| 2653 forward_variables_from(invoker, [ "deps" ]) |
| 2654 if (!defined(deps)) { |
| 2655 deps = [] |
| 2656 } |
| 2657 deps += [ ":$_unpack_target_name" ] |
| 2658 resource_dirs = [] |
| 2659 generated_resource_dirs = [ "${_output_path}/res" ] |
| 2660 generated_resource_files = |
| 2661 rebase_path(_scanned_files.resources, "", _output_path) |
| 2662 android_manifest_dep = ":$_unpack_target_name" |
| 2663 android_manifest = "${_output_path}/AndroidManifest.xml" |
| 2664 v14_skip = true |
| 2665 } |
| 2666 } |
| 2667 |
| 2668 java_group(target_name) { |
| 2669 deps = _sub_target_names |
| 2670 } |
| 2671 } |
2561 } | 2672 } |
OLD | NEW |