libv8 3.11.8.4 → 3.11.8.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ pkg/*
9
9
  tmp/*
10
10
  lib/libv8/build/*
11
11
  lib/libv8/VERSION
12
+ /ext/libv8/.location.yml
data/README.md CHANGED
@@ -29,7 +29,7 @@ If you can fix the "Makefile" so that it correctly compiles for your platform, w
29
29
 
30
30
  To get the source, these commands will get you started:
31
31
 
32
- git clone git@github.com:cowboyd/libv8
32
+ git clone git://github.com/cowboyd/libv8.git
33
33
  cd libv8
34
34
  bundle install
35
35
  bundle exec rake checkout
@@ -39,7 +39,7 @@ To get the source, these commands will get you started:
39
39
  ### About
40
40
 
41
41
  This project spun off of [therubyracer](http://github.com/cowboyd/therubyracer) which depends on having
42
- a specific version of v8 to compile and run against. However, actually delivering that version
42
+ a specific version of v8 to compile and run against. However, actually delivering that version
43
43
  reliably to all the different platforms proved to be a challenge to say the least.
44
44
 
45
45
  We got tired of waiting 5 minutes for v8 to compile every time we installed that gem.
data/Rakefile CHANGED
@@ -52,7 +52,7 @@ def get_binary_gemspec(platform = RUBY_PLATFORM)
52
52
  gemspec
53
53
  end
54
54
 
55
- begin
55
+ begin
56
56
  binary_gem_name = File.basename get_binary_gemspec.cache_file
57
57
  rescue
58
58
  binary_gem_name = ''
@@ -63,7 +63,10 @@ task :binary => :compile do
63
63
  gemspec = get_binary_gemspec
64
64
  gemspec.extensions.clear
65
65
  # We don't need most things for the binary
66
- gemspec.files = ['lib/libv8.rb', 'ext/libv8/arch.rb', 'lib/libv8/version.rb']
66
+ gemspec.files = []
67
+ gemspec.files += ['lib/libv8.rb', 'lib/libv8/version.rb']
68
+ gemspec.files += ['ext/libv8/arch.rb', 'ext/libv8/location.rb', 'ext/libv8/paths.rb']
69
+ gemspec.files += ['ext/libv8/.location.yml']
67
70
  # V8
68
71
  gemspec.files += Dir['vendor/v8/include/*']
69
72
  gemspec.files += Dir['vendor/v8/out/**/*.a']
@@ -75,7 +78,7 @@ desc "clean up artifacts of the build"
75
78
  task :clean do
76
79
  sh "rm -rf pkg"
77
80
  sh "git clean -df"
78
- sh "cd #{V8_Source} && git clean -dxf"
81
+ sh "cd #{V8_Source} && git co -f && git clean -dxf"
79
82
  end
80
83
 
81
84
  task :default => [:checkout, :compile, :spec]
@@ -0,0 +1,20 @@
1
+ require File.expand_path '../compiler', __FILE__
2
+ require File.expand_path '../arch', __FILE__
3
+ require File.expand_path '../make', __FILE__
4
+
5
+ module Libv8
6
+ class Builder
7
+ include Libv8::Arch
8
+ include Libv8::Compiler
9
+ include Libv8::Make
10
+
11
+ def build_libv8!
12
+ profile = enable_config('debug') ? 'debug' : 'release'
13
+
14
+ Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do
15
+ puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{libv8_arch}.#{profile} GYPFLAGS="-Dhost_arch=#{libv8_arch}"`
16
+ end
17
+ return $?.exitstatus
18
+ end
19
+ end
20
+ end
@@ -1,16 +1,7 @@
1
1
  require 'mkmf'
2
2
  create_makefile('libv8')
3
- require File.expand_path '../arch.rb', __FILE__
4
- require File.expand_path '../make.rb', __FILE__
5
- require File.expand_path '../compiler.rb', __FILE__
6
3
 
