@@ -185,16 +185,19 @@ def ruby_launcher
185
185
return @ruby_launcher if defined? @ruby_launcher
186
186
187
187
@ruby_name ||= ENV [ 'RUBY_BIN' ] || 'jvm'
188
- @ ruby_launcher = if @ruby_name == 'ruby'
189
- ENV [ 'RBENV_ROOT' ] ? `rbenv which ruby` . chomp : which ( 'ruby' )
190
- elsif File . executable? ( @ruby_name )
191
- @ruby_name
192
- else
193
- "#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-#{ @ruby_name } /#{ language_dir } /ruby/bin/ruby"
194
- end
188
+ ruby_launcher = if @ruby_name == 'ruby'
189
+ ENV [ 'RBENV_ROOT' ] ? `rbenv which ruby` . chomp : which ( 'ruby' )
190
+ elsif File . executable? ( @ruby_name )
191
+ @ruby_name
192
+ else
193
+ "#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-#{ @ruby_name } /#{ language_dir } /ruby/bin/ruby"
194
+ end
195
195
196
- raise "The Ruby executable #{ @ruby_launcher } does not exist" unless File . exist? ( @ruby_launcher )
197
- raise "The Ruby executable #{ @ruby_launcher } is not executable" unless File . executable? ( @ruby_launcher )
196
+ raise "The Ruby executable #{ ruby_launcher } does not exist" unless File . exist? ( ruby_launcher )
197
+ ruby_launcher = File . realpath ( ruby_launcher )
198
+
199
+ raise "The Ruby executable #{ ruby_launcher } is not executable" unless File . executable? ( ruby_launcher )
200
+ @ruby_launcher = ruby_launcher
198
201
199
202
unless @silent
200
203
shortened_path = @ruby_launcher . sub ( %r[^#{ Regexp . escape TRUFFLERUBY_DIR } /] , '' ) . sub ( %r[/bin/ruby$] , '' ) . sub ( %r[/#{ language_dir } /ruby$] , '' )
@@ -210,9 +213,12 @@ def ruby_launcher
210
213
ENV [ 'RUBY_BIN' ] = ruby_launcher
211
214
@ruby_launcher
212
215
end
213
-
214
216
alias_method :require_ruby_launcher! , :ruby_launcher
215
217
218
+ def ruby_home
219
+ File . expand_path ( '../..' , ruby_launcher )
220
+ end
221
+
216
222
def truffleruby_native!
217
223
unless truffleruby_native?
218
224
raise "The ruby executable #{ ruby_launcher } is not native."
@@ -239,8 +245,7 @@ def truffleruby_compiler?
239
245
return @truffleruby_compiler = true if truffleruby_native?
240
246
241
247
# Detect if the compiler is present by reading the $graalvm_home/release file
242
- # Use realpath to always use the executable in languages/ruby/bin/
243
- graalvm_home = File . expand_path ( "../../../..#{ '/..' * language_dir . count ( '/' ) } " , File . realpath ( ruby_launcher ) )
248
+ graalvm_home = File . expand_path ( "..#{ '/..' * ( language_dir . count ( '/' ) + 1 ) } " , ruby_home )
244
249
@truffleruby_compiler = File . readlines ( "#{ graalvm_home } /release" ) . grep ( /^COMMIT_INFO=/ ) . any? do |line |
245
250
line . include? ( '"compiler":' ) || line . include? ( "'compiler':" )
246
251
end
@@ -907,7 +912,7 @@ def test(*args)
907
912
# TODO (eregon, 4 Feb 2019): This should run on GraalVM, not development jars
908
913
# The home needs to be set, otherwise TruffleFile does not allow access to files in the TruffleRuby home,
909
914
# because it cannot find the correct home.
910
- home = "-Druby.home=#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-jvm/ #{ language_dir } /ruby "
915
+ home = "-Druby.home=#{ ruby_home } "
911
916
mx 'unittest' , home , *tests
912
917
when 'tck' then mx 'tck' , *rest
913
918
else
@@ -1143,7 +1148,7 @@ def retag(*args)
1143
1148
1144
1149
# Test that running the post-install hook works, even when opt &
1145
1150
# llvm-link are not on PATH, as it is the case on macOS.
1146
- sh ( { 'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true' } , "mxbuild/truffleruby-jvm/ #{ language_dir } /ruby /lib/truffle/post_install_hook.sh" )
1151
+ sh ( { 'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true' } , "#{ ruby_home } /lib/truffle/post_install_hook.sh" )
1147
1152
1148
1153
when 'gems'
1149
1154
# Test that we can compile and run some real C extensions
@@ -1745,8 +1750,6 @@ def format_time_metrics(*args)
1745
1750
end
1746
1751
1747
1752
def benchmark ( *args )
1748
- require_ruby_launcher!
1749
-
1750
1753
vm_args = [ ]
1751
1754
if truffleruby?
1752
1755
vm_args << '--experimental-options' << '--engine.CompilationExceptionsAreFatal'
0 commit comments