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

Side by Side Diff: build/android/play_services/preprocess.py

Issue 1849403003: [gmscore] Allow specifying resource files to whitelist for preprocess (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 '''Prepares the Google Play services split client libraries before usage by 7 '''Prepares the Google Play services split client libraries before usage by
8 Chrome's build system. 8 Chrome's build system.
9 9
10 We need to preprocess Google Play services before using it in Chrome 10 We need to preprocess Google Play services before using it in Chrome
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 tmp_root = tempfile.mkdtemp() 118 tmp_root = tempfile.mkdtemp()
119 try: 119 try:
120 tmp_paths = _SetupTempDir(tmp_root) 120 tmp_paths = _SetupTempDir(tmp_root)
121 121
122 if is_extracted_repo: 122 if is_extracted_repo:
123 _ImportFromExtractedRepo(config, tmp_paths, repo) 123 _ImportFromExtractedRepo(config, tmp_paths, repo)
124 else: 124 else:
125 _ImportFromAars(config, tmp_paths, repo) 125 _ImportFromAars(config, tmp_paths, repo)
126 126
127 _GenerateCombinedJar(tmp_paths) 127 _GenerateCombinedJar(tmp_paths)
128 _ProcessResources(config, tmp_paths) 128 _ProcessResources(config, tmp_paths, repo)
129 _BuildOutput(config, tmp_paths, out_dir) 129 _BuildOutput(config, tmp_paths, out_dir)
130 finally: 130 finally:
131 shutil.rmtree(tmp_root) 131 shutil.rmtree(tmp_root)
132 132
133 return 0 133 return 0
134 134
135 135
136 def _SetupTempDir(tmp_root): 136 def _SetupTempDir(tmp_root):
137 tmp_paths = { 137 tmp_paths = {
138 'root': tmp_root, 138 'root': tmp_root,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 finally: 192 finally:
193 _MakeWritable(tmp_paths['imported_clients']) 193 _MakeWritable(tmp_paths['imported_clients'])
194 194
195 195
196 def _GenerateCombinedJar(tmp_paths): 196 def _GenerateCombinedJar(tmp_paths):
197 out_file_name = tmp_paths['combined_jar'] 197 out_file_name = tmp_paths['combined_jar']
198 working_dir = tmp_paths['extracted_jars'] 198 working_dir = tmp_paths['extracted_jars']
199 cmd_helper.Call(['jar', '-cf', out_file_name, '-C', working_dir, '.']) 199 cmd_helper.Call(['jar', '-cf', out_file_name, '-C', working_dir, '.'])
200 200
201 201
202 def _ProcessResources(config, tmp_paths): 202 def _ProcessResources(config, tmp_paths, repo):
203 LOCALIZED_VALUES_BASE_NAME = 'values-' 203 LOCALIZED_VALUES_BASE_NAME = 'values-'
204 locale_whitelist = set(config.locale_whitelist) 204 locale_whitelist = set(config.locale_whitelist)
205 205
206 glob_pattern = os.path.join(tmp_paths['imported_clients'], '*', 'res', '*') 206 glob_pattern = os.path.join(tmp_paths['imported_clients'], '*', 'res', '*')
207 for res_dir in glob.glob(glob_pattern): 207 for res_dir in glob.glob(glob_pattern):
208 dir_name = os.path.basename(res_dir) 208 dir_name = os.path.basename(res_dir)
209 209
210 if dir_name.startswith('drawable'): 210 if dir_name.startswith('drawable'):
211 shutil.rmtree(res_dir) 211 shutil.rmtree(res_dir)
212 continue 212 continue
213 213
214 if dir_name.startswith(LOCALIZED_VALUES_BASE_NAME): 214 if dir_name.startswith(LOCALIZED_VALUES_BASE_NAME):
215 dir_locale = dir_name[len(LOCALIZED_VALUES_BASE_NAME):] 215 dir_locale = dir_name[len(LOCALIZED_VALUES_BASE_NAME):]
216 if dir_locale not in locale_whitelist: 216 if dir_locale not in locale_whitelist:
217 shutil.rmtree(res_dir) 217 shutil.rmtree(res_dir)
218 218
219 # Reimport files from the whitelist.
220 for res_path in config.resource_whitelist:
221 rebased_res_path = os.path.join(tmp_paths['imported_clients'], res_path)
222 if not os.path.exists(os.path.dirname(rebased_res_path)):
223 os.makedirs(os.path.dirname(rebased_res_path))
224 shutil.copy(os.path.join(repo, res_path), rebased_res_path)
225
219 226
220 def _BuildOutput(config, tmp_paths, out_dir): 227 def _BuildOutput(config, tmp_paths, out_dir):
221 generation_date = datetime.utcnow() 228 generation_date = datetime.utcnow()
222 version_xml_path = os.path.join(tmp_paths['imported_clients'], 229 version_xml_path = os.path.join(tmp_paths['imported_clients'],
223 config.version_xml_path) 230 config.version_xml_path)
224 play_services_full_version = utils.GetVersionNumberFromLibraryResources( 231 play_services_full_version = utils.GetVersionNumberFromLibraryResources(
225 version_xml_path) 232 version_xml_path)
226 233
227 out_paths = _SetupOutputDir(out_dir) 234 out_paths = _SetupOutputDir(out_dir)
228 235
(...skipping 25 matching lines...) Expand all
254 261
255 config.UpdateVersionNumber(play_services_full_version) 262 config.UpdateVersionNumber(play_services_full_version)
256 263
257 264
258 def _ExtractAll(zip_path, out_path): 265 def _ExtractAll(zip_path, out_path):
259 with zipfile.ZipFile(zip_path, 'r') as zip_file: 266 with zipfile.ZipFile(zip_path, 'r') as zip_file:
260 zip_file.extractall(out_path) 267 zip_file.extractall(out_path)
261 268
262 if __name__ == '__main__': 269 if __name__ == '__main__':
263 sys.exit(main()) 270 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/play_services/utils.py » ('j') | build/android/play_services/utils.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698