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

Side by Side Diff: build/android/gyp/copy_resources_v17.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 Newton's comment. Investigating warnings. Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
newt (away) 2013/04/26 21:22:24 maybe name this copy_v17_resources.py for consiste
newt (away) 2013/04/26 22:50:47 p.s. if you rename it, do it as a separate patch s
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
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 import optparse
8 import os
9 import sys
10
11 from util import build_utils
12
13
14 def copy_resources_in_dir(input_dir, output_dir):
15 """Copy resources in the directory.
newt (away) 2013/04/26 21:22:24 "Copy all XML resources from input_dir to output_d
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
16 """
17
18 for name in os.listdir(options.res_dir):
19 if not os.path.isfile(name):
20 continue
21
22 if not name.lower().endswith('.xml'):
23 continue
24
25 input_filename = os.path.join(input_dir, name)
26 output_filename = os.path.join(output_dir, name)
27
28 build_utils.MakeDirectory(input_dir)
newt (away) 2013/04/26 21:22:24 it doesn't make sense to create the input director
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
29 build_utils.MakeDirectory(output_dir)
30 build_utils.CopyFile(input_filename, output_filename)
newt (away) 2013/04/26 21:22:24 Did you consider using symlinks here? I believe t
cjhopman 2013/04/26 21:48:47 Ah! please don't use symlinks -- it tends to break
newt (away) 2013/04/26 22:50:47 ok fine :) My preference is to minimize utility f
Kibeom Kim (inactive) 2013/04/27 00:05:07 ok..
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
31
32
33 def ParseArgs():
34 """Parses command line options.
35
36 Returns:
37 An options object as from optparse.OptionsParser.parse_args()
38 """
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='dest directory to be copied.')
newt (away) 2013/04/26 21:22:24 "output directory to which resources will be copie
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
44
45 (options, args) = parser.parse_args()
46
47 if args:
48 parser.error('No positional arguments should be given.')
49
50 # Check that required options have been provided.
51 required_options = ('res_dir', 'res_v17_dir')
52 build_utils.CheckOptions(options, parser, required=required_options)
53 return options
54
55
56 def main(argv):
newt (away) 2013/04/26 21:22:24 we should probably delete the output directory bef
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
57 """Copy resource files and add -v17 to the sub directory names.
58
59 This is coupled with generate_v14_resources.py. Please refer to
60 generate_v14_resources.py's comment for why we are doing this.
61 Or crbug.com/235118 .
62 """
63 options = ParseArgs()
64
65 build_utils.MakeDirectory(options.res_v17_dir)
66
67 for name in os.listdir(options.res_dir):
68 if not os.path.isdir(name):
69 continue
70
71 dir_pieces = name.split('-')
72 resource_type = dir_pieces[0]
73 qualifiers = dir_pieces[1:]
74
75 # We only copy resources under layout*/ and xml*/.
76 if resource_type not in ('layout', 'xml'):
77 continue
78
79 # Skip RTL resources because they are not supported by API 14.
80 if 'ldrtl' in qualifiers:
81 continue
82
83 # Copy all the resource files.
84 input_path = os.path.join(options.res_dir, name)
85 output_path = os.path.join(options.res_v17_dir, name + '-v17')
86 copy_resources_in_dir(input_path, output_path)
87
88
89 if __name__ == '__main__':
90 sys.exit(main(sys.argv))
91
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