Skip to content

Commit

Permalink
Logic to automatically find Graal if it's built as a sibling
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Aug 7, 2017
1 parent fda7129 commit dc57b99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 4 additions & 2 deletions doc/contributor/workflow.md
Expand Up @@ -142,10 +142,12 @@ $ export GRAALVM_BIN=.../graalvm-0.nn/bin/java
$ jt ruby --graal -e 'p Truffle.graal?'
```

To run with Graal built from source, set `GRAAL_HOME`.
To run with Graal built from source, set `GRAAL_HOME`. Or it will be
automatically found if it is cloned into the same directory as `truffleruby`, it
is built, and you are not using a binary suite for Truffle.

```bash
$ export GRAAL_HOME=.../graal-core
$ export GRAAL_HOME=.../graal
$ jt ruby --graal ...
```

Expand Down
20 changes: 16 additions & 4 deletions tool/jt.rb
Expand Up @@ -85,8 +85,12 @@ def self.find_graal_javacmd_and_options
"--module-path=#{jvmci_graal_home}/../truffle/mxbuild/modules/com.oracle.truffle.truffle_api.jar:#{jvmci_graal_home}/mxbuild/modules/com.oracle.graal.graal_core.jar"
]
options = ['--no-bootclasspath']
elsif graal_home
graal_home = File.expand_path(graal_home, TRUFFLERUBY_DIR)
elsif graal_home || auto_graal_home = find_auto_graal_home
if graal_home
graal_home = File.expand_path(graal_home, TRUFFLERUBY_DIR)
else
graal_home = auto_graal_home
end
output, _ = ShellUtils.mx('-v', '-p', graal_home, 'vm', '-version', :err => :out, capture: true)
command_line = output.lines.select { |line| line.include? '-version' }
if command_line.size == 1
Expand All @@ -105,6 +109,14 @@ def self.find_graal_javacmd_and_options
end
[javacmd, vm_args.map { |arg| "-J#{arg}" } + options]
end

def self.find_auto_graal_home
sibling_compiler = File.expand_path('../graal/compiler', TRUFFLERUBY_DIR)
return nil unless Dir.exist?(sibling_compiler)
return nil unless File.exist?("#{sibling_compiler}/mxbuild/dists/graal-compiler.jar")
return nil if Dir.exist?("#{TRUFFLERUBY_DIR}/mx.imports/binary/truffle")
sibling_compiler
end

def self.which(binary)
ENV["PATH"].split(File::PATH_SEPARATOR).each do |dir|
Expand Down Expand Up @@ -381,7 +393,7 @@ def help
jt rebuild clean, sforceimports, and build
jt dis <file> finds the bc file in the project, disassembles, and returns new filename
jt run [options] args... run JRuby with args
--graal use Graal (set either GRAALVM_BIN or GRAAL_HOME)
--graal use Graal (set either GRAALVM_BIN, JVMCI_BIN or GRAAL_HOME, or have graal built as a sibling)
--stress stress the compiler (compile immediately, foreground compilation, compilation exceptions are fatal)
--js add Graal.js to the classpath (set GRAAL_JS_JAR)
--asm show assembly (implies --graal)
Expand All @@ -404,7 +416,7 @@ def help
--syslog runs syslog tests
--openssl runs openssl tests
--aot use AOT TruffleRuby image (set AOT_BIN)
--graal use Graal (set either GRAALVM_BIN, JVMCI_BIN or GRAAL_HOME)
--graal use Graal (set either GRAALVM_BIN, JVMCI_BIN or GRAAL_HOME, or have graal built as a sibling)
jt test specs run all specs
jt test specs fast run all specs except sub-processes, GC, sleep, ...
jt test spec/ruby/language run specs in this directory
Expand Down

0 comments on commit dc57b99

Please sign in to comment.