OLD | NEW |
---|---|
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 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 self_dir = os.path.dirname(__file__) | 31 self_dir = os.path.dirname(__file__) |
32 classpath = [{classpath}] | 32 classpath = [{classpath}] |
33 bootclasspath = [{bootclasspath}] | 33 bootclasspath = [{bootclasspath}] |
34 extra_program_args = {extra_program_args} | 34 extra_program_args = {extra_program_args} |
35 if os.getcwd() != self_dir: | 35 if os.getcwd() != self_dir: |
36 offset = os.path.relpath(self_dir, os.getcwd()) | 36 offset = os.path.relpath(self_dir, os.getcwd()) |
37 classpath = [os.path.join(offset, p) for p in classpath] | 37 classpath = [os.path.join(offset, p) for p in classpath] |
38 bootclasspath = [os.path.join(offset, p) for p in bootclasspath] | 38 bootclasspath = [os.path.join(offset, p) for p in bootclasspath] |
39 java_cmd = ["java"] | 39 java_cmd = ["java"] |
40 java_cmd.append("-noverify") | |
BigBossZhiling
2016/04/22 21:37:02
Otherwise emma will run into a werid error.
| |
40 if bootclasspath: | 41 if bootclasspath: |
41 java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath)) | 42 java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath)) |
42 java_cmd.extend( | 43 java_cmd.extend( |
43 ["-classpath", ":".join(classpath), "-enableassertions", \"{main_class}\"]) | 44 ["-classpath", ":".join(classpath), "-enableassertions", \"{main_class}\"]) |
44 java_cmd.extend(extra_program_args) | 45 java_cmd.extend(extra_program_args) |
45 java_cmd.extend(sys.argv[1:]) | 46 java_cmd.extend(sys.argv[1:]) |
46 os.execvp("java", java_cmd) | 47 os.execvp("java", java_cmd) |
47 """ | 48 """ |
48 | 49 |
49 def main(argv): | 50 def main(argv): |
50 argv = build_utils.ExpandFileArgs(argv) | 51 argv = build_utils.ExpandFileArgs(argv) |
51 parser = optparse.OptionParser() | 52 parser = optparse.OptionParser() |
52 build_utils.AddDepfileOption(parser) | 53 build_utils.AddDepfileOption(parser) |
53 parser.add_option('--output', help='Output path for executable script.') | 54 parser.add_option('--output', help='Output path for executable script.') |
54 parser.add_option('--jar-path', help='Path to the main jar.') | 55 parser.add_option('--jar-path', help='Path to the main jar.') |
55 parser.add_option('--main-class', | 56 parser.add_option('--main-class', |
56 help='Name of the java class with the "main" entry point.') | 57 help='Name of the java class with the "main" entry point.') |
57 parser.add_option('--classpath', action='append', default=[], | 58 parser.add_option('--classpath', action='append', default=[], |
58 help='Classpath for running the jar.') | 59 help='Classpath for running the jar.') |
59 parser.add_option('--bootclasspath', action='append', default=[], | 60 parser.add_option('--bootclasspath', action='append', default=[], |
60 help='zip/jar files to add to bootclasspath for java cmd.') | 61 help='zip/jar files to add to bootclasspath for java cmd.') |
61 options, extra_program_args = parser.parse_args(argv) | 62 options, extra_program_args = parser.parse_args(argv) |
62 | 63 |
63 classpath = [options.jar_path] | 64 classpath = [options.jar_path] |
64 for cp_arg in options.classpath: | 65 for cp_arg in options.classpath: |
65 classpath += build_utils.ParseGypList(cp_arg) | 66 classpath += build_utils.ParseGypList(cp_arg) |
67 classpath += \ | |
68 ['../../third_party/android_tools_internal/sdk/tools/lib/emma.jar'] | |
BigBossZhiling
2016/04/22 21:37:02
After talking to Andrew, he said that since I don'
jbudorick
2016/04/22 21:38:24
I don't think we should be adding this uncondition
mikecase (-- gone --)
2016/04/22 23:51:45
Do you need this in the classpath when running the
BigBossZhiling
2016/04/23 01:00:55
Yes, we need this classpath when we run the test,
BigBossZhiling
2016/04/26 00:01:46
I took away my change and tried to run junit tests
agrieve
2016/04/26 00:08:01
I meant to hardcode it in the .gni file here:
http
| |
66 | 69 |
67 bootclasspath = [] | 70 bootclasspath = [] |
68 for bootcp_arg in options.bootclasspath: | 71 for bootcp_arg in options.bootclasspath: |
69 bootclasspath += build_utils.ParseGypList(bootcp_arg) | 72 bootclasspath += build_utils.ParseGypList(bootcp_arg) |
70 | 73 |
71 run_dir = os.path.dirname(options.output) | 74 run_dir = os.path.dirname(options.output) |
72 bootclasspath = [os.path.relpath(p, run_dir) for p in bootclasspath] | 75 bootclasspath = [os.path.relpath(p, run_dir) for p in bootclasspath] |
73 classpath = [os.path.relpath(p, run_dir) for p in classpath] | 76 classpath = [os.path.relpath(p, run_dir) for p in classpath] |
mikecase (-- gone --)
2016/04/25 18:36:40
I dont think hard coding the path will work. It ma
| |
74 | 77 |
75 with open(options.output, 'w') as script: | 78 with open(options.output, 'w') as script: |
76 script.write(script_template.format( | 79 script.write(script_template.format( |
77 classpath=('"%s"' % '", "'.join(classpath)), | 80 classpath=('"%s"' % '", "'.join(classpath)), |
78 bootclasspath=('"%s"' % '", "'.join(bootclasspath) | 81 bootclasspath=('"%s"' % '", "'.join(bootclasspath) |
79 if bootclasspath else ''), | 82 if bootclasspath else ''), |
80 main_class=options.main_class, | 83 main_class=options.main_class, |
81 extra_program_args=repr(extra_program_args))) | 84 extra_program_args=repr(extra_program_args))) |
82 | 85 |
83 os.chmod(options.output, 0750) | 86 os.chmod(options.output, 0750) |
84 | 87 |
85 if options.depfile: | 88 if options.depfile: |
86 build_utils.WriteDepfile( | 89 build_utils.WriteDepfile( |
87 options.depfile, | 90 options.depfile, |
88 build_utils.GetPythonDependencies()) | 91 build_utils.GetPythonDependencies()) |
89 | 92 |
90 | 93 |
91 if __name__ == '__main__': | 94 if __name__ == '__main__': |
92 sys.exit(main(sys.argv[1:])) | 95 sys.exit(main(sys.argv[1:])) |
OLD | NEW |