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: 61b9e4e2d534
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ca6e1c3db57b
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 13, 2016

  1. Copy the full SHA
    02284a0 View commit details
  2. Copy the full SHA
    b917728 View commit details
  3. Copy the full SHA
    ca6e1c3 View commit details
Showing with 132 additions and 5 deletions.
  1. +119 −2 lib/ruby/truffle/truffle/io/console.rb
  2. +13 −3 tool/jt.rb
121 changes: 119 additions & 2 deletions lib/ruby/truffle/truffle/io/console.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,119 @@
# left unimplemented
# shim needed for bundler, thor
# Copyright (c) 2007-2016 The JRuby project. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

# This is a shim based on JRuby's implementation with stty

# This implementation of io/console is a little hacky. It shells out to `stty`
# for most operations, which does not work on Windows, in secured environments,
# and so on.
#
# Finally, since we're using stty to shell out, we can only manipulate stdin/
# stdout tty rather than manipulating whatever terminal is actually associated
# with the IO we're calling against. This will produce surprising results if
# anyone is actually using io/console against non-stdio ttys...but that case
# seems like it would be pretty rare.

require 'rbconfig'

# Methods common to all backend impls
class IO
def getch(*)
raw do
getc
end
end

def getpass(prompt = nil)
wio = self == $stdin ? $stderr : self
wio.write(prompt) if prompt
begin
str = nil
noecho do
str = gets
end
ensure
puts($/)
end
str.chomp
end
end


class IO
if RbConfig::CONFIG['host_os'].downcase =~ /linux/ && File.exists?("/proc/#{Process.pid}/fd")
def stty(*args)
`stty #{args.join(' ')} < /proc/#{Process.pid}/fd/#{fileno}`
end
else
def stty(*args)
`stty #{args.join(' ')}`
end
end

def raw(*)
saved = stty('-g')
stty('raw')
yield self
ensure
stty(saved)
end

def raw!(*)
stty('raw')
end

def cooked(*)
saved = stty('-g')
stty('-raw')
yield self
ensure
stty(saved)
end

def cooked!(*)
stty('-raw')
end

def echo=(echo)
stty(echo ? 'echo' : '-echo')
end

def echo?
(stty('-a') =~ / -echo /) ? false : true
end

def noecho
saved = stty('-g')
stty('-echo')
yield self
ensure
stty(saved)
end

# Not all systems return same format of stty -a output
IEEE_STD_1003_2 = '(?<rows>\d+) rows; (?<columns>\d+) columns'
UBUNTU = 'rows (?<rows>\d+); columns (?<columns>\d+)'

def winsize
match = stty('-a').match(/#{IEEE_STD_1003_2}|#{UBUNTU}/)
[match[:rows].to_i, match[:columns].to_i]
end

def winsize=(size)
stty("rows #{size[0]} cols #{size[1]}")
end

def iflush
end

def oflush
end

def ioflush
end
end
16 changes: 13 additions & 3 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -106,7 +106,15 @@ def self.find_graal_javacmd_and_options
options = ['--no-bootclasspath']
elsif graal_home
graal_home = File.expand_path(graal_home)
command_line = `mx -v -p #{graal_home} vm -version`.lines.to_a.last
output = `mx -v -p #{graal_home} vm -version 2>&1`.lines.to_a
command_line = output.select { |line| line.include? '-version' }
if command_line.size == 1
command_line = command_line[0]
else
$stderr.puts "Error in mx for setting up Graal:"
$stderr.puts output
abort
end
vm_args = command_line.split
vm_args.pop # Drop "-version"
javacmd = vm_args.shift
@@ -662,12 +670,14 @@ def run(*args)
jruby_args << "-J-Dgraal.TraceTruffleCompilation=true"
end

args << options = {}

if args.delete('--no-print-cmd')
args << { no_print_cmd: true }
options[:no_print_cmd] = true
end

if args.delete('--exec')
args << { use_exec: true }
options[:use_exec] = true
end

raw_sh env_vars, Utilities.find_jruby, *jruby_args, *args