Index: build/config/android/rules.gni |
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni |
index 7bd22b43c34468cb834661a5a0b3f0812c6f46e5..52758cdb165ea33091eb3d9890ee1a397473bdf0 100644 |
--- a/build/config/android/rules.gni |
+++ b/build/config/android/rules.gni |
@@ -680,6 +680,79 @@ template("android_resources") { |
} |
} |
+# Declare an Android assets target. |
+# |
+# Defines a set of files to include as assets in a dependent apk. |
+# |
+# To include these assets in an apk, this target should be listed in |
+# the apk's deps, or in the deps of a library target used by an apk. |
+# |
+# Variables |
+# deps: Specifies the dependencies of this target. Any Android assets |
+# listed in deps will be included by libraries/apks that depend on this |
+# target. |
+# sources: List of files to include as assets. |
+# outputs: List of asset paths to use for the assets. If there are fewer |
+# values than exist in sources, remaining sources will use the default path. |
pkotwicz
2015/10/29 22:57:47
In which cases would this parameter be useful?
If
pkotwicz
2015/10/29 23:23:33
I think that the purpose of outputs parameter is t
agrieve
2015/10/30 00:04:45
I've modelled this after the copy() rule, which al
|
+# disable_compression: Whether to diesable compression for files that are |
+# known to be compressable (default: false). |
+# |
+# Example: |
+# android_assets("content_shell_assets") { |
+# deps = [ |
+# ":generates_foo", |
+# ":other_assets", |
+# ] |
+# sources = [ |
+# "//path/asset1.png", |
+# "//path/asset2.png", |
+# "$target_gen_dir/foo.dat", |
+# ] |
+# outputs = [ |
+# "subdir/asset1.png", |
+# "subdir/asset2.png", |
+# ] |
+# } |
+# |
+# android_assets("overriding_content_shell_assets") { |
+# deps = [ |
+# ":content_shell_assets", |
+# ] |
+# sources = [ |
+# "//custom/foo.dat" # Override foo.dat from content_shell_assets. |
+# ] |
+# } |
+template("android_assets") { |
+ set_sources_assignment_filter([]) |
+ forward_variables_from(invoker, [ "testonly" ]) |
+ |
+ _build_config = "$target_gen_dir/$target_name.build_config" |
+ _build_config_target_name = "${target_name}__build_config" |
+ |
+ write_build_config(_build_config_target_name) { |
+ forward_variables_from(invoker, |
+ [ |
+ "deps", |
+ "disable_compression", |
+ ]) |
+ type = "android_assets" |
+ build_config = _build_config |
+ assets = invoker.sources |
+ if (defined(invoker.outputs)) { |
+ asset_outputs = invoker.outputs |
+ } |
+ } |
+ |
+ group(target_name) { |
+ forward_variables_from(invoker, [ "visibility" ]) |
+ if (invoker.sources != []) { |
+ public_deps = [ |
+ ":$_build_config_target_name", |
+ ] |
+ } |
+ } |
+} |
+ |
# Declare a target that generates localized strings.xml from a .grd file. |
# |
# If this target is included in the deps of an android resources/library/apk, |
@@ -1520,6 +1593,7 @@ template("android_apk") { |
]) |
apk_path = _final_apk_path |
android_manifest = _android_manifest |
+ assets_build_config = _build_config |
resources_zip = _all_resources_zip_path |
dex_path = final_dex_path |
load_library_from_apk = _load_library_from_apk |
@@ -1540,11 +1614,14 @@ template("android_apk") { |
keystore_password = _keystore_password |
# Incremental apk does not use native libs nor final dex. |
- incremental_deps = |
- deps + _android_manifest_deps + [ ":$process_resources_target" ] |
+ incremental_deps = deps + _android_manifest_deps + [ |
+ ":$build_config_target", |
+ ":$process_resources_target", |
+ ] |
# This target generates the input file _all_resources_zip_path. |
deps += _android_manifest_deps + [ |
+ ":$build_config_target", |
":$process_resources_target", |
":$final_dex_target_name", |
] |