comparison mx/commands.py @ 4252:67e88b7624d5

Removed need for GRAAL environment variable on Windows.
author Doug Simon <doug.simon@oracle.com>
date Mon, 09 Jan 2012 22:01:39 +0100
parents 3f6c6e61614e
children 32b8274f52ad
comparison
equal deleted inserted replaced
4251:44f3dae303ae 4252:67e88b7624d5
33 import sanitycheck 33 import sanitycheck
34 34
35 _graal_home = dirname(dirname(__file__)) 35 _graal_home = dirname(dirname(__file__))
36 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) 36 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src'))
37 _vmbuild = 'product' 37 _vmbuild = 'product'
38 _winSDK = 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\'
39 _mksHome = 'C:\\cygwin\\bin'
40 38
41 def clean(args): 39 def clean(args):
42 """cleans the GraalVM source tree""" 40 """cleans the GraalVM source tree"""
43 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean')) 41 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean'))
44 if opts.native: 42 if opts.native:
189 def _jdk(build='product', create=False): 187 def _jdk(build='product', create=False):
190 """ 188 """
191 Get the JDK into which Graal is installed, creating it first if necessary. 189 Get the JDK into which Graal is installed, creating it first if necessary.
192 """ 190 """
193 jdk = join(_graal_home, 'jdk' + mx.java().version) 191 jdk = join(_graal_home, 'jdk' + mx.java().version)
192 jdkContents = ['bin', 'db', 'include', 'jre', 'lib']
193 if mx.get_os() != 'windows':
194 jdkContents.append('man')
194 if not exists(jdk): 195 if not exists(jdk):
195 srcJdk = mx.java().jdk 196 srcJdk = mx.java().jdk
196 mx.log('Creating ' + jdk + ' from ' + srcJdk) 197 mx.log('Creating ' + jdk + ' from ' + srcJdk)
197 os.mkdir(jdk) 198 os.mkdir(jdk)
198 for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: 199 for d in jdkContents:
199 src = join(srcJdk, d) 200 src = join(srcJdk, d)
200 dst = join(jdk, d) 201 dst = join(jdk, d)
201 if not exists(src): 202 if not exists(src):
202 mx.abort('Host JDK directory is missing: ' + src) 203 mx.abort('Host JDK directory is missing: ' + src)
203 shutil.copytree(src, dst) 204 shutil.copytree(src, dst)
224 if not exists(res): 225 if not exists(res):
225 if not create: 226 if not create:
226 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') 227 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'')
227 mx.log('Creating ' + res) 228 mx.log('Creating ' + res)
228 os.mkdir(res) 229 os.mkdir(res)
229 for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']: 230 for d in jdkContents:
230 shutil.copytree(join(jdk, d), join(res, d)) 231 shutil.copytree(join(jdk, d), join(res, d))
231 return res 232 return res
232 else: 233 else:
233 mx.abort('Unknown build type: ' + build) 234 mx.abort('Unknown build type: ' + build)
234 235
235 # run a command in the windows SDK Debug Shell 236 # run a command in the windows SDK Debug Shell
236 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}): 237 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}):
237 newLine = os.linesep 238 newLine = os.linesep
238 STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE' 239 STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE'
239 ENDTOKEN = 'RUNINDEBUGSHELL_ENDSEQUENCE' 240 ENDTOKEN = 'RUNINDEBUGSHELL_ENDSEQUENCE'
240 p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + _winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \ 241
241 shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 242 winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\')
243
244 p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \
245 shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
242 output = p.stdout 246 output = p.stdout
243 input = p.stdin 247 input = p.stdin
244 if logFile: 248 if logFile:
245 log = open(logFile, 'w') 249 log = open(logFile, 'w')
246 ret = False 250 ret = False
300 if not 'Xusage.txt' in line: 304 if not 'Xusage.txt' in line:
301 sys.stderr.write(line + os.linesep) 305 sys.stderr.write(line + os.linesep)
302 306
303 if platform.system() == 'Windows': 307 if platform.system() == 'Windows':
304 compilelogfile = _graal_home + '/graalCompile.log' 308 compilelogfile = _graal_home + '/graalCompile.log'
309 mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
310
305 _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=compiler1_product /target:clean', _graal_home) 311 _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=compiler1_product /target:clean', _graal_home)
306 winCompileCmd = r'set HotSpotMksHome=' + _mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + '' 312 winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + ''
307 print(winCompileCmd) 313 print(winCompileCmd)
308 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:") 314 winCompileSuccess = re.compile(r"^Writing \.vcxproj file:")
309 if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess): 315 if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess):
310 mx.log('Error executing create command') 316 mx.log('Error executing create command')
311 return 317 return