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

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

Issue 1399343002: Roll Mojo to b88737ed62969ce3203085748f0d53ff4f09ba5b. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « build/android/gyp/package_resources.py ('k') | mojo/services/network/host_resolver_apptest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 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 """Process Android resources to generate R.java, and prepare for packaging. 7 """Process Android resources to generate R.java, and prepare for packaging.
8 8
9 This will crunch images and generate v14 compatible resources 9 This will crunch images and generate v14 compatible resources
10 (see generate_v14_compatible_resources.py). 10 (see generate_v14_compatible_resources.py).
11 """ 11 """
12 12
13 import codecs 13 import codecs
14 import optparse 14 import optparse
15 import os 15 import os
16 import re 16 import re
17 import shutil 17 import shutil
18 import sys 18 import sys
19 import zipfile 19 import zipfile
20 20
21 import generate_v14_compatible_resources 21 import generate_v14_compatible_resources
22 22
23 from util import build_utils 23 from util import build_utils
24 24
25 # Import jinja2 from third_party/jinja2 25 # Import jinja2 from third_party/jinja2
26 sys.path.insert(1, os.path.join( 26 sys.path.insert(1,
27 os.path.dirname(__file__), 27 os.path.join(os.path.dirname(__file__), '../../../third_party'))
28 '../../../third_party/mojo/src/mojo/public/third_party'))
29 from jinja2 import Template # pylint: disable=F0401 28 from jinja2 import Template # pylint: disable=F0401
30 29
31 30
32 def ParseArgs(args): 31 def ParseArgs(args):
33 """Parses command line options. 32 """Parses command line options.
34 33
35 Returns: 34 Returns:
36 An options object as from optparse.OptionsParser.parse_args() 35 An options object as from optparse.OptionsParser.parse_args()
37 """ 36 """
38 parser = optparse.OptionParser() 37 parser = optparse.OptionParser()
39 build_utils.AddDepfileOption(parser) 38 build_utils.AddDepfileOption(parser)
40 39
41 parser.add_option('--android-sdk', help='path to the Android SDK folder') 40 parser.add_option('--android-sdk', help='path to the Android SDK folder')
42 parser.add_option('--android-sdk-tools', 41 parser.add_option('--aapt-path',
43 help='path to the Android SDK build tools folder') 42 help='path to the Android aapt tool')
44 parser.add_option('--non-constant-id', action='store_true') 43 parser.add_option('--non-constant-id', action='store_true')
45 44
46 parser.add_option('--android-manifest', help='AndroidManifest.xml path') 45 parser.add_option('--android-manifest', help='AndroidManifest.xml path')
47 parser.add_option('--custom-package', help='Java package for R.java') 46 parser.add_option('--custom-package', help='Java package for R.java')
48 parser.add_option( 47 parser.add_option(
49 '--shared-resources', 48 '--shared-resources',
50 action='store_true', 49 action='store_true',
51 help='Make a resource package that can be loaded by a different' 50 help='Make a resource package that can be loaded by a different'
52 'application at runtime to access the package\'s resources.') 51 'application at runtime to access the package\'s resources.')
53 52
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 parser.add_option('--stamp', help='File to touch on success') 95 parser.add_option('--stamp', help='File to touch on success')
97 96
98 (options, args) = parser.parse_args(args) 97 (options, args) = parser.parse_args(args)
99 98
100 if args: 99 if args:
101 parser.error('No positional arguments should be given.') 100 parser.error('No positional arguments should be given.')
102 101
103 # Check that required options have been provided. 102 # Check that required options have been provided.
104 required_options = ( 103 required_options = (
105 'android_sdk', 104 'android_sdk',
106 'android_sdk_tools', 105 'aapt_path',
107 'android_manifest', 106 'android_manifest',
108 'dependencies_res_zips', 107 'dependencies_res_zips',
109 'resource_dirs', 108 'resource_dirs',
110 'resource_zip_out', 109 'resource_zip_out',
111 ) 110 )
112 build_utils.CheckOptions(options, parser, required=required_options) 111 build_utils.CheckOptions(options, parser, required=required_options)
113 112
114 if (options.R_dir is None) == (options.srcjar_out is None): 113 if (options.R_dir is None) == (options.srcjar_out is None):
115 raise Exception('Exactly one of --R-dir or --srcjar-out must be specified.') 114 raise Exception('Exactly one of --R-dir or --srcjar-out must be specified.')
116 115
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 for name in inzip.namelist(): 296 for name in inzip.namelist():
298 new_name = '%d/%s' % (i, name) 297 new_name = '%d/%s' % (i, name)
299 outzip.writestr(new_name, inzip.read(name)) 298 outzip.writestr(new_name, inzip.read(name))
300 299
301 300
302 def main(): 301 def main():
303 args = build_utils.ExpandFileArgs(sys.argv[1:]) 302 args = build_utils.ExpandFileArgs(sys.argv[1:])
304 303
305 options = ParseArgs(args) 304 options = ParseArgs(args)
306 android_jar = os.path.join(options.android_sdk, 'android.jar') 305 android_jar = os.path.join(options.android_sdk, 'android.jar')
307 aapt = os.path.join(options.android_sdk_tools, 'aapt') 306 aapt = options.aapt_path
308 307
309 input_files = [] 308 input_files = []
310 309
311 with build_utils.TempDir() as temp_dir: 310 with build_utils.TempDir() as temp_dir:
312 deps_dir = os.path.join(temp_dir, 'deps') 311 deps_dir = os.path.join(temp_dir, 'deps')
313 build_utils.MakeDirectory(deps_dir) 312 build_utils.MakeDirectory(deps_dir)
314 v14_dir = os.path.join(temp_dir, 'v14') 313 v14_dir = os.path.join(temp_dir, 'v14')
315 build_utils.MakeDirectory(v14_dir) 314 build_utils.MakeDirectory(v14_dir)
316 315
317 gen_dir = os.path.join(temp_dir, 'gen') 316 gen_dir = os.path.join(temp_dir, 'gen')
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if options.depfile: 411 if options.depfile:
413 input_files += build_utils.GetPythonDependencies() 412 input_files += build_utils.GetPythonDependencies()
414 build_utils.WriteDepfile(options.depfile, input_files) 413 build_utils.WriteDepfile(options.depfile, input_files)
415 414
416 if options.stamp: 415 if options.stamp:
417 build_utils.Touch(options.stamp) 416 build_utils.Touch(options.stamp)
418 417
419 418
420 if __name__ == '__main__': 419 if __name__ == '__main__':
421 main() 420 main()
OLDNEW
« no previous file with comments | « build/android/gyp/package_resources.py ('k') | mojo/services/network/host_resolver_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698