Skip to content

Commit

Permalink
Merge pull request #1170 from enebo/jruby_rake
Browse files Browse the repository at this point in the history
Allow JRuby to run Rake
  • Loading branch information
jemmaissroff authored Jul 28, 2023
2 parents 094b2b7 + 00202d5 commit 52085fd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
31 changes: 24 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ require "rake/extensiontask"
require "rake/testtask"
require "rake/clean"
require "rdoc/task"
require "ruby_memcheck"

Rake.add_rakelib("tasks")

RubyMemcheck.config(binary_name: "yarp")
if RUBY_ENGINE != "jruby"
require "ruby_memcheck"
RubyMemcheck.config(binary_name: "yarp")
end

task compile: :make
task compile_no_debug: :make_no_debug
Expand Down Expand Up @@ -61,11 +63,26 @@ task build: [:templates, :check_manifest]

# the C extension
task "compile:yarp" => ["configure", "templates"] # must be before the ExtensionTask is created
Rake::ExtensionTask.new(:compile) do |ext|
ext.name = "yarp"
ext.ext_dir = "ext/yarp"
ext.lib_dir = "lib"
ext.gem_spec = Gem::Specification.load("yarp.gemspec")

if RUBY_ENGINE == 'jruby'
require 'rake/javaextensiontask'

# This compiles java to make sure any templating changes produces valid code.
Rake::JavaExtensionTask.new(:compile) do |ext|
ext.name = "yarp"
ext.ext_dir = "java"
ext.lib_dir = "tmp"
ext.source_version = "1.8"
ext.target_version = "1.8"
ext.gem_spec = Gem::Specification.load("yarp.gemspec")
end
else
Rake::ExtensionTask.new(:compile) do |ext|
ext.name = "yarp"
ext.ext_dir = "ext/yarp"
ext.lib_dir = "lib"
ext.gem_spec = Gem::Specification.load("yarp.gemspec")
end
end

# So `rake clobber` will delete generated files
Expand Down
24 changes: 13 additions & 11 deletions tasks/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ class LldbTestTask < Rake::TestTask
end

namespace :test do
RubyMemcheck::TestTask.new(valgrind_internal: :compile, &test_config)
Rake::Task['test:valgrind_internal'].clear_comments # Hide test:valgrind_internal from rake -T
if RUBY_ENGINE != "jruby"
RubyMemcheck::TestTask.new(valgrind_internal: :compile, &test_config)
Rake::Task['test:valgrind_internal'].clear_comments # Hide test:valgrind_internal from rake -T

desc "Run tests under valgrind"
task :valgrind do
# Recompile with YARP_DEBUG_MODE_BUILD=1
ENV['YARP_DEBUG_MODE_BUILD'] = '1'
Rake::Task['clobber'].invoke
Rake::Task['test:valgrind_internal'].invoke
end

desc "Run tests under valgrind"
task :valgrind do
# Recompile with YARP_DEBUG_MODE_BUILD=1
ENV['YARP_DEBUG_MODE_BUILD'] = '1'
Rake::Task['clobber'].invoke
Rake::Task['test:valgrind_internal'].invoke
GdbTestTask.new(gdb: :compile, &test_config)
LldbTestTask.new(lldb: :compile, &test_config)
end

GdbTestTask.new(gdb: :compile, &test_config)
LldbTestTask.new(lldb: :compile, &test_config)
end

0 comments on commit 52085fd

Please sign in to comment.