Mercurial > hg > truffle
diff mxtool/mx.py @ 17262:b641450c19ce
mx: rename helper functions for cygwin support and update comments
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Tue, 30 Sep 2014 10:05:30 +0200 |
parents | eff18e262a13 |
children | 83bbc0e5891a |
line wrap: on
line diff
--- a/mxtool/mx.py Tue Sep 30 08:59:11 2014 +0200 +++ b/mxtool/mx.py Tue Sep 30 10:05:30 2014 +0200 @@ -1345,39 +1345,43 @@ else: abort('Unknown operating system ' + sys.platform) -def _tpU2W(p): +def _cygpathU2W(p): """ - Translate a path from unix-style to windows-style + Translate a path from unix-style to windows-style. + This method has no effects on other platforms than cygwin. """ if p is None or get_os() != "cygwin": return p return subprocess.check_output(['cygpath', '-w', p]).strip() -def _tpW2U(p): +def _cygpathW2U(p): """ - Translate a path from windows-style to unix-style + Translate a path from windows-style to unix-style. + This method has no effects on other platforms than cygwin. """ if p is None or get_os() != "cygwin": return p return subprocess.check_output(['cygpath', '-u', p]).strip() -def _tspU2W(p): +def _separatedCygpathU2W(p): """ - Translate a group of paths, seperated by a path seperator. + Translate a group of paths, separated by a path separator. unix-style to windows-style. + This method has no effects on other platforms than cygwin. """ if p is None or p == "" or get_os() != "cygwin": return p - return ';'.join(map(_tpU2W, p.split(os.pathsep))) - -def _tspW2U(p): + return ';'.join(map(_cygpathU2W, p.split(os.pathsep))) + +def _separatedCygpathW2U(p): """ - Translate a group of paths, seperated by a path seperator. + Translate a group of paths, separated by a path separator. windows-style to unix-style. + This method has no effects on other platforms than cygwin. """ if p is None or p == "" or get_os() != "cygwin": return p - return os.pathsep.join(map(_tpW2U, p.split(';'))) + return os.pathsep.join(map(_cygpathW2U, p.split(';'))) def get_arch(): machine = platform.uname()[4] @@ -1568,7 +1572,7 @@ if includeBootClasspath: result = os.pathsep.join([java().bootclasspath(), result]) - return _tspU2W(result) + return _separatedCygpathU2W(result) def classpath_walk(names=None, resolve=True, includeSelf=True, includeBootClasspath=False): """ @@ -2036,7 +2040,7 @@ return cmp(self.parts, other.parts) def _filter_non_existant_paths(paths): - return os.pathsep.join([path for path in _tspW2U(paths).split(os.pathsep) if exists(path)]) + return os.pathsep.join([path for path in _separatedCygpathW2U(paths).split(os.pathsep) if exists(path)]) """ A JavaConfig object encapsulates info on how Java commands are run. @@ -2101,8 +2105,8 @@ os.makedirs(outDir) javaSource = join(myDir, 'ClasspathDump.java') if not exists(join(outDir, 'ClasspathDump.class')): - subprocess.check_call([self.javac, '-d', _tpU2W(outDir), _tpU2W(javaSource)], stderr=subprocess.PIPE, stdout=subprocess.PIPE) - self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', _tspU2W(outDir), 'ClasspathDump'], stderr=subprocess.PIPE).split('|')] + subprocess.check_call([self.javac, '-d', _cygpathU2W(outDir), _cygpathU2W(javaSource)], stderr=subprocess.PIPE, stdout=subprocess.PIPE) + self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', _separatedCygpathU2W(outDir), 'ClasspathDump'], stderr=subprocess.PIPE).split('|')] if not self._bootclasspath or not self._extdirs or not self._endorseddirs: warn("Could not find all classpaths: boot='" + str(self._bootclasspath) + "' extdirs='" + str(self._extdirs) + "' endorseddirs='" + str(self._endorseddirs) + "'") self._bootclasspath = _filter_non_existant_paths(self._bootclasspath) @@ -2129,17 +2133,17 @@ def bootclasspath(self): if self._bootclasspath is None: self._init_classpaths() - return _tspU2W(self._bootclasspath) + return _separatedCygpathU2W(self._bootclasspath) def extdirs(self): if self._extdirs is None: self._init_classpaths() - return _tspU2W(self._extdirs) + return _separatedCygpathU2W(self._extdirs) def endorseddirs(self): if self._endorseddirs is None: self._init_classpaths() - return _tspU2W(self._endorseddirs) + return _separatedCygpathU2W(self._endorseddirs) def containsJar(self, jar): if self._bootclasspath is None: @@ -2285,11 +2289,11 @@ javaSource = join(myDir, 'URLConnectionDownload.java') javaClass = join(myDir, 'URLConnectionDownload.class') if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource): - subprocess.check_call([java().javac, '-d', _tpU2W(myDir), _tpU2W(javaSource)]) + subprocess.check_call([java().javac, '-d', _cygpathU2W(myDir), _cygpathU2W(javaSource)]) verbose = [] if sys.stderr.isatty(): verbose.append("-v") - if run([java().java, '-cp', _tpU2W(myDir), 'URLConnectionDownload', _tpU2W(path)] + verbose + urls, nonZeroIsFatal=False) == 0: + if run([java().java, '-cp', _cygpathU2W(myDir), 'URLConnectionDownload', _cygpathU2W(path)] + verbose + urls, nonZeroIsFatal=False) == 0: return abort('Could not download to ' + path + ' from any of the following URLs:\n\n ' + @@ -2344,7 +2348,7 @@ def execute(self): argfileName = join(self.proj.dir, 'javafilelist.txt') argfile = open(argfileName, 'wb') - argfile.write('\n'.join(map(_tpU2W, self.javafilelist))) + argfile.write('\n'.join(map(_cygpathU2W, self.javafilelist))) argfile.close() processorArgs = [] @@ -2354,13 +2358,13 @@ if exists(genDir): shutil.rmtree(genDir) os.mkdir(genDir) - processorArgs += ['-processorpath', _tspU2W(join(processorPath)), '-s', _tpU2W(genDir)] + processorArgs += ['-processorpath', _separatedCygpathU2W(join(processorPath)), '-s', _cygpathU2W(genDir)] else: processorArgs += ['-proc:none'] args = self.args jdk = self.jdk - outputDir = _tpU2W(self.outputDir) + outputDir = _cygpathU2W(self.outputDir) compliance = str(jdk.javaCompliance) cp = classpath(self.proj.name, includeSelf=True) toBeDeleted = [argfileName] @@ -2375,7 +2379,7 @@ if jdk.debug_port is not None: javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] javacCmd += processorArgs - javacCmd += ['@' + _tpU2W(argfile.name)] + javacCmd += ['@' + _cygpathU2W(argfile.name)] if not args.warnAPI: javacCmd.append('-XDignore.symbol.file') @@ -2392,7 +2396,7 @@ else: self.logCompilation('JDT') - jdtVmArgs = ['-Xmx1g', '-jar', _tpU2W(self.jdtJar)] + jdtVmArgs = ['-Xmx1g', '-jar', _cygpathU2W(self.jdtJar)] jdtArgs = ['-' + compliance, '-cp', cp, '-g', '-enableJavadoc', @@ -2422,10 +2426,10 @@ with open(jdtPropertiesTmp, 'w') as fp: fp.write(content) toBeDeleted.append(jdtPropertiesTmp) - jdtArgs += ['-properties', _tpU2W(jdtPropertiesTmp)] + jdtArgs += ['-properties', _cygpathU2W(jdtPropertiesTmp)] else: - jdtArgs += ['-properties', _tpU2W(jdtProperties)] - jdtArgs.append('@' + _tpU2W(argfile.name)) + jdtArgs += ['-properties', _cygpathU2W(jdtProperties)] + jdtArgs.append('@' + _cygpathU2W(argfile.name)) run_java(jdtVmArgs + jdtArgs)