diff 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
line wrap: on
line diff
--- a/mx/mx_graal.py	Fri Sep 05 12:27:04 2014 +0200
+++ b/mx/mx_graal.py	Thu Sep 04 20:12:10 2014 +0200
@@ -378,7 +378,9 @@
 def _jdksDir():
     return os.path.abspath(join(_installed_jdks if _installed_jdks else _graal_home, 'jdk' + str(mx.java().version)))
 
-def _handle_missing_VM(bld, vm):
+def _handle_missing_VM(bld, vm=None):
+    if not vm:
+        vm = _get_vm()
     mx.log('The ' + bld + ' ' + vm + ' VM has not been created')
     if sys.stdout.isatty():
         if mx.ask_yes_no('Build it now', 'y'):
@@ -387,10 +389,12 @@
             return
     mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM')
 
-def _jdk(build='product', vmToCheck=None, create=False, installJars=True):
+def _jdk(build=None, vmToCheck=None, create=False, installJars=True):
     """
     Get the JDK into which Graal is installed, creating it first if necessary.
     """
+    if not build:
+        build = _vmbuild if _vmSourcesAvailable else 'product'
     jdk = join(_jdksDir(), build)
     if create:
         srcJdk = mx.java().jdk
@@ -462,7 +466,7 @@
         if not exists(jdk):
             if _installed_jdks:
                 mx.log("The selected JDK directory does not (yet) exist: " + jdk)
-            _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal')
+            _handle_missing_VM(build, vmToCheck)
 
     if installJars:
         for jdkDist in _jdkDeployedDists:
@@ -655,8 +659,7 @@
 
 def jdkhome(vm=None):
     """return the JDK directory selected for the 'vm' command"""
-    build = _vmbuild if _vmSourcesAvailable else 'product'
-    return _jdk(build, installJars=False)
+    return _jdk(installJars=False)
 
 def print_jdkhome(args, vm=None):
     """print the JDK directory selected for the 'vm' command"""
@@ -975,7 +978,7 @@
     elif _vm_cwd is not None and _vm_cwd != cwd:
         mx.abort("conflicting working directories: do not set --vmcwd for this command")
 
-    build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product'
+    build = vmbuild if vmbuild else _vmbuild if _vmSourcesAvailable else 'product'
     jdk = _jdk(build, vmToCheck=vm, installJars=False)
     _updateInstalledGraalOptionsFile(jdk)
     mx.expand_project_in_args(args)