Skip to content

Commit e087803

Browse files
committed
skip build in graalvm_jdk if GRAAL_JDK_HOME env var is set
1 parent 9e56b9d commit e087803

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "95c740e3e3b11c3f64a88005aa64e46e46e7caec" }
1+
{ "overlay": "4b12b552845acf0e50bdebdebf46df25aaf93a6d" }

mx.graalpython/mx_graalpython.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

859859
def 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

Comments
 (0)