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

Side by Side Diff: build/android/gyp/generate_v14_compatible_resources.py

Issue 314363002: Revert of Add creation of v14 compatible resources to process_resources.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/gyp/process_resources.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 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 """Convert Android xml resources to API 14 compatible. 7 """Convert Android xml resources to API 14 compatible.
8 8
9 There are two reasons that we cannot just use API 17 attributes, 9 There are two reasons that we cannot just use API 17 attributes,
10 so we are generating another set of resources by this script. 10 so we are generating another set of resources by this script.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 options, args = parser.parse_args() 273 options, args = parser.parse_args()
274 274
275 if args: 275 if args:
276 parser.error('No positional arguments should be given.') 276 parser.error('No positional arguments should be given.')
277 277
278 # Check that required options have been provided. 278 # Check that required options have been provided.
279 required_options = ('res_dir', 'res_v14_compatibility_dir') 279 required_options = ('res_dir', 'res_v14_compatibility_dir')
280 build_utils.CheckOptions(options, parser, required=required_options) 280 build_utils.CheckOptions(options, parser, required=required_options)
281 return options 281 return options
282 282
283 def GenerateV14Resources(res_dir, res_v14_dir, verify_only):
284 build_utils.DeleteDirectory(res_v14_dir)
285 build_utils.MakeDirectory(res_v14_dir)
286 283
287 for name in os.listdir(res_dir): 284 def main():
288 if not os.path.isdir(os.path.join(res_dir, name)): 285 options = ParseArgs()
286
287 build_utils.DeleteDirectory(options.res_v14_compatibility_dir)
288 build_utils.MakeDirectory(options.res_v14_compatibility_dir)
289
290 for name in os.listdir(options.res_dir):
291 if not os.path.isdir(os.path.join(options.res_dir, name)):
289 continue 292 continue
290 293
291 dir_pieces = name.split('-') 294 dir_pieces = name.split('-')
292 resource_type = dir_pieces[0] 295 resource_type = dir_pieces[0]
293 qualifiers = dir_pieces[1:] 296 qualifiers = dir_pieces[1:]
294 297
295 api_level_qualifier_index = -1 298 api_level_qualifier_index = -1
296 api_level_qualifier = '' 299 api_level_qualifier = ''
297 for index, qualifier in enumerate(qualifiers): 300 for index, qualifier in enumerate(qualifiers):
298 if re.match('v[0-9]+$', qualifier): 301 if re.match('v[0-9]+$', qualifier):
299 api_level_qualifier_index = index 302 api_level_qualifier_index = index
300 api_level_qualifier = qualifier 303 api_level_qualifier = qualifier
301 break 304 break
302 305
303 # Android pre-v17 API doesn't support RTL. Skip. 306 # Android pre-v17 API doesn't support RTL. Skip.
304 if 'ldrtl' in qualifiers: 307 if 'ldrtl' in qualifiers:
305 continue 308 continue
306 309
307 input_dir = os.path.abspath(os.path.join(res_dir, name)) 310 input_dir = os.path.abspath(os.path.join(options.res_dir, name))
308 311
309 if verify_only: 312 if options.verify_only:
310 if not api_level_qualifier or int(api_level_qualifier[1:]) < 17: 313 if not api_level_qualifier or int(api_level_qualifier[1:]) < 17:
311 VerifyV14ResourcesInDir(input_dir, resource_type) 314 VerifyV14ResourcesInDir(input_dir, resource_type)
312 else: 315 else:
313 AssertNoDeprecatedAttributesInDir(input_dir, resource_type) 316 AssertNoDeprecatedAttributesInDir(input_dir, resource_type)
314 else: 317 else:
315 # We also need to copy the original v17 resource to *-v17 directory 318 # We also need to copy the original v17 resource to *-v17 directory
316 # because the generated v14 resource will hide the original resource. 319 # because the generated v14 resource will hide the original resource.
317 output_v14_dir = os.path.join(res_v14_dir, name) 320 output_v14_dir = os.path.join(options.res_v14_compatibility_dir, name)
318 output_v17_dir = os.path.join(res_v14_dir, name + '-v17') 321 output_v17_dir = os.path.join(options.res_v14_compatibility_dir, name +
322 '-v17')
319 323
320 # We only convert layout resources under layout*/, xml*/, 324 # We only convert layout resources under layout*/, xml*/,
321 # and style resources under values*/. 325 # and style resources under values*/.
322 if resource_type in ('layout', 'xml'): 326 if resource_type in ('layout', 'xml'):
323 if not api_level_qualifier: 327 if not api_level_qualifier:
324 GenerateV14LayoutResourcesInDir(input_dir, output_v14_dir, 328 GenerateV14LayoutResourcesInDir(input_dir, output_v14_dir,
325 output_v17_dir) 329 output_v17_dir)
326 elif resource_type == 'values': 330 elif resource_type == 'values':
327 if api_level_qualifier == 'v17': 331 if api_level_qualifier == 'v17':
328 output_qualifiers = qualifiers[:] 332 output_qualifiers = qualifiers[:]
329 del output_qualifiers[api_level_qualifier_index] 333 del output_qualifiers[api_level_qualifier_index]
330 output_v14_dir = os.path.join(res_v14_dir, 334 output_v14_dir = os.path.join(options.res_v14_compatibility_dir,
331 '-'.join([resource_type] + 335 '-'.join([resource_type] +
332 output_qualifiers)) 336 output_qualifiers))
333 GenerateV14StyleResourcesInDir(input_dir, output_v14_dir) 337 GenerateV14StyleResourcesInDir(input_dir, output_v14_dir)
334 elif not api_level_qualifier: 338 elif not api_level_qualifier:
335 ErrorIfStyleResourceExistsInDir(input_dir) 339 ErrorIfStyleResourceExistsInDir(input_dir)
336 340
337 def main():
338 options = ParseArgs()
339
340 GenerateV14Resources(
341 options.res_dir, options.res_v14_compatibility_dir, options.verify_only)
342
343 if options.stamp: 341 if options.stamp:
344 build_utils.Touch(options.stamp) 342 build_utils.Touch(options.stamp)
345 343
346 if __name__ == '__main__': 344 if __name__ == '__main__':
347 sys.exit(main()) 345 sys.exit(main())
348 346
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/process_resources.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698