@@ -231,9 +231,9 @@ def find_mx
231
231
232
232
def find_launcher ( use_native )
233
233
if use_native
234
- ENV [ 'AOT_BIN' ] || "#{ TRUFFLERUBY_DIR } /bin/native- ruby"
234
+ ENV [ 'AOT_BIN' ] || "#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-native/jre/languages/ruby/bin/ ruby"
235
235
else
236
- ENV [ 'RUBY_BIN' ] || "#{ TRUFFLERUBY_DIR } /mxbuild/graalvm /jre/languages/ruby/bin/ruby"
236
+ ENV [ 'RUBY_BIN' ] || "#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-jvm /jre/languages/ruby/bin/ruby"
237
237
end
238
238
end
239
239
@@ -519,17 +519,19 @@ module Commands
519
519
520
520
def help
521
521
puts <<-TXT . gsub ( /^#{ ' ' *6 } / , '' )
522
- jt build [options] build
522
+ jt build [what] [options] by default it builds graalvm
523
+ --no-sforceimports do not run sforceimports before building
523
524
parser build the parser
524
525
options build the options
525
526
cexts build only the C extensions (part of "jt build")
526
- graalvm [--graal] [--native] build a minimal JVM-only GraalVM containing only TruffleRuby
527
- --graal include the GraalVM Compiler in the build
528
- --native build native ruby image as well
529
- native [--no-sulong] [--no-tools] [extra mx image options]
530
- build a native image of TruffleRuby
531
- (--no-tools to exclude chromeinspector and profiler)
532
- --no-sforceimports
527
+ graalvm build a minimal JVM-only GraalVM containing only TruffleRuby,
528
+ available by default in mxbuild/truffleruby-jvm,
529
+ the Ruby is symlinked into rbenv or chruby if available
530
+ --graal include the GraalVM Compiler in the build
531
+ --native build native ruby image as well, available in mxbuild/truffleruby-native
532
+ --name NAME specify the name of the build "mxbuild/truffleruby-NAME"
533
+ it is also linked in your ruby manager (if found) under the same name
534
+ the named build stays until it is rebuilt or deleted manually
533
535
jt build_stats [--json] <attribute> prints attribute's value from build process (e.g., binary size)
534
536
jt clean clean
535
537
jt env prints the current environment
@@ -1159,7 +1161,7 @@ def test_cexts(*args)
1159
1161
1160
1162
# Test that running the post-install hook works, even when opt &
1161
1163
# llvm-link are not on PATH, as it is the case on macOS.
1162
- sh ( { 'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true' } , 'mxbuild/graalvm /jre/languages/ruby/lib/truffle/post_install_hook.sh' )
1164
+ sh ( { 'TRUFFLERUBY_RECOMPILE_OPENSSL' => 'true' } , 'mxbuild/truffleruby-jvm /jre/languages/ruby/lib/truffle/post_install_hook.sh' )
1163
1165
1164
1166
when 'gems'
1165
1167
# Test that we can compile and run some real C extensions
@@ -1932,6 +1934,12 @@ def build_graalvm(*options)
1932
1934
1933
1935
graal = options . delete ( '--graal' )
1934
1936
native = options . delete ( '--native' )
1937
+ name = if ( i = options . index ( '--name' ) )
1938
+ options . delete_at ( i )
1939
+ options . delete_at ( i )
1940
+ else
1941
+ native ? 'native' : 'jvm'
1942
+ end
1935
1943
1936
1944
mx_args = [ '-p' , TRUFFLERUBY_DIR ,
1937
1945
'--dynamicimports' , '/vm' ,
@@ -1942,34 +1950,31 @@ def build_graalvm(*options)
1942
1950
mx ( *mx_args , 'build' )
1943
1951
build_dir = mx ( *mx_args , 'graalvm-home' , capture : true ) . lines . last . chomp
1944
1952
1945
- dest = "#{ TRUFFLERUBY_DIR } /mxbuild/graalvm"
1953
+ dest = "#{ TRUFFLERUBY_DIR } /mxbuild/truffleruby-#{ name } "
1954
+ dest_ruby = "#{ dest } /jre/languages/ruby"
1955
+ dest_bin = "#{ dest_ruby } /bin"
1946
1956
FileUtils . rm_rf dest
1947
1957
FileUtils . cp_r build_dir , dest
1948
1958
1959
+ # Insert native wrapper around the bash launcher
1960
+ # since nested shebang does not work on macOS when fish shell is used.
1949
1961
if MAC && !native
1950
- bin = "#{ dest } /jre/languages/ruby/bin"
1951
- FileUtils . mv "#{ bin } /truffleruby" , "#{ bin } /truffleruby.sh"
1952
- FileUtils . cp "#{ TRUFFLERUBY_DIR } /tool/native_launcher_darwin" , "#{ bin } /truffleruby"
1962
+ FileUtils . mv "#{ dest_bin } /truffleruby" , "#{ dest_bin } /truffleruby.sh"
1963
+ FileUtils . cp "#{ TRUFFLERUBY_DIR } /tool/native_launcher_darwin" , "#{ dest_bin } /truffleruby"
1953
1964
end
1954
- end
1955
-
1956
- def build_native_image ( *options )
1957
- sforceimports = !options . delete ( "--no-sforceimports" )
1958
1965
1959
- mx 'sforceimports' if sforceimports
1966
+ # Symlink builds into version manager
1967
+ rbenv_root = ENV [ 'RBENV_ROOT' ]
1968
+ rubies_dir = File . join ( rbenv_root , 'versions' ) if rbenv_root && File . directory? ( rbenv_root )
1960
1969
1961
- graal = checkout_or_update_graal_repo ( sforceimports : sforceimports )
1970
+ chruby_versions = File . expand_path ( '~/.rubies' )
1971
+ rubies_dir = chruby_versions if File . directory? ( chruby_versions )
1962
1972
1963
- mx_args = %w[ --dynamicimports /substratevm,truffleruby --disable-polyglot --disable-libpolyglot --force-bash-launchers=lli,native-image ]
1964
-
1965
- puts 'Building TruffleRuby native binary'
1966
- chdir ( "#{ graal } /vm" ) do
1967
- mx *mx_args , 'build'
1973
+ if rubies_dir
1974
+ link_path = "#{ rubies_dir } /#{ name } "
1975
+ File . delete link_path if File . exist? link_path
1976
+ File . symlink dest_ruby , link_path
1968
1977
end
1969
-
1970
- local_target = "#{ TRUFFLERUBY_DIR } /bin/native-ruby"
1971
- built_bin = Dir . glob ( "#{ graal } /vm/mxbuild/#{ mx_os } -amd64/RUBY_STANDALONE_SVM/*/bin/ruby" ) . first
1972
- FileUtils . ln_sf ( built_bin , local_target )
1973
1978
end
1974
1979
1975
1980
def next ( *args )
0 commit comments