Skip to content

Commit f0891ec

Browse files
committed
Add a new --install option to jt build for installing custom builds.
1 parent 14e0cc5 commit f0891ec

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

tool/jt.rb

+30-18
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ def help
788788
by default it is the name of the mx env file,
789789
the named build stays until it is rebuilt or deleted manually
790790
--new-hash update the git commit hash in RUBY_DESCRIPTION
791+
--install PATH move the build to the specified directory
792+
by default, builds will remain localized to the source tree
791793
mx options: options passed directly to mx
792794
-d start the Java debugger and enables assertions when running truffleruby to configure C extensions
793795
mx build options options passed to the 'build' command of mx
@@ -2504,6 +2506,12 @@ def bootstrap_toolchain
25042506
env
25052507
end
25062508

2509+
install_path = if (i = options.index('--install') || options.index('-i'))
2510+
options.delete_at i
2511+
options.delete_at i
2512+
end
2513+
raise 'Installation path already exists' if File.exist?(install_path.to_s)
2514+
25072515
name = "truffleruby-#{@ruby_name}"
25082516
mx_base_args = ['--env', env]
25092517

@@ -2543,26 +2551,30 @@ def bootstrap_toolchain
25432551
File.symlink(build_dir, dest)
25442552
end
25452553

2546-
# Symlink builds into version manager
2547-
rbenv_root = ENV['RBENV_ROOT']
2548-
rubies_dir = File.join(rbenv_root, 'versions') if rbenv_root && File.directory?(rbenv_root)
2549-
2550-
chruby_versions = File.expand_path('~/.rubies')
2551-
rubies_dir = chruby_versions if File.directory?(chruby_versions)
2554+
if install_path
2555+
File.rename build_dir, install_path
2556+
else
2557+
# Symlink builds into version manager
2558+
rbenv_root = ENV['RBENV_ROOT']
2559+
rubies_dir = File.join(rbenv_root, 'versions') if rbenv_root && File.directory?(rbenv_root)
2560+
2561+
chruby_versions = File.expand_path('~/.rubies')
2562+
rubies_dir = chruby_versions if File.directory?(chruby_versions)
2563+
2564+
if rubies_dir
2565+
Dir.glob(rubies_dir + '/truffleruby-*').each do |link|
2566+
next unless File.symlink?(link)
2567+
next if File.exist?(link)
2568+
target = File.readlink(link)
2569+
next unless target.start_with?("#{TRUFFLERUBY_DIR}/mxbuild")
2570+
File.delete link
2571+
puts "Deleted broken link: #{link} -> #{target}"
2572+
end
25522573

2553-
if rubies_dir
2554-
Dir.glob(rubies_dir + '/truffleruby-*').each do |link|
2555-
next unless File.symlink?(link)
2556-
next if File.exist?(link)
2557-
target = File.readlink(link)
2558-
next unless target.start_with?("#{TRUFFLERUBY_DIR}/mxbuild")
2559-
File.delete link
2560-
puts "Deleted broken link: #{link} -> #{target}"
2574+
link_path = "#{rubies_dir}/#{name}"
2575+
File.delete link_path if File.symlink? link_path or File.exist? link_path
2576+
File.symlink dest_ruby, link_path
25612577
end
2562-
2563-
link_path = "#{rubies_dir}/#{name}"
2564-
File.delete link_path if File.symlink? link_path or File.exist? link_path
2565-
File.symlink dest_ruby, link_path
25662578
end
25672579
end
25682580

0 commit comments

Comments
 (0)