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:
parent
0f386d326f
commit
5258daef0b
5 changed files with 57 additions and 11 deletions
|
@ -7,3 +7,5 @@ notifications:
|
||||||
recipients:
|
recipients:
|
||||||
- cowboyd@thefrontside.net
|
- cowboyd@thefrontside.net
|
||||||
- bordjukov@gmail.com
|
- bordjukov@gmail.com
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get install git-svn
|
12
Rakefile
12
Rakefile
|
@ -9,19 +9,15 @@ end
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
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/make.rb', __FILE__
|
||||||
|
require File.expand_path '../ext/libv8/checkout.rb', __FILE__
|
||||||
include Libv8::Make
|
include Libv8::Make
|
||||||
|
include Libv8::Checkout
|
||||||
|
|
||||||
desc "setup the vendored v8 source to correspond to the libv8 gem version"
|
desc "setup the vendored v8 source to correspond to the libv8 gem version"
|
||||||
task :checkout do
|
task :checkout do
|
||||||
sh "git submodule update --init"
|
sh "git submodule update --init"
|
||||||
Dir.chdir(V8_Source) do
|
checkout!
|
||||||
sh "git fetch"
|
|
||||||
sh "git checkout #{V8_Version} -f"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "compile v8 via the ruby extension mechanism"
|
desc "compile v8 via the ruby extension mechanism"
|
||||||
|
@ -29,7 +25,6 @@ task :compile do
|
||||||
sh "ruby ext/libv8/extconf.rb"
|
sh "ruby ext/libv8/extconf.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
desc "manually invoke the GYP compile. Useful for seeing debug output"
|
desc "manually invoke the GYP compile. Useful for seeing debug output"
|
||||||
task :manual_compile do
|
task :manual_compile do
|
||||||
require File.expand_path '../ext/libv8/arch.rb', __FILE__
|
require File.expand_path '../ext/libv8/arch.rb', __FILE__
|
||||||
|
@ -79,6 +74,7 @@ task :clean do
|
||||||
sh "rm -rf pkg"
|
sh "rm -rf pkg"
|
||||||
sh "git clean -df"
|
sh "git clean -df"
|
||||||
sh "cd #{V8_Source} && git checkout -f && git clean -dxf"
|
sh "cd #{V8_Source} && git checkout -f && git clean -dxf"
|
||||||
|
sh "cd #{GYP_Source} && git checkout -f && git clean -dxf"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "build a binary on heroku (you must have vulcan configured for this)"
|
desc "build a binary on heroku (you must have vulcan configured for this)"
|
||||||
|
|
|
@ -2,12 +2,14 @@ require 'mkmf'
|
||||||
require File.expand_path '../compiler', __FILE__
|
require File.expand_path '../compiler', __FILE__
|
||||||
require File.expand_path '../arch', __FILE__
|
require File.expand_path '../arch', __FILE__
|
||||||
require File.expand_path '../make', __FILE__
|
require File.expand_path '../make', __FILE__
|
||||||
|
require File.expand_path '../checkout', __FILE__
|
||||||
|
|
||||||
module Libv8
|
module Libv8
|
||||||
class Builder
|
class Builder
|
||||||
include Libv8::Arch
|
include Libv8::Arch
|
||||||
include Libv8::Compiler
|
include Libv8::Compiler
|
||||||
include Libv8::Make
|
include Libv8::Make
|
||||||
|
include Libv8::Checkout
|
||||||
|
|
||||||
def make_flags(*flags)
|
def make_flags(*flags)
|
||||||
profile = enable_config('debug') ? 'debug' : 'release'
|
profile = enable_config('debug') ? 'debug' : 'release'
|
||||||
|
@ -32,7 +34,8 @@ module Libv8
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_libv8!
|
def build_libv8!
|
||||||
Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do
|
Dir.chdir(V8_Source) do
|
||||||
|
checkout!
|
||||||
setup_python!
|
setup_python!
|
||||||
setup_build_deps!
|
setup_build_deps!
|
||||||
apply_patches!
|
apply_patches!
|
||||||
|
@ -60,7 +63,7 @@ module Libv8
|
||||||
# This uses the Git mirror of the svn repository used by
|
# This uses the Git mirror of the svn repository used by
|
||||||
# "make dependencies", instead of calling that make target
|
# "make dependencies", instead of calling that make target
|
||||||
`rm -rf build/gyp`
|
`rm -rf build/gyp`
|
||||||
`ln -fs #{File.expand_path '../../../vendor/gyp', __FILE__} build/gyp`
|
`ln -fs #{GYP_Source} build/gyp`
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_patches!
|
def apply_patches!
|
||||||
|
|
45
ext/libv8/checkout.rb
Normal file
45
ext/libv8/checkout.rb
Normal 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
2
vendor/gyp
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 878ee285239e5777028c31d6b9d10fbc930ccda2
|
Subproject commit f7bc250ccc4d619a1cf238db87e5979f89ff36d7
|
Loading…
Reference in a new issue