7
- include Libv8::Arch
8
- include Libv8::Make
9
- include Libv8::Compiler
4
+ require File.expand_path '../location', __FILE__
5
+ location = with_config('system-v8') ? Libv8::Location::System.new : Libv8::Location::Vendor.new
10
6
 
11
- profile = enable_config('debug') ? 'debug' : 'release'
12
-
13
- Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do
14
- puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{libv8_arch}.#{profile} GYPFLAGS="-Dhost_arch=#{libv8_arch}"`
15
- end
16
- exit $?.exitstatus
7
+ exit location.install!
@@ -0,0 +1,81 @@
1
+ require 'yaml'
2
+ require 'pathname'
3
+ require File.expand_path '../paths', __FILE__
4
+
5
+ module Libv8
6
+ class Location
7
+ def install!
8
+ File.open(Pathname(__FILE__).dirname.join('.location.yml'), "w") do |f|
9
+ f.write self.to_yaml
10
+ end
11
+ return 0
12
+ end
13
+
14
+ def self.load!
15
+ File.open(Pathname(__FILE__).dirname.join('.location.yml')) do |f|
16
+ YAML.load f
17
+ end
18
+ end
19
+
20
+ class Vendor < Location
21
+ def install!
22
+ require File.expand_path '../builder', __FILE__
23
+ builder = Libv8::Builder.new
24
+ exit_status = builder.build_libv8!
25
+ super if exit_status == 0
26
+ verify_installation!
27
+ return exit_status
28
+ end
29
+ def configure(context = MkmfContext.new)
30
+ context.incflags.insert 0, Libv8::Paths.include_paths.map{|p| "-I#{p}"}.join(" ") + " "
31
+ context.ldflags.insert 0, Libv8::Paths.object_paths.join(" ") + " "
32
+ end
33
+
34
+ def verify_installation!
35
+ Libv8::Paths.object_paths.each do |p|
36
+ fail ArchiveNotFound, p unless File.exists? p
37
+ end
38
+ end
39
+
40
+ class ArchiveNotFound < StandardError
41
+ def initialize(filename)
42
+ super "libv8 did not install properly, expected binary v8 archive '#{filename}'to exist, but it was not found"
43
+ end
44
+ end
45
+ end
46
+
47
+ class System < Location
48
+ def configure(context = MkmfContext.new)
49
+ context.dir_config('v8')
50
+ context.find_header('v8.h') or fail NotFoundError
51
+ end
52
+
53
+ class NotFoundError < StandardError
54
+ def initialize(*args)
55
+ super(<<-EOS)
56
+ You have chosen to use the version of V8 found on your system
57
+ and *not* the one that is bundle with the libv8 rubygem. However,
58
+ it could not be located. please make sure you have a version of
59
+ v8 that is compatible with #{Libv8::VERSION} installed. You may
60
+ need to special --with-v8-dir options if it is in a non-standard
61
+ location
62
+
63
+ thanks,
64
+ The Mgmt
65
+
66
+ EOS
67
+ end
68
+ end
69
+ end
70
+
71
+ class MkmfContext
72
+ def incflags
73
+ $INCFLAGS
74
+ end
75
+
76
+ def ldflags
77
+ $LDFLAGS
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,38 @@
1
+ require 'rbconfig'
2
+ require File.expand_path '../arch', __FILE__
3
+
4
+ module Libv8
5
+ module Paths
6
+ module_function
7
+
8
+ def include_paths
9
+ ["#{vendored_source_path}/include"]
10
+ end
11
+
12
+ def object_paths
13
+ [libv8_object(:base), libv8_object(:snapshot)]
14
+ end
15
+
16
+ def config
17
+ RbConfig::MAKEFILE_CONFIG
18
+ end
19
+
20
+ def libv8_object(name)
21
+ filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}"
22
+ unless File.exists? filename
23
+ filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}"
24
+ end
25
+ return filename
26
+ end
27
+
28
+ def libv8_profile
29
+ base = "#{vendored_source_path}/out/#{Libv8::Arch.libv8_arch}"
30
+ debug = "#{base}.debug"
31
+ File.exists?(debug) ? debug : "#{base}.release"
32
+ end
33
+
34
+ def vendored_source_path
35
+ File.expand_path "../../../vendor/v8", __FILE__
36
+ end
37
+ end
38
+ end
@@ -1,61 +1,9 @@
1
- require 'rbconfig'
1
+ require 'libv8/version'
2
+ require 'libv8/location'
2
3
 
