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

Side by Side Diff: build/java_apk.gypi

Issue 12963009: Split apk-build.xml into 3 steps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 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 unified diff | Download patch
« no previous file with comments | « build/android/empty_proguard.flags ('k') | chrome/chrome_android.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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',
11 # 'type': 'none', 11 # 'type': 'none',
12 # 'variables': { 12 # 'variables': {
13 # 'apk_name': 'MyPackage', 13 # 'apk_name': 'MyPackage',
14 # 'java_in_dir': 'path/to/package/root', 14 # 'java_in_dir': 'path/to/package/root',
15 # 'resource_dir': 'res', 15 # 'resource_dir': 'path/to/package/root/res',
16 # }, 16 # },
17 # 'includes': ['path/to/this/gypi/file'], 17 # 'includes': ['path/to/this/gypi/file'],
18 # } 18 # }
19 # 19 #
20 # Required variables: 20 # Required variables:
21 # apk_name - The final apk will be named <apk_name>.apk 21 # apk_name - The final apk will be named <apk_name>.apk
22 # java_in_dir - The top-level java directory. The src should be in 22 # java_in_dir - The top-level java directory. The src should be in
23 # <(java_in_dir)/src. 23 # <(java_in_dir)/src.
24 # Optional/automatic variables: 24 # Optional/automatic variables:
25 # additional_input_paths - These paths will be included in the 'inputs' list to 25 # additional_input_paths - These paths will be included in the 'inputs' list to
26 # ensure that this target is rebuilt when one of these paths changes. 26 # ensure that this target is rebuilt when one of these paths changes.
27 # additional_res_dirs - Additional directories containing Android resources. 27 # additional_res_dirs - Additional directories containing Android resources.
28 # additional_res_packages - Package names of the R.java files corresponding to 28 # additional_res_packages - Package names of the R.java files corresponding to
29 # each directory in additional_res_dirs. 29 # each directory in additional_res_dirs.
30 # additional_src_dirs - Additional directories with .java files to be compiled 30 # additional_src_dirs - Additional directories with .java files to be compiled
31 # and included in the output of this target. 31 # and included in the output of this target.
32 # asset_location - The directory where assets are located (default: 32 # asset_location - The directory where assets are located.
33 # <(ant_build_out)/<(_target_name)/assets).
34 # generated_src_dirs - Same as additional_src_dirs except used for .java files 33 # generated_src_dirs - Same as additional_src_dirs except used for .java files
35 # that are generated at build time. This should be set automatically by a 34 # that are generated at build time. This should be set automatically by a
36 # target's dependencies. The .java files in these directories are not 35 # target's dependencies. The .java files in these directories are not
37 # included in the 'inputs' list (unlike additional_src_dirs). 36 # included in the 'inputs' list (unlike additional_src_dirs).
38 # input_jars_paths - The path to jars to be included in the classpath. This 37 # input_jars_paths - The path to jars to be included in the classpath. This
39 # should be filled automatically by depending on the appropriate targets. 38 # should be filled automatically by depending on the appropriate targets.
40 # is_test_apk - Set to 1 if building a test apk. This prevents resources from 39 # is_test_apk - Set to 1 if building a test apk. This prevents resources from
41 # dependencies from being re-included. 40 # dependencies from being re-included.
42 # native_libs_paths - The path to any native library to be included in this 41 # native_libs_paths - The path to any native library to be included in this
43 # target. This should be a path in <(SHARED_LIB_DIR). A stripped copy of 42 # target. This should be a path in <(SHARED_LIB_DIR). A stripped copy of
44 # the library will be included in the apk. 43 # the library will be included in the apk.
45 # resource_dir - The directory for resources. 44 # resource_dir - The directory for resources.
46 # R_package - A custom Java package to generate the resource file R.java in. 45 # 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. 46 # 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 47 # java_strings_grd - The name of the grd file from which to generate localized
49 # strings.xml files, if any. 48 # strings.xml files, if any.
50 # library_manifest_paths'- Paths to additional AndroidManifest.xml files from 49 # library_manifest_paths'- Paths to additional AndroidManifest.xml files from
51 # libraries. 50 # libraries.
52 51
53 { 52 {
54 'variables': { 53 'variables': {
55 'asset_location%': '',
56 'additional_input_paths': [], 54 'additional_input_paths': [],
57 'input_jars_paths': [], 55 'input_jars_paths': [],
58 'additional_src_dirs': [], 56 'additional_src_dirs': [],
59 'generated_src_dirs': [], 57 'generated_src_dirs': [],
60 'app_manifest_version_name%': '<(android_app_version_name)', 58 'app_manifest_version_name%': '<(android_app_version_name)',
61 'app_manifest_version_code%': '<(android_app_version_code)', 59 'app_manifest_version_code%': '<(android_app_version_code)',
62 'proguard_enabled%': 'false', 60 'proguard_enabled%': 'false',
63 'proguard_flags%': '', 61 'proguard_flags_path%': '<(DEPTH)/build/android/empty_proguard.flags',
64 'native_libs_paths': [], 62 'native_libs_paths': [],
65 'jar_name%': 'chromium_apk_<(_target_name).jar', 63 'jar_name%': 'chromium_apk_<(_target_name).jar',
66 'resource_dir%':'', 64 'resource_dir%':'<(DEPTH)/build/android/ant/empty/res',
67 'R_package%':'', 65 'R_package%':'',
68 'additional_res_dirs': [], 66 'additional_res_dirs': [],
69 'additional_res_packages': [], 67 'additional_res_packages': [],
70 'is_test_apk%': 0, 68 'is_test_apk%': 0,
71 'java_strings_grd%': '', 69 'java_strings_grd%': '',
72 'res_grit_files': [], 70 'library_manifest_paths' : [],
73 'library_manifest_paths%' : [], 71 'resource_input_paths': [],
72 'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
73 'asset_location%': '<(intermediate_dir)/assets',
74 'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
75 'compile_stamp': '<(intermediate_dir)/compile.stamp',
76 'android_manifest': '<(java_in_dir)/AndroidManifest.xml',
77 'codegen_input_paths': [],
74 }, 78 },
75 'sources': [ 79 'sources': [
76 '<@(native_libs_paths)' 80 '<@(native_libs_paths)'
77 ], 81 ],
78 # Pass the jar path to the apk's "fake" jar target. This would be better as 82 # 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 83 # direct_dependent_settings, but a variable set by a direct_dependent_settings
80 # cannot be lifted in a dependent to all_dependent_settings. 84 # cannot be lifted in a dependent to all_dependent_settings.
81 'all_dependent_settings': { 85 'all_dependent_settings': {
82 'variables': { 86 'variables': {
83 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', 87 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
84 }, 88 },
85 }, 89 },
86 'rules': [ 90 'rules': [
87 { 91 {
88 'rule_name': 'copy_and_strip_native_libraries', 92 'rule_name': 'copy_and_strip_native_libraries',
89 'extension': 'so', 93 'extension': 'so',
90 'variables': { 94 'variables': {
91 'apk_libraries_dir': '<(PRODUCT_DIR)/<(_target_name)/libs/<(android_app_ abi)', 95 'apk_libraries_dir': '<(intermediate_dir)/libs/<(android_app_abi)',
92 'stripped_library_path': '<(apk_libraries_dir)/<(RULE_INPUT_ROOT).so', 96 'stripped_library_path': '<(apk_libraries_dir)/<(RULE_INPUT_ROOT).so',
93 }, 97 },
94 'inputs': [ 98 'inputs': [
95 '<(DEPTH)/build/android/strip_library_for_apk.py', 99 '<(DEPTH)/build/android/strip_library_for_apk.py',
96 ], 100 ],
97 'outputs': [ 101 'outputs': [
98 '<(stripped_library_path)', 102 '<(stripped_library_path)',
99 ], 103 ],
100 'action': [ 104 'action': [
101 'python', '<(DEPTH)/build/android/strip_library_for_apk.py', 105 'python', '<(DEPTH)/build/android/strip_library_for_apk.py',
102 '--android-strip=<(android_strip)', 106 '--android-strip=<(android_strip)',
103 '--android-strip-arg=--strip-unneeded', 107 '--android-strip-arg=--strip-unneeded',
104 '--stripped-libraries-dir=<(apk_libraries_dir)', 108 '--stripped-libraries-dir=<(apk_libraries_dir)',
105 '<(RULE_INPUT_PATH)', 109 '<(RULE_INPUT_PATH)',
106 ], 110 ],
107 }, 111 },
108 ], 112 ],
109 'conditions': [ 113 'conditions': [
114 ['resource_dir!=""', {
115 'variables': {
116 'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
117 },
118 }],
110 ['R_package != ""', { 119 ['R_package != ""', {
111 'variables': { 120 'variables': {
112 # We generate R.java in package R_package (in addition to the package 121 # We generate R.java in package R_package (in addition to the package
113 # listed in the AndroidManifest.xml, which is unavoidable). 122 # listed in the AndroidManifest.xml, which is unavoidable).
114 'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'], 123 'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'],
115 'additional_res_packages': ['<(R_package)'], 124 'additional_res_packages': ['<(R_package)'],
116 'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'], 125 'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'],
117 }, 126 },
118 }], 127 }],
119 ['java_strings_grd != ""', { 128 ['java_strings_grd != ""', {
120 'variables': { 129 'variables': {
121 'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit ', 130 'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit ',
122 'additional_res_dirs': ['<(res_grit_dir)'], 131 'additional_res_dirs': ['<(res_grit_dir)'],
123 # grit_grd_file is used by grit_action.gypi, included below. 132 # grit_grd_file is used by grit_action.gypi, included below.
124 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', 133 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)',
125 'res_grit_files': ['<!@pymod_do_main(grit_info <@(grit_defines) --output s "<(res_grit_dir)" <(grit_grd_file))'], 134 'resource_input_paths': [
135 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir )" <(grit_grd_file))'
136 ],
126 }, 137 },
127 'actions': [ 138 'actions': [
128 { 139 {
129 'action_name': 'generate_localized_strings_xml', 140 'action_name': 'generate_localized_strings_xml',
130 'variables': { 141 'variables': {
131 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'], 142 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'],
132 'grit_out_dir': '<(res_grit_dir)', 143 'grit_out_dir': '<(res_grit_dir)',
133 # resource_ids is unneeded since we don't generate .h headers. 144 # resource_ids is unneeded since we don't generate .h headers.
134 'grit_resource_ids': '', 145 'grit_resource_ids': '',
135 }, 146 },
136 'includes': ['../build/grit_action.gypi'], 147 'includes': ['../build/grit_action.gypi'],
137 }, 148 },
138 ], 149 ],
139 }], 150 }],
140 ], 151 ],
141 'actions': [ 152 'actions': [
142 { 153 {
143 'action_name': 'ant_<(_target_name)', 154 'action_name': 'ant_codegen_<(_target_name)',
144 'message': 'Building <(_target_name).', 155 'message': 'Generating R.java for <(_target_name)',
145 'inputs': [
146 '<(java_in_dir)/AndroidManifest.xml',
147 '<(DEPTH)/build/android/ant/chromium-apk.xml',
148 '<(DEPTH)/build/android/ant/common.xml',
149 '<(DEPTH)/build/android/ant/apk-build.xml',
150 # If there is a separate find for additional_src_dirs, it will find the
151 # wrong .java files when additional_src_dirs is empty.
152 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")',
153 '>@(input_jars_paths)',
154 '>@(native_libs_paths)',
155 '>@(additional_input_paths)',
156 '>@(library_manifest_paths)',
157 '<@(res_grit_files)',
158 ],
159 'conditions': [ 156 'conditions': [
160 ['resource_dir!=""', {
161 'inputs': ['<!@(find <(java_in_dir)/<(resource_dir) -name "*")']
162 }],
163 ['is_test_apk == 1', { 157 ['is_test_apk == 1', {
164 'variables': { 158 'variables': {
165 'additional_res_dirs=': [], 159 'additional_res_dirs=': [],
166 'additional_res_packages=': [], 160 'additional_res_packages=': [],
167 } 161 }
168 }], 162 }],
169 ['proguard_enabled == "true" and proguard_flags != ""', { 163 ],
170 'inputs': ['<(java_in_dir)/<(proguard_flags)'] 164 'inputs': [
165 '<(DEPTH)/build/android/ant/apk-codegen.xml',
166 '<(android_manifest)',
167 '>@(library_manifest_paths)'
168 '>@(codegen_input_paths)',
169 '>@(additional_input_paths)',
170 ],
171 'outputs': [
172 '<(codegen_stamp)',
173 ],
174 'action': [
175 'ant', '-quiet',
176 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)',
177 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)',
178 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
179 '-DANDROID_MANIFEST=<(android_manifest)',
180 '-DANDROID_SDK_JAR=<(android_sdk_jar)',
181 '-DANDROID_SDK_ROOT=<(android_sdk_root)',
182 '-DANDROID_SDK_VERSION=<(android_sdk_version)',
183 '-DLIBRARY_MANIFEST_PATHS=>(library_manifest_paths)',
184 '-DOUT_DIR=<(intermediate_dir)',
185 '-DRESOURCE_DIR=<(resource_dir)',
186
187 '-DSTAMP=<(codegen_stamp)',
188 '-Dbasedir=.',
189 '-buildfile',
190 '<(DEPTH)/build/android/ant/apk-codegen.xml',
191
192 # 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.
194 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
195 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)',
196 ],
197 },
198 {
199 'action_name': 'ant_compile_<(_target_name)',
200 'message': 'Compiling java for <(_target_name)',
201 'inputs': [
202 '<(DEPTH)/build/android/ant/apk-compile.xml',
203 '<(DEPTH)/build/android/ant/create-test-jar.js',
204 # If there is a separate find for additional_src_dirs, it will find the
205 # wrong .java files when additional_src_dirs is empty.
206 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")',
207 '>@(input_jars_paths)',
208 '<(codegen_stamp)',
209 '<(proguard_flags_path)',
210 ],
211 'outputs': [
212 '<(compile_stamp)',
213 ],
214 'action': [
215 'ant', '-quiet',
216 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)',
217 '-DANDROID_SDK_JAR=<(android_sdk_jar)',
218 '-DANDROID_SDK_ROOT=<(android_sdk_root)',
219 '-DANDROID_SDK_VERSION=<(android_sdk_version)',
220 '-DAPK_NAME=<(apk_name)',
221 '-DCREATE_TEST_JAR_PATH=<(DEPTH)/build/android/ant/create-test-jar.js',
222 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)',
223 '-DINPUT_JARS_PATHS=>(input_jars_paths)',
224 '-DIS_TEST_APK=<(is_test_apk)',
225 '-DJAR_PATH=<(PRODUCT_DIR)/lib.java/<(jar_name)',
226 '-DOUT_DIR=<(intermediate_dir)',
227 '-DPROGUARD_ENABLED=<(proguard_enabled)',
228 '-DPROGUARD_FLAGS=<(proguard_flags_path)',
229 '-DSOURCE_DIR=<(java_in_dir)/src',
230 '-DTEST_JAR_PATH=<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar',
231
232 '-DSTAMP=<(compile_stamp)',
233 '-Dbasedir=.',
234 '-buildfile',
235 '<(DEPTH)/build/android/ant/apk-compile.xml',
236
237 # 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.
239 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
240 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)',
241 ],
242 },
243 {
244 'action_name': 'ant_package_<(_target_name)',
245 'message': 'Packaging <(_target_name).',
246 'inputs': [
247 '<(DEPTH)/build/android/ant/apk-package.xml',
248 #TODO(cjhopman): this should be the stripped library paths.
249 '>@(native_libs_paths)',
250 '<(codegen_stamp)',
251 '<(compile_stamp)',
252 ],
253 'conditions': [
254 ['is_test_apk == 1', {
255 'variables': {
256 'additional_res_dirs=': [],
257 'additional_res_packages=': [],
258 }
171 }], 259 }],
172 ], 260 ],
173 'outputs': [ 261 'outputs': [
174 '<(PRODUCT_DIR)/apks/<(apk_name).apk', 262 '<(PRODUCT_DIR)/apks/<(apk_name).apk',
175 ], 263 ],
176 'action': [ 264 'action': [
177 'ant', '-quiet', 265 'ant', '-quiet',
178 '-DAPP_ABI=<(android_app_abi)',
179 '-DANDROID_GDBSERVER=<(android_gdbserver)',
180 '-DANDROID_SDK=<(android_sdk)',
181 '-DANDROID_SDK_ROOT=<(android_sdk_root)',
182 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
183 '-DANDROID_SDK_VERSION=<(android_sdk_version)',
184 '-DANDROID_TOOLCHAIN=<(android_toolchain)',
185 '-DCHROMIUM_SRC=<(ant_build_out)/../..',
186 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
187 '-DPRODUCT_DIR=<(ant_build_out)',
188
189 '-DAPK_NAME=<(apk_name)',
190 '-DASSET_DIR=<(asset_location)',
191 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)',
192 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)',
193 '-DINPUT_JARS_PATHS=>(input_jars_paths)',
194 '-DJAR_NAME=<(jar_name)',
195 '-DOUT_DIR=<(ant_build_out)/<(_target_name)',
196 '-DRESOURCE_DIR=<(resource_dir)',
197 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
198 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', 266 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)',
199 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', 267 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)',
268 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
269 '-DANDROID_SDK_JAR=<(android_sdk_jar)',
270 '-DANDROID_SDK_ROOT=<(android_sdk_root)',
271 '-DANDROID_SDK_VERSION=<(android_sdk_version)',
272 '-DAPKS_DIR=<(PRODUCT_DIR)/apks',
273 '-DAPK_NAME=<(apk_name)',
274 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)',
200 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', 275 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)',
201 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', 276 '-DASSET_DIR=<(asset_location)',
202 '-DPROGUARD_FLAGS=>(proguard_flags)', 277 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
203 '-DPROGUARD_ENABLED=>(proguard_enabled)', 278 '-DKEYSTORE_PATH=<(DEPTH)/build/android/ant/chromium-debug.keystore',
204 '-DLIBRARY_MANIFEST_PATHS=>(library_manifest_paths)', 279 '-DOUT_DIR=<(intermediate_dir)',
280 '-DRESOURCE_DIR=<(resource_dir)',
281 '-DSOURCE_DIR=<(java_in_dir)/src',
282
283 '-Dbasedir=.',
284 '-buildfile',
285 '<(DEPTH)/build/android/ant/apk-package.xml',
205 286
206 # Add list of inputs to the command line, so if inputs change 287 # Add list of inputs to the command line, so if inputs change
207 # (e.g. if a Java file is removed), the command will be re-run. 288 # (e.g. if a Java file is removed), the command will be re-run.
208 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. 289 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
209 '-DTHIS_IS_IGNORED=>(_inputs)', 290 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)',
210 291
211 '-Dbasedir=<(java_in_dir)',
212 '-buildfile',
213 '<(DEPTH)/build/android/ant/chromium-apk.xml',
214
215 # Specify CONFIGURATION_NAME as the target for ant to build. The
216 # buildfile will then build the appropriate SDK tools target.
217 '<(CONFIGURATION_NAME)',
218 ] 292 ]
219 }, 293 },
220 ], 294 ],
221 } 295 }
OLDNEW
« no previous file with comments | « build/android/empty_proguard.flags ('k') | chrome/chrome_android.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698