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

Unified Diff: build/android/gyp/manifest.py

Issue 574433003: [Android] JUnit runner + gyp changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@deps-changes
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: build/android/gyp/manifest.py
diff --git a/build/android/gyp/manifest.py b/build/android/gyp/manifest.py
new file mode 100755
index 0000000000000000000000000000000000000000..fbc6bda298cfe766e7b6f8d687f5f16e3897b8bc
--- /dev/null
+++ b/build/android/gyp/manifest.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# Copyright 2014 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.
cjhopman 2014/09/15 22:27:36 Could you add a docstring here (something really s
jbudorick 2014/09/16 02:50:41 Manifest functionality moved into javac.py. Added
+
+import argparse
+import os
+import sys
+
+_MAX_LINE_LEN = 72
+
+def _wrap(str_to_wrap):
+ """Wraps lines according to manifest requirements.
+
+ Java requires that lines in a manifest file be no longer than
+ 72 characters and that wrapped lines begin with a space.
+
+ Args:
+ str_to_wrap: the string to wrap.
+ Returns:
+ The wrapped string.
+ """
+ output = []
cjhopman 2014/09/15 22:27:36 could probably use textwrap return '\r\n'.join(te
jbudorick 2014/09/16 02:50:41 Didn't realize this existed. Nice.
+ for line in str_to_wrap.splitlines():
+ s = ([0] + range(_MAX_LINE_LEN - 2, len(line), _MAX_LINE_LEN - 3)
+ + [len(line)])
+ lsplit = [line[s[i]:s[i+1]] for i in xrange(len(s) - 1)]
+ output.append('\r\n '.join(lsplit))
+ return '\r\n'.join(output)
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Generate a manifest file for a JAR.')
+ parser.add_argument('--main-class', dest='main_class',
cjhopman 2014/09/15 22:27:36 Is there a reason to not just infer dest from the
jbudorick 2014/09/16 02:50:41 Nope. I think I was in the habit of being explicit
+ help='The class containing the main method.')
+ parser.add_argument('--classpath', help='The JAR\'s classpath.')
+ parser.add_argument('--output-file', dest='output_file',
+ help='The output manifest file path.')
+ args = parser.parse_args()
+
+ try:
+ output = ['Manifest-Version: 1.0']
+ if args.main_class:
+ output.append('Main-Class: %s' % args.main_class)
+ if args.classpath:
+ paths = args.classpath.split()
+ sanitized_paths = []
+ for path in paths:
+ sanitized_paths.append(os.path.basename(path.strip('"')))
+ output.append('Class-Path: %s' % ' '.join(sanitized_paths))
+ output.append('Created-By: ')
+ output.append('')
+
+ output = _wrap('\r\n'.join(output))
+
+ if args.output_file:
+ with open(args.output_file, 'w') as f:
+ f.write(output)
+ else:
+ sys.stdout.write(output)
+ except Exception as e:
+ print 'Error while writing JAR manifest file: %s' % str(e)
+ return 1
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
+

Powered by Google App Engine
This is Rietveld 408576698