Chromium Code Reviews| 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 # JVM argumments have prefix JVM. | |
|
jbudorick
2016/05/09 21:13:40
Let's try something a little different here:
- us
| |
| 41 jvm_arguments = [ x[3:] for x in sys.argv[1:] if x.startswith('JVM')] | |
|
mikecase (-- gone --)
2016/05/09 21:11:46
What does this 3 mean?
BigBossZhiling
2016/05/09 21:14:19
JVM arguments start with JVM to differentiate betw
| |
| 42 jar_arguments = [ x for x in sys.argv[1:] if not x.startswith('JVM')] | |
| 43 java_cmd.extend(jvm_arguments) | |
| 40 {noverify_flag} | 44 {noverify_flag} |
| 41 if bootclasspath: | 45 if bootclasspath: |
| 42 java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath)) | 46 java_cmd.append("-Xbootclasspath/p:" + ":".join(bootclasspath)) |
| 43 java_cmd.extend( | 47 java_cmd.extend( |
| 44 ["-classpath", ":".join(classpath), "-enableassertions", \"{main_class}\"]) | 48 ["-classpath", ":".join(classpath), "-enableassertions", \"{main_class}\"]) |
| 45 java_cmd.extend(extra_program_args) | 49 java_cmd.extend(extra_program_args) |
| 46 java_cmd.extend(sys.argv[1:]) | 50 java_cmd.extend(jar_arguments) |
| 47 os.execvp("java", java_cmd) | 51 os.execvp("java", java_cmd) |
| 48 """ | 52 """ |
| 49 | 53 |
| 50 def main(argv): | 54 def main(argv): |
| 51 argv = build_utils.ExpandFileArgs(argv) | 55 argv = build_utils.ExpandFileArgs(argv) |
| 52 parser = optparse.OptionParser() | 56 parser = optparse.OptionParser() |
| 53 build_utils.AddDepfileOption(parser) | 57 build_utils.AddDepfileOption(parser) |
| 54 parser.add_option('--output', help='Output path for executable script.') | 58 parser.add_option('--output', help='Output path for executable script.') |
| 55 parser.add_option('--jar-path', help='Path to the main jar.') | 59 parser.add_option('--jar-path', help='Path to the main jar.') |
| 56 parser.add_option('--main-class', | 60 parser.add_option('--main-class', |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 os.chmod(options.output, 0750) | 97 os.chmod(options.output, 0750) |
| 94 | 98 |
| 95 if options.depfile: | 99 if options.depfile: |
| 96 build_utils.WriteDepfile( | 100 build_utils.WriteDepfile( |
| 97 options.depfile, | 101 options.depfile, |
| 98 build_utils.GetPythonDependencies()) | 102 build_utils.GetPythonDependencies()) |
| 99 | 103 |
| 100 | 104 |
| 101 if __name__ == '__main__': | 105 if __name__ == '__main__': |
| 102 sys.exit(main(sys.argv[1:])) | 106 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |