Skip to content

Commit c4bb6dd

Browse files
committed
Add a new --install option to jt build for installing custom builds.
1 parent 0315d12 commit c4bb6dd

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

tool/jt.rb

Lines changed: 30 additions & 18 deletions
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
@@ -2518,6 +2520,12 @@ def bootstrap_toolchain
25182520
env
25192521
end
25202522

2523+
install_path = if (i = options.index('--install') || options.index('-i'))
2524+
options.delete_at i
2525+
options.delete_at i
2526+
end
2527+
raise 'Installation path already exists' if File.exist?(install_path.to_s)
2528+
25212529
name = "truffleruby-#{@ruby_name}"
25222530
mx_base_args = ['--env', env]
25232531

@@ -2557,26 +2565,30 @@ def bootstrap_toolchain
25572565
File.symlink(build_dir, dest)
25582566
end
25592567

2560-
# Symlink builds into version manager
2561-
rbenv_root = ENV['RBENV_ROOT']
2562-
rubies_dir = File.join(rbenv_root, 'versions') if rbenv_root && File.directory?(rbenv_root)
2563-
2564-
chruby_versions = File.expand_path('~/.rubies')
2565-
rubies_dir = chruby_versions if File.directory?(chruby_versions)
2568+
if install_path
2569+
File.rename build_dir, install_path
2570+
else
2571+
# Symlink builds into version manager
2572+
rbenv_root = ENV['RBENV_ROOT']
2573+
rubies_dir = File.join(rbenv_root, 'versions') if rbenv_root && File.directory?(rbenv_root)
2574+
2575+
chruby_versions = File.expand_path('~/.rubies')
2576+
rubies_dir = chruby_versions if File.directory?(chruby_versions)
2577+
2578+
if rubies_dir
2579+
Dir.glob(rubies_dir + '/truffleruby-*').each do |link|
2580+
next unless File.symlink?(link)
2581+
next if File.exist?(link)
2582+
target = File.readlink(link)
2583+
next unless target.start_with?("#{TRUFFLERUBY_DIR}/mxbuild")
2584+
File.delete link
2585+
puts "Deleted broken link: #{link} -> #{target}"
2586+
end
25662587

2567-
if rubies_dir
2568-
Dir.glob(rubies_dir + '/truffleruby-*').each do |link|
2569-
next unless File.symlink?(link)
2570-
next if File.exist?(link)
2571-
target = File.readlink(link)
2572-
next unless target.start_with?("#{TRUFFLERUBY_DIR}/mxbuild")
2573-
File.delete link
2574-
puts "Deleted broken link: #{link} -> #{target}"
2588+
link_path = "#{rubies_dir}/#{name}"
2589+
File.delete link_path if File.symlink? link_path or File.exist? link_path
2590+
File.symlink dest_ruby, link_path
25752591
end
2576-
2577-
link_path = "#{rubies_dir}/#{name}"
2578-
File.delete link_path if File.symlink? link_path or File.exist? link_path
2579-
File.symlink dest_ruby, link_path
25802592
end
25812593
end
25822594

0 commit comments

Comments
 (0)