Skip to content

Commit

Permalink
Upgrade JRuby to 9.1.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje committed Nov 17, 2017
1 parent 09f2635 commit bcae008
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 63 deletions.
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require 'rake-tasks/crazy_fun/mappings/export'
require 'rake-tasks/crazy_fun/mappings/folder'
require 'rake-tasks/crazy_fun/mappings/gcc'
require 'rake-tasks/crazy_fun/mappings/javascript'
require 'rake-tasks/crazy_fun/mappings/jruby'
require 'rake-tasks/crazy_fun/mappings/mozilla'
require 'rake-tasks/crazy_fun/mappings/python'
require 'rake-tasks/crazy_fun/mappings/rake'
Expand All @@ -38,7 +39,7 @@ require 'rake-tasks/ie_code_generator'
require 'rake-tasks/ci'
require 'rake-tasks/copyright'

$DEBUG = orig_verbose != :default ? true : false
$DEBUG = orig_verbose != Rake::FileUtilsExt::DEFAULT ? true : false
if (ENV['debug'] == 'true')
$DEBUG = true
end
Expand Down Expand Up @@ -75,6 +76,7 @@ ExportMappings.new.add_all(crazy_fun)
FolderMappings.new.add_all(crazy_fun)
GccMappings.new.add_all(crazy_fun)
JavascriptMappings.new.add_all(crazy_fun)
JRubyMappings.new.add_all(crazy_fun)
MozillaMappings.new.add_all(crazy_fun)
PythonMappings.new.add_all(crazy_fun)
RakeMappings.new.add_all(crazy_fun)
Expand Down Expand Up @@ -623,6 +625,6 @@ end

at_exit do
if File.exist?(".git") && !Platform.windows?
sh "sh .git-fixfiles"
system "sh", ".git-fixfiles"
end
end
83 changes: 30 additions & 53 deletions rake-tasks/buck.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'childprocess'
require 'open3'
require 'rake-tasks/checks'

module Buck
Expand Down Expand Up @@ -46,55 +46,32 @@ def self.download
)
end

def self.buck_cmd
(
lambda { |command, args, &block|
buck = []
pex = Buck::download
buck.push(*pex)
def self.buck_cmd(command, args, &block)
buck = []
pex = Buck.download
buck.push(*pex)

args ||= []
buck.push(command)
buck.push(*args)
args ||= []
buck.push(command)
buck.push(*args)

pump_class = Class.new(Java::java.io.OutputStream) {
attr_writer :stream
output = ''
Open3.popen3(*buck) do |stdin, stdout, stderr, wait|
stdin.close

def initialize
@output = ''
end

def write(b)
if @stream
@stream.write(b)
end
@output += b
end

def output
@output
end
}

err = ''
proc = ChildProcess.build(*buck)
proc.io.stdout = pump_class.new()
proc.io.stderr = pump_class.new()
if command == 'build' || command == 'publish' || command == 'test'
proc.io.stderr.stream = $stdout
end
proc.start
proc.wait
while (error = stderr.gets)
STDERR.print(error)
end

if proc.exit_code != 0
raise "Buck build failed with exit code: #{proc.exit_code}
stdout: #{proc.io.stdout.output}"
end
while (line = stdout.gets)
output << line
STDOUT.print line
end

block.call(proc.io.stdout.output) if block
}
)
raise "#{buck.join(' ')} failed with exit code: #{wait.value.exitstatus}" unless wait.value.success?
end

block.call(output) if block
end

def self.enhance_task(task)
Expand All @@ -115,7 +92,7 @@ def out
def self.find_buck_out(target)
out = nil

Buck::buck_cmd.call('targets', ['--show-output', target]) do |output|
Buck.buck_cmd('targets', ['--show-output', target]) do |output|
sections = output.chomp.split
# Not all buck rules have an output file.
if sections.size > 1
Expand Down Expand Up @@ -150,7 +127,7 @@ def buck(*args, &block)

task = Rake::Task.task_defined?(name) ? Rake::Task[name] : Rake::Task.define_task(name)
task.enhance prereqs do
Buck::buck_cmd.call('build', [name])
Buck.buck_cmd('build', [name])
block.call if block
end

Expand All @@ -164,13 +141,13 @@ def buck(*args, &block)

task.enhance do
# Figure out if this is an executable or a test target.
Buck::buck_cmd.call('query', [short, '--output-attributes', 'buck.type']) do |output|
Buck.buck_cmd('query', [short, '--output-attributes', 'buck.type']) do |output|
hash = JSON.parse(output)
type = hash[short]['buck.type']
if type =~ /.*_test/
Buck::buck_cmd.call('test', [short])
Buck.buck_cmd('test', [short])
else
Buck::buck_cmd.call('run', ['--verbose', '5', short])
Buck.buck_cmd('run', ['--verbose', '5', short])
end
end
end
Expand All @@ -187,7 +164,7 @@ def buck(*args, &block)
working_dir = "buck-out/crazy-fun/#{dir}/#{target}_zip"

