diff --git a/.gitignore b/.gitignore index a5d20c3..ff70a0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ -Makefile + v8.bundle *.o *.log *~ docs/cpp/html/* -ext/v8/upstream/scons/build -ext/v8/upstream/scons/install +ext/v8/upstream/build + pkg/ tmp/ \ No newline at end of file diff --git a/Rakefile b/Rakefile index bcde25c..3eb40c2 100644 --- a/Rakefile +++ b/Rakefile @@ -16,7 +16,7 @@ begin gemspec.homepage = "http://github.com/cowboyd/therubyracer" gemspec.authors = ["Charles Lowell", "Bill Robertson"] gemspec.extra_rdoc_files = ["README.rdoc"] - gemspec.files.exclude "ext/**/test/*", "ext/**/samples/*", "ext/**/benchmarks/*", "ext/**/*.o", "ext/**/*.o", "#{SCONS}/build", "#{SCONS}/install" + gemspec.files.exclude "ext/**/test/*", "ext/**/samples/*", "ext/**/benchmarks/*", "#{UPSTREAM}/build" end rescue LoadError puts "Jeweler not available. Install it with: gem install jeweler" @@ -42,10 +42,7 @@ task :build task "clean-v8" => "clean" do - sh "rm -f #{V8_SRC}/libv8.a" - sh "rm -rf #{SCONS}/build" - sh "rm -rf #{SCONS}/install" - sh "rm -rf #{V8_SRC}/obj" + sh "cd #{UPSTREAM} && make clean" end task :clean do diff --git a/ext/v8/extconf.rb b/ext/v8/extconf.rb index 802d639..53fe53f 100755 --- a/ext/v8/extconf.rb +++ b/ext/v8/extconf.rb @@ -1,25 +1,15 @@ require 'mkmf' +UPSTREAM = File.expand_path(File.dirname(__FILE__) + "/upstream") +BUILD = "#{UPSTREAM}/build/v8" + + puts "Compiling V8" -arch = ['foo'].pack('p').size == 8 ? 'x64' : 'ia32' +system("cd #{UPSTREAM} && make") or raise "Error compiling V8" -UPSTREAM_SRC = File.expand_path(File.dirname(__FILE__) + "/upstream") -SCONS_SRC = "#{UPSTREAM_SRC}/scons" -V8_SRC = "#{UPSTREAM_SRC}/2.0.6" -CCSC = "cd #{SCONS_SRC} && python setup.py install --prefix=#{SCONS_SRC}/install" -unless File.exists?("#{SCONS_SRC}/install") -puts CCSC -`#{CCSC}` -end -unless File.exists?("#{V8_SRC}/libv8.a") -CCV8 = "cd #{V8_SRC} && #{SCONS_SRC}/install/bin/scons arch=#{arch}" -puts CCV8 -`#{CCV8}` -end - -dir_config('v8', "#{V8_SRC}/include", "#{V8_SRC}") -have_library('v8') +dir_config('v8', "#{BUILD}/include", "#{BUILD}") +have_library('v8') or raise "Unable to find libv8 in #{BUILD}, was there an error compiling it?" $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall" diff --git a/ext/v8/upstream/Makefile b/ext/v8/upstream/Makefile new file mode 100644 index 0000000..b4a38b9 --- /dev/null +++ b/ext/v8/upstream/Makefile @@ -0,0 +1,31 @@ + +SCONS=build/scons/install/bin/scons +SCONSSRC=build/scons +V8SRC=build/v8 +LIBV8=build/v8/libv8.a +GCC_VERSION=$(shell ruby -e 'puts %x{gcc --version} =~ /(\d)\.(\d)\.\d/ ? $$1 + $$2 : "UNKNOWN"') +ARCH=$(shell ruby -e "puts ['foo'].pack('p').size == 8 ? 'x64' : 'ia32'") + +all: $(LIBV8) + +$(LIBV8): $(SCONS) $(V8SRC) + cd build/v8 && GCC_VERSION=$(GCC_VERSION) ../scons/install/bin/scons arch=$(ARCH) + +$(SCONS): $(SCONSSRC) + mkdir -p $(SCONSSRC)/install + python build/scons/setup.py install --prefix=install + +$(V8SRC): build + cp -r 2.0.6 build/v8 + patch -td build/v8 -i ../../no-strict-aliasing.patch + +$(SCONSSRC): build + cp -r scons build + +build: + mkdir -p build + +scons: $(SCONS) + +clean: + rm -rf build diff --git a/ext/v8/upstream/no-strict-aliasing.patch b/ext/v8/upstream/no-strict-aliasing.patch new file mode 100644 index 0000000..5be66cb --- /dev/null +++ b/ext/v8/upstream/no-strict-aliasing.patch @@ -0,0 +1,13 @@ +Index: SConstruct +=================================================================== +--- SConstruct (revision 3521) ++++ SConstruct (working copy) +@@ -47,7 +47,7 @@ + # on linux we need these compiler flags to avoid crashes in the v8 test suite + # and avoid dtoa.c strict aliasing issues + if os.environ.get('GCC_VERSION') == '44': +- GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp'] ++ GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp', '-fno-strict-aliasing'] + GCC_DTOA_EXTRA_CCFLAGS = ['-fno-strict-aliasing'] + else: + GCC_EXTRA_CCFLAGS = []