Mercurial > hg > graal-jvmci-8
comparison pytools/gl.py @ 3623:3b2ab8970aa4
Improved gl.py script.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 09 Nov 2011 16:02:46 +0100 |
parents | de066dcbf607 |
children | e81927755129 |
comparison
equal
deleted
inserted
replaced
3622:05b6ae7c23b1 | 3623:3b2ab8970aa4 |
---|---|
54 | 54 |
55 def __init__(self): | 55 def __init__(self): |
56 self.dacapo = os.getenv('DACAPO') | 56 self.dacapo = os.getenv('DACAPO') |
57 self.jdk7 = os.getenv('JDK7') | 57 self.jdk7 = os.getenv('JDK7') |
58 self.jdk7g = os.getenv('JDK7G') | 58 self.jdk7g = os.getenv('JDK7G') |
59 self.maxine_home = os.getenv('MAXINE') | 59 self.maxine = os.getenv('MAXINE') |
60 | 60 |
61 ArgumentParser.__init__(self, prog='gl') | 61 ArgumentParser.__init__(self, prog='gl') |
62 | 62 |
63 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') | 63 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') |
64 self.add_argument('--dacapo', help='path to DaCapo 91.12 jar file') | 64 self.add_argument('--dacapo', help='path to DaCapo 91.12 jar file') |
65 self.add_argument('--jdk7', help='JDK7 installation in which the GraalVM binary is installed', metavar='<path>') | 65 self.add_argument('--jdk7', help='JDK7 installation in which the GraalVM binary is installed', metavar='<path>') |
66 self.add_argument('--jdk7g', help='JDK7G installation in which the GraalVM binary is installed', metavar='<path>') | 66 self.add_argument('--jdk7g', help='JDK7G installation in which the GraalVM binary is installed', metavar='<path>') |
67 self.add_argument('-M', '--maxine', dest='maxine_home', help='path to Maxine code base', metavar='<path>') | 67 self.add_argument('-M', '--maxine', dest='maxine', help='path to Maxine code base', metavar='<path>') |
68 | 68 |
69 def parse_cmd_line(self): | 69 def parse_cmd_line(self, configFile): |
70 | 70 |
71 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') | 71 self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...') |
72 | 72 |
73 self.parse_args(namespace=self) | 73 self.parse_args(namespace=self) |
74 | 74 |
75 if not isdir(self.jdk7): | 75 if self.jdk7 is None or not isdir(self.jdk7): |
76 self.log('JDK7 is required. Use --jdk7 option or set JDK7 environment variable') | 76 self.log('JDK7 is required. Use --jdk7 option or set JDK7 environment variable (in ' + configFile + ')') |
77 self.abort(1) | 77 self.abort(1) |
78 | 78 |
79 if not isdir(self.jdk7g): | 79 if self.jdk7g is None or not isdir(self.jdk7g): |
80 self.log('JDK7G is required. Use --jdk7g option or set JDK7G environment variable') | 80 self.log('JDK7G is required. Use --jdk7g option or set JDK7G environment variable (in ' + configFile + ')') |
81 self.abort(1) | 81 self.abort(1) |
82 | 82 |
83 self.graal_home = dirname(abspath(dirname(sys.argv[0]))) | 83 self.graal_home = dirname(abspath(dirname(sys.argv[0]))) |
84 | 84 |
85 def load_config_file(self, configFile): | 85 def load_config_file(self, configFile): |
86 """ adds attributes to this object from a file containing key=value lines """ | 86 """ adds attributes to this object from a file containing key=value lines """ |
87 if exists(configFile): | 87 if exists(configFile): |
88 with open(configFile) as f: | 88 with open(configFile) as f: |
89 self.log('[loading vars from ' + configFile + ']') | 89 #self.log('[loading vars from ' + configFile + ']') |
90 for line in f: | 90 for line in f: |
91 kv = line.split('=', 1) | 91 if not line.startswith('#'): |
92 if len(kv) == 2: | 92 kv = line.split('=', 1) |
93 k = kv[0].strip().lower() | 93 if len(kv) == 2: |
94 setattr(self, k, os.path.expandvars(kv[1].strip())) | 94 k = kv[0].strip().lower() |
95 setattr(self, k, os.path.expandvars(kv[1].strip())) | |
95 | 96 |
96 def get_os(self): | 97 def get_os(self): |
97 if sys.platform.startswith('darwin'): | 98 if sys.platform.startswith('darwin'): |
98 return 'darwin' | 99 return 'darwin' |
99 elif sys.platform.startswith('linux'): | 100 elif sys.platform.startswith('linux'): |
117 self.log('Specified DaCapo jar file does not exist or is not a jar file: ' + self.dacapo) | 118 self.log('Specified DaCapo jar file does not exist or is not a jar file: ' + self.dacapo) |
118 self.abort(1) | 119 self.abort(1) |
119 return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-XX:-GraalBailoutIsFatal', '-G:-QuietBailout', '-cp', self.dacapo] + args) | 120 return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-XX:-GraalBailoutIsFatal', '-G:-QuietBailout', '-cp', self.dacapo] + args) |
120 | 121 |
121 def run_vm(self, args): | 122 def run_vm(self, args): |
122 if self.maxine_home is None: | 123 if self.maxine is None: |
123 self.log('Path to Maxine code base must be specified with -M option of MAXINE environment variable') | 124 configFile = join(dirname(sys.argv[0]), 'glrc') |
124 self.abort(1) | 125 self.log('Path to Maxine code base must be specified with -M option or MAXINE environment variable (in ' + configFile + ')') |
125 if not exists(join(self.maxine_home, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')): | 126 self.abort(1) |
126 self.log('Maxine code base path specified -M option or MAXINE environment variable does not contain com.oracle.max.graal.hotspot/bin/com/oracle/max/graal/hotspot/VMEntriesNative.class: ' + self.maxine_home) | 127 if not exists(join(self.maxine, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')): |
128 self.log('Maxine code base path specified -M option or MAXINE environment variable does not contain com.oracle.max.graal.hotspot/bin/com/oracle/max/graal/hotspot/VMEntriesNative.class: ' + self.maxine) | |
127 self.abort(1) | 129 self.abort(1) |
128 | 130 |
129 os.environ['MAXINE'] = self.maxine_home | 131 os.environ['MAXINE'] = self.maxine |
130 exe = join(self.jdk7, 'bin', self.exe('java')) | 132 exe = join(self.jdk7, 'bin', self.exe('java')) |
131 return self.run([exe, '-graal'] + args) | 133 return self.run([exe, '-graal'] + args) |
132 | 134 |
133 def run(self, args, nonZeroIsFatal=True, out=None, err=None, cwd=None): | 135 def run(self, args, nonZeroIsFatal=True, out=None, err=None, cwd=None): |
134 """ | 136 """ |
194 raise SystemExit(code) | 196 raise SystemExit(code) |
195 | 197 |
196 def main(env): | 198 def main(env): |
197 configFile = join(dirname(sys.argv[0]), 'glrc') | 199 configFile = join(dirname(sys.argv[0]), 'glrc') |
198 env.load_config_file(configFile) | 200 env.load_config_file(configFile) |
199 env.parse_cmd_line() | 201 env.parse_cmd_line(configFile) |
200 | 202 |
201 if len(env.commandAndArgs) == 0: | 203 if len(env.commandAndArgs) == 0: |
202 env.print_help() | 204 env.print_help() |
203 return | 205 return |
204 | 206 |