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

Merge remote-tracking branch 'origin/master' into 3.27

Conflicts:
	.gitmodules
	.travis.yml
	Rakefile
	ext/libv8/builder.rb
	ext/libv8/checkout.rb
	ext/libv8/compiler/gcc.rb
	ext/libv8/compiler/generic_compiler.rb
	ext/libv8/patcher.rb
	lib/libv8/version.rb
	libv8.gemspec
	patches/arm/do-not-imply-vfp3-and-armv7.patch
	patches/fPIC-for-static.patch
This commit is contained in:
Charles Lowell 2015-07-03 02:53:25 -05:00
commit abc49f0740
19 changed files with 447 additions and 20 deletions

2
.gitignore vendored
View file

@ -10,3 +10,5 @@ tmp/*
lib/libv8/build/* lib/libv8/build/*
lib/libv8/VERSION lib/libv8/VERSION
/ext/libv8/.location.yml /ext/libv8/.location.yml
/release/**/libv8
/release/**/.vagrant

1
.gitmodules vendored
View file

@ -7,3 +7,4 @@
[submodule "vendor/buildtools"] [submodule "vendor/buildtools"]
path = vendor/buildtools path = vendor/buildtools
url = https://chromium.googlesource.com/chromium/buildtools.git url = https://chromium.googlesource.com/chromium/buildtools.git

View file

@ -1,15 +1,11 @@
language: ruby language: ruby
rvm: rvm:
- 2.2.2
- 2.1.2 - 2.1.2
- 2.0.0 - 2.0.0
- 1.9.3 - 1.9.3
- rbx-2 - rbx-2
- ree
- 1.8.7
matrix: matrix:
allow_failures:
- rvm: ree
- rvm: 1.8.7
include: include:
- rvm: 2.1.2-clang - rvm: 2.1.2-clang
env: CXX=clang++ env: CXX=clang++
@ -22,4 +18,4 @@ notifications:
recipients: recipients:
- cowboyd@thefrontside.net - cowboyd@thefrontside.net
- bordjukov@gmail.com - bordjukov@gmail.com
cache: bundler cache: bundler

View file

