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
|
|
|
|
2012-05-12 11:38:07 +01:00
|
|
|
require File.expand_path '../ext/libv8/make.rb', __FILE__
|
2013-06-20 16:26:55 +02:00
|
|
|
require File.expand_path '../ext/libv8/checkout.rb', __FILE__
|
2012-05-12 11:38:07 +01:00
|
|
|
include Libv8::Make
|
2013-06-20 16:26:55 +02:00
|
|
|
include Libv8::Checkout
|
2012-05-12 11:38:07 +01:00
|
|
|
|
2013-06-19 16:25:06 +02:00
|
|
|
desc "setup the vendored v8 source to correspond to the libv8 gem version"
|
2012-04-25 22:46:30 -05:00
|
|
|
task :checkout do
|
|
|
|
sh "git submodule update --init"
|
2013-06-20 16:26:55 +02:00
|
|
|
checkout!
|
2013-05-15 15:09:49 +03:00
|
|
|
end
|
|
|
|
|
2012-04-26 10:28:27 -05:00
|
|
|
desc "compile v8 via the ruby extension mechanism"
|
2015-04-09 01:34:36 +09:30
|
|
|
task :compile => :devkit do
|
2012-04-26 10:28:27 -05:00
|
|
|
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
|
2013-01-09 11:53:34 +02:00
|
|
|
sh %Q{#{make} -j2 #{libv8_arch}.release ARFLAGS.target=crs}
|
2011-05-25 15:41:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-21 15:55:00 +03:00
|
|
|
def get_binary_gemspec(platform = RUBY_PLATFORM)
|
2012-04-25 22:26:17 -05:00
|
|
|
gemspec = eval(File.read('libv8.gemspec'))
|
2012-06-21 15:55:00 +03:00
|
|
|
gemspec.platform = Gem::Platform.new(platform)
|
|
|
|
gemspec
|
|
|
|
end
|
|
|
|
|
2012-12-20 14:31:11 -06:00
|
|
|
begin
|
2012-06-21 15:55:00 +03:00
|
|
|
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
|
2012-07-01 23:10:13 -05:00
|
|
|
gemspec.extensions.clear
|
2012-04-25 22:26:17 -05:00
|
|
|
# We don't need most things for the binary
|
2013-01-04 15:41:18 -06:00
|
|
|
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']
|
2012-04-25 22:26:17 -05:00
|
|
|
# V8
|
|
|
|
gemspec.files += Dir['vendor/v8/include/*']
|
2012-05-01 15:04:47 -07:00
|
|
|
gemspec.files += Dir['vendor/v8/out/**/*.a']
|
2013-02-01 20:46:40 -05:00
|
|
|
FileUtils.chmod 'a+r', gemspec.files
|
2012-04-25 22:26:17 -05:00
|
|
|
FileUtils.mkdir_p 'pkg'
|
2013-03-22 10:53:42 -05:00
|
|
|
package = if Gem::VERSION < '2.0.0'
|
2013-03-28 09:04:22 -05:00
|
|
|
Gem::Builder.new(gemspec).build
|
2013-03-22 10:53:42 -05:00
|
|
|
else
|
|
|
|
require 'rubygems/package'
|
|
|
|
Gem::Package.build(gemspec)
|
|
|
|
end
|
2013-03-04 18:26:19 +02:00
|
|
|
FileUtils.mv(package, 'pkg')
|
2012-04-25 22:26:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "clean up artifacts of the build"
|
2012-04-25 22:46:30 -05:00
|
|
|
task :clean do
|
|
|
|
sh "rm -rf pkg"
|
2012-04-26 10:28:27 -05:00
|
|
|
sh "git clean -df"
|
2013-01-06 08:58:08 +02:00
|
|
|
sh "cd #{V8_Source} && git checkout -f && git clean -dxf"
|
2015-04-09 17:08:25 -05:00
|
|
|
if Dir.chdir GYP_Source
|
|
|
|
sh "git checkout -f"
|
|
|
|
puts "git clean -dxf"
|
|
|
|
`git clean -dxf`
|
|
|
|
end
|
2011-06-15 15:55:18 -05:00
|
|
|
end
|
|
|
|
|
2015-04-09 01:34:36 +09:30
|
|
|
task :devkit do
|
|
|
|
begin
|
|
|
|
if RUBY_PLATFORM =~ /mingw/
|
|
|
|
require "devkit"
|
|
|
|
end
|
|
|
|
rescue LoadError => e
|
|
|
|
abort "Failed to activate RubyInstaller's DevKit required for compilation."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
framework for building binary gems
I'm tired of our releases getting held up because building the binaries
is such a yak shave. We're in dire need of some automation. I tried
spiking some things out with Docker, but for the time being, it was
easier to just go with Vagrant.
Currently, our release process for binary gems involves
1. a source release at an even point (e.g. 3.16.14.8)
2. a version bump to serve as the basis for binary releases
3. a mish-mash of gem builds and pushes for osx, linux, freebsd, etc...
In order to make things eaiser for us to manage these binary builds, I'm
proposing a standardized build using Vagrant. For each supported
release, a Vagrant file goes into /release/<arch>/Vagrantfile
The vagrantfile is responsible for provisioning a modern
ruby toolchain including bundler, git, git-svn, ruby and ruby source and
headers.
It should also clone the libv8 source into the /libv8
This can then be used to build the binary gem for that platform.
This PR includes the Vagrantfile for x86_64-linux
2015-06-27 02:36:57 +03:00
|
|
|
namespace :build do
|
|
|
|
['x86_64-linux'].each do |arch|
|
|
|
|
desc "build binary gem for #{arch}"
|
|
|
|
task arch do
|
|
|
|
arch_dir = Pathname(__FILE__).dirname.join("release/#{arch}")
|
|
|
|
Dir.chdir(arch_dir) do
|
|
|
|
sh "vagrant up"
|
|
|
|
sh "vagrant ssh -c 'cd /vagrant && rm -rf libv8 && git clone /libv8/.git libv8'"
|
|
|
|
sh "vagrant ssh -c 'cd /vagrant/libv8 && bundle install --path vendor/bundle'"
|
|
|
|
sh "vagrant ssh -c 'cd /vagrant/libv8 && bundle exec rake checkout binary'"
|
|
|
|
sh "vagrant ssh -c 'cp /vagrant/libv8/pkg/*.gem /vagrant'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-04-26 09:52:47 -05:00
|
|
|
task :default => [:checkout, :compile, :spec]
|
2013-06-19 16:25:06 +02:00
|
|
|
task :build => [:clean, :checkout]
|