Mercurial > hg > truffle
comparison mx/commands.py @ 3730:4e3851bab8d0
Added mechanism for downloading a JDK 7 if the JDK7 environment variable is not set. This only works on Linux as only it has a single tar.gz version of the JDK available from the Oracle JDK download website.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 16 Dec 2011 21:56:00 +0100 |
parents | 7c5524a4e86e |
children | 3e2e8b8abdaf |
comparison
equal
deleted
inserted
replaced
3729:c83fdc80e217 | 3730:4e3851bab8d0 |
---|---|
24 # or visit www.oracle.com if you need additional information or have any | 24 # or visit www.oracle.com if you need additional information or have any |
25 # questions. | 25 # questions. |
26 # | 26 # |
27 # ---------------------------------------------------------------------------------------------------- | 27 # ---------------------------------------------------------------------------------------------------- |
28 | 28 |
29 import os, sys, shutil | 29 import os, sys, shutil, tarfile |
30 from os.path import join, exists, dirname, isfile, isdir | 30 from os.path import join, exists, dirname, isfile, isdir |
31 | 31 |
32 graal_home = dirname(dirname(__file__)) | 32 graal_home = dirname(dirname(__file__)) |
33 | 33 |
34 def clean(env, args): | 34 def clean(env, args): |
143 jtt('optimize'), | 143 jtt('optimize'), |
144 jtt('reflect'), | 144 jtt('reflect'), |
145 jtt('threads'), | 145 jtt('threads'), |
146 jtt('hotspot')]) | 146 jtt('hotspot')]) |
147 | 147 |
148 | |
149 def _download_and_extract_targz_jdk7(env, url, dst): | |
150 assert url.endswith('.tar.gz') | |
151 dl = join(graal_home, 'jdk7.tar.gz') | |
152 try: | |
153 if not exists(dl): | |
154 env.download(dl, [url]) | |
155 tmp = join(graal_home, 'tmp') | |
156 if not exists(tmp): | |
157 os.mkdir(tmp) | |
158 with tarfile.open(dl, mode='r:gz') as f: | |
159 env.log('Extracting ' + dl) | |
160 f.extractall(path=tmp) | |
161 jdk = os.listdir(tmp)[0] | |
162 shutil.move(join(tmp, jdk), dst) | |
163 os.rmdir(tmp) | |
164 os.remove(dl) | |
165 except SystemExit: | |
166 env.abort('Could not download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html.\n' + | |
167 'Please do this manually and install it at ' + dst + ' or set the JDK7 environment variable to the install location.') | |
168 | |
169 | |
148 def _jdk7(env, build='product', create=False): | 170 def _jdk7(env, build='product', create=False): |
149 jdk7 = env.check_get_env('JDK7') | 171 jdk7 = os.environ.get('JDK7') |
172 if jdk7 is None: | |
173 jdk7 = join(graal_home, 'jdk7') | |
174 if not exists(jdk7): | |
175 # Try to download it | |
176 if env.os == 'linux': | |
177 _download_and_extract_targz_jdk7(env, 'http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz', jdk7) | |
178 else: | |
179 env.abort('Download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html\n' + | |
180 'and install it at ' + jdk7 + ' or set the JDK7 environment variable to the JDK7 install location.') | |
181 | |
150 jre = join(jdk7, 'jre') | 182 jre = join(jdk7, 'jre') |
151 if not exists(jre) or not isdir(jre): | 183 if not exists(jre) or not isdir(jre): |
152 env.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)') | 184 env.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)') |
153 | 185 |
154 if build == 'product': | 186 if build == 'product': |