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

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: 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 import sys
13
14
15 REQUIRED_VARIABLES = ['ANDROID_JAR', 'AAPT', 'DUMMY_MANIFEST', 'RES_DIR',
16 'CRUNCHED_RES_DIR', 'R_PACKAGE', 'R_DIR']
17
18
19 def parse_args():
20 parser = optparse.OptionParser()
21 parser.add_option('-D', action='append', dest='defines',
cjhopman 2012/12/11 16:54:29 I'd prefer that each of the required variables wer
22 help='define variable NAME to be VALUE',
23 metavar='NAME=VALUE', default=[])
24 (options, args) = parser.parse_args()
25
26 defines = {}
27 for define in options.defines:
28 name, _, value = define.partition('=')
29 if name not in REQUIRED_VARIABLES:
30 parser.error('Unknown variable defined: {0}'.format(name))
31 defines[name] = value
32
33 missing_variables = set(REQUIRED_VARIABLES).difference(defines.keys())
34 if missing_variables:
35 parser.error('No definitions for required variables: {0}'
36 .format(sorted(missing_variables)))
37
38 return defines
39
40
41 def main():
42 defines = parse_args()
43
44 # Generate R.java.
45 subprocess.check_call([defines['AAPT'],
46 'package',
47 '-m',
48 '--non-constant-id',
49 '--custom-package', defines['R_PACKAGE'],
50 '-M', defines['DUMMY_MANIFEST'],
51 '-S', defines['RES_DIR'],
52 '-I', defines['ANDROID_JAR'],
53 '-J', defines['R_DIR']])
54
55 # Crunch image resources.
56 subprocess.check_call([defines['AAPT'],
57 'crunch',
58 '-S', defines['RES_DIR'],
59 '-C', defines['CRUNCHED_RES_DIR']])
60
61
62 if __name__ == '__main__':
63 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