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

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

Issue 1317853006: GN: Make the wrapper script generated for junit work without extra args (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('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 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 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 """Creates a simple script to run a java "binary". 7 """Creates a simple script to run a java "binary".
8 8
9 This creates a script that sets up the java command line for running a java 9 This creates a script that sets up the java command line for running a java
10 jar. This includes correctly setting the classpath and the main class. 10 jar. This includes correctly setting the classpath and the main class.
(...skipping 12 matching lines...) Expand all
23 script_template = """\ 23 script_template = """\
24 #!/usr/bin/env python 24 #!/usr/bin/env python
25 # 25 #
26 # This file was generated by build/android/gyp/create_java_binary_script.py 26 # This file was generated by build/android/gyp/create_java_binary_script.py
27 27
28 import os 28 import os
29 import sys 29 import sys
30 30
31 self_dir = os.path.dirname(__file__) 31 self_dir = os.path.dirname(__file__)
32 classpath = [{classpath}] 32 classpath = [{classpath}]
33 extra_args = {extra_args}
33 if os.getcwd() != self_dir: 34 if os.getcwd() != self_dir:
34 offset = os.path.relpath(self_dir, os.getcwd()) 35 offset = os.path.relpath(self_dir, os.getcwd())
35 classpath = [os.path.join(offset, p) for p in classpath] 36 classpath = [os.path.join(offset, p) for p in classpath]
36 java_args = [ 37 java_args = [
37 "java", 38 "java",
38 "-classpath", ":".join(classpath), 39 "-classpath", ":".join(classpath),
39 "-enableassertions", 40 "-enableassertions",
40 \"{main_class}\"] + sys.argv[1:] 41 \"{main_class}\"] + extra_args + sys.argv[1:]
41 os.execvp("java", java_args) 42 os.execvp("java", java_args)
42 """ 43 """
43 44
44 def main(argv): 45 def main(argv):
45 argv = build_utils.ExpandFileArgs(argv) 46 argv = build_utils.ExpandFileArgs(argv)
46 parser = optparse.OptionParser() 47 parser = optparse.OptionParser()
47 build_utils.AddDepfileOption(parser) 48 build_utils.AddDepfileOption(parser)
48 parser.add_option('--output', help='Output path for executable script.') 49 parser.add_option('--output', help='Output path for executable script.')
49 parser.add_option('--jar-path', help='Path to the main jar.') 50 parser.add_option('--jar-path', help='Path to the main jar.')
50 parser.add_option('--main-class', 51 parser.add_option('--main-class',
51 help='Name of the java class with the "main" entry point.') 52 help='Name of the java class with the "main" entry point.')
52 parser.add_option('--classpath', action='append', 53 parser.add_option('--classpath', action='append',
53 help='Classpath for running the jar.') 54 help='Classpath for running the jar.')
54 options, _ = parser.parse_args(argv) 55 options, extra_args = parser.parse_args(argv)
55 56
56 classpath = [options.jar_path] 57 classpath = [options.jar_path]
57 for cp_arg in options.classpath: 58 for cp_arg in options.classpath:
58 classpath += build_utils.ParseGypList(cp_arg) 59 classpath += build_utils.ParseGypList(cp_arg)
59 60
60 run_dir = os.path.dirname(options.output) 61 run_dir = os.path.dirname(options.output)
61 classpath = [os.path.relpath(p, run_dir) for p in classpath] 62 classpath = [os.path.relpath(p, run_dir) for p in classpath]
62 63
63 with open(options.output, 'w') as script: 64 with open(options.output, 'w') as script:
64 script.write(script_template.format( 65 script.write(script_template.format(
65 classpath=('"%s"' % '", "'.join(classpath)), 66 classpath=('"%s"' % '", "'.join(classpath)),
66 main_class=options.main_class)) 67 main_class=options.main_class,
68 extra_args=repr(extra_args)))
67 69
68 os.chmod(options.output, 0750) 70 os.chmod(options.output, 0750)
69 71
70 if options.depfile: 72 if options.depfile:
71 build_utils.WriteDepfile( 73 build_utils.WriteDepfile(
72 options.depfile, 74 options.depfile,
73 build_utils.GetPythonDependencies()) 75 build_utils.GetPythonDependencies())
74 76
75 77
76 if __name__ == '__main__': 78 if __name__ == '__main__':
77 sys.exit(main(sys.argv[1:])) 79 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698