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

Separated code checkout to a module.

This will make sure the right version of the code will be shipped in the gem
and the right version will be used when compiling directly from git.
This commit is contained in:
Joris van Rooij 2013-06-20 16:26:55 +02:00 committed by ignisf
parent 0f386d326f
commit 5258daef0b
5 changed files with 57 additions and 11 deletions

View file

@ -7,3 +7,5 @@ notifications:
recipients:
- cowboyd@thefrontside.net
- bordjukov@gmail.com
before_install:
- sudo apt-get install git-svn

View file

@ -9,19 +9,15 @@ end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
V8_Version = Libv8::VERSION.gsub(/\.\d+$/,'')
V8_Source = File.expand_path '../vendor/v8', __FILE__
require File.expand_path '../ext/libv8/make.rb', __FILE__
require File.expand_path '../ext/libv8/checkout.rb', __FILE__
include Libv8::Make
include Libv8::Checkout
desc "setup the vendored v8 source to correspond to the libv8 gem version"
task :checkout do
sh "git submodule update --init"
Dir.chdir(V8_Source) do
sh "git fetch"
sh "git checkout #{V8_Version} -f"
end
checkout!
end
desc "compile v8 via the ruby extension mechanism"
@ -29,7 +25,6 @@ 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
require File.expand_path '../ext/libv8/arch.rb', __FILE__
@ -79,6 +74,7 @@ task :clean do
sh "rm -rf pkg"
sh "git clean -df"
sh "cd #{V8_Source} && git checkout -f && git clean -dxf"
sh "cd #{GYP_Source} && git checkout -f && git clean -dxf"
end
desc "build a binary on heroku (you must have vulcan configured for this)"

View file

@ -2,12 +2,14 @@ require 'mkmf'
require File.expand_path '../compiler', __FILE__
require File.expand_path '../arch', __FILE__
require File.expand_path '../make', __FILE__
require File.expand_path '../checkout', __FILE__
module Libv8
class Builder
include Libv8::Arch
include Libv8::Compiler
include Libv8::Make
include Libv8::Checkout
def make_flags(*flags)
profile = enable_config('debug') ? 'debug' : 'release'
@ -32,7 +34,8 @@ module Libv8
end
def build_libv8!
Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do
Dir.chdir(V8_Source) do
checkout!
setup_python!
setup_build_deps!
apply_patches!
@ -60,7 +63,7 @@ module Libv8
# This uses the Git mirror of the svn repository used by
# "make dependencies", instead of calling that make target
`rm -rf build/gyp`
`ln -fs #{File.expand_path '../../../vendor/gyp', __FILE__} build/gyp`
`ln -fs #{GYP_Source} build/gyp`
end
def apply_patches!

45
ext/libv8/checkout.rb Normal file
View file

@ -0,0 +1,45 @@
module Libv8
module Checkout
module_function
GYP_SVN = 'http://gyp.googlecode.com/svn'
V8_Source = File.expand_path '../../../vendor/v8', __FILE__
GYP_Source = File.expand_path '../../../vendor/gyp', __FILE__
def checkout!
# When compiling from a source gem, it's not a git repository anymore and
# we assume the right code is already checked out.
return unless git?(V8_Source)
Dir.chdir(V8_Source) do
`git fetch`
`git checkout #{Libv8::VERSION.gsub(/\.\d+$/,'')} -f`
end
return unless git?(GYP_Source)
check_git_svn!
Dir.chdir(GYP_Source) do
mkf = File.readlines(File.join(V8_Source, 'Makefile'))
idx = mkf.index {|l| l =~ /#{GYP_SVN}/} + 1
rev = /--revision (\d+)/.match(mkf[idx])[1]
`git fetch`
# --git-dir is needed for older versions of git and git-svn
`git --git-dir=../../.git/modules/vendor/gyp/ svn init #{GYP_SVN} -Ttrunk`
`git config --replace-all svn-remote.svn.fetch trunk:refs/remotes/origin/master`
`git checkout $(git --git-dir=../../.git/modules/vendor/gyp/ svn find-rev r#{rev} | tail -n 1) -f`
end
end
def git?(dir)
File.exists?(File.join(dir, '.git'))
end
def check_git_svn!
unless system 'git help svn 2>&1 > /dev/null'
fail "git-svn not installed!\nPlease install git-svn."
end
end
end
end

2
vendor/gyp vendored

@ -1 +1 @@
Subproject commit 878ee285239e5777028c31d6b9d10fbc930ccda2
Subproject commit f7bc250ccc4d619a1cf238db87e5979f89ff36d7