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

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

Issue 1288023003: Create *_managed targets for android_apk()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add template comments Created 5 years, 4 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 | « no previous file | build/config/android/rules.gni » ('j') | build/config/android/rules.gni » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/android/internal_rules.gni
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni
index c777cf55c73511d903f1622b167e912989606b83..fab1c3bae2850f71cde2c046f81426ed37e71675 100644
--- a/build/config/android/internal_rules.gni
+++ b/build/config/android/internal_rules.gni
@@ -15,6 +15,11 @@ android_sdk_jar = "$android_sdk/android.jar"
rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
android_aapt_path = "$rebased_android_sdk_build_tools/aapt"
+android_configuration_name = "Release"
+if (is_debug) {
+ android_configuration_name = "Debug"
+}
+
template("android_lint") {
set_sources_assignment_filter([])
if (defined(invoker.testonly)) {
@@ -504,6 +509,75 @@ template("process_java_prebuilt") {
}
}
+# Creates an unsigned .apk
+#
+# Variables
+# deps: Specifies the dependencies of this target.
+# dex_path: Path to classes.dex file to include (optional).
+# resource_packaged_apk_path: Path to .ap_ to use.
Dirk Pranke 2015/08/17 21:14:13 is `.ap_` a typo?
agrieve 2015/08/18 14:48:47 Awesomely, no. That's the actual extension chosen
+# output_apk_path: Output path for the generated .apk.
+# native_libs_dir: Directory containing native libraries.
+template("package_apk") {
+ action(target_name) {
+ if (defined(invoker.testonly)) {
+ testonly = invoker.testonly
+ }
+ script = "//build/android/gyp/ant.py"
+ _ant_script = "//build/android/ant/apk-package.xml"
+
+ deps = invoker.deps
+ depfile = "$target_gen_dir/$target_name.d"
+
+ inputs = [
+ invoker.resource_packaged_apk_path,
+ _ant_script,
+ ]
+ if (defined(invoker.dex_path)) {
+ inputs += [ invoker.dex_path ]
+ }
Dirk Pranke 2015/08/17 21:14:13 you can (and should) use forward_variables_f
agrieve 2015/08/18 14:48:47 Done.
+
+ outputs = [
+ depfile,
+ invoker.output_apk_path,
+ ]
+
+ _rebased_emma_jar = ""
+ _rebased_resource_packaged_apk_path =
+ rebase_path(invoker.resource_packaged_apk_path, root_build_dir)
+ _rebased_packaged_apk_path =
+ rebase_path(invoker.output_apk_path, root_build_dir)
+ _rebased_native_libs_dir =
+ rebase_path(invoker.native_libs_dir, root_build_dir)
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--",
+ "-quiet",
+ "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
+ "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
+ "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
+ "-DCONFIGURATION_NAME=$android_configuration_name",
+ "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
+ "-DOUT_DIR=",
+ "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
+ "-DEMMA_INSTRUMENT=0",
+ "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
+ "-Dbasedir=.",
+ "-buildfile",
+ rebase_path(_ant_script, root_build_dir),
+ ]
+ if (defined(invoker.dex_path)) {
+ _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir)
+ args += [
+ "-DDEX_FILE_PATH=$_rebased_dex_path",
+ "-DHAS_CODE=true",
+ ]
+ } else {
+ args += [ "-DHAS_CODE=false" ]
+ }
+ }
+}
+
template("finalize_apk") {
action(target_name) {
script = "//build/android/gyp/finalize_apk.py"
@@ -573,6 +647,10 @@ template("create_apk") {
_android_manifest = invoker.android_manifest
_base_path = invoker.base_path
_final_apk_path = invoker.apk_path
+ _managed_final_apk_path_helper =
+ process_file_template([ _final_apk_path ],
+ "{{source_dir}}/{{source_name_part}}_managed.apk")
+ _managed_final_apk_path = _managed_final_apk_path_helper[0]
if (defined(invoker.resources_zip)) {
_resources_zip = invoker.resources_zip
@@ -603,14 +681,10 @@ template("create_apk") {
_resource_packaged_apk_path = _base_apk_path + ".ap_"
_packaged_apk_path = _base_apk_path + ".unfinished.apk"
+ _managed_packaged_apk_path = _base_apk_path + "_managed.unfinished.apk"
_shared_resources =
defined(invoker.shared_resources) && invoker.shared_resources
- _configuration_name = "Release"
- if (is_debug) {
- _configuration_name = "Debug"
- }
-
_keystore_path = invoker.keystore_path
_keystore_name = invoker.keystore_name
_keystore_password = invoker.keystore_password
@@ -655,7 +729,7 @@ template("create_apk") {
rebased_android_sdk,
"--aapt-path",
android_aapt_path,
- "--configuration-name=$_configuration_name",
+ "--configuration-name=$android_configuration_name",
"--android-manifest",
rebase_path(_android_manifest, root_build_dir),
"--version-code",
@@ -702,63 +776,39 @@ template("create_apk") {
}
package_target = "${target_name}__package"
- action(package_target) {
- script = "//build/android/gyp/ant.py"
- _ant_script = "//build/android/ant/apk-package.xml"
-
+ package_apk(package_target) {
deps = [
":${_package_resources_target_name}",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
- depfile = "$target_gen_dir/$target_name.d"
-
- inputs = [
- _resource_packaged_apk_path,
- _ant_script,
- ]
if (defined(_dex_path)) {
- inputs += [ _dex_path ]
+ dex_path = _dex_path
}
+ native_libs_dir = _native_libs_dir
+ output_apk_path = _packaged_apk_path
+ resource_packaged_apk_path = _resource_packaged_apk_path
+ }
- outputs = [
- depfile,
- _packaged_apk_path,
+ _managed_package_target = "${target_name}_managed__package"
+ package_apk(_managed_package_target) {
+ deps = [
+ ":${_package_resources_target_name}",
]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
Dirk Pranke 2015/08/17 21:14:13 same comment
agrieve 2015/08/18 14:48:47 Done.
+ }
- _rebased_emma_jar = ""
- _rebased_resource_packaged_apk_path =
- rebase_path(_resource_packaged_apk_path, root_build_dir)
- _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir)
- _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir)
- args = [
- "--depfile",
- rebase_path(depfile, root_build_dir),
- "--",
- "-quiet",
- "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
- "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
- "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
- "-DCONFIGURATION_NAME=$_configuration_name",
- "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
- "-DOUT_DIR=",
- "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
- "-DEMMA_INSTRUMENT=0",
- "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
- "-Dbasedir=.",
- "-buildfile",
- rebase_path(_ant_script, root_build_dir),
- ]
+ # TODO(agrieve): Multidex
if (defined(_dex_path)) {
- _rebased_dex_path = rebase_path(_dex_path, root_build_dir)
- args += [
- "-DDEX_FILE_PATH=$_rebased_dex_path",
- "-DHAS_CODE=true",
- ]
- } else {
- args += [ "-DHAS_CODE=false" ]
+ dex_path = _dex_path
}
+
+ # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638
+ native_libs_dir = "//build/android/empty/res"
+ output_apk_path = _managed_packaged_apk_path
+ resource_packaged_apk_path = _resource_packaged_apk_path
}
_finalize_apk_rule_name = "${target_name}__finalize"
@@ -776,7 +826,20 @@ template("create_apk") {
]
}
- _final_deps = [ ":${_finalize_apk_rule_name}" ]
+ _managed_finalize_apk_rule_name = "${target_name}_managed__finalize"
+ finalize_apk(_managed_finalize_apk_rule_name) {
+ input_apk_path = _managed_packaged_apk_path
+ output_apk_path = _managed_final_apk_path
+ keystore_path = _keystore_path
+ keystore_name = _keystore_name
+ keystore_password = _keystore_password
+
+ public_deps = [
+ ":$_managed_package_target",
+ ]
+ }
+
+ _split_deps = []
template("finalize_split") {
finalize_apk(target_name) {
@@ -802,7 +865,7 @@ template("create_apk") {
split_type = "density"
split_config = _split
}
- _final_deps += [ ":$_split_rule" ]
+ _split_deps += [ ":$_split_rule" ]
}
foreach(_split, _split_languages) {
_split_rule = "${target_name}__finalize_${_split}_split"
@@ -810,11 +873,14 @@ template("create_apk") {
split_type = "lang"
split_config = _split
}
- _final_deps += [ ":$_split_rule" ]
+ _split_deps += [ ":$_split_rule" ]
}
group(target_name) {
- public_deps = _final_deps
+ public_deps = [ ":${_finalize_apk_rule_name}" ] + _split_deps
+ }
+ group("${target_name}_managed") {
+ public_deps = [ ":${_managed_finalize_apk_rule_name}" ] + _split_deps
}
}
« no previous file with comments | « no previous file | build/config/android/rules.gni » ('j') | build/config/android/rules.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698