@@ -180,12 +180,16 @@ def ee_jdk?
180
180
ee?
181
181
end
182
182
183
+ def graal_common_json
184
+ "#{ GRAAL_DIR } /common.json"
185
+ end
186
+
183
187
def jvmci_version
184
188
@jvmci_version ||= begin
185
- ci = File . read ( " #{ TRUFFLERUBY_DIR } /common.json" )
189
+ common_json = File . read ( graal_common_json )
186
190
edition = ee_jdk? ? 'ee' : 'ce'
187
191
regex = /"labsjdk-#{ edition } -#{ @jdk_version } ":\s *\{ \s *"name":\s *"labsjdk"\s *,\s *"version":\s *"[^"]+-(jvmci-[^"]+)"\s *,/
188
- raise "JVMCI version not found for labsjdk-#{ edition } -#{ @jdk_version } in common.json " unless regex =~ ci
192
+ raise "JVMCI version not found for labsjdk-#{ edition } -#{ @jdk_version } in #{ graal_common_json } " unless regex =~ common_json
189
193
$1
190
194
end
191
195
end
@@ -592,6 +596,7 @@ def find_java_home
592
596
end
593
597
end
594
598
java_home ||= ENV [ 'JAVA_HOME' ]
599
+ fix = 'Run `unset JAVA_HOME` and retry to automatically download the correct JDK.'
595
600
596
601
if java_home
597
602
java_home = File . realpath ( java_home )
@@ -603,10 +608,10 @@ def find_java_home
603
608
if java_version_output . include? ( jvmci_version )
604
609
:use_env_java_home
605
610
elsif java_version_output . include? ( 'jvmci' )
606
- warn "warning: JAVA_HOME=#{ java_home } is not the same JVMCI version as in common.json (#{ jvmci_version } )"
611
+ warn "warning: JAVA_HOME=#{ java_home } is not the same JVMCI version as in #{ graal_common_json } (#{ jvmci_version } ). \n #{ fix } "
607
612
:use_env_java_home
608
613
else
609
- raise "$JAVA_HOME does not seem to point to a JVMCI-enabled JDK (`#{ java_home } /bin/java -version` does not contain 'jvmci')"
614
+ raise "$JAVA_HOME does not seem to point to a JVMCI-enabled JDK (`#{ java_home } /bin/java -version` does not contain 'jvmci'). \n #{ fix } "
610
615
end
611
616
else
612
617
raise '$JAVA_HOME should be set in CI' if ci?
@@ -2329,7 +2334,7 @@ def graph(*args)
2329
2334
ruby2_keywords :cfg2asm if respond_to? ( :ruby2_keywords , true )
2330
2335
2331
2336
def igv
2332
- compiler = File . expand_path '../graal/ compiler' , TRUFFLERUBY_DIR
2337
+ compiler = " #{ GRAAL_DIR } / compiler"
2333
2338
mx ( 'igv' , chdir : compiler )
2334
2339
end
2335
2340
@@ -2358,7 +2363,7 @@ def install(name, *options)
2358
2363
jdk_binaries = File . expand_path '../graal-enterprise/ci/jdk-binaries.json' , TRUFFLERUBY_DIR
2359
2364
end
2360
2365
mx '-y' , 'fetch-jdk' ,
2361
- '--configuration' , " #{ TRUFFLERUBY_DIR } /common.json" ,
2366
+ '--configuration' , graal_common_json ,
2362
2367
*( [ '--jdk-binaries' , jdk_binaries ] if jdk_binaries ) ,
2363
2368
'--java-distribution' , jdk_name ,
2364
2369
'--to' , JDKS_CACHE_DIR ,
@@ -2468,7 +2473,9 @@ def bootstrap_toolchain
2468
2473
end
2469
2474
2470
2475
private def sforceimports? ( mx_base_args )
2471
- scheckimports_output = mx ( *mx_base_args , 'scheckimports' , '--ignore-uncommitted' , '--warn-only' , primary_suite : TRUFFLERUBY_DIR , capture : :both )
2476
+ return true unless File . directory? ( GRAAL_DIR )
2477
+
2478
+ scheckimports_output = mx ( *mx_base_args , 'scheckimports' , '--ignore-uncommitted' , '--warn-only' , java_home : :none , primary_suite : TRUFFLERUBY_DIR , capture : :both )
2472
2479
2473
2480
unless scheckimports_output . empty?
2474
2481
# Don't ask to update, just warn.
@@ -2537,14 +2544,14 @@ def bootstrap_toolchain
2537
2544
checkout_enterprise_revision ( env ) if cloned
2538
2545
2539
2546
if options . delete ( '--sforceimports' ) || sforceimports? ( mx_base_args )
2540
- mx ( 'sforceimports' , primary_suite : TRUFFLERUBY_DIR )
2547
+ mx ( 'sforceimports' , java_home : :none , primary_suite : TRUFFLERUBY_DIR )
2541
2548
if ee
2542
2549
checkout_enterprise_revision ( env ) if !cloned
2543
2550
# sforceimports for optional suites imported in vm-enterprise like substratevm-enterprise-gcs
2544
2551
vm_enterprise = File . expand_path '../graal-enterprise/vm-enterprise' , TRUFFLERUBY_DIR
2545
- mx ( '--env' , env_path ( env ) , 'sforceimports' , primary_suite : vm_enterprise )
2552
+ mx ( '--env' , env_path ( env ) , 'sforceimports' , java_home : :none , primary_suite : vm_enterprise )
2546
2553
# And still make sure we import the graal revision as in mx.truffleruby/suite.py
2547
- mx ( 'sforceimports' , primary_suite : TRUFFLERUBY_DIR )
2554
+ mx ( 'sforceimports' , java_home : :none , primary_suite : TRUFFLERUBY_DIR )
2548
2555
end
2549
2556
end
2550
2557
0 commit comments