Skip to content

Commit

Permalink
Add a new --install option to jt build for installing custom builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Aug 17, 2023
1 parent 0315d12 commit c4bb6dd
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions tool/jt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ def help
by default it is the name of the mx env file,
the named build stays until it is rebuilt or deleted manually
--new-hash update the git commit hash in RUBY_DESCRIPTION
--install PATH move the build to the specified directory
by default, builds will remain localized to the source tree
mx options: options passed directly to mx
-d start the Java debugger and enables assertions when running truffleruby to configure C extensions
mx build options options passed to the 'build' command of mx
Expand Down Expand Up @@ -2518,6 +2520,12 @@ def bootstrap_toolchain
env
end

install_path = if (i = options.index('--install') || options.index('-i'))
options.delete_at i
options.delete_at i
end
raise 'Installation path already exists' if File.exist?(install_path.to_s)

name = "truffleruby-#{@ruby_name}"
mx_base_args = ['--env', env]

Expand Down Expand Up @@ -2557,26 +2565,30 @@ def bootstrap_toolchain
File.symlink(build_dir, dest)
end

# Symlink builds into version manager
rbenv_root = ENV['RBENV_ROOT']
rubies_dir = File.join(rbenv_root, 'versions') if rbenv_root && File.directory?(rbenv_root)

chruby_versions = File.expand_path('~/.rubies')
rubies_dir = chruby_versions if File.directory?(chruby_versions)
if install_path
File.rename build_dir, install_path
else
# Symlink builds into version manager
rbenv_root = ENV['RBENV_ROOT']
rubies_dir = File.join(rbenv_root, 'versions') if rbenv_root && File.directory?(rbenv_root)

chruby_versions = File.expand_path('~/.rubies')
rubies_dir = chruby_versions if File.directory?(chruby_versions)

if rubies_dir
Dir.glob(rubies_dir + '/truffleruby-*').each do |link|
next unless File.symlink?(link)
next if File.exist?(link)
target = File.readlink(link)
next unless target.start_with?("#{TRUFFLERUBY_DIR}/mxbuild")
File.delete link
puts "Deleted broken link: #{link} -> #{target}"
end

if rubies_dir
Dir.glob(rubies_dir + '/truffleruby-*').each do |link|
next unless File.symlink?(link)
next if File.exist?(link)
target = File.readlink(link)
next unless target.start_with?("#{TRUFFLERUBY_DIR}/mxbuild")
File.delete link
puts "Deleted broken link: #{link} -> #{target}"
link_path = "#{rubies_dir}/#{name}"
File.delete link_path if File.symlink? link_path or File.exist? link_path
File.symlink dest_ruby, link_path
end

link_path = "#{rubies_dir}/#{name}"
File.delete link_path if File.symlink? link_path or File.exist? link_path
File.symlink dest_ruby, link_path
end
end

Expand Down

0 comments on commit c4bb6dd

Please sign in to comment.