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

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

Issue 1965013008: Add directory option for JUnit coverage files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 7 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/android/pylib/junit/test_runner.py » ('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.
11 """ 11 """
12 12
13 import optparse 13 import optparse
14 import os 14 import os
15 import sys 15 import sys
16 16
17 from util import build_utils 17 from util import build_utils
18 18
19 # The java command must be executed in the current directory because there may 19 # The java command must be executed in the current directory because there may
20 # be user-supplied paths in the args. The script receives the classpath relative 20 # be user-supplied paths in the args. The script receives the classpath relative
21 # to the directory that the script is written in and then, when run, must 21 # to the directory that the script is written in and then, when run, must
22 # recalculate the paths relative to the current directory. 22 # recalculate the paths relative to the current directory.
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 argparse
28 import os 29 import os
29 import sys 30 import sys
30 31
31 self_dir = os.path.dirname(__file__) 32 self_dir = os.path.dirname(__file__)
32 classpath = [{classpath}] 33 classpath = [{classpath}]
33 bootclasspath = [{bootclasspath}] 34 bootclasspath = [{bootclasspath}]
34 extra_program_args = {extra_program_args} 35 extra_program_args = {extra_program_args}
35 if os.getcwd() != self_dir: 36 if os.getcwd() != self_dir:
36 offset = os.path.relpath(self_dir, os.getcwd()) 37 offset = os.path.relpath(self_dir, os.getcwd())
37 classpath = [os.path.join(offset, p) for p in classpath] 38 classpath = [os.path.join(offset, p) for p in classpath]
38 bootclasspath = [os.path.join(offset, p) for p in bootclasspath] 39 bootclasspath = [os.path.join(offset, p) for p in bootclasspath]
39 java_cmd = ["java"] 40 java_cmd = ["java"]
41 # This is a simple argparser for jvm and jar arguments.
42 parser = argparse.ArgumentParser()
43 parser.add_argument('--jar-args')
44 parser.add_argument('--jvm-args')
45
46 known_args, unknown_args = parser.parse_known_args(sys.argv[1:])
47 if known_args.jvm_args:
48 jvm_arguments = known_args.jvm_args.strip('"').split()
49 java_cmd.extend(jvm_arguments)
50 if known_args.jar_args:
51 jar_arguments = known_args.jar_args.strip('"').split()
52 if unknown_args:
53 raise Exception('There are unknown arguments')
54 else:
55 jar_arguments = unknown_args
56
40 {noverify_flag} 57 {noverify_flag}
41 if bootclasspath: 58 if bootclasspath:
42 java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath)) 59 java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath))
43 java_cmd.extend( 60 java_cmd.extend(
44 ["-classpath", ":".join(classpath), "-enableassertions", \"{main_class}\"]) 61 ["-classpath", ":".join(classpath), "-enableassertions", \"{main_class}\"])
45 java_cmd.extend(extra_program_args) 62 java_cmd.extend(extra_program_args)
46 java_cmd.extend(sys.argv[1:]) 63 java_cmd.extend(jar_arguments)
47 os.execvp("java", java_cmd) 64 os.execvp("java", java_cmd)
48 """ 65 """
49 66
50 def main(argv): 67 def main(argv):
51 argv = build_utils.ExpandFileArgs(argv) 68 argv = build_utils.ExpandFileArgs(argv)
52 parser = optparse.OptionParser() 69 parser = optparse.OptionParser()
53 build_utils.AddDepfileOption(parser) 70 build_utils.AddDepfileOption(parser)
54 parser.add_option('--output', help='Output path for executable script.') 71 parser.add_option('--output', help='Output path for executable script.')
55 parser.add_option('--jar-path', help='Path to the main jar.') 72 parser.add_option('--jar-path', help='Path to the main jar.')
56 parser.add_option('--main-class', 73 parser.add_option('--main-class',
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 os.chmod(options.output, 0750) 110 os.chmod(options.output, 0750)
94 111
95 if options.depfile: 112 if options.depfile:
96 build_utils.WriteDepfile( 113 build_utils.WriteDepfile(
97 options.depfile, 114 options.depfile,
98 build_utils.GetPythonDependencies()) 115 build_utils.GetPythonDependencies())
99 116
100 117
101 if __name__ == '__main__': 118 if __name__ == '__main__':
102 sys.exit(main(sys.argv[1:])) 119 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/junit/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698