Skip to content

Commit 9459868

Browse files
committed
[GR-17457] [GR-46573] Pass just the JDK basename to mx, as it can now resolve it
PullRequest: truffleruby/3867
2 parents fc3010e + 3246423 commit 9459868

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

tool/jt.rb

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -613,17 +613,26 @@ 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
623624
# Make sure $JAVA_HOME is not set, as a wrong value causes mx to abort
624625
env['JAVA_HOME'] = nil
625626
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
627636
end
628637

629638
sh(env, find_mx, *mx_args, **options)
@@ -2396,7 +2405,7 @@ def clone_enterprise
23962405
end
23972406

23982407
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)
24002409
end
24012410

24022411
def bootstrap_toolchain
@@ -2408,8 +2417,8 @@ def bootstrap_toolchain
24082417
destination = File.join(toolchain_dir, graal_version)
24092418
unless File.exist? destination
24102419
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
24132422
FileUtils.mkdir_p destination
24142423
FileUtils.cp_r toolchain_graalvm + '/.', destination
24152424
end
@@ -2429,7 +2438,7 @@ def bootstrap_toolchain
24292438
end
24302439

24312440
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)
24332442

24342443
unless scheckimports_output.empty?
24352444
# Don't ask to update, just warn.
@@ -2495,22 +2504,22 @@ def bootstrap_toolchain
24952504
end
24962505

24972506
name = "truffleruby-#{@ruby_name}"
2498-
mx_base_args = ['-p', TRUFFLERUBY_DIR, '--env', env]
2507+
mx_base_args = ['--env', env]
24992508

25002509
# Must clone enterprise before running `mx scheckimports` in `sforceimports?`
25012510
ee = ee?
25022511
cloned = clone_enterprise if ee
25032512
checkout_enterprise_revision(env) if cloned
25042513

25052514
if options.delete('--sforceimports') || sforceimports?(mx_base_args)
2506-
mx('-p', TRUFFLERUBY_DIR, 'sforceimports')
2515+
mx('sforceimports', primary_suite: TRUFFLERUBY_DIR)
25072516
if ee
25082517
checkout_enterprise_revision(env) if !cloned
25092518
# sforceimports for optional suites imported in vm-enterprise like substratevm-enterprise-gcs
25102519
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)
25122521
# 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)
25142523
end
25152524
end
25162525

@@ -2519,8 +2528,8 @@ def bootstrap_toolchain
25192528

25202529
process_env = ENV['JT_CACHE_TOOLCHAIN'] ? { 'SULONG_BOOTSTRAP_GRAALVM' => bootstrap_toolchain } : {}
25212530

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
25242533

25252534
dest = "#{TRUFFLERUBY_DIR}/mxbuild/#{name}"
25262535
dest_ruby = "#{dest}/languages/ruby"

0 commit comments

Comments
 (0)