Skip to content

Commit 699a9eb

Browse files
committed
Add a simple tool to synchronize changes from Ruby source files to the GraalVM build
PullRequest: truffleruby/671
2 parents b2b8a85 + 934c916 commit 699a9eb

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

tool/jt.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ def help
593593
jt install jvmci install a JVMCI JDK in the parent directory
594594
jt install graal [--no-jvmci] install Graal in the parent directory (--no-jvmci to use the system Java)
595595
jt docker build a Docker image - see doc/contributor/docker.md
596+
jt sync continuously synchronize changes from the Ruby source files to the GraalVM build
596597
597598
you can also put --build or --rebuild in front of any command to build or rebuild first
598599
@@ -2097,6 +2098,10 @@ def verify_native_bin!
20972098
end
20982099
private :verify_native_bin!
20992100

2101+
def sync
2102+
exec(RbConfig.ruby, "#{TRUFFLERUBY_DIR}/tool/sync.rb")
2103+
end
2104+
21002105
def docker(*args)
21012106
command = args.shift
21022107
case command

tool/sync.rb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env ruby
2+
3+
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
4+
# This code is released under a tri EPL/GPL/LGPL license. You can use it,
5+
# redistribute it and/or modify it under the terms of the:
6+
#
7+
# Eclipse Public License version 1.0, or
8+
# GNU General Public License version 2, or
9+
# GNU Lesser General Public License version 2.1.
10+
11+
# A script to synchronize changes from the Ruby source files
12+
# to the GraalVM build instantaneously.
13+
14+
# Use 'gem install listen' to install this dependency
15+
require 'listen'
16+
17+
require 'fileutils'
18+
19+
FROM = File.expand_path('../..', File.realpath(__FILE__))
20+
TO = "#{FROM}/mxbuild/graalvm/jre/languages/ruby"
21+
22+
# Must be consistent with TRUFFLERUBY_GRAALVM_SUPPORT in suite.py
23+
DIRS_TO_SYNC = %w[
24+
lib/json
25+
lib/mri
26+
lib/patches
27+
lib/truffle
28+
].map { |path| "#{FROM}/#{path}" }
29+
30+
listener = Listen.to(*DIRS_TO_SYNC) do |modified, added, removed|
31+
(modified + added).each do |file|
32+
target = "#{TO}#{file[FROM.size..-1]}"
33+
FileUtils::Verbose.cp file, target
34+
end
35+
removed.each do |file|
36+
target = "#{TO}#{file[FROM.size..-1]}"
37+
FileUtils::Verbose.rm target
38+
end
39+
end
40+
41+
listener.start # not blocking
42+
sleep

0 commit comments

Comments
 (0)