2011-05-24 14:17:58 -04:00
|
|
|
require 'bundler/setup'
|
|
|
|
Bundler::GemHelper.install_tasks
|
2012-07-02 00:31:37 -04:00
|
|
|
class Bundler::GemHelper
|
|
|
|
def clean?
|
|
|
|
sh_with_code('git diff --exit-code --ignore-submodules')[1] == 0
|
|
|
|
end
|
|
|
|
end
|
2011-05-24 14:17:58 -04:00
|
|
|
|
2012-04-25 23:46:30 -04:00
|
|
|
require 'rspec/core/rake_task'
|
|
|
|
RSpec::Core::RakeTask.new(:spec)
|
2011-05-24 14:17:58 -04:00
|
|
|
|
2013-01-06 21:56:36 -05:00
|
|
|
V8_Version = Libv8::VERSION.gsub(/\.\d+$/,'')
|
2012-04-25 23:46:30 -04:00
|
|
|
V8_Source = File.expand_path '../vendor/v8', __FILE__
|
2011-05-24 14:17:58 -04:00
|
|
|
|
2012-05-12 06:38:07 -04:00
|
|
|
require File.expand_path '../ext/libv8/make.rb', __FILE__
|
|
|
|
include Libv8::Make
|
|
|
|
|
2012-04-26 11:28:27 -04:00
|
|
|
desc "setup the vendored v8 source to correspond to the libv8 gem version and prepare deps"
|
2012-04-25 23:46:30 -04:00
|
|
|
task :checkout do
|
|
|
|
sh "git submodule update --init"
|
|
|
|
Dir.chdir(V8_Source) do
|
|
|
|
sh "git fetch"
|
2012-05-09 21:07:19 -04:00
|
|
|
sh "git checkout #{V8_Version} -f"
|
2012-05-12 06:38:30 -04:00
|
|
|
sh "#{make} dependencies"
|
2011-05-25 16:41:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-26 11:28:27 -04:00
|
|
|
desc "compile v8 via the ruby extension mechanism"
|
2012-04-25 23:46:30 -04:00
|
|
|
task :compile do
|
2012-04-26 11:28:27 -04: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 17:47:07 -04:00
|
|
|
require File.expand_path '../ext/libv8/arch.rb', __FILE__
|
|
|
|
include Libv8::Arch
|
2012-04-25 23:46:30 -04:00
|
|
|
Dir.chdir(V8_Source) do
|
2013-01-09 04:53:34 -05:00
|
|
|
sh %Q{#{make} -j2 #{libv8_arch}.release ARFLAGS.target=crs}
|
2011-05-25 16:41:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-21 08:55:00 -04:00
|
|
|
def get_binary_gemspec(platform = RUBY_PLATFORM)
|
2012-04-25 23:26:17 -04:00
|
|
|
gemspec = eval(File.read('libv8.gemspec'))
|
2012-06-21 08:55:00 -04:00
|
|
|
gemspec.platform = Gem::Platform.new(platform)
|
|
|
|
gemspec
|
|
|
|
end
|
|
|
|
|
2012-12-20 15:31:11 -05:00
|
|
|
begin
|
2012-06-21 08:55:00 -04: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-02 00:10:13 -04:00
|
|
|
gemspec.extensions.clear
|
2012-04-25 23:26:17 -04:00
|
|
|
# We don't need most things for the binary
|
2013-01-04 16:41:18 -05: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 23:26:17 -04:00
|
|
|
# V8
|
|
|
|
gemspec.files += Dir['vendor/v8/include/*']
|
2012-05-01 18:04:47 -04: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 23:26:17 -04:00
|
|
|
FileUtils.mkdir_p 'pkg'
|
2013-03-22 11:53:42 -04:00
|
|
|
package = if Gem::VERSION < '2.0.0'
|
|
|
|
Gem::Builder.new(gempsec).build
|
|
|
|
else
|
|
|
|
require 'rubygems/package'
|
|
|
|
Gem::Package.build(gemspec)
|
|
|
|
end
|
2013-03-04 11:26:19 -05:00
|
|
|
FileUtils.mv(package, 'pkg')
|
2012-04-25 23:26:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "clean up artifacts of the build"
|
2012-04-25 23:46:30 -04:00
|
|
|
task :clean do
|
|
|
|
sh "rm -rf pkg"
|
2012-04-26 11:28:27 -04:00
|
|
|
sh "git clean -df"
|
2013-01-06 01:58:08 -05:00
|
|
|
sh "cd #{V8_Source} && git checkout -f && git clean -dxf"
|
2011-06-15 16:55:18 -04:00
|
|
|
end
|
|
|
|
|
2013-01-08 00:33:48 -05:00
|
|
|
desc "build a binary on heroku (you must have vulcan configured for this)"
|
|
|
|
task :vulcan => directory("tmp/vulcan") do
|
|
|
|
Dir.chdir('tmp/vulcan') do
|
|
|
|
sh "vulcan build -v -c 'LANG=en_US.UTF-8 export BIN=/`pwd`/bin && export GEM=$BIN/gem && curl https://s3.amazonaws.com/heroku-buildpack-ruby/ruby-1.9.3.tgz > ruby-1.9.3.tgz && tar xf ruby-1.9.3.tgz && cd /tmp && $GEM fetch libv8 --platform=ruby --version=#{Libv8::VERSION} && $GEM unpack libv8*.gem && $GEM install bundler -n $BIN --no-ri --no-rdoc && cd libv8-#{Libv8::VERSION} && $BIN/bundle && $BIN/bundle exec rake binary' -p /tmp/libv8-#{Libv8::VERSION}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-26 10:52:47 -04:00
|
|
|
task :default => [:checkout, :compile, :spec]
|
2012-05-12 06:44:16 -04:00
|
|
|
task :build => [:clean, :checkout]
|