Skip to content

Commit

Permalink
merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboyd committed Apr 26, 2012
1 parent 6a0f6ff commit 1ff9b95
Show file tree
Hide file tree
Showing 214 changed files with 71 additions and 71,823 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "ext/libv8/v8"]
path = lib/libv8/v8
[submodule "vendor/v8"]
path = vendor/v8
url = https://github.com/v8/v8.git
121 changes: 19 additions & 102 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,115 +1,32 @@
# This is a sanity check to enforce that the v8 submodule is initialized
# before we try to run any rake tasks.
if !File.exist? File.join('lib', 'libv8', 'v8', 'SConstruct') then
puts "V8 source appears to be missing. Updating..."
`git submodule update --init`
end

# Now we include the bundler stuff...
# We had to do the fetch first since our version code requires that we have
# the V8 source

require 'bundler'
require 'bundler/setup'

Bundler::GemHelper.install_tasks
MAKE = /GNU/ =~ `make --version 2>/dev/null` ? 'make' : 'gmake'

# desc "remove all generated artifacts except built v8 objects"
# task :clean do
# sh "rm -rf pkg"
# sh "rm -rf ext/v8/Makefile"
# sh "rm -rf ext/v8/*.bundle ext/v8/*.so"
# sh "rm -rf lib/v8/*.bundle lib/v8/*.so"
# end
#
# desc "build v8 with debugging symbols (much slower)"
# task "v8:debug" do
# sh "cd ext/v8/upstream && #{MAKE} debug"
# end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

# Rake::ExtensionTask.new("libv8", eval(File.read("libv8.gemspec"))) do |ext|
# ext.lib_dir = "lib/libv8"
# end
V8_Version = Libv8::VERSION.gsub(/\.\d$/,'')
V8_Source = File.expand_path '../vendor/v8', __FILE__

latest_v8 = nil
Dir.chdir(File.join('lib', 'libv8', 'v8')) do
latest_v8 = `git tag`.split.map{|v| Gem::Version.new(v)}.sort.last.to_s
end

desc "Check out a version of V8"
task :checkout, :version do |t, options|
options.with_defaults(:version => latest_v8)
Dir.chdir(File.join('lib', 'libv8', 'v8')) do
`git fetch`
# We're checking out the latest tag. Sorted using Gem::Version
versions = `git tag`.split.map{|v| Gem::Version.new(v)}.sort
fail "Version #{options.version} does not exist! Aborting..." if !versions.member?(Gem::Version.new(options.version))
puts "Checking out version #{options.version}"
`git checkout -f tags/#{options.version}`
File.open(File.join(File.dirname(__FILE__), 'lib', 'libv8', 'VERSION'), 'w') { |f| f.write options.version.to_s }
task :checkout do
sh "git submodule update --init"
Dir.chdir(V8_Source) do
sh "git fetch"
sh "git checkout #{V8_Version}"
end
end

desc "Compile the V8 JavaScript engine"
task :compile, [:version] do |t, options|
options.with_defaults(:version => latest_v8)

begin
def crash(str)
printf("Unable to build libv8: %s\n", str)
exit 1
end

print "Checking for Python..."
version = `python --version 2>&1`
version_number = version.split.last.match("[0-9.]+")[0]
crash "Python not found!" if version.split.first != "Python"
crash "Python 3.x is unsupported by V8!" if
Gem::Version.new(version_number) >=
Gem::Version.new(3)
crash "Python 2.4+ is required by V8!" if Gem::Version.new(version_number) < Gem::Version.new("2.4")
puts version_number
end

puts "Compiling V8 (#{options.version})..."
Rake::Task[:checkout].invoke(options.version)
Dir.chdir(File.join('lib', 'libv8')) do
system(MAKE)
task :compile do
Dir.chdir(V8_Source) do
puts "compiling libv8"
sh "make dependencies"
sh "make native GYP_GENERATORS=make"
end
end

desc "Clean up from the build"
task :clean do |t, options|
Dir.chdir(File.join('lib', 'libv8')) do
system(MAKE, 'clean')
end
end

desc "List all versions of V8"
task :list do
Dir.chdir(File.join('lib', 'libv8', 'v8')) do
puts `git tag`.split.map{|v| Gem::Version.new(v)}.sort
end
end

desc "Create a binary gem for this current platform"
task :binary, [:version] => [:compile] do |t, options|
gemspec = eval(File.read('libv8.gemspec'))
gemspec.extensions.clear
gemspec.platform = Gem::Platform.new(RUBY_PLATFORM)

# We don't need most things for the binary
gemspec.files = []
# Lib
gemspec.files << 'lib/libv8.rb'
gemspec.files << 'lib/libv8/version.rb'
# V8
Dir.glob('lib/libv8/v8/include/*').each { |f| gemspec.files << f }
gemspec.files << "lib/libv8/build/v8/libv8.a"
gemspec.files << "lib/libv8/build/v8/libv8preparser.a"
FileUtils.mkdir_p 'pkg'
FileUtils.mv(Gem::Builder.new(gemspec).build, 'pkg')
"clean up artifacts of the build"
task :clean do
sh "rm -rf pkg"
sh "cd #{V8_Source} && rm -rf out"
end

task :default => :binary
task :default => [:compile, :spec]
28 changes: 5 additions & 23 deletions ext/libv8/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
require 'mkmf'
require 'pathname'
create_makefile('libv8')

begin
def crash(str)
printf("Unable to build libv8: %s\n", str)
exit 1
end

print "Checking for Python..."
version = `python --version 2>&1`
crash "Python not found!" if version.split.first != "Python"
require 'rubygems'
crash "Python 3.x is unsupported by V8!" if Gem::Version.new(version.split.last) >= Gem::Version.new(3)
crash "Python 2.4+ is required by V8!" if Gem::Version.new(version.split.last) < Gem::Version.new("2.4")
puts version.split.last
rescue StandardError => e
warn e
Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do
puts "compiling libv8"
puts `make dependencies`
puts `make native GYP_GENERATORS=make`
end


Dir.chdir(Pathname(__FILE__).dirname.join('..', '..', 'lib', 'libv8')) do
puts "Compiling V8..."
/GNU/ =~ `make --version 2>/dev/null` ? `make` : `gmake`
end

create_makefile('libv8')
29 changes: 21 additions & 8 deletions lib/libv8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@
require 'libv8/version'

module Libv8
LIBRARY_PATH = Pathname(__FILE__).dirname.join('libv8', 'build', 'v8').to_s
def self.library_path
LIBRARY_PATH
end

INCLUDE_PATH = Pathname(__FILE__).dirname.join('libv8', 'v8', 'include').to_s
def self.include_path
INCLUDE_PATH

module_function

def libv8(name)
File.expand_path "../../vendor/v8/out/native/libv8_#{name}.a", __FILE__
end

def libv8_base
libv8 :base
end

def libv8_snapshot
libv8 :snapshot
end

def libv8_nosnapshot
libv8 :nosnapshot
end

def libv8_ldflags
"-l#{libv8_base} -l#{libv8_snapshot}"
end
end
39 changes: 0 additions & 39 deletions lib/libv8/Makefile

This file was deleted.

27 changes: 0 additions & 27 deletions lib/libv8/detect_cpu.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/libv8/fpic-on-linux-amd64.patch

This file was deleted.

Loading

0 comments on commit 1ff9b95

Please sign in to comment.