Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1a724dbc6b3c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 11780a0332f6
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jan 4, 2016

  1. [Truffle] j+tr: rename --rest to --no-truffle

    Runs common JRuby in prepared environment.
    pitr-ch committed Jan 4, 2016
    Copy the full SHA
    9300d80 View commit details
  2. Copy the full SHA
    11780a0 View commit details
Showing with 26 additions and 18 deletions.
  1. +26 −18 lib/ruby/truffle/jruby+truffle/runner.rb
44 changes: 26 additions & 18 deletions lib/ruby/truffle/jruby+truffle/runner.rb
Original file line number Diff line number Diff line change
@@ -13,7 +13,13 @@
require 'shellwords'
require 'pathname'

# TODO (pitr 01-Sep-2015): add pre stored run options combinations like -S irb, -I test
require 'rubygems'
begin
require 'bundler'
rescue LoadError => e
puts "Bundler has to be installed.\n"
raise e
end

class JRubyTruffleRunner
attr_reader :options
@@ -59,7 +65,7 @@ class JRubyTruffleRunner
assign_new_value, 'mocks'],
use_fs_core: ['--[no-]use-fs-core', 'Use core from the filesystem rather than the JAR',
assign_new_value, true],
bundle_cmd: ['--bundle-cmd CMD', 'Command to run for bundle', assign_new_value, 'bundle'],
bundle_options: ['--bundle-options OPTIONS', 'bundle options separated by space', assign_new_value, ''],
configuration: ['--config GEM_NAME', 'Load configuration for specified gem', assign_new_value, nil],
dir: ['--dir DIRECTORY', 'Set working directory', assign_new_value, Dir.pwd],
},
@@ -71,7 +77,7 @@ class JRubyTruffleRunner
},
run: {
help: ['-h', '--help', 'Show this message', assign_new_value, false],
test: ['-t', '--test', "Use conventional JRuby instead of #{BRANDING}", assign_new_value, false],
no_truffle: ['-n', '--no-truffle', "Use conventional JRuby instead of #{BRANDING}", assign_new_value, false],
graal: ['-g', '--graal', 'Run on graal', assign_new_value, false],
build: ['-b', '--build', 'Run `jt build` using conventional JRuby', assign_new_value, false],
rebuild: ['--rebuild', 'Run `jt rebuild` using conventional JRuby', assign_new_value, false],
@@ -306,21 +312,15 @@ def eval_yaml_strings(value)
end
end

# TODO (pitr 24-Nov-2015): use correct gem and bundler commands, do not pick them up from PATH
def subcommand_setup(rest)
bundle_cmd = @options[:global][:bundle_cmd].split(' ')
bundle_path = File.expand_path(@options[:global][:truffle_bundle_path])

if bundle_cmd == ['bundle']
bundle_installed = execute_cmd 'command -v bundle 2>/dev/null 1>&2', fail: false
execute_cmd 'gem install bundler' unless bundle_installed
end
bundle_options = @options[:global][:bundle_options].split(' ')
bundle_path = File.expand_path(@options[:global][:truffle_bundle_path])

execute_cmd [*bundle_cmd,
'install',
'--standalone',
'--path', bundle_path,
*(['--without', @options[:setup][:without].join(' ')] unless @options[:setup][:without].empty?)]
bundle_cli([*bundle_options,
'install',
'--standalone',
'--path', bundle_path,
*(['--without', @options[:setup][:without].join(' ')] unless @options[:setup][:without].empty?)])

link_path = "#{bundle_path}/jruby+truffle"
FileUtils.rm link_path if File.exist? link_path
@@ -344,6 +344,14 @@ def subcommand_setup(rest)
end
end

def bundle_cli(argv)
require 'bundler/friendly_errors'
Bundler.with_friendly_errors do
require 'bundler/cli'
Bundler::CLI.start(argv, :debug => true)
end
end

def subcommand_run(rest)
jruby_path = Pathname("#{@options[:global][:interpreter_path]}/../..").expand_path
ruby_options, rest = if rest.include?('--')
@@ -376,12 +384,12 @@ def subcommand_run(rest)
truffle_options = [
('-X+T'),
("-Xtruffle.core.load_path=#{core_load_path}" if @options[:global][:use_fs_core]),
('-Xtruffle.exceptions.print_java=true' if @options[:run][:jexception] && !@options[:run][:test]),
('-Xtruffle.exceptions.print_java=true' if @options[:run][:jexception]),
(format(@options[:global][:debug_option], @options[:global][:debug_port]) if @options[:run][:debug])
]

cmd_options = [
*(truffle_options unless @options[:run][:test]),
*(truffle_options unless @options[:run][:no_truffle]),
*ruby_options,
'-r', "./#{@options[:global][:truffle_bundle_path]}/bundler/setup.rb",
*@options[:run][:load_path].flat_map { |v| ['-I', v] },