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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/java.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/process_resources.py
diff --git a/build/android/process_resources.py b/build/android/process_resources.py
new file mode 100755
index 0000000000000000000000000000000000000000..198bd4299a2ecc3f014a5beb34c8f596b3c88058
--- /dev/null
+++ b/build/android/process_resources.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Process Android library resources to generate R.java and crunched images."""
+
+import optparse
+import os
+import subprocess
+import sys
+
+
+REQUIRED_VARIABLES = ['ANDROID_JAR', 'AAPT', 'DUMMY_MANIFEST', 'RES_DIR',
+ 'CRUNCHED_RES_DIR', 'R_PACKAGE', 'R_DIR']
+
+
+def parse_args():
+ parser = optparse.OptionParser()
+ 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
+ help='define variable NAME to be VALUE',
+ metavar='NAME=VALUE', default=[])
+ (options, args) = parser.parse_args()
+
+ defines = {}
+ for define in options.defines:
+ name, _, value = define.partition('=')
+ if name not in REQUIRED_VARIABLES:
+ parser.error('Unknown variable defined: {0}'.format(name))
+ defines[name] = value
+
+ missing_variables = set(REQUIRED_VARIABLES).difference(defines.keys())
+ if missing_variables:
+ parser.error('No definitions for required variables: {0}'
+ .format(sorted(missing_variables)))
+
+ return defines
+
+
+def main():
+ defines = parse_args()
+
+ # Generate R.java.
+ subprocess.check_call([defines['AAPT'],
+ 'package',
+ '-m',
+ '--non-constant-id',
+ '--custom-package', defines['R_PACKAGE'],
+ '-M', defines['DUMMY_MANIFEST'],
+ '-S', defines['RES_DIR'],
+ '-I', defines['ANDROID_JAR'],
+ '-J', defines['R_DIR']])
+
+ # Crunch image resources.
+ subprocess.check_call([defines['AAPT'],
+ 'crunch',
+ '-S', defines['RES_DIR'],
+ '-C', defines['CRUNCHED_RES_DIR']])
+
+
+if __name__ == '__main__':
+ main()
« 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