Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build installation option #3217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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