# HG changeset patch # User Bernhard Urban # Date 1412064330 -7200 # Node ID b641450c19ce054a0db00547b53e370a586f1649 # Parent d4fe684410729dffed3e38926c94f845df579e50 mx: rename helper functions for cygwin support and update comments diff -r d4fe68441072 -r b641450c19ce mx/mx_graal.py --- a/mx/mx_graal.py Tue Sep 30 08:59:11 2014 +0200 +++ b/mx/mx_graal.py Tue Sep 30 10:05:30 2014 +0200 @@ -529,7 +529,7 @@ graalRuntime_inline_hpp = join(genSrcDir, 'graalRuntime.inline.hpp') cp = os.pathsep.join([mx.distribution(d).path for d in dist.distDependencies] + [dist.path, p.output_dir()]) tmp = StringIO.StringIO() - mx.run_java(['-cp', mx._tspU2W(cp), mainClass], out=tmp.write) + mx.run_java(['-cp', mx._separatedCygpathU2W(cp), mainClass], out=tmp.write) # Compute SHA1 for currently generated graalRuntime.inline.hpp content # and all other generated sources in genSrcDir @@ -552,7 +552,7 @@ javaClass = join(_graal_home, 'GeneratedSourcesSha1.class') with open(javaSource, 'w') as fp: print >> fp, 'class GeneratedSourcesSha1 { private static final String value = "' + sha1 + '"; }' - subprocess.check_call([mx.java().javac, '-d', mx._tpU2W(_graal_home), mx._tpU2W(javaSource)], stderr=subprocess.PIPE, stdout=subprocess.PIPE) + subprocess.check_call([mx.java().javac, '-d', mx._cygpathU2W(_graal_home), mx._cygpathU2W(javaSource)], stderr=subprocess.PIPE, stdout=subprocess.PIPE) zf = zipfile.ZipFile(dist.path, 'a') with open(javaClass, 'rb') as fp: zf.writestr(os.path.basename(javaClass), fp.read()) @@ -611,14 +611,14 @@ winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\') - if not exists(mx._tpW2U(winSDK)): + if not exists(mx._cygpathW2U(winSDK)): mx.abort("Could not find Windows SDK : '" + winSDK + "' does not exist") - winSDKSetEnv = mx._tpW2U(join(winSDK, 'Bin', 'SetEnv.cmd')) + winSDKSetEnv = mx._cygpathW2U(join(winSDK, 'Bin', 'SetEnv.cmd')) if not exists(winSDKSetEnv): mx.abort("Invalid Windows SDK path (" + winSDK + ") : could not find Bin/SetEnv.cmd (you can use the WIN_SDK environment variable to specify an other path)") - wincmd = 'cmd.exe /E:ON /V:ON /K "' + mx._tpU2W(winSDKSetEnv) + '"' + wincmd = 'cmd.exe /E:ON /V:ON /K "' + mx._cygpathU2W(winSDKSetEnv) + '"' p = subprocess.Popen(wincmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout = p.stdout stdin = p.stdin @@ -847,14 +847,14 @@ continue if platform.system() == 'Windows' or "CYGWIN" in platform.system(): - t_compilelogfile = mx._tpU2W(os.path.join(_graal_home, "graalCompile.log")) + t_compilelogfile = mx._cygpathU2W(os.path.join(_graal_home, "graalCompile.log")) mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin') variant = {'client': 'compiler1', 'server': 'compiler2'}.get(vm, vm) project_config = variant + '_' + build - t_graal_home = mx._tpU2W(_graal_home) + t_graal_home = mx._cygpathU2W(_graal_home) _runInDebugShell('msbuild ' + t_graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=' + project_config + ' /target:clean', t_graal_home) - winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + mx._tpU2W(jdk) + r'& set JAVA_HOME=' + mx._tpU2W(jdk) + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' + t_graal_home + r'\make\windows"& call create.bat ' + t_graal_home + winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + mx._cygpathU2W(jdk) + r'& set JAVA_HOME=' + mx._cygpathU2W(jdk) + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' + t_graal_home + r'\make\windows"& call create.bat ' + t_graal_home print winCompileCmd winCompileSuccess = re.compile(r"^Writing \.vcxproj file:") if not _runInDebugShell(winCompileCmd, t_graal_home, t_compilelogfile, winCompileSuccess): @@ -1451,7 +1451,7 @@ _jacoco = 'off' t = Task('CleanAndBuildIdealGraphVisualizer') - buildxml = mx._tpU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')) + buildxml = mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')) mx.run(['ant', '-f', buildxml, '-q', 'clean', 'build']) tasks.append(t.stop()) @@ -2245,13 +2245,13 @@ findbugsJar = join(findbugsLib, 'findbugs.jar') assert exists(findbugsJar) nonTestProjects = [p for p in mx.projects() if not p.name.endswith('.test') and not p.name.endswith('.jtt')] - outputDirs = map(mx._tpU2W, [p.output_dir() for p in nonTestProjects]) + outputDirs = map(mx._cygpathU2W, [p.output_dir() for p in nonTestProjects]) findbugsResults = join(_graal_home, 'findbugs.results') - cmd = ['-jar', mx._tpU2W(findbugsJar), '-textui', '-low', '-maxRank', '15'] + cmd = ['-jar', mx._cygpathU2W(findbugsJar), '-textui', '-low', '-maxRank', '15'] if sys.stdout.isatty(): cmd.append('-progress') - cmd = cmd + ['-auxclasspath', mx.classpath([d.name for d in _jdkDeployedDists] + [p.name for p in nonTestProjects]), '-output', mx._tpU2W(findbugsResults), '-exitcode'] + args + outputDirs + cmd = cmd + ['-auxclasspath', mx.classpath([d.name for d in _jdkDeployedDists] + [p.name for p in nonTestProjects]), '-output', mx._cygpathU2W(findbugsResults), '-exitcode'] + args + outputDirs exitcode = mx.run_java(cmd, nonZeroIsFatal=False) if exitcode != 0: with open(findbugsResults) as fp: diff -r d4fe68441072 -r b641450c19ce mxtool/mx.py --- 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)