@@ -613,17 +613,26 @@ def find_java_home
613
613
end
614
614
end
615
615
616
- def mx ( *args , java_home : find_java_home , **options )
616
+ def mx ( *args , java_home : find_java_home , primary_suite : nil , **options )
617
617
mx_args = args . dup
618
618
619
619
env = mx_args . first . is_a? ( Hash ) ? mx_args . shift : { }
620
+
620
621
if java_home == :use_env_java_home
621
622
# mx reads $JAVA_HOME
622
623
elsif java_home == :none
623
624
# Make sure $JAVA_HOME is not set, as a wrong value causes mx to abort
624
625
env [ 'JAVA_HOME' ] = nil
625
626
else
626
- mx_args . unshift '--java-home' , java_home
627
+ if java_home . start_with? ( JDKS_CACHE_DIR )
628
+ mx_args . unshift '--java-home' , java_home [ JDKS_CACHE_DIR . size +1 ..-1 ]
629
+ else
630
+ mx_args . unshift '--java-home' , java_home
631
+ end
632
+ end
633
+
634
+ if primary_suite and Dir . pwd != primary_suite
635
+ mx_args . unshift '-p' , primary_suite
627
636
end
628
637
629
638
sh ( env , find_mx , *mx_args , **options )
@@ -2396,7 +2405,7 @@ def clone_enterprise
2396
2405
end
2397
2406
2398
2407
def checkout_enterprise_revision ( env = 'jvm-ee' )
2399
- mx ( '-p' , TRUFFLERUBY_DIR , '-- env', env , 'checkout-downstream' , 'compiler' , 'graal-enterprise' )
2408
+ mx ( '-- env' , env , 'checkout-downstream' , 'compiler' , 'graal-enterprise' , primary_suite : TRUFFLERUBY_DIR )
2400
2409
end
2401
2410
2402
2411
def bootstrap_toolchain
@@ -2408,8 +2417,8 @@ def bootstrap_toolchain
2408
2417
destination = File . join ( toolchain_dir , graal_version )
2409
2418
unless File . exist? destination
2410
2419
puts "Building toolchain for: #{ graal_version } "
2411
- mx '-p' , sulong_home , '-- env', 'toolchain-only' , 'build'
2412
- toolchain_graalvm = mx ( '-p' , sulong_home , '-- env', 'toolchain-only' , 'graalvm-home' , capture : :out ) . lines . last . chomp
2420
+ mx '-- env' , 'toolchain-only' , 'build' , primary_suite : sulong_home
2421
+ toolchain_graalvm = mx ( '-- env' , 'toolchain-only' , 'graalvm-home' , primary_suite : sulong_home , capture : :out ) . lines . last . chomp
2413
2422
FileUtils . mkdir_p destination
2414
2423
FileUtils . cp_r toolchain_graalvm + '/.' , destination
2415
2424
end
@@ -2429,7 +2438,7 @@ def bootstrap_toolchain
2429
2438
end
2430
2439
2431
2440
private def sforceimports? ( mx_base_args )
2432
- scheckimports_output = mx ( *mx_base_args , 'scheckimports' , '--ignore-uncommitted' , '--warn-only' , capture : :both )
2441
+ scheckimports_output = mx ( *mx_base_args , 'scheckimports' , '--ignore-uncommitted' , '--warn-only' , primary_suite : TRUFFLERUBY_DIR , capture : :both )
2433
2442
2434
2443
unless scheckimports_output . empty?
2435
2444
# Don't ask to update, just warn.
@@ -2495,22 +2504,22 @@ def bootstrap_toolchain
2495
2504
end
2496
2505
2497
2506
name = "truffleruby-#{ @ruby_name } "
2498
- mx_base_args = [ '-p' , TRUFFLERUBY_DIR , '- -env', env ]
2507
+ mx_base_args = [ '--env' , env ]
2499
2508
2500
2509
# Must clone enterprise before running `mx scheckimports` in `sforceimports?`
2501
2510
ee = ee?
2502
2511
cloned = clone_enterprise if ee
2503
2512
checkout_enterprise_revision ( env ) if cloned
2504
2513
2505
2514
if options . delete ( '--sforceimports' ) || sforceimports? ( mx_base_args )
2506
- mx ( '-p ' , TRUFFLERUBY_DIR , 'sforceimports' )
2515
+ mx ( 'sforceimports ' , primary_suite : TRUFFLERUBY_DIR )
2507
2516
if ee
2508
2517
checkout_enterprise_revision ( env ) if !cloned
2509
2518
# sforceimports for optional suites imported in vm-enterprise like substratevm-enterprise-gcs
2510
2519
vm_enterprise = File . expand_path '../graal-enterprise/vm-enterprise' , TRUFFLERUBY_DIR
2511
- mx ( '-p' , vm_enterprise , '-- env', env_path ( env ) , 'sforceimports' )
2520
+ mx ( '-- env' , env_path ( env ) , 'sforceimports' , primary_suite : vm_enterprise )
2512
2521
# And still make sure we import the graal revision as in mx.truffleruby/suite.py
2513
- mx ( '-p ' , TRUFFLERUBY_DIR , 'sforceimports' )
2522
+ mx ( 'sforceimports ' , primary_suite : TRUFFLERUBY_DIR )
2514
2523
end
2515
2524
end
2516
2525
@@ -2519,8 +2528,8 @@ def bootstrap_toolchain
2519
2528
2520
2529
process_env = ENV [ 'JT_CACHE_TOOLCHAIN' ] ? { 'SULONG_BOOTSTRAP_GRAALVM' => bootstrap_toolchain } : { }
2521
2530
2522
- mx ( process_env , *mx_args , 'build' , *mx_build_options )
2523
- build_dir = mx ( *mx_args , 'graalvm-home' , capture : :out ) . lines . last . chomp
2531
+ mx ( process_env , *mx_args , 'build' , *mx_build_options , primary_suite : TRUFFLERUBY_DIR )
2532
+ build_dir = mx ( *mx_args , 'graalvm-home' , primary_suite : TRUFFLERUBY_DIR , capture : :out ) . lines . last . chomp
2524
2533
2525
2534
dest = "#{ TRUFFLERUBY_DIR } /mxbuild/#{ name } "
2526
2535
dest_ruby = "#{ dest } /languages/ruby"
0 commit comments