Mercurial > hg > truffle
comparison mxtool/mx.py @ 14914:a6bd486b1b44
Extend JavaConfig bootclasspath detection to detect extdirs and endorseddirs
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 16:21:49 +0200 |
parents | 2d1cc640512c |
children | 32121774dfea |
comparison
equal
deleted
inserted
replaced
14913:2d1cc640512c | 14914:a6bd486b1b44 |
---|---|
1420 self.javaCompliance = JavaCompliance(self.version.versionString) | 1420 self.javaCompliance = JavaCompliance(self.version.versionString) |
1421 | 1421 |
1422 if self.debug_port is not None: | 1422 if self.debug_port is not None: |
1423 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)] | 1423 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)] |
1424 | 1424 |
1425 def _init_classpaths(self): | |
1426 myDir = dirname(__file__) | |
1427 javaSource = join(myDir, 'ClasspathDump.java') | |
1428 javaClass = join(myDir, 'ClasspathDump.class') | |
1429 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): | |
1430 subprocess.check_call([self.javac, '-d', myDir, javaSource]) | |
1431 self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', myDir, 'ClasspathDump']).split('|')] | |
1432 if not self._bootclasspath or not self._extdirs or not self._endorseddirs: | |
1433 warn("Could not find all classpaths: boot='" + str(self._bootclasspath) + "' extdirs='" + str(self._extdirs) + "' endorseddirs='" + str(self._endorseddirs) + "'") | |
1434 | |
1425 def __hash__(self): | 1435 def __hash__(self): |
1426 return hash(self.jdk) | 1436 return hash(self.jdk) |
1427 | 1437 |
1428 def __cmp__(self, other): | 1438 def __cmp__(self, other): |
1429 if isinstance(other, JavaConfig): | 1439 if isinstance(other, JavaConfig): |
1439 def processArgs(self, args): | 1449 def processArgs(self, args): |
1440 return self.java_args_pfx + self.java_args + self.java_args_sfx + args | 1450 return self.java_args_pfx + self.java_args + self.java_args_sfx + args |
1441 | 1451 |
1442 def bootclasspath(self): | 1452 def bootclasspath(self): |
1443 if self._bootclasspath is None: | 1453 if self._bootclasspath is None: |
1444 tmpDir = tempfile.mkdtemp() | 1454 self._init_classpaths() |
1445 try: | |
1446 src = join(tmpDir, 'bootclasspath.java') | |
1447 with open(src, 'w') as fp: | |
1448 print >> fp, """ | |
1449 public class bootclasspath { | |
1450 public static void main(String[] args) { | |
1451 String s = System.getProperty("sun.boot.class.path"); | |
1452 if (s != null) { | |
1453 System.out.println(s); | |
1454 } | |
1455 } | |
1456 }""" | |
1457 subprocess.check_call([self.javac, '-d', tmpDir, src]) | |
1458 self._bootclasspath = subprocess.check_output([self.java, '-cp', tmpDir, 'bootclasspath']) | |
1459 finally: | |
1460 shutil.rmtree(tmpDir) | |
1461 return self._bootclasspath | 1455 return self._bootclasspath |
1456 | |
1457 def extdirs(self): | |
1458 if self._extdirs is None: | |
1459 self._init_classpaths() | |
1460 return self._extdirs | |
1461 | |
1462 def endorseddirs(self): | |
1463 if self._endorseddirs is None: | |
1464 self._init_classpaths() | |
1465 return self._endorseddirs | |
1462 | 1466 |
1463 def check_get_env(key): | 1467 def check_get_env(key): |
1464 """ | 1468 """ |
1465 Gets an environment variable, aborting with a useful message if it is not set. | 1469 Gets an environment variable, aborting with a useful message if it is not set. |
1466 """ | 1470 """ |
1571 """ | 1575 """ |
1572 d = dirname(path) | 1576 d = dirname(path) |
1573 if d != '' and not exists(d): | 1577 if d != '' and not exists(d): |
1574 os.makedirs(d) | 1578 os.makedirs(d) |
1575 | 1579 |
1576 # Try it with the Java tool first since it can show a progress counter | |
1577 myDir = dirname(__file__) | |
1578 | 1580 |
1579 if not path.endswith(os.sep): | 1581 if not path.endswith(os.sep): |
1582 # Try it with the Java tool first since it can show a progress counter | |
1583 myDir = dirname(__file__) | |
1580 javaSource = join(myDir, 'URLConnectionDownload.java') | 1584 javaSource = join(myDir, 'URLConnectionDownload.java') |
1581 javaClass = join(myDir, 'URLConnectionDownload.class') | 1585 javaClass = join(myDir, 'URLConnectionDownload.class') |
1582 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): | 1586 if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): |
1583 subprocess.check_call([java().javac, '-d', myDir, javaSource]) | 1587 subprocess.check_call([java().javac, '-d', myDir, javaSource]) |
1584 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls, nonZeroIsFatal=False) == 0: | 1588 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls, nonZeroIsFatal=False) == 0: |