3
- require 'libv8/arch'
4
4
  module Libv8
5
-
6
- module_function
7
-
8
- def config
9
- Config::MAKEFILE_CONFIG
10
- end
11
-
12
- def libv8_object(name)
13
- filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}"
14
- unless File.exists? filename
15
- filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}"
16
- end
17
- return filename
18
- end
19
-
20
- def libv8_profile
21
- base = "#{libv8_source_path}/out/#{Libv8::Arch.libv8_arch}"
22
- debug = "#{base}.debug"
23
- File.exists?(debug) ? debug : "#{base}.release"
24
- end
25
-
26
- def libv8_base
27
- libv8_object :base
28
- end
29
-
30
- def libv8_snapshot
31
- libv8_object :snapshot
32
- end
33
-
34
- def libv8_nosnapshot
35
- libv8_object :nosnapshot
36
- end
37
-
38
- def libv8_objects(*names)
39
- names = [:base, :snapshot] if names.empty?
40
- names.map do |name|
41
- fail "no libv8 object #{name}" unless File.exists?(object = libv8_object(name))
42
- object
43
- end
44
- end
45
-
46
- def libv8_ldflags
47
- "-L#{libv8_base} -L#{libv8_snapshot}"
48
- end
49
-
50
- def libv8_include_flags
51
- "-I#{libv8_include_path}"
52
- end
53
-
54
- def libv8_include_path
55
- "#{libv8_source_path}/include"
56
- end
57
-
58
- def libv8_source_path
59
- File.expand_path "../../vendor/v8", __FILE__
5
+ def self.configure_makefile
6
+ location = Location.load!
7
+ location.configure
60
8
  end
61
9
  end
@@ -1,3 +1,3 @@
1
1
  module Libv8
2
- VERSION = "3.11.8.4"
2
+ VERSION = "3.11.8.7"
3
3
  end
@@ -24,7 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.extensions = ["ext/libv8/extconf.rb"]
25
25
  s.require_paths = ["lib", "ext"]
26
26
 
27
- s.add_development_dependency "rake", "~> 0.9.2"
27
+ s.add_development_dependency "rake"
28
28
  s.add_development_dependency "rake-compiler"
29
29
  s.add_development_dependency "rspec"
