@@ -613,10 +613,11 @@ 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
@@ -630,6 +631,10 @@ def mx(*args, java_home: find_java_home, **options)
630
631
end
631
632
end
632
633
634
+ if primary_suite and Dir . pwd != primary_suite
635
+ mx_args . unshift '-p' , primary_suite
636
+ end
637
+
633
638
sh ( env , find_mx , *mx_args , **options )
634
639
end
635
640
@@ -2400,7 +2405,7 @@ def clone_enterprise
2400
2405
end
2401
2406
2402
2407
def checkout_enterprise_revision ( env = 'jvm-ee' )
2403
- mx ( '-p' , TRUFFLERUBY_DIR , '-- env', env , 'checkout-downstream' , 'compiler' , 'graal-enterprise' )
2408
+ mx ( '-- env' , env , 'checkout-downstream' , 'compiler' , 'graal-enterprise' , primary_suite : TRUFFLERUBY_DIR )
2404
2409
end
2405
2410
2406
2411
def bootstrap_toolchain
@@ -2412,8 +2417,8 @@ def bootstrap_toolchain
2412
2417
destination = File . join ( toolchain_dir , graal_version )
2413
2418
unless File . exist? destination
2414
2419
puts "Building toolchain for: #{ graal_version } "
2415
- mx '-p' , sulong_home , '-- env', 'toolchain-only' , 'build'
2416
- 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
2417
2422
FileUtils . mkdir_p destination
2418
2423
FileUtils . cp_r toolchain_graalvm + '/.' , destination
2419
2424
end
@@ -2433,7 +2438,7 @@ def bootstrap_toolchain
2433
2438
end
2434
2439
2435
2440
private def sforceimports? ( mx_base_args )
2436
- 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 )
2437
2442
2438
2443
unless scheckimports_output . empty?
2439
2444
# Don't ask to update, just warn.
@@ -2499,22 +2504,22 @@ def bootstrap_toolchain
2499
2504
end
2500
2505
2501
2506
name = "truffleruby-#{ @ruby_name } "
2502
- mx_base_args = [ '-p' , TRUFFLERUBY_DIR , '- -env', env ]
2507
+ mx_base_args = [ '--env' , env ]
2503
2508
2504
2509
# Must clone enterprise before running `mx scheckimports` in `sforceimports?`
2505
2510
ee = ee?
2506
2511
cloned = clone_enterprise if ee
2507
2512
checkout_enterprise_revision ( env ) if cloned
2508
2513
2509
2514
if options . delete ( '--sforceimports' ) || sforceimports? ( mx_base_args )
2510
- mx ( '-p ' , TRUFFLERUBY_DIR , 'sforceimports' )
2515
+ mx ( 'sforceimports ' , primary_suite : TRUFFLERUBY_DIR )
2511
2516
if ee
2512
2517
checkout_enterprise_revision ( env ) if !cloned
2513
2518
# sforceimports for optional suites imported in vm-enterprise like substratevm-enterprise-gcs
2514
2519
vm_enterprise = File . expand_path '../graal-enterprise/vm-enterprise' , TRUFFLERUBY_DIR
2515
- mx ( '-p' , vm_enterprise , '-- env', env_path ( env ) , 'sforceimports' )
2520
+ mx ( '-- env' , env_path ( env ) , 'sforceimports' , primary_suite : vm_enterprise )
2516
2521
# And still make sure we import the graal revision as in mx.truffleruby/suite.py
2517
- mx ( '-p ' , TRUFFLERUBY_DIR , 'sforceimports' )
2522
+ mx ( 'sforceimports ' , primary_suite : TRUFFLERUBY_DIR )
2518
2523
end
2519
2524
end
2520
2525
@@ -2523,8 +2528,8 @@ def bootstrap_toolchain
2523
2528
2524
2529
process_env = ENV [ 'JT_CACHE_TOOLCHAIN' ] ? { 'SULONG_BOOTSTRAP_GRAALVM' => bootstrap_toolchain } : { }
2525
2530
2526
- mx ( process_env , *mx_args , 'build' , *mx_build_options )
2527
- 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
2528
2533
2529
2534
dest = "#{ TRUFFLERUBY_DIR } /mxbuild/#{ name } "
2530
2535
dest_ruby = "#{ dest } /languages/ruby"
0 commit comments