Skip to content

Commit d1c8bfe

Browse files
committed
[GR-18163] Add mx ruby_from_classpath
PullRequest: truffleruby/4558
2 parents 94cf370 + 24fba6b commit d1c8bfe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mx.truffleruby/mx_truffleruby.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def __init__(self):
8484
def apply(self, config):
8585
vmArgs, mainClass, mainClassArgs = config
8686
mx_truffle.enable_truffle_native_access(vmArgs)
87+
mx_truffle.enable_sun_misc_unsafe(vmArgs)
8788
return (vmArgs, mainClass, mainClassArgs)
8889

8990
mx_unittest.register_unittest_config(TruffleRubyUnittestConfig())
@@ -153,6 +154,7 @@ def contents(self, result):
153154
classpath_deps = [dep for dep in self.subject.buildDependencies if isinstance(dep, mx.ClasspathDependency)]
154155
jvm_args = [shlex.quote(arg) for arg in mx.get_runtime_jvm_args(classpath_deps)]
155156
mx_truffle.enable_truffle_native_access(jvm_args)
157+
mx_truffle.enable_sun_misc_unsafe(jvm_args)
156158

157159
debug_args = mx.java_debug_args()
158160
jvm_args.extend(debug_args)
@@ -219,6 +221,7 @@ def ruby_check_heap_dump(input_args, out=None):
219221
vm_args, truffleruby_args = mx.extract_VM_args(args, useDoubleDash=True, defaultAllVMArgs=False)
220222
vm_args += mx.get_runtime_jvm_args(dists)
221223
mx_truffle.enable_truffle_native_access(vm_args)
224+
mx_truffle.enable_sun_misc_unsafe(vm_args)
222225
# vm_args.append("-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=y")
223226
vm_args.append("org.truffleruby.test.internal.LeakTest")
224227
out = mx.OutputCapture() if out is None else out
@@ -251,6 +254,19 @@ def ruby_run_ruby(args):
251254
ruby = join(standalone_home, 'bin/ruby')
252255
os.execlp(ruby, ruby, *args)
253256

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+
254270
def ruby_run_specs(ruby, args):
255271
with VerboseMx():
256272
jt('--use', ruby, 'test', 'specs', *args)
@@ -375,6 +391,7 @@ def ruby_maven_deploy_public_repo_dir(args):
375391

376392
mx.update_commands(_suite, {
377393
'ruby': [ruby_run_ruby, ''],
394+
'ruby_from_classpath': [ruby_run_ruby_from_classpath, ''],
378395
'build_truffleruby': [build_truffleruby, ''],
379396
'ruby_check_heap_dump': [ruby_check_heap_dump, ''],
380397
'ruby_testdownstream_aot': [ruby_testdownstream_aot, 'aot_bin'],

0 commit comments

Comments
 (0)