@ -1,4 +1,8 @@
# libv8 # libv8
[![Gem Version](https://badge.fury.io/rb/libv8.svg)](http://badge.fury.io/rb/libv8)
[![Build Status](https://travis-ci.org/cowboyd/libv8.svg?branch=master)](https://travis-ci.org/cowboyd/libv8)
[![Build status](https://ci.appveyor.com/api/projects/status/ugeqff972kxlba5j?svg=true)](https://ci.appveyor.com/project/cowboyd/libv8)
[![Join the chat at https://gitter.im/cowboyd/therubyracer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cowboyd/therubyracer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A gem for distributing the v8 runtime libraries and headers in both A gem for distributing the v8 runtime libraries and headers in both
source and binary form. source and binary form.

View file

@ -18,7 +18,7 @@ module Helpers
end end
desc "compile v8 via the ruby extension mechanism" desc "compile v8 via the ruby extension mechanism"
task :compile do task :compile do
sh "ruby ext/libv8/extconf.rb" sh "ruby ext/libv8/extconf.rb"
end end
@ -50,6 +50,22 @@ task :binary => :compile do
FileUtils.mv package, 'pkg' FileUtils.mv package, 'pkg'
end end
namespace :build do
['x86_64-linux', 'x86-linux'].each do |arch|
desc "build binary gem for #{arch}"
task arch do
arch_dir = Pathname(__FILE__).dirname.join("release/#{arch}")
Dir.chdir(arch_dir) do
sh "vagrant up"
sh "vagrant ssh -c 'cd /vagrant && rm -rf libv8 && git clone /libv8/.git libv8'"
sh "vagrant ssh -c 'cd /vagrant/libv8 && bundle install --path vendor/bundle'"
sh "vagrant ssh -c 'cd /vagrant/libv8 && bundle exec rake checkout binary'"
sh "vagrant ssh -c 'cp /vagrant/libv8/pkg/*.gem /vagrant'"
end
end
end
end
task :clean_submodules do task :clean_submodules do
sh "git submodule --quiet foreach git reset --hard" sh "git submodule --quiet foreach git reset --hard"
sh "git submodule --quiet foreach git clean -dxf" sh "git submodule --quiet foreach git clean -dxf"

36
appveyor.yml Normal file
View file

@ -0,0 +1,36 @@
version: 3.16.14.8.b{build}
# Operating system (build VM template)
os: Windows Server 2012
clone_depth: 10
environment:
matrix:
- ruby_version: "22-x64"
- ruby_version: "22"
- ruby_version: "21-x64"
- ruby_version: "21"
- ruby_version: "200-x64"
- ruby_version: "200"
- ruby_version: "193"
# scripts that run after cloning repository
install:
- set PATH=C:\Ruby%ruby_version%\bin;%PATH%
- git submodule update --init
- ruby --version
- gem --version
- gem install bundler --no-ri --no-rdoc
- bundle --version
- bundle install --jobs=1 --retry=3
build_script:
- bundle exec rake binary
test_script:
- bundle exec rake spec
artifacts:
- path: pkg\*.gem

View file

@ -14,9 +14,12 @@ module Libv8
@compiler = choose_compiler @compiler = choose_compiler
end end
def make_flags(*flags) def make_target
profile = enable_config('debug') ? 'debug' : 'release' profile = enable_config('debug') ? 'debug' : 'release'
"#{libv8_arch}.#{profile}"
end
def make_flags(*flags)
# FreeBSD uses gcc 4.2 by default which leads to # FreeBSD uses gcc 4.2 by default which leads to
# compilation failures due to warnings about aliasing. # compilation failures due to warnings about aliasing.
# http://svnweb.freebsd.org/ports/head/lang/v8/Makefile?view=markup # http://svnweb.freebsd.org/ports/head/lang/v8/Makefile?view=markup
@ -40,7 +43,11 @@ module Libv8
# Solaris / Smart OS requires additional -G flag to use with -fPIC # Solaris / Smart OS requires additional -G flag to use with -fPIC
flags << "CFLAGS=-G" if @compiler.target =~ /solaris/ flags << "CFLAGS=-G" if @compiler.target =~ /solaris/
"#{libv8_arch}.#{profile} #{flags.join ' '}" # Disable werror as this version of v8 is getting difficult to maintain
# with it on
flags << 'werror=no'
"#{make_target} #{flags.join ' '}"
end end
def build_libv8! def build_libv8!
@ -91,8 +98,8 @@ module Libv8
end end
def python_version def python_version
if system 'which python 2>&1 > /dev/null' if `which python` =~ /python/
`python -c 'import platform; print(platform.python_version())'`.chomp `python -c "import platform; print(platform.python_version())"`.chomp
else else
"not available" "not available"
end end

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

@ -0,0 +1,52 @@
require File.expand_path '../../../lib/libv8/version.rb', __FILE__
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+(\.rc\d+)?$/,'')} -f`
`rm -f .applied_patches`
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`
svn_rev = `git --git-dir=../../.git/modules/vendor/gyp/ svn find-rev r#{rev} | tail -n 1`.chomp
`git checkout #{svn_rev} -f`
end
end
def git?(dir)
File.exist?(File.join(dir, '.git'))
end
def check_git_svn!
# msysgit provides git svn
return if RUBY_PLATFORM =~ /mingw/
unless system 'git help svn 2>&1 > /dev/null'
fail "git-svn not installed!\nPlease install git-svn."
end
end
end
end

View file

@ -33,7 +33,7 @@ module Libv8
def verify_installation! def verify_installation!
Libv8::Paths.object_paths.each do |p| Libv8::Paths.object_paths.each do |p|
fail ArchiveNotFound, p unless File.exists? p fail ArchiveNotFound, p unless File.exist? p
end end
end end
@ -48,6 +48,7 @@ module Libv8
def configure(context = MkmfContext.new) def configure(context = MkmfContext.new)
context.send(:dir_config, 'v8') context.send(:dir_config, 'v8')
context.send(:find_header, 'v8.h') or fail NotFoundError context.send(:find_header, 'v8.h') or fail NotFoundError
context.send(:have_library, 'v8') or fail NotFoundError
end end
class NotFoundError < StandardError class NotFoundError < StandardError

View file

@ -11,6 +11,7 @@ module Libv8
(available_patches - applied_patches).each do |patch| (available_patches - applied_patches).each do |patch|
`patch -p1 -N < #{patch}` `patch -p1 -N < #{patch}`
fail 'failed to apply patch' unless $?.success?
f.puts patch f.puts patch
puts "Applying #{patch}" puts "Applying #{patch}"
end end

View file

@ -1,4 +1,5 @@
require 'rbconfig' require 'rbconfig'
require 'shellwords'
require File.expand_path '../arch', __FILE__ require File.expand_path '../arch', __FILE__
module Libv8 module Libv8
@ -6,11 +7,13 @@ module Libv8
module_function module_function
def include_paths def include_paths
["#{vendored_source_path}/include"] [Shellwords.escape("#{vendored_source_path}/include")]
end end
def object_paths def object_paths
[libv8_object(:base), libv8_object(:snapshot)] [libv8_object(:base), libv8_object(:snapshot)].map do |path|
Shellwords.escape path
end
end end
def config def config
@ -19,7 +22,7 @@ module Libv8
def libv8_object(name) def libv8_object(name)
filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}" filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}"
unless File.exists? filename unless File.exist? filename
filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}" filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}"
end end
return filename return filename
@ -28,7 +31,7 @@ module Libv8
def libv8_profile def libv8_profile
base = "#{vendored_source_path}/out/#{Libv8::Arch.libv8_arch}" base = "#{vendored_source_path}/out/#{Libv8::Arch.libv8_arch}"
debug = "#{base}.debug" debug = "#{base}.debug"
File.exists?(debug) ? debug : "#{base}.release" File.exist?(debug) ? debug : "#{base}.release"
end end
def vendored_source_path def vendored_source_path

View file

@ -29,4 +29,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 10' s.add_development_dependency 'rake', '~> 10'
s.add_development_dependency 'rake-compiler', '~> 0' s.add_development_dependency 'rake-compiler', '~> 0'
s.add_development_dependency 'rspec', '~> 2.14', '< 2.14.99' s.add_development_dependency 'rspec', '~> 2.14', '< 2.14.99'
s.add_development_dependency 'rspec-spies', '~> 2.0'
end end

View file

@ -0,0 +1,16 @@
diff --git a/build/standalone.gypi b/build/standalone.gypi
index 125c5bf..9900c5b 100644
--- a/build/standalone.gypi
+++ b/build/standalone.gypi
@@ -77,9 +77,9 @@
}],
],
# Default ARM variable settings.
- 'armv7%': 1,
+ 'armv7%': 0,
'arm_neon%': 0,
- 'arm_fpu%': 'vfpv3',
+ 'arm_fpu%': 'vfp',
},
'target_defaults': {
'default_configuration': 'Debug',

View file

@ -0,0 +1,13 @@
diff --git a/build/common.gypi b/build/common.gypi
index 3a59639..594abe4 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -173,7 +173,6 @@
[ 'v8_use_arm_eabi_hardfloat=="true"', {
'defines': [
'USE_EABI_HARDFLOAT=1',
- 'CAN_USE_VFP2_INSTRUCTIONS',
],
'target_conditions': [
['_toolset=="target"', {

View file

@ -0,0 +1,12 @@
diff --git a/build/standalone.gypi b/build/standalone.gypi
index 125c5bf..a283a28 100644
--- a/build/standalone.gypi
+++ b/build/standalone.gypi
@@ -210,6 +212,7 @@
'-Wendif-labels',
'-W',
'-Wno-unused-parameter',
+ '-Wno-unused-variable',
'-Wnon-virtual-dtor',
],
},

View file

@ -0,0 +1,97 @@
#!/bin/sh
# Copyright 2013 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Monkey-patch GYP.
cat > build/gyp/gyp.mingw << EOF
#!/usr/bin/env python
# Copyright (c) 2009 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import sys
# TODO(mark): sys.path manipulation is some temporary testing stuff.
try:
import gyp
except ImportError, e:
import os.path
sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'pylib'))
import gyp
def MonkeyBuildFileTargets(target_list, build_file):
"""From a target_list, returns the subset from the specified build_file.
"""
build_file = build_file.replace('/', '\\\\')
return [p for p in target_list if gyp.common.BuildFile(p) == build_file]
gyp.common.BuildFileTargets = MonkeyBuildFileTargets
import gyp.generator.make
import os
def Monkey_ITIP(self):
"""Returns the location of the final output for an installable target."""
sep = os.path.sep
# Xcode puts shared_library results into PRODUCT_DIR, and some gyp files
# rely on this. Emulate this behavior for mac.
if (self.type == 'shared_library' and
(self.flavor != 'mac' or self.toolset != 'target')):
# Install all shared libs into a common directory (per toolset) for
# convenient access with LD_LIBRARY_PATH.
return '\$(builddir)%slib.%s%s%s' % (sep, self.toolset, sep, self.alias)
return '\$(builddir)' + sep + self.alias
gyp.generator.make.MakefileWriter._InstallableTargetInstallPath = Monkey_ITIP
if __name__ == '__main__':
sys.exit(gyp.main(sys.argv[1:]))
EOF
# Delete old generated Makefiles.
find out -name '*.mk' -or -name 'Makefile*' -exec rm {} \;
# Generate fresh Makefiles.
mv build/gyp/gyp build/gyp/gyp.original
mv build/gyp/gyp.mingw build/gyp/gyp
make out/Makefile.ia32 out/Makefile.x64
mv build/gyp/gyp build/gyp/gyp.mingw
mv build/gyp/gyp.original build/gyp/gyp
# Patch generated Makefiles: replace most backslashes with forward slashes,
# fix library names in linker flags.
FILES=$(find out -name '*.mk' -or -name 'Makefile*')
for F in $FILES ; do
echo "Patching $F..."
cp $F $F.orig
cat $F.orig \
| sed -e 's|\([)a-zA-Z0-9]\)\\\([a-zA-Z]\)|\1/\2|g' \
-e 's|\([)a-zA-Z0-9]\)\\\\\([a-zA-Z]\)|\1/\2|g' \
-e 's|'%s/n'|'%s\\\\n'|g' \
-e 's|-lwinmm\.lib|-lwinmm|g' \
-e 's|-lws2_32\.lib|-lws2_32|g' \
> $F
rm $F.orig
done

75
release/x86-linux/Vagrantfile vendored Normal file
View file

@ -0,0 +1,75 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
# https://atlas.hashicorp.com/boxcutter/boxes/debian80-i386
config.vm.box = "boxcutter/debian80-i386"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "../..", "/libv8"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y gcc-4.8 g++-4.8 build-essential git git-svn python ruby ruby-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --config gcc
gem install bundler
SHELL
end

75
release/x86_64-linux/Vagrantfile vendored Normal file
View file

@ -0,0 +1,75 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
# https://atlas.hashicorp.com/quarkslab/boxes/debian-8.0-amd64
config.vm.box = "quarkslab/debian-8.0-amd64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "../..", "/libv8"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y gcc-4.8 g++-4.8 build-essential git git-svn python ruby ruby-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --config gcc
gem install bundler
SHELL
end

View file

@ -4,25 +4,44 @@ describe "libv8 locations" do
before do before do
@context = double(:CompilationContext) @context = double(:CompilationContext)
end end
describe "the system location" do describe "the system location" do
before do before do
@location = Libv8::Location::System.new @location = Libv8::Location::System.new
@context.stub(:dir_config) @context.stub(:dir_config)
end end
describe "configuring a compliation context with it" do describe "configuring a compliation context with it" do
before do before do
@context.stub(:find_header) {true} @context.stub(:find_header) {true}
@context.stub(:have_library) {true}
@location.configure @context @location.configure @context
end end
it "adds the include path to the front of the include flags" do it "adds the include path to the front of the include flags" do
@context.should have_received(:dir_config).with('v8').at_least(:once) @context.should have_received(:dir_config).with('v8').at_least(:once)
@context.should have_received(:find_header).with('v8.h').at_least(:once) @context.should have_received(:find_header).with('v8.h').at_least(:once)
@context.should have_received(:have_library).with('v8').at_least(:once)
end end
end end
describe "when the v8 library cannot be found" do
before do
@context.stub(:find_header) {true}
@context.stub(:have_library) {false}
end
it "raises a NotFoundError" do
expect {@location.configure @context}.to raise_error Libv8::Location::System::NotFoundError
end
end
describe "when the v8.h header cannot be found" do describe "when the v8.h header cannot be found" do
before do before do
@context.stub(:find_header) {false} @context.stub(:find_header) {false}
@context.stub(:have_library) {true}
end end
it "raises a NotFoundError" do it "raises a NotFoundError" do
expect {@location.configure @context}.to raise_error Libv8::Location::System::NotFoundError expect {@location.configure @context}.to raise_error Libv8::Location::System::NotFoundError
end end
@ -35,17 +54,17 @@ describe "libv8 locations" do
@context.stub(:incflags) {@incflags ||= "-I/usr/include -I/usr/local/include"} @context.stub(:incflags) {@incflags ||= "-I/usr/include -I/usr/local/include"}
@context.stub(:ldflags) {@ldflags ||= "-lobjc -lpthread"} @context.stub(:ldflags) {@ldflags ||= "-lobjc -lpthread"}
Libv8::Paths.stub(:include_paths) {["/frp/v8/include"]} Libv8::Paths.stub(:vendored_source_path) {"/foo bar/v8"}
Libv8::Paths.stub(:object_paths) {["/frp/v8/obj/libv8_base.a", "/frp/v8/obj/libv8_snapshot.a"]} Libv8::Arch.stub(:libv8_arch) {'x64'}
@location.configure @context @location.configure @context
end end
it "prepends its own incflags before any pre-existing ones" do it "prepends its own incflags before any pre-existing ones" do
@context.incflags.should eql "-I/frp/v8/include -I/usr/include -I/usr/local/include" @context.incflags.should eql "-I/foo\\ bar/v8/include -I/usr/include -I/usr/local/include"
end end
it "prepends the locations of any libv8 objects on the the ldflags" do it "prepends the locations of any libv8 objects on the the ldflags" do
@context.ldflags.should eql "/frp/v8/obj/libv8_base.a /frp/v8/obj/libv8_snapshot.a -lobjc -lpthread" @context.ldflags.should eql "/foo\\ bar/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a /foo\\ bar/v8/out/x64.release/obj.target/tools/gyp/libv8_snapshot.a -lobjc -lpthread"
end end
end end
end end