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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 # resource_dir - The directory for resources. | 45 # resource_dir - The directory for resources. |
46 # R_package - A custom Java package to generate the resource file R.java in. | 46 # R_package - A custom Java package to generate the resource file R.java in. |
47 # By default, the package given in AndroidManifest.xml will be used. | 47 # By default, the package given in AndroidManifest.xml will be used. |
48 # java_strings_grd - The name of the grd file from which to generate localized | 48 # java_strings_grd - The name of the grd file from which to generate localized |
49 # strings.xml files, if any. | 49 # strings.xml files, if any. |
50 # library_manifest_paths'- Paths to additional AndroidManifest.xml files from | 50 # library_manifest_paths'- Paths to additional AndroidManifest.xml files from |
51 # libraries. | 51 # libraries. |
52 | 52 |
53 { | 53 { |
54 'variables': { | 54 'variables': { |
55 'asset_location%': '', | |
56 'additional_input_paths': [], | 55 'additional_input_paths': [], |
57 'input_jars_paths': [], | 56 'input_jars_paths': [], |
58 'additional_src_dirs': [], | 57 'additional_src_dirs': [], |
59 'generated_src_dirs': [], | 58 'generated_src_dirs': [], |
60 'app_manifest_version_name%': '<(android_app_version_name)', | 59 'app_manifest_version_name%': '<(android_app_version_name)', |
61 'app_manifest_version_code%': '<(android_app_version_code)', | 60 'app_manifest_version_code%': '<(android_app_version_code)', |
62 'proguard_enabled%': 'false', | 61 'proguard_enabled%': 'false', |
63 'proguard_flags%': '', | 62 'proguard_flags_path%': '<(DEPTH)/build/android/empty_proguard.flags', |
64 'native_libs_paths': [], | 63 'native_libs_paths': [], |
65 'jar_name%': 'chromium_apk_<(_target_name).jar', | 64 'jar_name%': 'chromium_apk_<(_target_name).jar', |
66 'resource_dir%':'', | 65 'resource_dir%':'<(DEPTH)/build/android/ant/empty/res', |
67 'R_package%':'', | 66 'R_package%':'', |
68 'additional_res_dirs': [], | 67 'additional_res_dirs': [], |
69 'additional_res_packages': [], | 68 'additional_res_packages': [], |
70 'is_test_apk%': 0, | 69 'is_test_apk%': 0, |
71 'java_strings_grd%': '', | 70 'java_strings_grd%': '', |
72 'grit_grd_file%': '', | 71 'grit_grd_file%': '', |
73 'library_manifest_paths%' : [], | 72 'library_manifest_paths' : [], |
73 'resource_input_paths': [], | |
74 'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)', | |
75 'asset_location%': '<(intermediate_dir)/<(_target_name)/assets', | |
Yaron
2013/03/22 22:32:35
+1 for Shashi's comment
cjhopman
2013/03/25 17:38:01
Done.
| |
76 'codegen_stamp': '<(intermediate_dir)/codegen.stamp', | |
77 'compile_stamp': '<(intermediate_dir)/compile.stamp', | |
78 'android_manifest': '<(java_in_dir)/AndroidManifest.xml', | |
79 'codegen_input_paths': [], | |
74 }, | 80 }, |
75 'sources': [ | 81 'sources': [ |
76 '<@(native_libs_paths)' | 82 '<@(native_libs_paths)' |
77 ], | 83 ], |
78 # Pass the jar path to the apk's "fake" jar target. This would be better as | 84 # Pass the jar path to the apk's "fake" jar target. This would be better as |
79 # direct_dependent_settings, but a variable set by a direct_dependent_settings | 85 # direct_dependent_settings, but a variable set by a direct_dependent_settings |
80 # cannot be lifted in a dependent to all_dependent_settings. | 86 # cannot be lifted in a dependent to all_dependent_settings. |
81 'all_dependent_settings': { | 87 'all_dependent_settings': { |
82 'variables': { | 88 'variables': { |
83 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', | 89 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
84 }, | 90 }, |
85 }, | 91 }, |
86 'rules': [ | 92 'rules': [ |
87 { | 93 { |
88 'rule_name': 'copy_and_strip_native_libraries', | 94 'rule_name': 'copy_and_strip_native_libraries', |
89 'extension': 'so', | 95 'extension': 'so', |
90 'variables': { | 96 'variables': { |
91 'apk_libraries_dir': '<(PRODUCT_DIR)/<(_target_name)/libs/<(android_app_ abi)', | 97 'apk_libraries_dir': '<(intermediate_dir)/libs/<(android_app_abi)', |
92 'stripped_library_path': '<(apk_libraries_dir)/<(RULE_INPUT_ROOT).so', | 98 'stripped_library_path': '<(apk_libraries_dir)/<(RULE_INPUT_ROOT).so', |
93 }, | 99 }, |
94 'inputs': [ | 100 'inputs': [ |
95 '<(DEPTH)/build/android/strip_library_for_apk.py', | 101 '<(DEPTH)/build/android/strip_library_for_apk.py', |
96 ], | 102 ], |
97 'outputs': [ | 103 'outputs': [ |
98 '<(stripped_library_path)', | 104 '<(stripped_library_path)', |
99 ], | 105 ], |
100 'action': [ | 106 'action': [ |
101 'python', '<(DEPTH)/build/android/strip_library_for_apk.py', | 107 'python', '<(DEPTH)/build/android/strip_library_for_apk.py', |
102 '--android-strip=<(android_strip)', | 108 '--android-strip=<(android_strip)', |
103 '--android-strip-arg=--strip-unneeded', | 109 '--android-strip-arg=--strip-unneeded', |
104 '--stripped-libraries-dir=<(apk_libraries_dir)', | 110 '--stripped-libraries-dir=<(apk_libraries_dir)', |
105 '<(RULE_INPUT_PATH)', | 111 '<(RULE_INPUT_PATH)', |
106 ], | 112 ], |
107 }, | 113 }, |
108 ], | 114 ], |
109 'conditions': [ | 115 'conditions': [ |
116 ['resource_dir!=""', { | |
117 'variables': { | |
118 'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ] | |
119 }, | |
120 }], | |
110 ['R_package != ""', { | 121 ['R_package != ""', { |
111 'variables': { | 122 'variables': { |
112 # We generate R.java in package R_package (in addition to the package | 123 # We generate R.java in package R_package (in addition to the package |
113 # listed in the AndroidManifest.xml, which is unavoidable). | 124 # listed in the AndroidManifest.xml, which is unavoidable). |
114 'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'], | 125 'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'], |
115 'additional_res_packages': ['<(R_package)'], | 126 'additional_res_packages': ['<(R_package)'], |
116 'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'], | 127 'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'], |
117 }, | 128 }, |
118 }], | 129 }], |
119 ['java_strings_grd != ""', { | 130 ['java_strings_grd != ""', { |
120 'variables': { | 131 'variables': { |
121 'out_res_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res', | 132 'out_res_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res', |
122 'additional_res_dirs': ['<(out_res_dir)'], | 133 'additional_res_dirs': ['<(out_res_dir)'], |
123 # grit_grd_file is used by grit_action.gypi, included below. | 134 # grit_grd_file is used by grit_action.gypi, included below. |
124 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', | 135 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', |
136 'resource_input_paths': [ | |
137 # TODO(newt): replace this with .../values/strings.xml once | |
138 # the English strings.xml is generated as well? That would be | |
139 # simpler and faster and should be equivalent. | |
140 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(out_res_dir) " <(grit_grd_file))', | |
141 ], | |
125 }, | 142 }, |
126 'actions': [ | 143 'actions': [ |
127 { | 144 { |
128 'action_name': 'generate_localized_strings_xml', | 145 'action_name': 'generate_localized_strings_xml', |
129 'variables': { | 146 'variables': { |
130 'grit_out_dir': '<(out_res_dir)', | 147 'grit_out_dir': '<(out_res_dir)', |
131 # resource_ids is unneeded since we don't generate .h headers. | 148 # resource_ids is unneeded since we don't generate .h headers. |
132 'grit_resource_ids': '', | 149 'grit_resource_ids': '', |
133 }, | 150 }, |
134 'includes': ['../build/grit_action.gypi'], | 151 'includes': ['../build/grit_action.gypi'], |
135 }, | 152 }, |
136 ], | 153 ], |
137 }], | 154 }], |
138 ], | 155 ], |
139 'actions': [ | 156 'actions': [ |
140 { | 157 { |
141 'action_name': 'ant_<(_target_name)', | 158 'action_name': 'ant_codegen_<(_target_name)', |
142 'message': 'Building <(_target_name).', | 159 'message': 'Generating R.java for <(_target_name)', |
143 'inputs': [ | |
144 '<(java_in_dir)/AndroidManifest.xml', | |
145 '<(DEPTH)/build/android/ant/chromium-apk.xml', | |
146 '<(DEPTH)/build/android/ant/common.xml', | |
147 '<(DEPTH)/build/android/ant/apk-build.xml', | |
148 # If there is a separate find for additional_src_dirs, it will find the | |
149 # wrong .java files when additional_src_dirs is empty. | |
150 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | |
151 '>@(input_jars_paths)', | |
152 '>@(native_libs_paths)', | |
153 '>@(additional_input_paths)', | |
154 '>@(library_manifest_paths)', | |
155 ], | |
156 'conditions': [ | 160 'conditions': [ |
157 ['resource_dir!=""', { | |
158 'inputs': ['<!@(find <(java_in_dir)/<(resource_dir) -name "*")'] | |
159 }], | |
160 ['java_strings_grd != ""', { | |
161 'inputs': [ | |
162 # TODO(newt): replace this with .../values/strings.xml once | |
163 # the English strings.xml is generated as well? That would be | |
164 # simpler and faster and should be equivalent. | |
165 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(out_res_di r)" <(grit_grd_file))', | |
166 ], | |
167 }], | |
168 ['is_test_apk == 1', { | 161 ['is_test_apk == 1', { |
169 'variables': { | 162 'variables': { |
170 'additional_res_dirs=': [], | 163 'additional_res_dirs=': [], |
171 'additional_res_packages=': [], | 164 'additional_res_packages=': [], |
172 } | 165 } |
173 }], | 166 }], |
174 ['proguard_enabled == "true" and proguard_flags != ""', { | 167 ], |
175 'inputs': ['<(java_in_dir)/<(proguard_flags)'] | 168 'inputs': [ |
169 '<(DEPTH)/build/android/ant/apk-codegen.xml', | |
170 '<(android_manifest)', | |
171 '>@(library_manifest_paths)' | |
172 '>@(codegen_input_paths)', | |
173 '>@(additional_input_paths)', | |
174 ], | |
175 'outputs': [ | |
176 '<(codegen_stamp)', | |
177 ], | |
178 'action': [ | |
179 'ant', '-quiet', | |
180 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | |
Yaron
2013/03/22 22:32:35
Probably keep common params in the same order so i
cjhopman
2013/03/25 17:38:01
Done. Sorted.
| |
181 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | |
182 '-DANDROID_SDK_JAR=<(android_sdk_jar)', | |
183 '-DOUT_DIR=<(intermediate_dir)', | |
184 '-DRESOURCE_DIR=<(resource_dir)', | |
185 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)', | |
186 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', | |
187 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', | |
188 '-DLIBRARY_MANIFEST_PATHS=>(library_manifest_paths)', | |
189 '-DANDROID_MANIFEST=<(android_manifest)', | |
190 '-DSTAMP=<(codegen_stamp)', | |
191 | |
192 '-Dbasedir=.', | |
193 '-buildfile', | |
194 '<(DEPTH)/build/android/ant/apk-codegen.xml', | |
195 | |
196 # Add list of inputs to the command line, so if inputs change | |
197 # (e.g. if a Java file is removed), the command will be re-run. | |
198 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | |
199 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', | |
200 ], | |
201 }, | |
202 { | |
203 'action_name': 'ant_compile_<(_target_name)', | |
204 'message': 'Compiling java for <(_target_name)', | |
205 'inputs': [ | |
206 '<(DEPTH)/build/android/ant/apk-compile.xml', | |
207 '<(DEPTH)/build/android/ant/create-test-jar.js', | |
208 # If there is a separate find for additional_src_dirs, it will find the | |
209 # wrong .java files when additional_src_dirs is empty. | |
210 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | |
211 '>@(input_jars_paths)', | |
212 '<(codegen_stamp)', | |
213 '<(proguard_flags_path)', | |
214 ], | |
215 'outputs': [ | |
216 '<(compile_stamp)', | |
217 ], | |
218 'action': [ | |
219 'ant', '-quiet', | |
220 '-DOUT_DIR=<(intermediate_dir)', | |
221 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | |
222 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | |
223 '-DANDROID_SDK_JAR=<(android_sdk_jar)', | |
224 '-DANDROID_MANIFEST=<(intermediate_dir)/AndroidManifest.xml', | |
225 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | |
226 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | |
227 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | |
228 '-DSOURCE_DIR=<(java_in_dir)/src', | |
229 '-DPROGUARD_FLAGS=<(proguard_flags_path)', | |
230 '-DPROGUARD_ENABLED=<(proguard_enabled)', | |
231 '-DJAR_PATH=<(PRODUCT_DIR)/lib.java/<(jar_name)', | |
232 '-DIS_TEST_APK=<(is_test_apk)', | |
233 '-DCREATE_TEST_JAR_PATH=<(DEPTH)/build/android/ant/create-test-jar.js', | |
234 '-DAPK_NAME=<(apk_name)', | |
235 | |
236 '-DSTAMP=<(compile_stamp)', | |
237 '-Dbasedir=.', | |
238 '-buildfile', | |
239 '<(DEPTH)/build/android/ant/apk-compile.xml', | |
240 | |
241 # Add list of inputs to the command line, so if inputs change | |
242 # (e.g. if a Java file is removed), the command will be re-run. | |
243 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | |
244 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', | |
245 ], | |
246 }, | |
247 { | |
248 'action_name': 'ant_package_<(_target_name)', | |
249 'message': 'Packaging <(_target_name).', | |
250 'inputs': [ | |
251 '<(DEPTH)/build/android/ant/apk-package.xml', | |
252 '<(java_in_dir)/AndroidManifest.xml', | |
253 #TODO(cjhopman): this should be the stripped library paths. | |
254 '>@(native_libs_paths)', | |
255 '<(codegen_stamp)', | |
256 '<(compile_stamp)', | |
257 ], | |
258 'conditions': [ | |
259 ['is_test_apk == 1', { | |
260 'variables': { | |
261 'additional_res_dirs=': [], | |
262 'additional_res_packages=': [], | |
263 } | |
176 }], | 264 }], |
177 ], | 265 ], |
178 'outputs': [ | 266 'outputs': [ |
179 '<(PRODUCT_DIR)/apks/<(apk_name).apk', | 267 '<(PRODUCT_DIR)/apks/<(apk_name).apk', |
180 ], | 268 ], |
181 'action': [ | 269 'action': [ |
182 'ant', '-quiet', | 270 'ant', '-quiet', |
183 '-DAPP_ABI=<(android_app_abi)', | 271 '-DOUT_DIR=<(intermediate_dir)', |
184 '-DANDROID_GDBSERVER=<(android_gdbserver)', | |
185 '-DANDROID_SDK=<(android_sdk)', | |
186 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | 272 '-DANDROID_SDK_ROOT=<(android_sdk_root)', |
187 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', | |
188 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | 273 '-DANDROID_SDK_VERSION=<(android_sdk_version)', |
189 '-DANDROID_TOOLCHAIN=<(android_toolchain)', | 274 '-DANDROID_SDK_JAR=<(android_sdk_jar)', |
190 '-DCHROMIUM_SRC=<(ant_build_out)/../..', | |
191 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', | 275 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', |
192 '-DPRODUCT_DIR=<(ant_build_out)', | 276 '-DANDROID_MANIFEST=<(intermediate_dir)/AndroidManifest.xml', |
193 | 277 '-DKEYSTORE_PATH=<(DEPTH)/build/android/ant/chromium-debug.keystore', |
194 '-DAPK_NAME=<(apk_name)', | 278 '-DAPK_NAME=<(apk_name)', |
279 '-DAPKS_DIR=<(PRODUCT_DIR)/apks', | |
195 '-DASSET_DIR=<(asset_location)', | 280 '-DASSET_DIR=<(asset_location)', |
196 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | |
197 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | |
198 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | |
199 '-DJAR_NAME=<(jar_name)', | |
200 '-DOUT_DIR=<(ant_build_out)/<(_target_name)', | |
201 '-DRESOURCE_DIR=<(resource_dir)', | 281 '-DRESOURCE_DIR=<(resource_dir)', |
282 '-DSOURCE_DIR=<(java_in_dir)/src', | |
283 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', | |
284 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', | |
202 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)', | 285 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)', |
203 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', | 286 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', |
204 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', | 287 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', |
205 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', | |
206 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', | |
207 '-DPROGUARD_FLAGS=>(proguard_flags)', | |
208 '-DPROGUARD_ENABLED=>(proguard_enabled)', | |
209 '-DLIBRARY_MANIFEST_PATHS=>(library_manifest_paths)', | |
210 | 288 |
211 # Add list of inputs to the command line, so if inputs change | 289 # Add list of inputs to the command line, so if inputs change |
212 # (e.g. if a Java file is removed), the command will be re-run. | 290 # (e.g. if a Java file is removed), the command will be re-run. |
213 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | 291 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. |
214 '-DTHIS_IS_IGNORED=>(_inputs)', | 292 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', |
215 | 293 |
216 '-Dbasedir=<(java_in_dir)', | 294 '-Dbasedir=.', |
217 '-buildfile', | 295 '-buildfile', |
218 '<(DEPTH)/build/android/ant/chromium-apk.xml', | 296 '<(DEPTH)/build/android/ant/apk-package.xml', |
219 | |
220 # Specify CONFIGURATION_NAME as the target for ant to build. The | |
221 # buildfile will then build the appropriate SDK tools target. | |
222 '<(CONFIGURATION_NAME)', | |
223 ] | 297 ] |
224 }, | 298 }, |
225 ], | 299 ], |
226 } | 300 } |
OLD | NEW |