Skip to content

Commit 3246423

Browse files
committed
jt: set the primary mx suite via a keyword argument
1 parent cd4292e commit 3246423

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

tool/jt.rb

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,11 @@ def find_java_home
613613
end
614614
end
615615

616-
def mx(*args, java_home: find_java_home, **options)
616+
def mx(*args, java_home: find_java_home, primary_suite: nil, **options)
617617
mx_args = args.dup
618618

619619
env = mx_args.first.is_a?(Hash) ? mx_args.shift : {}
620+
620621
if java_home == :use_env_java_home
621622
# mx reads $JAVA_HOME
622623
elsif java_home == :none
@@ -630,6 +631,10 @@ def mx(*args, java_home: find_java_home, **options)
630631
end
631632
end
632633

634+
if primary_suite and Dir.pwd != primary_suite
635+
mx_args.unshift '-p', primary_suite
636+
end
637+
633638
sh(env, find_mx, *mx_args, **options)
634639
end
635640

@@ -2400,7 +2405,7 @@ def clone_enterprise
24002405
end
24012406

24022407
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)
24042409
end
24052410

24062411
def bootstrap_toolchain
@@ -2412,8 +2417,8 @@ def bootstrap_toolchain
24122417
destination = File.join(toolchain_dir, graal_version)
24132418
unless File.exist? destination
24142419
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
24172422
FileUtils.mkdir_p destination
24182423
FileUtils.cp_r toolchain_graalvm + '/.', destination
24192424
end
@@ -2433,7 +2438,7 @@ def bootstrap_toolchain
24332438
end
24342439

24352440
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)
24372442

24382443
unless scheckimports_output.empty?
24392444
# Don't ask to update, just warn.
@@ -2499,22 +2504,22 @@ def bootstrap_toolchain
24992504
end
25002505

25012506
name = "truffleruby-#{@ruby_name}"
2502-
mx_base_args = ['-p', TRUFFLERUBY_DIR, '--env', env]
2507+
mx_base_args = ['--env', env]
25032508

25042509
# Must clone enterprise before running `mx scheckimports` in `sforceimports?`
25052510
ee = ee?
25062511
cloned = clone_enterprise if ee
25072512
checkout_enterprise_revision(env) if cloned
25082513

25092514
if options.delete('--sforceimports') || sforceimports?(mx_base_args)
2510-
mx('-p', TRUFFLERUBY_DIR, 'sforceimports')
2515+
mx('sforceimports', primary_suite: TRUFFLERUBY_DIR)
25112516
if ee
25122517
checkout_enterprise_revision(env) if !cloned
25132518
# sforceimports for optional suites imported in vm-enterprise like substratevm-enterprise-gcs
25142519
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)
25162521
# 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)
25182523
end
25192524
end
25202525

@@ -2523,8 +2528,8 @@ def bootstrap_toolchain
25232528

25242529
process_env = ENV['JT_CACHE_TOOLCHAIN'] ? { 'SULONG_BOOTSTRAP_GRAALVM' => bootstrap_toolchain } : {}
25252530

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
25282533

25292534
dest = "#{TRUFFLERUBY_DIR}/mxbuild/#{name}"
25302535
dest_ruby = "#{dest}/languages/ruby"

0 commit comments

Comments
 (0)