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

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: Fixed one missing dependencies_res_input_dirs renaming 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
7 """Copy resource files and add -v17 to the sub directory names.
cjhopman 2013/05/03 21:23:04 Nit: Copy xml resource files? See comment below.
Kibeom Kim (inactive) 2013/05/03 22:09:57 Done.
8
9 This is coupled with generate_v14_resources.py. Please refer to
10 generate_v14_resources.py's comment for why we are doing this.
11 Or crbug.com/235118 .
cjhopman 2013/05/03 21:23:04 Nit: add http:// (many linkifiers require it).
Kibeom Kim (inactive) 2013/05/03 22:09:57 Done.
12 """
13
14 import optparse
15 import os
16 import shutil
17 import sys
18
19 from util import build_utils
20
21
22 def CopyResourcesInDir(input_dir, output_dir):
cjhopman 2013/05/03 21:23:04 Nit: Maybe rename to CopyXmlResourcesInDir? Or is
Kibeom Kim (inactive) 2013/05/03 22:09:57 Done.
23 """Copy all XML resources from input_dir to output_dir."""
24 for input_file in build_utils.FindInDirectory(input_dir, '*.xml'):
25 output_path = os.path.join(output_dir,
26 os.path.relpath(input_file, input_dir))
27 build_utils.MakeDirectory(os.path.dirname(output_path))
28 shutil.copy2(input_file, output_path)
29
30
31 def ParseArgs():
32 """Parses command line options.
33
34 Returns:
35 An options object as from optparse.OptionsParser.parse_args()
36 """
37 parser = optparse.OptionParser()
38 parser.add_option('--res-dir',
39 help='directory containing resources to be copied')
40 parser.add_option('--res-v17-dir',
41 help='output directory to which resources will be copied.')
42 parser.add_option('--stamp', help='File to touch on success')
43
44 options, args = parser.parse_args()
45
46 if args:
47 parser.error('No positional arguments should be given.')
48
49 # Check that required options have been provided.
50 required_options = ('res_dir', 'res_v17_dir')
51 build_utils.CheckOptions(options, parser, required=required_options)
52 return options
53
54
55 def main(argv):
56 options = ParseArgs()
57
58 build_utils.DeleteDirectory(options.res_v17_dir)
59 build_utils.MakeDirectory(options.res_v17_dir)
60
61 for name in os.listdir(options.res_dir):
62 if not os.path.isdir(os.path.join(options.res_dir, name)):
63 continue
64
65 dir_pieces = name.split('-')
66 resource_type = dir_pieces[0]
67 qualifiers = dir_pieces[1:]
68
69 # We only copy resources under layout*/ and xml*/.
70 if resource_type not in ('layout', 'xml'):
71 continue
72
73 # Skip RTL resources because they are not supported by API 14.
74 if 'ldrtl' in qualifiers:
75 continue
76
77 # Copy all the resource files.
78 input_path = os.path.join(options.res_dir, name)
79 output_path = os.path.join(options.res_v17_dir, name + '-v17')
80 CopyResourcesInDir(input_path, output_path)
81
82 if options.stamp:
83 build_utils.Touch(options.stamp)
84
85 if __name__ == '__main__':
86 sys.exit(main(sys.argv))
87
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