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 | 6 |
7 assert(is_android) | 7 assert(is_android) |
8 | 8 |
9 | 9 |
10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) | 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 if (defined(invoker.args)) { | 140 if (defined(invoker.args)) { |
141 args += invoker.args | 141 args += invoker.args |
142 } | 142 } |
143 | 143 |
144 args += rebase_path(invoker.sources, root_build_dir) | 144 args += rebase_path(invoker.sources, root_build_dir) |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
| 148 # Packages resources, assets, dex, and native libraries into an apk. Signs and |
| 149 # zipaligns the apk. |
| 150 template("create_apk") { |
| 151 _android_manifest = invoker.android_manifest |
| 152 _base_path = invoker.base_path |
| 153 _final_apk_path = invoker.apk_path |
| 154 _resources_zip = invoker.resources_zip |
| 155 _dex_path = invoker.dex_path |
| 156 _keystore_path = invoker.keystore_path |
| 157 _keystore_name = invoker.keystore_name |
| 158 _keystore_password = invoker.keystore_password |
| 159 |
| 160 _deps = [] |
| 161 if (defined(invoker.deps)) { |
| 162 _deps = invoker.deps |
| 163 } |
| 164 |
| 165 _native_libs_dir = "//build/android/empty/res" |
| 166 if (defined(invoker.native_libs_dir)) { |
| 167 _native_libs_dir = invoker.native_libs_dir |
| 168 } |
| 169 |
| 170 _asset_location = "//build/android/empty/res" |
| 171 if (defined(invoker.asset_location)) { |
| 172 _asset_location = invoker.asset_location |
| 173 } |
| 174 |
| 175 _version_code = "0" |
| 176 _version_name = "Developer Build" |
| 177 |
| 178 _base_apk_path = _base_path + ".apk_intermediates" |
| 179 |
| 180 _resource_packaged_apk_path = _base_apk_path + ".ap_" |
| 181 _packaged_apk_path = _base_apk_path + ".unfinished.apk" |
| 182 |
| 183 |
| 184 _configuration_name = "Release" |
| 185 if (is_debug) { |
| 186 _configuration_name = "Debug" |
| 187 } |
| 188 |
| 189 action("${target_name}__package_resources") { |
| 190 deps = _deps |
| 191 |
| 192 script = "//build/android/gyp/package_resources.py" |
| 193 depfile = "${target_gen_dir}/${target_name}.d" |
| 194 source_prereqs = [ |
| 195 _android_manifest, |
| 196 _resources_zip, |
| 197 ] |
| 198 outputs = [depfile, _resource_packaged_apk_path] |
| 199 |
| 200 _rebased_resources_zips = [rebase_path(_resources_zip, root_build_dir)] |
| 201 args = [ |
| 202 "--depfile", rebase_path(depfile, root_build_dir), |
| 203 "--android-sdk", rebased_android_sdk, |
| 204 "--android-sdk-tools", rebased_android_sdk_build_tools, |
| 205 |
| 206 "--configuration-name=$_configuration_name", |
| 207 |
| 208 "--android-manifest", rebase_path(_android_manifest, root_build_dir), |
| 209 "--version-code", _version_code, |
| 210 "--version-name", _version_name, |
| 211 |
| 212 "--asset-dir", rebase_path(_asset_location, root_build_dir), |
| 213 "--resource-zips=$_rebased_resources_zips", |
| 214 |
| 215 "--apk-path", rebase_path(_resource_packaged_apk_path, root_build_dir), |
| 216 ] |
| 217 } |
| 218 |
| 219 action("${target_name}__package") { |
| 220 script = "//build/android/gyp/ant.py" |
| 221 _ant_script = "//build/android/ant/apk-package.xml" |
| 222 |
| 223 depfile = "$target_gen_dir/$target_name.d" |
| 224 |
| 225 source_prereqs = [ |
| 226 _dex_path, |
| 227 _resource_packaged_apk_path, |
| 228 _ant_script |
| 229 ] |
| 230 |
| 231 outputs = [ |
| 232 depfile, |
| 233 _packaged_apk_path, |
| 234 ] |
| 235 |
| 236 _rebased_emma_jar = "" |
| 237 _rebased_resource_packaged_apk_path = rebase_path( |
| 238 _resource_packaged_apk_path, root_build_dir) |
| 239 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir) |
| 240 _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir) |
| 241 _rebased_dex_path = rebase_path(_dex_path, root_build_dir) |
| 242 args = [ |
| 243 "--depfile", rebase_path(depfile, root_build_dir), |
| 244 "--", |
| 245 "-quiet", |
| 246 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root", |
| 247 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools", |
| 248 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path", |
| 249 "-DCONFIGURATION_NAME=$_configuration_name", |
| 250 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir", |
| 251 "-DOUT_DIR=", |
| 252 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path", |
| 253 "-DEMMA_INSTRUMENT=0", |
| 254 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar", |
| 255 "-DDEX_FILE_PATH=$_rebased_dex_path", |
| 256 |
| 257 "-Dbasedir=.", |
| 258 "-buildfile", rebase_path(_ant_script, root_build_dir) |
| 259 ] |
| 260 } |
| 261 |
| 262 action("${target_name}__finalize") { |
| 263 script = "//build/android/gyp/finalize_apk.py" |
| 264 depfile = "$target_gen_dir/$target_name.d" |
| 265 |
| 266 sources = [_packaged_apk_path] |
| 267 source_prereqs = [_keystore_path] |
| 268 outputs = [depfile, _final_apk_path] |
| 269 |
| 270 args = [ |
| 271 "--depfile", rebase_path(depfile, root_build_dir), |
| 272 "--zipalign-path", rebase_path(zipalign_path, root_build_dir), |
| 273 "--unsigned-apk-path", rebase_path(_packaged_apk_path, root_build_dir), |
| 274 "--final-apk-path", rebase_path(_final_apk_path, root_build_dir), |
| 275 "--key-path", rebase_path(_keystore_path, root_build_dir), |
| 276 "--key-name", _keystore_name, |
| 277 "--key-passwd", _keystore_password, |
| 278 ] |
| 279 } |
| 280 |
| 281 group(target_name) { |
| 282 deps = [":${target_name}__finalize"] |
| 283 } |
| 284 } |
| 285 |
148 # Compiles and jars a set of java files. | 286 # Compiles and jars a set of java files. |
149 # | 287 # |
150 # Outputs: | 288 # Outputs: |
151 # $jar_path.jar | 289 # $jar_path.jar |
152 # $jar_path.jar.TOC | 290 # $jar_path.jar.TOC |
153 # | 291 # |
154 # Variables | 292 # Variables |
155 # java_files: List of .java files to compile. | 293 # java_files: List of .java files to compile. |
156 # java_deps: List of java dependencies. These should all have a .jar output | 294 # java_deps: List of java dependencies. These should all have a .jar output |
157 # at "${target_gen_dir}/${target_name}.jar. | 295 # at "${target_gen_dir}/${target_name}.jar. |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 args += [ | 508 args += [ |
371 "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir
) | 509 "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir
) |
372 ] | 510 ] |
373 } | 511 } |
374 | 512 |
375 if (defined(invoker.args)) { | 513 if (defined(invoker.args)) { |
376 args += invoker.args | 514 args += invoker.args |
377 } | 515 } |
378 } | 516 } |
379 } | 517 } |
OLD | NEW |