Skip to content

Commit 24fba6b

Browse files
committed
Add mx ruby_from_classpath to simulate running TruffleRuby from the classpath/from Maven
1 parent 510383d commit 24fba6b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mx.truffleruby/mx_truffleruby.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ def ruby_run_ruby(args):
254254
ruby = join(standalone_home, 'bin/ruby')
255255
os.execlp(ruby, ruby, *args)
256256

257+
def ruby_run_ruby_from_classpath(args):
258+
"""run TruffleRuby from the classpath"""
259+
dists = ['RUBY_COMMUNITY', 'TRUFFLERUBY-LAUNCHER']
260+
if '--skip-build' in args:
261+
args.remove('--skip-build')
262+
else:
263+
mx.command_function('build')(['--dependencies', ','.join(dists)])
264+
classpath = mx.classpath(dists)
265+
jvm_args = ['-cp', classpath]
266+
mx_truffle.enable_truffle_native_access(jvm_args)
267+
mx_truffle.enable_sun_misc_unsafe(jvm_args)
268+
mx.run_java([*jvm_args, 'org.truffleruby.launcher.RubyLauncher', *args], jdk=jdk, nonZeroIsFatal=True)
269+
257270
def ruby_run_specs(ruby, args):
258271
with VerboseMx():
259272
jt('--use', ruby, 'test', 'specs', *args)
@@ -378,6 +391,7 @@ def ruby_maven_deploy_public_repo_dir(args):
378391

379392
mx.update_commands(_suite, {
380393
'ruby': [ruby_run_ruby, ''],
394+
'ruby_from_classpath': [ruby_run_ruby_from_classpath, ''],
381395
'build_truffleruby': [build_truffleruby, ''],
382396
'ruby_check_heap_dump': [ruby_check_heap_dump, ''],
383397
'ruby_testdownstream_aot': [ruby_testdownstream_aot, 'aot_bin'],

0 commit comments

Comments
 (0)