@@ -681,7 +681,7 @@ class GraalPythonTags(object):
681681 unittest_posix = 'python-unittest-posix'
682682 unittest_standalone = 'python-unittest-standalone'
683683 unittest_gradle_plugin = 'python-unittest-gradle-plugin'
684- unittest_maven_plugin = 'python-unittest-maven-plugin'
684+ unittest_maven_plugin = 'python-unittest-maven-plugin'
685685 ginstall = 'python-ginstall'
686686 tagged = 'python-tagged-unittest'
687687 svmunit = 'python-svm-unittest'
@@ -857,6 +857,48 @@ def graalpy_standalone_native_enterprise():
857857
858858
859859def graalvm_jdk ():
860+ jdk_version = mx .get_jdk ().version
861+
862+ # Check if GRAAL_JDK_HOME points to some compatible pre-built gvm
863+ graal_jdk_home = os .environ .get ("GRAAL_JDK_HOME" , None )
864+ if graal_jdk_home and "*" in graal_jdk_home :
865+ graal_jdk_home = os .path .abspath (glob .glob (graal_jdk_home )[0 ])
866+ if sys .platform == "darwin" :
867+ graal_jdk_home = os .path .join (graal_jdk_home , 'Contents' , 'Home' )
868+ mx .log ("Using GraalPy standalone from GRAAL_JDK_HOME: " + graal_jdk_home )
869+
870+ # Try to verify that we're getting what we expect:
871+ has_java = os .path .exists (os .path .join (graal_jdk_home , 'bin' , 'java.exe' if WIN32 else 'java' ))
872+ if not has_java :
873+ mx .abort (f"GRAAL_JDK_HOME does not contain java executable." )
874+
875+ release = os .path .join (graal_jdk_home , 'release' )
876+ if not os .path .exists (release ):
877+ mx .abort (f"No 'release' file in GRAAL_JDK_HOME." )
878+
879+ java_version = None
880+ implementor = None
881+ with open (release , 'r' ) as f :
882+ while not (java_version and implementor ):
883+ line = f .readline ()
884+ if 'JAVA_VERSION=' in line :
885+ java_version = line
886+ if 'IMPLEMENTOR=' in line :
887+ implementor = line
888+
889+ if not java_version :
890+ mx .abort (f"Could not check Java version in GRAAL_JDK_HOME 'release' file." )
891+ actual_jdk_version = mx .VersionSpec (java_version .strip ('JAVA_VERSION=' ).strip (' "\n \r ' ))
892+ if actual_jdk_version != jdk_version :
893+ mx .abort (f"GRAAL_JDK_HOME is not compatible with the requested JDK version.\n "
894+ f"actual version: '{ actual_jdk_version } ', version string: { java_version } , requested version: { jdk_version } ." )
895+
896+ if not implementor :
897+ mx .abort (f"Could not check implementor in GRAAL_JDK_HOME 'release' file." )
898+ if 'GraalVM' not in implementor :
899+ mx .abort (f"GRAAL_JDK_HOME 'releases' has an unexpected implementor: '{ implementor } '." )
900+ return graal_jdk_home
901+
860902 jdk_major_version = mx .get_jdk ().version .parts [0 ]
861903 mx_args = ['-p' , os .path .join (mx .suite ('truffle' ).dir , '..' , 'vm' ), '--env' , 'ce' ]
862904 if not DISABLE_REBUILD :
0 commit comments