30
+ s.add_development_dependency "rspec-spies"
30
31
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe "libv8 locations" do
4
+ before do
5
+ @context = mock(:CompilationContext)
6
+ end
7
+ describe "the system location" do
8
+ before do
9
+ @location = Libv8::Location::System.new
10
+ @context.stub(:dir_config)
11
+ end
12
+ describe "configuring a compliation context with it" do
13
+ before do
14
+ @context.stub(:find_header) {true}
15
+ @location.configure @context
16
+ end
17
+ it "adds the include path to the front of the include flags" do
18
+ @context.should have_received(:dir_config).with 'v8'
19
+ @context.should have_received(:find_header).with 'v8.h'
20
+ end
21
+ end
22
+ describe "when the v8.h header cannot be found" do
23
+ before do
24
+ @context.stub(:find_header) {false}
25
+ end
26
+ it "raises a NotFoundError" do
27
+ expect {@location.configure @context}.to raise_error Libv8::Location::System::NotFoundError
28
+ end
29
+ end
30
+ end
31
+
32
+ describe "the vendor location" do
33
+ before do
34
+ @location = Libv8::Location::Vendor.new
35
+ @context.stub(:incflags) {@incflags ||= "-I/usr/include -I/usr/local/include"}
36
+ @context.stub(:ldflags) {@ldflags ||= "-lobjc -lpthread"}
37
+
38
+ Libv8::Paths.stub(:include_paths) {["/frp/v8/include"]}
39
+ Libv8::Paths.stub(:object_paths) {["/frp/v8/obj/libv8_base.a", "/frp/v8/obj/libv8_snapshot.a"]}
40
+ @location.configure @context
41
+ end
42
+
43
+ it "prepends its own incflags before any pre-existing ones" do
44
+ @context.incflags.should eql "-I/frp/v8/include -I/usr/include -I/usr/local/include"
45
+ end
46
+
47
+ it "prepends the locations of any libv8 objects on the the ldflags" do
48
+ @context.ldflags.should eql "/frp/v8/obj/libv8_base.a /frp/v8/obj/libv8_snapshot.a -lobjc -lpthread"
49
+ end
50
+ end
51
+ end
@@ -1,2 +1,4 @@
1
1
  $:.unshift File.expand_path '../../lib', __FILE__
2
- require 'libv8'
2
+ require 'rspec'
3
+ require 'rspec-spies'
4
+ require 'libv8'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libv8
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.8.4
4
+ version: 3.11.8.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-05 00:00:00.000000000 Z
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.9.2
21
+ version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.9.2
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake-compiler
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec-spies
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  description: Distributes the V8 JavaScript engine in binary and source forms in order
63
79
  to support fast builds of The Ruby Racer
64
80
  email:
@@ -75,9 +91,12 @@ files:
75
91
  - README.md
76
92
  - Rakefile
77
93
  - ext/libv8/arch.rb
94
+ - ext/libv8/builder.rb
78
95
  - ext/libv8/compiler.rb
79
96
  - ext/libv8/extconf.rb
97
+ - ext/libv8/location.rb
80
98
  - ext/libv8/make.rb
99
+ - ext/libv8/paths.rb
81
100
  - lib/libv8.rb
82
101
  - lib/libv8/fpic-on-freebsd-amd64.patch
83
102
  - lib/libv8/version.rb
@@ -86,7 +105,7 @@ files:
86
105
  - patches/fPIC-on-x64.patch
87
106
  - patches/gcc42-on-freebsd.patch
88
107
  - patches/src_platform-freebsd.cc.patch
89
- - spec/libv8_spec.rb
108
+ - spec/location_spec.rb
90
109
  - spec/spec_helper.rb
91
110
  - thefrontside.png
92
111
  - vendor/v8/.gitignore
@@ -2515,7 +2534,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
2515
2534
  version: '0'
2516
2535
  segments:
2517
2536
  - 0
2518
- hash: 44742288692122060
2537
+ hash: -3100645073355860443
2519
2538
  required_rubygems_version: !ruby/object:Gem::Requirement
2520
2539
  none: false
2521
2540
  requirements:
@@ -2524,7 +2543,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2524
2543
  version: '0'
2525
2544
  segments:
2526
2545
  - 0
2527
- hash: 44742288692122060
2546
+ hash: -3100645073355860443
2528
2547
  requirements: []
2529
2548
  rubyforge_project: libv8
2530
2549
  rubygems_version: 1.8.24
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
- require 'pathname'
3
-
4
- describe Libv8 do
5
- include Libv8
6
-
7
- it "can find the static library components" do
8
- Pathname(libv8_base).should exist
9
- Pathname(libv8_snapshot).should exist
10
- end
11
-
12
- it "has a valid include path" do
13
- Pathname(libv8_include_path).should be_exist
14
- end
15
-
16
- it "can retrieve objects by name" do
17
- libv8_objects(:base, :snapshot).each do |obj|
18
- Pathname(obj).should exist
19
- end
20
- end
21
-
22
- end