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

Unified Diff: build/config/android/rules.gni

Issue 2156453002: Add AAR support to Chrome and convert support libraries to using AARs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert change in 3p/android_async_task/README.chromium Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | build/secondary/third_party/android_tools/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/android/rules.gni
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index c827830dbc55e72486b788412c8f0b3cf0bc6ddc..35be87bd3d76bd25c55bcf65a4b5c27264f05b10 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -2558,4 +2558,115 @@ if (enable_java_templates) {
]
}
}
+
+ # Declare an Android library target for a prebuilt AAR.
+ #
+ # This target creates an Android library containing java code and Android
+ # resources. For libraries without resources, it will not generate
+ # corresponding android_resources targets.
+ #
+ # Variables
+ # aar_path: Path to the AAR.
+ # TODO(jbudorick@): remove this arguments after crbug.com/522043 is fixed.
+ # requires_android: Whether this target can only be used for compiling Android related targets.
+ #
+ # Example
+ # android_aar_prebuilt("foo_java") {
+ # aar_path = "foo.aar"
+ # }
+ template("android_aar_prebuilt") {
+ assert(defined(invoker.aar_path))
+ _output_path = "${target_gen_dir}/${target_name}"
+ _unpack_target_name = "${target_name}__unpack_aar"
+
+ # Scan the AAR file and determine the resources and jar files.
+ # Some libraries might not have resources; others might have two jars.
+ _scanned_files =
+ exec_script("//build/android/gyp/aar.py",
+ [
+ "--input-file",
+ rebase_path(invoker.aar_path, root_build_dir),
+ "--list",
+ ],
+ "scope")
+
+ action(_unpack_target_name) {
+ script = "//build/android/gyp/aar.py" # Unzips the AAR
+ args = [
+ "--input-file",
+ rebase_path(invoker.aar_path, root_build_dir),
+ "--output-dir",
+ rebase_path(_output_path, root_build_dir),
+ "--extract",
+ ]
+ inputs = [
+ invoker.aar_path,
+ ]
+ outputs = [
+ "${_output_path}/AndroidManifest.xml",
+ ]
+
+ if (_scanned_files.resources != []) {
+ outputs += [ "${_output_path}/R.txt" ]
+ outputs += get_path_info(
+ rebase_path(_scanned_files.resources, "", _output_path),
+ "abspath")
+ }
+ if (defined(_scanned_files.jars)) {
+ outputs +=
+ get_path_info(rebase_path(_scanned_files.jars, "", _output_path),
+ "abspath")
+ }
+ }
+
+ _sub_target_names = []
+
+ # Create android_java_prebuilt targets for jar files.
+ _counter = 0
+ foreach(jar, _scanned_files.jars) {
+ _counter += 1
+ _current_target = "${target_name}__jar_$_counter"
+ _sub_target_names += [ ":$_current_target" ]
+ java_prebuilt(_current_target) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "requires_android",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_unpack_target_name" ]
+ if (!defined(requires_android)) {
+ requires_android = true
+ }
+ supports_android = true
+ jar_path = "${_output_path}/$jar"
+ }
+ }
+
+ # Create the android_resources target for resources.
+ if (_scanned_files.resources != []) {
+ _res_target_name = "${target_name}__res"
+ _sub_target_names += [ ":$_res_target_name" ]
+ android_resources(_res_target_name) {
+ forward_variables_from(invoker, [ "deps" ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_unpack_target_name" ]
+ resource_dirs = []
+ generated_resource_dirs = [ "${_output_path}/res" ]
+ generated_resource_files =
+ rebase_path(_scanned_files.resources, "", _output_path)
+ android_manifest_dep = ":$_unpack_target_name"
+ android_manifest = "${_output_path}/AndroidManifest.xml"
+ v14_skip = true
+ }
+ }
+
+ java_group(target_name) {
+ deps = _sub_target_names
+ }
+ }
}
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | build/secondary/third_party/android_tools/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698