1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
require 'bundler/gem_tasks'
require 'rake/clean'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
RSpec::Core::RakeTask.new(:rcov) do |task|
task.rcov = true
end
task :default => %w(compile spec)
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "cool.io #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
require 'rake/extensiontask'
spec = eval(File.read("cool.io.gemspec"))
def configure_cross_compilation(ext)
unless RUBY_PLATFORM =~ /mswin|mingw/
ext.cross_compile = true
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
end
end
Rake::ExtensionTask.new('cool.io_ext', spec) do |ext|
ext.ext_dir = 'ext/cool.io'
configure_cross_compilation(ext)
end
# Note that this rake-compiler-dock rake task dose not support bundle install(1) --path option.
# Please use bundle install instead when you execute this rake task.
namespace :build do
desc 'Build gems for Windows per rake-compiler-dock'
task :windows do
require 'rake_compiler_dock'
RakeCompilerDock.sh <<-CROSS
bundle && bundle exec rake cross native gem RUBY_CC_VERSION='3.0.0:2.7.0:2.6.0:2.5.0:2.4.0'
CROSS
end
end
# adapted from http://flavoriffic.blogspot.com/2009/06/easily-valgrind-gdb-your-ruby-c.html
def specs_command
require "find"
files = []
Find.find("spec") do |f|
files << f if File.basename(f) =~ /.*spec.*\.rb$/
end
cmdline = "#{RUBY} -I.:lib:ext:spec \
-e '%w[#{files.join(' ')}].each { |f| require f }'"
end
namespace :spec do
desc "run specs with valgrind"
task :valgrind => :compile do
system "valgrind --num-callers=15 \
--partial-loads-ok=yes --undef-value-errors=no \
--tool=memcheck --leak-check=yes --track-fds=yes \
--show-reachable=yes #{specs_command}"
end
end
CLEAN.include "**/*.rbc", "**/*.o", "**/*.so", "**/*.bundle"
CLEAN.exclude "vendor/**/*.rbc", "vendor/**/*.o", "vendor/**/*.so", "vendor/**/*.bundle"
|