@@ -190,7 +190,8 @@ def ruby_launcher
190
190
elsif File . executable? ( @ruby_name )
191
191
@ruby_name
192
192
else
193
- "#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-#{ @ruby_name } /#{ language_dir } /ruby/bin/ruby"
193
+ graalvm = "#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-#{ @ruby_name } "
194
+ "#{ graalvm } /#{ language_dir ( graalvm ) } /ruby/bin/ruby"
194
195
end
195
196
196
197
raise "The Ruby executable #{ ruby_launcher } does not exist" unless File . exist? ( ruby_launcher )
@@ -200,7 +201,8 @@ def ruby_launcher
200
201
@ruby_launcher = ruby_launcher
201
202
202
203
unless @silent
203
- shortened_path = @ruby_launcher . sub ( %r[^#{ Regexp . escape TRUFFLERUBY_DIR } /] , '' ) . sub ( %r[/bin/ruby$] , '' ) . sub ( %r[/#{ language_dir } /ruby$] , '' )
204
+ shortened_path = @ruby_launcher . sub ( %r[^#{ Regexp . escape TRUFFLERUBY_DIR } /] , '' ) . sub ( %r[/bin/(ruby|truffleruby)$] , '' )
205
+ shortened_path = shortened_path . sub ( %r[/#{ language_dir ( graalvm_home ) } /ruby$] , '' ) if graalvm_home
204
206
tags = [ *( 'Native' if truffleruby_native? ) ,
205
207
*( 'Interpreted' if truffleruby? && !truffleruby_compiler? ) ,
206
208
truffleruby? ? 'TruffleRuby' : 'a Ruby' ,
@@ -219,6 +221,18 @@ def ruby_home
219
221
File . expand_path ( '../..' , ruby_launcher )
220
222
end
221
223
224
+ def graalvm_home
225
+ up = if ruby_home . end_with? ( 'jre/languages/ruby' )
226
+ 3
227
+ elsif ruby_home . end_with? ( 'languages/ruby' )
228
+ 2
229
+ else
230
+ nil # standalone
231
+ end
232
+ return nil unless up
233
+ File . expand_path ( ( [ '..' ] * up ) . join ( '/' ) , ruby_home )
234
+ end
235
+
222
236
def truffleruby_native!
223
237
unless truffleruby_native?
224
238
raise "The ruby executable #{ ruby_launcher } is not native."
@@ -245,7 +259,6 @@ def truffleruby_compiler?
245
259
return @truffleruby_compiler = true if truffleruby_native?
246
260
247
261
# Detect if the compiler is present by reading the $graalvm_home/release file
248
- graalvm_home = File . expand_path ( "..#{ '/..' * ( language_dir . count ( '/' ) + 1 ) } " , ruby_home )
249
262
@truffleruby_compiler = File . readlines ( "#{ graalvm_home } /release" ) . grep ( /^COMMIT_INFO=/ ) . any? do |line |
250
263
line . include? ( '"compiler":' ) || line . include? ( "'compiler':" )
251
264
end
@@ -470,10 +483,9 @@ def find_java_home
470
483
@java_home ||= ci? ? nil : ENV [ 'JVMCI_HOME' ] || install_jvmci
471
484
end
472
485
473
- def language_dir
474
- java_home = find_java_home || ENV . fetch ( 'JAVA_HOME' )
475
- raise "Java home #{ java_home } does not exist" unless Dir . exist? ( java_home )
476
- if Dir . exist? ( "#{ java_home } /jmods" )
486
+ def language_dir ( graalvm_home )
487
+ raise "GraalVM #{ graalvm_home } does not exist" unless Dir . exist? ( graalvm_home )
488
+ if Dir . exist? ( "#{ graalvm_home } /jmods" )
477
489
'languages'
478
490
else
479
491
'jre/languages'
@@ -1920,7 +1932,7 @@ def bootstrap_toolchain
1920
1932
build_dir = mx ( *mx_args , 'graalvm-home' , capture : true ) . lines . last . chomp
1921
1933
1922
1934
dest = "#{ TRUFFLERUBY_DIR } /mxbuild/#{ name } "
1923
- dest_ruby = "#{ dest } /#{ language_dir } /ruby"
1935
+ dest_ruby = "#{ dest } /#{ language_dir ( build_dir ) } /ruby"
1924
1936
dest_bin = "#{ dest_ruby } /bin"
1925
1937
FileUtils . rm_rf dest
1926
1938
FileUtils . cp_r build_dir , dest
0 commit comments