# Build the source zip
Buck::buck_cmd.call('query', ["kind(java_library, deps(#{short}))"]) do |output|
Buck.buck_cmd('query', ["kind(java_library, deps(#{short}))"]) do |output|
# Collect all the targets
to_build = []
output.lines do |line|
Expand All @@ -205,7 +182,7 @@ def buck(*args, &block)
mkdir_p "#{working_dir}/lib"
mkdir_p "#{working_dir}/uber"

Buck::buck_cmd.call('build', ['--show-output'] + to_build) do |built|
Buck.buck_cmd('build', ['--show-output'] + to_build) do |built|
built.lines do |line|
line.chomp!
line.split[1].each do |file|
Expand All @@ -218,7 +195,7 @@ def buck(*args, &block)
end

# Figure out if this is an executable or a test target.
Buck::buck_cmd.call('audit', ['classpath', short]) do |output|
Buck.buck_cmd('audit', ['classpath', short]) do |output|
third_party = []
first_party = []

Expand Down Expand Up @@ -266,7 +243,7 @@ def buck(*args, &block)

if task.class == Rake::FileTask && !task.out && File.exists?(buck_file)
task.enhance do
Buck::buck_cmd.call('build', ['--deep', task.name])
Buck.buck_cmd('build', ['--deep', task.name])
end

Buck::enhance_task(task)
Expand Down
4 changes: 2 additions & 2 deletions rake-tasks/crazy_fun/mappings/javascript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def resolve_deps(file, symbol, result_list, seen_list)

result_list = [File.join(@closure_dir, "base.js")]
seen_list = []
files.each do |file|
Array(files).each do |file|
file = File.expand_path(file)
parse_file(file)
info = @files[file]
Expand Down Expand Up @@ -403,7 +403,7 @@ def execute(cmd)

def calc_deps(src_files, js_files)
deps = ClosureDeps.new
js_files.each {|f| deps.parse_file(f)}
Array(js_files).each {|f| deps.parse_file(f)}
deps.calc_deps(src_files).uniq
end

Expand Down
44 changes: 44 additions & 0 deletions rake-tasks/crazy_fun/mappings/jruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require 'rake-tasks/crazy_fun/mappings/common'

class JRubyMappings
def add_all(fun)
fun.add_mapping("jruby_package", Package.new)
end

class Package < Tasks
def handle(_fun, dir, args)
task_name = task_name(dir, "jruby_package")

jar_name = "jruby-complete-#{args[:version]}.jar"
url = "https://repo1.maven.org/maven2/org/jruby/jruby-complete/#{args[:version]}/#{jar_name}"

desc "Package JRuby #{args[:version]}"
task task_name do
require 'open-uri'

Dir.chdir(dir) do
puts "Downloading #{jar_name} from #{url}..."
File.open(jar_name, "wb") do |write_file|
open(url, "rb") do |read_file|
write_file.write(read_file.read)
end
end

puts "Installing gems..."
args[:gems].map(&:first).each do |gem_name, gem_version|
sh "java", "-jar", jar_name, "-S", "gem", "install", "-i", "./#{gem_name}", gem_name, "-v", gem_version
sh "jar", "uf", jar_name, "-C", gem_name, "."
rm_rf gem_name
end

puts "Bumping VERSION..."
jruby_version = `java -jar #{jar_name} -version`.split("\n").first
File.write('VERSION', "#{jruby_version}\n")

mv jar_name, "jruby-complete.jar"
puts "Done!"
end
end
end
end
end
4 changes: 2 additions & 2 deletions rake-tasks/crazy_fun/mappings/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ def define_build_task(dir, args)

desc "Build #{args[:gemspec]}"
task "//#{dir}:gem:build" => deps do
require 'rubygems/builder'
require 'rubygems/package'

file = Dir.chdir(spec_dir) do
spec = eval(File.read(gemspec))
Gem::Builder.new(spec).build
Gem::Package.build(spec)
end

mv File.join(spec_dir, file), "build/"
Expand Down
5 changes: 1 addition & 4 deletions third_party/jruby/VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
JRuby: JRuby: jruby 1.6.0.dev @ 2011-01-04 e1fe932
Bundled gems: childprocess, json_pure, albacore, rspec (2.4.0), rake, ci_reporter, rubyzip

How to update the jar: https://gist.github.com/733501
jruby 9.1.14.0 (2.3.3) 2017-11-08 2176f24 Java HotSpot(TM) 64-Bit Server VM 25.152-b16 on 1.8.0_152-b16 +jit [darwin-x86_64]
6 changes: 6 additions & 0 deletions third_party/jruby/build.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
jruby_package(
version = "9.1.14.0",
gems = [
{"albacore": "1.0.0"}
]
)
Binary file modified third_party/jruby/jruby-complete.jar
Binary file not shown.

0 comments on commit bcae008

Please sign in to comment.