comparison mx/mx_graal.py @ 17055:3e4d3be0b6bf

mx: fix default handling of vm config and build type
author Gilles Duboscq <duboscq@ssw.jku.at>
date Thu, 04 Sep 2014 20:12:10 +0200
parents 35fda668ed6e
children a02c295218aa
comparison
equal deleted inserted replaced
17054:fb8fe09c00a3 17055:3e4d3be0b6bf
376 return join(_vmLibDirInJdk(jdk), jvmCfgFile) 376 return join(_vmLibDirInJdk(jdk), jvmCfgFile)
377 377
378 def _jdksDir(): 378 def _jdksDir():
379 return os.path.abspath(join(_installed_jdks if _installed_jdks else _graal_home, 'jdk' + str(mx.java().version))) 379 return os.path.abspath(join(_installed_jdks if _installed_jdks else _graal_home, 'jdk' + str(mx.java().version)))
380 380
381 def _handle_missing_VM(bld, vm): 381 def _handle_missing_VM(bld, vm=None):
382 if not vm:
383 vm = _get_vm()
382 mx.log('The ' + bld + ' ' + vm + ' VM has not been created') 384 mx.log('The ' + bld + ' ' + vm + ' VM has not been created')
383 if sys.stdout.isatty(): 385 if sys.stdout.isatty():
384 if mx.ask_yes_no('Build it now', 'y'): 386 if mx.ask_yes_no('Build it now', 'y'):
385 with VM(vm, bld): 387 with VM(vm, bld):
386 build([]) 388 build([])
387 return 389 return
388 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') 390 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM')
389 391
390 def _jdk(build='product', vmToCheck=None, create=False, installJars=True): 392 def _jdk(build=None, vmToCheck=None, create=False, installJars=True):
391 """ 393 """
392 Get the JDK into which Graal is installed, creating it first if necessary. 394 Get the JDK into which Graal is installed, creating it first if necessary.
393 """ 395 """
396 if not build:
397 build = _vmbuild if _vmSourcesAvailable else 'product'
394 jdk = join(_jdksDir(), build) 398 jdk = join(_jdksDir(), build)
395 if create: 399 if create:
396 srcJdk = mx.java().jdk 400 srcJdk = mx.java().jdk
397 if not exists(jdk): 401 if not exists(jdk):
398 mx.log('Creating ' + jdk + ' from ' + srcJdk) 402 mx.log('Creating ' + jdk + ' from ' + srcJdk)
460 pass 464 pass
461 else: 465 else:
462 if not exists(jdk): 466 if not exists(jdk):
463 if _installed_jdks: 467 if _installed_jdks:
464 mx.log("The selected JDK directory does not (yet) exist: " + jdk) 468 mx.log("The selected JDK directory does not (yet) exist: " + jdk)
465 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') 469 _handle_missing_VM(build, vmToCheck)
466 470
467 if installJars: 471 if installJars:
468 for jdkDist in _jdkDeployedDists: 472 for jdkDist in _jdkDeployedDists:
469 dist = mx.distribution(jdkDist.name) 473 dist = mx.distribution(jdkDist.name)
470 if exists(dist.path): 474 if exists(dist.path):
653 log.close() 657 log.close()
654 return ret 658 return ret
655 659
656 def jdkhome(vm=None): 660 def jdkhome(vm=None):
657 """return the JDK directory selected for the 'vm' command""" 661 """return the JDK directory selected for the 'vm' command"""
658 build = _vmbuild if _vmSourcesAvailable else 'product' 662 return _jdk(installJars=False)
659 return _jdk(build, installJars=False)
660 663
661 def print_jdkhome(args, vm=None): 664 def print_jdkhome(args, vm=None):
662 """print the JDK directory selected for the 'vm' command""" 665 """print the JDK directory selected for the 'vm' command"""
663 print jdkhome(vm) 666 print jdkhome(vm)
664 667
973 if cwd is None: 976 if cwd is None:
974 cwd = _vm_cwd 977 cwd = _vm_cwd
975 elif _vm_cwd is not None and _vm_cwd != cwd: 978 elif _vm_cwd is not None and _vm_cwd != cwd:
976 mx.abort("conflicting working directories: do not set --vmcwd for this command") 979 mx.abort("conflicting working directories: do not set --vmcwd for this command")
977 980
978 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product' 981 build = vmbuild if vmbuild else _vmbuild if _vmSourcesAvailable else 'product'
979 jdk = _jdk(build, vmToCheck=vm, installJars=False) 982 jdk = _jdk(build, vmToCheck=vm, installJars=False)
980 _updateInstalledGraalOptionsFile(jdk) 983 _updateInstalledGraalOptionsFile(jdk)
981 mx.expand_project_in_args(args) 984 mx.expand_project_in_args(args)
982 if _make_eclipse_launch: 985 if _make_eclipse_launch:
983 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) 986 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True))