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

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

Issue 11516024: [Android] Add process_resources.py to build Android library resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use individual options instead of -D Created 8 years 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/java.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
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
5 # found in the LICENSE file.
6
7 """Process Android library resources to generate R.java and crunched images."""
8
9 import optparse
10 import os
11 import subprocess
12
13
14 BUILD_ANDROID_DIR = os.path.dirname(__file__)
15
16
17 def parse_args():
18 parser = optparse.OptionParser()
19 parser.add_option('--android_sdk', help='path to the Android SDK folder')
frankf 2012/12/11 22:27:02 Using both underscore and dash for options names a
newt (away) 2012/12/11 23:55:32 Done.
20 parser.add_option('--android_sdk_tools',
21 help='path to the Android SDK platform tools folder')
22 parser.add_option('--R_package', help='Java package for generated R.java')
23 parser.add_option('--R_dir', help='directory to hold generated R.java')
24 parser.add_option('--res_dir', help='directory containing resources')
25 parser.add_option('--crunched_res_dir',
26 help='directory to hold crunched resources')
27 (options, args) = parser.parse_args()
28
29 if args:
30 parser.error('No positional arguments should be given.')
31
32 # Check that required options have been provided.
33 required_options = ('android_sdk', 'android_sdk_tools', 'R_package',
34 'R_dir', 'res_dir', 'crunched_res_dir')
35 for option_name in required_options:
36 if getattr(options, option_name) is None:
37 parser.error('--%s is required' % option_name)
38
39 return options
40
41
42 def main():
43 options = parse_args()
44 android_jar = os.path.join(options.android_sdk, 'android.jar')
45 aapt = os.path.join(options.android_sdk_tools, 'aapt')
46 dummy_manifest = os.path.join(BUILD_ANDROID_DIR, 'AndroidManifest.xml')
47
48 # Generate R.java. This R.java contains non-final constants and is used only
49 # while compiling the library jar (e.g. chromium_content.jar). When building
50 # an apk, a new R.java file with the correct resource -> ID mappings will be
51 # generated by merging the resources from all libraries and the main apk
52 # project.
53 subprocess.check_call([aapt,
54 'package',
55 '-m',
56 '--non-constant-id',
57 '--custom-package', options.R_package,
58 '-M', dummy_manifest,
59 '-S', options.res_dir,
60 '-I', android_jar,
61 '-J', options.R_dir])
62
63 # Crunch image resources. This shrinks png files and is necessary for 9-patch
64 # images to display correctly.
65 subprocess.check_call([aapt,
66 'crunch',
67 '-S', options.res_dir,
68 '-C', options.crunched_res_dir])
69
70
71 if __name__ == '__main__':
72 main()
OLDNEW
« no previous file with comments | « no previous file | build/java.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698