diff --git a/Rakefile b/Rakefile index a6e018a371fce..78069534f4433 100644 --- a/Rakefile +++ b/Rakefile @@ -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' @@ -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 @@ -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) @@ -623,6 +625,6 @@ end at_exit do if File.exist?(".git") && !Platform.windows? - sh "sh .git-fixfiles" + system "sh", ".git-fixfiles" end end diff --git a/rake-tasks/buck.rb b/rake-tasks/buck.rb index 560f6679923f6..b53e74e7644cf 100644 --- a/rake-tasks/buck.rb +++ b/rake-tasks/buck.rb @@ -1,4 +1,4 @@ -require 'childprocess' +require 'open3' require 'rake-tasks/checks' module Buck @@ -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) @@ -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 @@ -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 @@ -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 @@ -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| @@ -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| @@ -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 = [] @@ -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) diff --git a/rake-tasks/crazy_fun/mappings/javascript.rb b/rake-tasks/crazy_fun/mappings/javascript.rb index 982d36314e7ae..1ac2b2066ac86 100644 --- a/rake-tasks/crazy_fun/mappings/javascript.rb +++ b/rake-tasks/crazy_fun/mappings/javascript.rb @@ -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] @@ -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 diff --git a/rake-tasks/crazy_fun/mappings/jruby.rb b/rake-tasks/crazy_fun/mappings/jruby.rb new file mode 100644 index 0000000000000..4abbedec31b40 --- /dev/null +++ b/rake-tasks/crazy_fun/mappings/jruby.rb @@ -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 diff --git a/rake-tasks/crazy_fun/mappings/ruby.rb b/rake-tasks/crazy_fun/mappings/ruby.rb index a19b5aaa46589..68101bb5dbf82 100644 --- a/rake-tasks/crazy_fun/mappings/ruby.rb +++ b/rake-tasks/crazy_fun/mappings/ruby.rb @@ -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/" diff --git a/third_party/jruby/VERSION b/third_party/jruby/VERSION index 2512c285f75b7..c9ed9fb0d1642 100644 --- a/third_party/jruby/VERSION +++ b/third_party/jruby/VERSION @@ -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] diff --git a/third_party/jruby/build.desc b/third_party/jruby/build.desc new file mode 100644 index 0000000000000..32d951ab49eb7 --- /dev/null +++ b/third_party/jruby/build.desc @@ -0,0 +1,6 @@ +jruby_package( + version = "9.1.14.0", + gems = [ + {"albacore": "1.0.0"} + ] +) diff --git a/third_party/jruby/jruby-complete.jar b/third_party/jruby/jruby-complete.jar index ad0da1fa57ba4..f886fb00a4fb0 100644 Binary files a/third_party/jruby/jruby-complete.jar and b/third_party/jruby/jruby-complete.jar differ