# HG changeset patch # User Doug Simon # Date 1324372492 -3600 # Node ID bf5efc22fb3f1ecd56109cfb19c49e500c196a7a # Parent 55376d8953a69638ac1c72c846c9426a4d83704a Replace downloading of JDK 7 with copying of host JDK 7. diff -r 55376d8953a6 -r bf5efc22fb3f mx/commands.py --- a/mx/commands.py Mon Dec 19 22:22:56 2011 +0100 +++ b/mx/commands.py Tue Dec 20 10:14:52 2011 +0100 @@ -123,43 +123,20 @@ config = benchmarks.get(bm) vm(vmOpts + ['Harness'] + config + [bm]) -def _download_and_extract_targz_jdk7(url, dst): - assert url.endswith('.tar.gz') - dl = join(_graal_home, 'jdk7.tar.gz') - try: - if not exists(dl): - mx.log('Downloading ' + url) - mx.download(dl, [url]) - tmp = join(_graal_home, 'tmp') - if not exists(tmp): - os.mkdir(tmp) - with tarfile.open(dl, mode='r:gz') as f: - mx.log('Extracting ' + dl) - f.extractall(path=tmp) - jdk = os.listdir(tmp)[0] - shutil.move(join(tmp, jdk), dst) - os.rmdir(tmp) - os.remove(dl) - except SystemExit: - mx.abort('Could not download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html.\n' + - 'Please do this manually and install it at ' + dst + ' or set the JDK7 environment variable to the install location.') - - def _jdk7(build='product', create=False): - jdk7 = os.environ.get('JDK7') - if jdk7 is None: - jdk7 = join(_graal_home, 'jdk1.7.0') - if not exists(jdk7): - # Try to download it - if mx.get_os() == 'linux': - _download_and_extract_targz_jdk7('http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz', jdk7) - else: - mx.abort('Download JDK7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html\n' + - 'and install it at ' + jdk7 + ' or set the JDK7 environment variable to the JDK7 install location.') - - jre = join(jdk7, 'jre') - if not exists(jre) or not isdir(jre): - mx.abort(jdk7 + ' does not appear to be a valid JDK directory ("jre" sub-directory is missing)') + jdk7 = join(_graal_home, 'jdk1.7.0') + if not exists(jdk7): + # Assume we are running with a JDK7 + assert mx.java().version.startswith('1.7') + srcJdk = mx.java().jdk + mx.log('Creating ' + jdk7 + ' from ' + srcJdk) + os.mkdir(jdk7) + for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: + src = join(srcJdk, d) + dst = join(jdk7, d) + if not exists(src): + mx.abort('Host JDK 7 directory is missing: ' + src) + shutil.copytree(src, dst) if build == 'product': return jdk7 @@ -168,9 +145,9 @@ if not exists(res): if not create: mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') - mx.log('[creating ' + res + '...]') + mx.log('Creating ' + res) os.mkdir(res) - for d in ['jre', 'lib', 'bin', 'include']: + for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: shutil.copytree(join(jdk7, d), join(res, d)) return res else: @@ -400,6 +377,15 @@ mx.commands.update(commands) def mx_post_parse_cmd_line(opts): + version = mx.java().version + parts = version.split('.') + assert len(parts) >= 2 + assert parts[0] == '1' + major = int(parts[1]) + if not major >= 7: + mx.abort('Requires Java version 1.7 or greater, got version ' + version) + + global _vmbuild if not opts.vmbuild is None: _vmbuild = opts.vmbuild diff -r 55376d8953a6 -r bf5efc22fb3f mxtool/mx.py --- a/mxtool/mx.py Mon Dec 19 22:22:56 2011 +0100 +++ b/mxtool/mx.py Tue Dec 20 10:14:52 2011 +0100 @@ -481,12 +481,6 @@ os.environ['HOME'] = opts.user_home commandAndArgs = opts.__dict__.pop('commandAndArgs') - - for s in suites(): - mod = s.commands - if hasattr(mod is not None and mod, 'mx_post_parse_cmd_line'): - mod.mx_post_parse_cmd_line(opts) - return opts, commandAndArgs def _format_commands(): @@ -585,15 +579,19 @@ # Prepend the -d64 VM option only if the java command supports it try: - subprocess.check_output([self.java, '-d64', '-version'], stderr=subprocess.STDOUT) + output = subprocess.check_output([self.java, '-d64', '-version'], stderr=subprocess.STDOUT) self.java_args = ['-d64'] + self.java_args except subprocess.CalledProcessError as e: try: - subprocess.check_output([self.java, '-version'], stderr=subprocess.STDOUT) + output = subprocess.check_output([self.java, '-version'], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print e.output abort(e.returncode) + output = output.split() + assert output[1] == 'version' + self.version = output[2].strip('"') + if self.debug: self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] @@ -1129,10 +1127,15 @@ _loadSuite(os.getcwd(), True) opts, commandAndArgs = _argParser._parse_cmd_line() + global _opts, _java _opts = opts _java = JavaConfig(opts) + for s in suites(): + if s.commands is not None and hasattr(s.commands, 'mx_post_parse_cmd_line'): + s.commands.mx_post_parse_cmd_line(opts) + if len(commandAndArgs) == 0: _argParser.print_help() return