OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 # This file is meant to be included into a target to provide a rule | 5 # This file is meant to be included into a target to provide a rule |
6 # to build Android APKs in a consistent manner. | 6 # to build Android APKs in a consistent manner. |
7 # | 7 # |
8 # To use this, create a gyp target with the following form: | 8 # To use this, create a gyp target with the following form: |
9 # { | 9 # { |
10 # 'target_name': 'my_package_apk', | 10 # 'target_name': 'my_package_apk', |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 'variables': { | 53 'variables': { |
54 'additional_input_paths': [], | 54 'additional_input_paths': [], |
55 'input_jars_paths': [], | 55 'input_jars_paths': [], |
56 'additional_src_dirs': [], | 56 'additional_src_dirs': [], |
57 'generated_src_dirs': [], | 57 'generated_src_dirs': [], |
58 'app_manifest_version_name%': '<(android_app_version_name)', | 58 'app_manifest_version_name%': '<(android_app_version_name)', |
59 'app_manifest_version_code%': '<(android_app_version_code)', | 59 'app_manifest_version_code%': '<(android_app_version_code)', |
60 'proguard_enabled%': 'false', | 60 'proguard_enabled%': 'false', |
61 'proguard_flags_path%': '<(DEPTH)/build/android/empty_proguard.flags', | 61 'proguard_flags_path%': '<(DEPTH)/build/android/empty_proguard.flags', |
62 'native_libs_paths': [], | 62 'native_libs_paths': [], |
63 'jar_name%': 'chromium_apk_<(_target_name).jar', | 63 'jar_name': 'chromium_apk_<(_target_name).jar', |
64 'resource_dir%':'<(DEPTH)/build/android/ant/empty/res', | 64 'resource_dir%':'<(DEPTH)/build/android/ant/empty/res', |
65 'R_package%':'', | 65 'R_package%':'', |
66 'additional_res_dirs': [], | 66 'additional_res_dirs': [], |
67 'additional_res_packages': [], | 67 'additional_res_packages': [], |
68 'is_test_apk%': 0, | 68 'is_test_apk%': 0, |
69 'java_strings_grd%': '', | 69 'java_strings_grd%': '', |
70 'library_manifest_paths' : [], | 70 'library_manifest_paths' : [], |
71 'resource_input_paths': [], | 71 'resource_input_paths': [], |
72 'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)', | 72 'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)', |
73 'asset_location%': '<(intermediate_dir)/assets', | 73 'asset_location%': '<(intermediate_dir)/assets', |
74 'codegen_stamp': '<(intermediate_dir)/codegen.stamp', | 74 'codegen_stamp': '<(intermediate_dir)/codegen.stamp', |
75 'compile_stamp': '<(intermediate_dir)/compile.stamp', | 75 'compile_stamp': '<(intermediate_dir)/compile.stamp', |
| 76 'jar_stamp': '<(intermediate_dir)/jar.stamp', |
| 77 'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp', |
| 78 'classes_dir': '<(intermediate_dir)/classes', |
| 79 'javac_includes': [], |
| 80 'jar_excluded_classes': [], |
| 81 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
| 82 'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar', |
| 83 'dex_path': '<(intermediate_dir)/classes.dex', |
76 'android_manifest': '<(java_in_dir)/AndroidManifest.xml', | 84 'android_manifest': '<(java_in_dir)/AndroidManifest.xml', |
77 'codegen_input_paths': [], | 85 'codegen_input_paths': [], |
78 }, | 86 }, |
79 'sources': [ | 87 'sources': [ |
80 '<@(native_libs_paths)' | 88 '<@(native_libs_paths)', |
81 ], | 89 ], |
82 # Pass the jar path to the apk's "fake" jar target. This would be better as | 90 # Pass the jar path to the apk's "fake" jar target. This would be better as |
83 # direct_dependent_settings, but a variable set by a direct_dependent_settings | 91 # direct_dependent_settings, but a variable set by a direct_dependent_settings |
84 # cannot be lifted in a dependent to all_dependent_settings. | 92 # cannot be lifted in a dependent to all_dependent_settings. |
85 'all_dependent_settings': { | 93 'all_dependent_settings': { |
86 'variables': { | 94 'variables': { |
87 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', | 95 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
88 }, | 96 }, |
89 }, | 97 }, |
90 'rules': [ | 98 'rules': [ |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 '-buildfile', | 197 '-buildfile', |
190 '<(DEPTH)/build/android/ant/apk-codegen.xml', | 198 '<(DEPTH)/build/android/ant/apk-codegen.xml', |
191 | 199 |
192 # Add list of inputs to the command line, so if inputs change | 200 # Add list of inputs to the command line, so if inputs change |
193 # (e.g. if a Java file is removed), the command will be re-run. | 201 # (e.g. if a Java file is removed), the command will be re-run. |
194 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | 202 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. |
195 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', | 203 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', |
196 ], | 204 ], |
197 }, | 205 }, |
198 { | 206 { |
199 'action_name': 'ant_compile_<(_target_name)', | 207 'action_name': 'javac_<(_target_name)', |
200 'message': 'Compiling java for <(_target_name)', | 208 'message': 'Compiling java for <(_target_name)', |
| 209 'variables': { |
| 210 'all_src_dirs': [ |
| 211 '<(java_in_dir)/src', |
| 212 '<(intermediate_dir)/gen', |
| 213 '>@(additional_src_dirs)', |
| 214 '>@(generated_src_dirs)', |
| 215 ], |
| 216 }, |
201 'inputs': [ | 217 'inputs': [ |
202 '<(DEPTH)/build/android/ant/apk-compile.xml', | 218 '<(DEPTH)/build/android/pylib/build_utils.py', |
203 '<(DEPTH)/build/android/ant/create-test-jar.js', | 219 '<(DEPTH)/build/android/javac.py', |
204 # If there is a separate find for additional_src_dirs, it will find the | 220 # If there is a separate find for additional_src_dirs, it will find the |
205 # wrong .java files when additional_src_dirs is empty. | 221 # wrong .java files when additional_src_dirs is empty. |
206 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | 222 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
207 '>@(input_jars_paths)', | 223 '>@(input_jars_paths)', |
208 '<(codegen_stamp)', | 224 '<(codegen_stamp)', |
209 '<(proguard_flags_path)', | |
210 ], | 225 ], |
211 'outputs': [ | 226 'outputs': [ |
212 '<(compile_stamp)', | 227 '<(compile_stamp)', |
213 ], | 228 ], |
214 'action': [ | 229 'action': [ |
| 230 'python', '<(DEPTH)/build/android/javac.py', |
| 231 '--output-dir=<(classes_dir)', |
| 232 '--classpath=>(input_jars_paths) <(android_sdk_jar)', |
| 233 '--src-dirs=>(all_src_dirs)', |
| 234 '--javac-includes=<(javac_includes)', |
| 235 '--stamp=<(compile_stamp)', |
| 236 |
| 237 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja
. |
| 238 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', |
| 239 ], |
| 240 }, |
| 241 { |
| 242 'action_name': 'jar_<(_target_name)', |
| 243 'message': 'Creating <(_target_name) jar', |
| 244 'inputs': [ |
| 245 '<(DEPTH)/build/android/pylib/build_utils.py', |
| 246 '<(DEPTH)/build/android/jar.py', |
| 247 '<(compile_stamp)', |
| 248 ], |
| 249 'outputs': [ |
| 250 '<(jar_stamp)', |
| 251 ], |
| 252 'action': [ |
| 253 'python', '<(DEPTH)/build/android/jar.py', |
| 254 '--classes-dir=<(classes_dir)', |
| 255 '--jar-path=<(jar_path)', |
| 256 '--excluded-classes=<(jar_excluded_classes)', |
| 257 '--stamp=<(jar_stamp)', |
| 258 |
| 259 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja
. |
| 260 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', |
| 261 ] |
| 262 }, |
| 263 { |
| 264 'action_name': 'ant_obfuscate_<(_target_name)', |
| 265 'message': 'Obfuscating <(_target_name)', |
| 266 'inputs': [ |
| 267 '<(DEPTH)/build/android/ant/apk-obfuscate.xml', |
| 268 '<(DEPTH)/build/android/ant/create-test-jar.js', |
| 269 '<(compile_stamp)', |
| 270 '<(proguard_flags_path)', |
| 271 ], |
| 272 'outputs': [ |
| 273 '<(obfuscate_stamp)', |
| 274 ], |
| 275 'action': [ |
215 'ant', '-quiet', | 276 'ant', '-quiet', |
216 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | 277 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', |
217 '-DANDROID_SDK_JAR=<(android_sdk_jar)', | 278 '-DANDROID_SDK_JAR=<(android_sdk_jar)', |
218 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | 279 '-DANDROID_SDK_ROOT=<(android_sdk_root)', |
219 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | 280 '-DANDROID_SDK_VERSION=<(android_sdk_version)', |
220 '-DAPK_NAME=<(apk_name)', | 281 '-DAPK_NAME=<(apk_name)', |
221 '-DCREATE_TEST_JAR_PATH=<(DEPTH)/build/android/ant/create-test-jar.js', | 282 '-DCREATE_TEST_JAR_PATH=<(DEPTH)/build/android/ant/create-test-jar.js', |
222 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | 283 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
223 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | 284 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
224 '-DIS_TEST_APK=<(is_test_apk)', | 285 '-DIS_TEST_APK=<(is_test_apk)', |
225 '-DJAR_PATH=<(PRODUCT_DIR)/lib.java/<(jar_name)', | 286 '-DJAR_PATH=<(PRODUCT_DIR)/lib.java/<(jar_name)', |
| 287 '-DOBFUSCATED_JAR_PATH=<(obfuscated_jar_path)', |
226 '-DOUT_DIR=<(intermediate_dir)', | 288 '-DOUT_DIR=<(intermediate_dir)', |
227 '-DPROGUARD_ENABLED=<(proguard_enabled)', | 289 '-DPROGUARD_ENABLED=<(proguard_enabled)', |
228 '-DPROGUARD_FLAGS=<(proguard_flags_path)', | 290 '-DPROGUARD_FLAGS=<(proguard_flags_path)', |
229 '-DSOURCE_DIR=<(java_in_dir)/src', | |
230 '-DTEST_JAR_PATH=<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar', | 291 '-DTEST_JAR_PATH=<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar', |
231 | 292 |
232 '-DSTAMP=<(compile_stamp)', | 293 '-DSTAMP=<(obfuscate_stamp)', |
233 '-Dbasedir=.', | 294 '-Dbasedir=.', |
234 '-buildfile', | 295 '-buildfile', |
235 '<(DEPTH)/build/android/ant/apk-compile.xml', | 296 '<(DEPTH)/build/android/ant/apk-obfuscate.xml', |
236 | 297 |
237 # Add list of inputs to the command line, so if inputs change | 298 # Add list of inputs to the command line, so if inputs change |
238 # (e.g. if a Java file is removed), the command will be re-run. | 299 # (e.g. if a Java file is removed), the command will be re-run. |
239 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | 300 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. |
240 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', | 301 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', |
241 ], | 302 ], |
242 }, | 303 }, |
243 { | 304 { |
| 305 'action_name': 'dex_<(_target_name)', |
| 306 'message': 'Dexing <(_target_name) jar', |
| 307 'variables': { |
| 308 'conditions': [ |
| 309 ['proguard_enabled==1', { |
| 310 'dex_inputs': [ '<(obfuscated_jar_path)' ], |
| 311 'dex_generated_inputs': [], |
| 312 }, { |
| 313 'dex_inputs': [ |
| 314 '>@(input_jars_paths)', |
| 315 ], |
| 316 'dex_generated_inputs': [ |
| 317 '<(classes_dir)', |
| 318 ], |
| 319 }], |
| 320 ], |
| 321 }, |
| 322 'inputs': [ |
| 323 '<(DEPTH)/build/android/pylib/build_utils.py', |
| 324 '<(DEPTH)/build/android/dex.py', |
| 325 '<(compile_stamp)', |
| 326 '>@(dex_inputs)', |
| 327 ], |
| 328 'outputs': [ |
| 329 '<(dex_path)', |
| 330 ], |
| 331 'action': [ |
| 332 'python', '<(DEPTH)/build/android/dex.py', |
| 333 '--dex-path=<(dex_path)', |
| 334 '--android-sdk-root=<(android_sdk_root)', |
| 335 |
| 336 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja
. |
| 337 '--ignore=>!(echo >(_inputs) | md5sum)', |
| 338 |
| 339 '>@(dex_inputs)', |
| 340 '>@(dex_generated_inputs)', |
| 341 ] |
| 342 }, |
| 343 { |
244 'action_name': 'ant_package_<(_target_name)', | 344 'action_name': 'ant_package_<(_target_name)', |
245 'message': 'Packaging <(_target_name).', | 345 'message': 'Packaging <(_target_name).', |
246 'inputs': [ | 346 'inputs': [ |
247 '<(DEPTH)/build/android/ant/apk-package.xml', | 347 '<(DEPTH)/build/android/ant/apk-package.xml', |
248 #TODO(cjhopman): this should be the stripped library paths. | 348 #TODO(cjhopman): this should be the stripped library paths. |
249 '>@(native_libs_paths)', | 349 '>@(native_libs_paths)', |
| 350 '<(dex_path)', |
250 '<(codegen_stamp)', | 351 '<(codegen_stamp)', |
251 '<(compile_stamp)', | 352 '<(obfuscate_stamp)', |
252 ], | 353 ], |
253 'conditions': [ | 354 'conditions': [ |
254 ['is_test_apk == 1', { | 355 ['is_test_apk == 1', { |
255 'variables': { | 356 'variables': { |
256 'additional_res_dirs=': [], | 357 'additional_res_dirs=': [], |
257 'additional_res_packages=': [], | 358 'additional_res_packages=': [], |
258 } | 359 } |
259 }], | 360 }], |
260 ], | 361 ], |
261 'outputs': [ | 362 'outputs': [ |
(...skipping 24 matching lines...) Expand all Loading... |
286 | 387 |
287 # Add list of inputs to the command line, so if inputs change | 388 # Add list of inputs to the command line, so if inputs change |
288 # (e.g. if a Java file is removed), the command will be re-run. | 389 # (e.g. if a Java file is removed), the command will be re-run. |
289 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | 390 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. |
290 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', | 391 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', |
291 | 392 |
292 ] | 393 ] |
293 }, | 394 }, |
294 ], | 395 ], |
295 } | 396 } |
OLD | NEW |