Mercurial > hg > truffle
comparison mx/commands.py @ 4148:bf5efc22fb3f
Replace downloading of JDK 7 with copying of host JDK 7.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 20 Dec 2011 10:14:52 +0100 |
parents | 55376d8953a6 |
children | c78bace5086a 527724d26036 |
comparison
equal
deleted
inserted
replaced
4147:55376d8953a6 | 4148:bf5efc22fb3f |
---|---|
121 vmOpts += args | 121 vmOpts += args |
122 for bm in runs: | 122 for bm in runs: |
123 config = benchmarks.get(bm) | 123 config = benchmarks.get(bm) |
124 vm(vmOpts + ['Harness'] + config + [bm]) | 124 vm(vmOpts + ['Harness'] + config + [bm]) |
125 | 125 |
126 def _download_and_extract_targz_jdk7(url, dst): | |
127 assert url.endswith('.tar.gz') | |
128 dl = join(_graal_home, 'jdk7.tar.gz') | |
129 try: | |
130 if not exists(dl): | |
131 mx.log('Downloading ' + url) | |
132 mx.download(dl, [url]) | |
133 tmp = join(_graal_home, 'tmp') | |
134 if not exists(tmp): | |
135 os.mkdir(tmp) | |
136 with tarfile.open(dl, mode='r:gz') as f: | |
137 mx.log('Extracting ' + dl) | |
138 f.extractall(path=tmp) | |
139 jdk = os.listdir(tmp)[0] | |
140 shutil.move(join(tmp, jdk), dst) | |
141 os.rmdir(tmp) | |
142 os.remove(dl) | |
143 except SystemExit: | |
144 mx.abort('Could not download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html.\n' + | |
145 'Please do this manually and install it at ' + dst + ' or set the JDK7 environment variable to the install location.') | |
146 | |
147 | |
148 def _jdk7(build='product', create=False): | 126 def _jdk7(build='product', create=False): |
149 jdk7 = os.environ.get('JDK7') | 127 jdk7 = join(_graal_home, 'jdk1.7.0') |
150 if jdk7 is None: | 128 if not exists(jdk7): |
151 jdk7 = join(_graal_home, 'jdk1.7.0') | 129 # Assume we are running with a JDK7 |
152 if not exists(jdk7): | 130 assert mx.java().version.startswith('1.7') |
153 # Try to download it | 131 srcJdk = mx.java().jdk |
154 if mx.get_os() == 'linux': | 132 mx.log('Creating ' + jdk7 + ' from ' + srcJdk) |
155 _download_and_extract_targz_jdk7('http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz', jdk7) | 133 os.mkdir(jdk7) |
156 else: | 134 for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: |
157 mx.abort('Download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html\n' + | 135 src = join(srcJdk, d) |
158 'and install it at ' + jdk7 + ' or set the JDK7 environment variable to the JDK7 install location.') | 136 dst = join(jdk7, d) |
159 | 137 if not exists(src): |
160 jre = join(jdk7, 'jre') | 138 mx.abort('Host JDK 7 directory is missing: ' + src) |
161 if not exists(jre) or not isdir(jre): | 139 shutil.copytree(src, dst) |
162 mx.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)') | |
163 | 140 |
164 if build == 'product': | 141 if build == 'product': |
165 return jdk7 | 142 return jdk7 |
166 elif build in ['debug', 'fastdebug', 'optimized']: | 143 elif build in ['debug', 'fastdebug', 'optimized']: |
167 res = join(jdk7, build) | 144 res = join(jdk7, build) |
168 if not exists(res): | 145 if not exists(res): |
169 if not create: | 146 if not create: |
170 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') | 147 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') |
171 mx.log('[creating ' + res + '...]') | 148 mx.log('Creating ' + res) |
172 os.mkdir(res) | 149 os.mkdir(res) |
173 for d in ['jre', 'lib', 'bin', 'include']: | 150 for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: |
174 shutil.copytree(join(jdk7, d), join(res, d)) | 151 shutil.copytree(join(jdk7, d), join(res, d)) |
175 return res | 152 return res |
176 else: | 153 else: |
177 mx.abort('Unknown build type: ' + build) | 154 mx.abort('Unknown build type: ' + build) |
178 | 155 |
398 'ideinit': [ideinit, ''], | 375 'ideinit': [ideinit, ''], |
399 } | 376 } |
400 mx.commands.update(commands) | 377 mx.commands.update(commands) |
401 | 378 |
402 def mx_post_parse_cmd_line(opts): | 379 def mx_post_parse_cmd_line(opts): |
380 version = mx.java().version | |
381 parts = version.split('.') | |
382 assert len(parts) >= 2 | |
383 assert parts[0] == '1' | |
384 major = int(parts[1]) | |
385 if not major >= 7: | |
386 mx.abort('Requires Java version 1.7 or greater, got version ' + version) | |
387 | |
388 | |
403 global _vmbuild | 389 global _vmbuild |
404 if not opts.vmbuild is None: | 390 if not opts.vmbuild is None: |
405 _vmbuild = opts.vmbuild | 391 _vmbuild = opts.vmbuild |