Skip to content

Commit

Permalink
Initial version!
Browse files Browse the repository at this point in the history
  • Loading branch information
Logan Lowell committed May 24, 2011
0 parents commit da58b23
Show file tree
Hide file tree
Showing 211 changed files with 70,333 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.gem
.bundle
Gemfile.lock
pkg/*
tmp/*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ext/libv8/v8"]
path = ext/libv8/v8
url = https://github.com/v8/v8.git
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in libv8.gemspec
gemspec
32 changes: 32 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'bundler'
require 'bundler/setup'

# require "rake/extensiontask"

Bundler::GemHelper.install_tasks

# 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

# Rake::ExtensionTask.new("libv8", eval(File.read("libv8.gemspec"))) do |ext|
# ext.lib_dir = "lib/libv8"
# end

desc "Compile the V8 JavaScript engine"
task "compile" do
Dir.chdir(File.join('lib', 'libv8')) do
puts "Compiling V8..."
$stdout.flush
`make`
end
end
10 changes: 10 additions & 0 deletions ext/libv8/extconf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'mkmf'
require 'pathname'

puts "Compiling V8..."

Dir.chdir(Pathname(__FILE__).dirname.join('..', '..', 'lib', 'libv8')) do
`make`
end

create_makefile('libv8')
9 changes: 9 additions & 0 deletions lib/libv8.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'pathname'

require 'libv8/version'

module Libv8
def self.LIB_PATH
Pathname(__FILE__).dirname.join('libv8', 'build', 'v8', 'libv8.a')
end
end
37 changes: 37 additions & 0 deletions lib/libv8/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

SCONS=build/scons/install/bin/scons
SCONSSRC=build/scons
V8SRC=build/v8
LIBV8=build/v8/libv8.a
LIBV8_G=build/v8/libv8_g.a
GCC_VERSION=$(shell ruby -e 'puts %x{gcc --version} =~ /(\d)\.(\d)\.\d/ ? $$1 + $$2 : "UNKNOWN"')
ARCH=$(shell ruby detect_cpu.rb)

all: $(LIBV8)

debug: $(LIBV8_G)
cp $(LIBV8_G) $(LIBV8)

$(LIBV8): $(SCONS) $(V8SRC)
cd build/v8 && GCC_VERSION=$(GCC_VERSION) ../scons/install/bin/scons arch=$(ARCH)

$(LIBV8_G): $(SCONS) $(V8SRC)
cd build/v8 && GCC_VERSION=$(GCC_VERSION) ../scons/install/bin/scons arch=$(ARCH) mode=debug

$(SCONS): $(SCONSSRC)
mkdir -p $(SCONSSRC)/install
python build/scons/setup.py install --prefix=install

$(V8SRC): build
cp -r v8 build

$(SCONSSRC): build
cp -r scons build

build:
mkdir -p build

scons: $(SCONS)

clean:
rm -rf build
27 changes: 27 additions & 0 deletions lib/libv8/detect_cpu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'rbconfig'

def x86_64_from_build_cpu
RbConfig::MAKEFILE_CONFIG['build_cpu'] == 'x86_64'
end

def x86_64_from_byte_length
['foo'].pack('p').size == 8
end

def x86_64_from_arch_flag
RbConfig::MAKEFILE_CONFIG['ARCH_FLAG'] =~ /x86_64/
end

def rubinius?
Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == "rbx"
end

def x64?
if rubinius?
x86_64_from_build_cpu || x86_64_from_arch_flag
else
x86_64_from_byte_length
end
end

puts x64? ? "x64" : "ia32"
Loading

0 comments on commit da58b23

Please sign in to comment.