1
0
Fork 0
mirror of https://github.com/rubyjs/libv8 synced 2023-03-27 23:21:48 -04:00
libv8/Rakefile

85 lines
2.4 KiB
Text
Raw Normal View History

2011-05-24 13:17:58 -05:00
require 'bundler/setup'
Bundler::GemHelper.install_tasks
2012-07-01 23:31:37 -05:00
class Bundler::GemHelper
def clean?
sh_with_code('git diff --exit-code --ignore-submodules')[1] == 0
end
end
2011-05-24 13:17:58 -05:00
2012-04-25 22:46:30 -05:00
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
2011-05-24 13:17:58 -05:00
2013-01-06 20:56:36 -06:00
V8_Version = Libv8::VERSION.gsub(/\.\d+$/,'')
2012-04-25 22:46:30 -05:00
V8_Source = File.expand_path '../vendor/v8', __FILE__
2011-05-24 13:17:58 -05:00
2012-05-12 11:38:07 +01:00
require File.expand_path '../ext/libv8/make.rb', __FILE__
include Libv8::Make
desc "setup the vendored v8 source to correspond to the libv8 gem version and prepare deps"
2012-04-25 22:46:30 -05:00
task :checkout do
sh "git submodule update --init"
Dir.chdir(V8_Source) do
sh "git fetch"
2012-05-09 20:07:19 -05:00
sh "git checkout #{V8_Version} -f"
sh "#{make} dependencies"
2011-05-25 15:41:01 -05:00
end
# Fix gyp trying to build platform-linux on FreeBSD 9 and FreeBSD 10.
# Based on: https://chromiumcodereview.appspot.com/10079030/patch/1/2
sh "patch -N -p0 -d vendor/v8 < patches/add-freebsd9-and-freebsd10-to-gyp-GetFlavor.patch"
2012-09-08 13:45:33 +02:00
sh "patch -N -p1 -d vendor/v8 < patches/fPIC-on-x64.patch"
2011-05-25 15:41:01 -05:00
end
desc "compile v8 via the ruby extension mechanism"
2012-04-25 22:46:30 -05:00
task :compile do
sh "ruby ext/libv8/extconf.rb"
end
desc "manually invoke the GYP compile. Useful for seeing debug output"
task :manual_compile do
2012-05-01 14:47:07 -07:00
require File.expand_path '../ext/libv8/arch.rb', __FILE__
include Libv8::Arch
2012-04-25 22:46:30 -05:00
Dir.chdir(V8_Source) do
sh %Q{#{make} -j2 #{libv8_arch}.release}
2011-05-25 15:41:01 -05:00
end
end
def get_binary_gemspec(platform = RUBY_PLATFORM)
gemspec = eval(File.read('libv8.gemspec'))
gemspec.platform = Gem::Platform.new(platform)
gemspec
end
begin
binary_gem_name = File.basename get_binary_gemspec.cache_file
rescue
binary_gem_name = ''
end
desc "build a binary gem #{binary_gem_name}"
task :binary => :compile do
gemspec = get_binary_gemspec
gemspec.extensions.clear
# We don't need most things for the binary
gemspec.files = []
gemspec.files += ['lib/libv8.rb', 'lib/libv8/version.rb']
gemspec.files += ['ext/libv8/arch.rb', 'ext/libv8/location.rb', 'ext/libv8/paths.rb']
gemspec.files += ['ext/libv8/.location.yml']
# V8
gemspec.files += Dir['vendor/v8/include/*']
2012-05-01 15:04:47 -07:00
gemspec.files += Dir['vendor/v8/out/**/*.a']
FileUtils.mkdir_p 'pkg'
FileUtils.mv(Gem::Builder.new(gemspec).build, 'pkg')
end
desc "clean up artifacts of the build"
2012-04-25 22:46:30 -05:00
task :clean do
sh "rm -rf pkg"
sh "git clean -df"
sh "cd #{V8_Source} && git checkout -f && git clean -dxf"
2011-06-15 15:55:18 -05:00
end
2012-04-26 09:52:47 -05:00
task :default => [:checkout, :compile, :spec]
task :build => [:clean, :checkout]