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

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

Issue 14476011: [Android] Auto-generate API 14 resources from the existing API 17 resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Excluded v17/v14/crunch resources from process_resources.py and included only at apk resource packa… Created 7 years, 7 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
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
5 # found in the LICENSE file.
6 """Copy resource files and add -v17 to the sub directory names.
newt (away) 2013/05/03 20:16:16 empty line before docstring
Kibeom Kim (inactive) 2013/05/03 20:34:57 Done.
7
8 This is coupled with generate_v14_resources.py. Please refer to
9 generate_v14_resources.py's comment for why we are doing this.
10 Or crbug.com/235118 .
11 """
12
13 import optparse
14 import os
15 import shutil
16 import sys
17
18 from util import build_utils
19
20
21 def CopyResourcesInDir(input_dir, output_dir):
22 """Copy all XML resources from input_dir to output_dir
newt (away) 2013/05/03 20:16:16 period and closing quotes at the end of the line
Kibeom Kim (inactive) 2013/05/03 20:34:57 Done.
23 """
24
newt (away) 2013/05/03 20:16:16 don't need an empty line after docstring
Kibeom Kim (inactive) 2013/05/03 20:34:57 Done.
25 for input_file in build_utils.FindInDirectory(input_dir, '*.xml'):
26 output_path = os.path.join(output_dir,
27 os.path.relpath(input_file, input_dir))
28 build_utils.MakeDirectory(os.path.dirname(output_path))
29 shutil.copy2(input_file, output_path)
30
31
32 def ParseArgs():
33 """Parses command line options.
34
35 Returns:
36 An options object as from optparse.OptionsParser.parse_args()
37 """
38
newt (away) 2013/05/03 20:16:16 don't need an empty line after docstring
Kibeom Kim (inactive) 2013/05/03 20:34:57 Done.
39 parser = optparse.OptionParser()
40 parser.add_option('--res-dir',
41 help='directory containing resources to be copied')
42 parser.add_option('--res-v17-dir',
43 help='output directory to which resources will be copied.')
44 parser.add_option('--stamp', help='File to touch on success')
45
46 options, args = parser.parse_args()
47
48 if args:
49 parser.error('No positional arguments should be given.')
50
51 # Check that required options have been provided.
52 required_options = ('res_dir', 'res_v17_dir')
53 build_utils.CheckOptions(options, parser, required=required_options)
54 return options
55
56
57 def main(argv):
58 options = ParseArgs()
59
60 build_utils.DeleteDirectory(options.res_v17_dir)
61 build_utils.MakeDirectory(options.res_v17_dir)
62
63 for name in os.listdir(options.res_dir):
64 if not os.path.isdir(os.path.join(options.res_dir, name)):
65 continue
66
67 dir_pieces = name.split('-')
68 resource_type = dir_pieces[0]
69 qualifiers = dir_pieces[1:]
70
71 # We only copy resources under layout*/ and xml*/.
72 if resource_type not in ('layout', 'xml'):
73 continue
74
75 # Skip RTL resources because they are not supported by API 14.
76 if 'ldrtl' in qualifiers:
77 continue
78
79 # Copy all the resource files.
80 input_path = os.path.join(options.res_dir, name)
81 output_path = os.path.join(options.res_v17_dir, name + '-v17')
82 CopyResourcesInDir(input_path, output_path)
83
84 if options.stamp:
85 build_utils.Touch(options.stamp)
86
87 if __name__ == '__main__':
88 sys.exit(main(sys.argv))
89
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/generate_v14_resources.py » ('j') | build/android/gyp/generate_v14_resources.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698