Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

support for windows with scons #40

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ task :binary => :compile do
# V8
gemspec.files += Dir['vendor/v8/include/*']
gemspec.files += Dir['vendor/v8/out/**/*.a']
# SCons build
gemspec.files += Dir['vendor/v8/libv8.a']
gemspec.files += Dir['vendor/v8/v8.dll']
FileUtils.mkdir_p 'pkg'
FileUtils.mv(Gem::Builder.new(gemspec).build, 'pkg')
end
Expand Down
39 changes: 30 additions & 9 deletions ext/libv8/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
require 'mkmf'
create_makefile('libv8')
require File.expand_path '../arch.rb', __FILE__
require File.expand_path '../make.rb', __FILE__
require File.expand_path '../compiler.rb', __FILE__
require File.expand_path '../../../lib/libv8', __FILE__

include Libv8::Arch
include Libv8::Make
include Libv8::Compiler
if Libv8.mingw?
File.open('Makefile', 'w'){|f| f.puts "all:\n\ninstall:\n" }
else
require 'mkmf'
create_makefile('libv8')
require File.expand_path '../arch.rb', __FILE__
require File.expand_path '../make.rb', __FILE__
require File.expand_path '../compiler.rb', __FILE__

include Libv8::Arch
include Libv8::Make
include Libv8::Compiler
end

Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do
puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{libv8_arch}.release GYPFLAGS="-Dhost_arch=#{libv8_arch}"`
if Libv8.mingw?
puts `scons os=win32 toolchain=gcc library=shared`
else
puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{libv8_arch}.release GYPFLAGS="-Dhost_arch=#{libv8_arch}"`
end
end

if $?.exitstatus != 0
exit $?.exitstatus
end

begin
Libv8.libv8_objects
rescue => e
puts e.message
exit 1
end
exit $?.exitstatus
19 changes: 17 additions & 2 deletions lib/libv8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ module Libv8

module_function

def mingw?
RUBY_PLATFORM =~ /mingw/
end

def libv8_object(name)
filename = "#{libv8_source_path}/out/#{Libv8::Arch.libv8_arch}.release/libv8_#{name}.#{$LIBEXT}"
unless File.exists? filename
filename = "#{libv8_source_path}/out/#{Libv8::Arch.libv8_arch}.release/obj.target/tools/gyp/libv8_#{name}.#{$LIBEXT}"
end
return filename
unless File.exists? filename
# SCons build
filename = "#{libv8_source_path}/#{name}.#{$LIBEXT}"
end
filename
end

def libv8_base
Expand All @@ -25,7 +33,14 @@ def libv8_nosnapshot
end

def libv8_objects(*names)
names = [:base, :snapshot] if names.empty?
if names.empty?
names = if mingw?
# SCons build
[:libv8]
else
[:base, :snapshot]
end
end
names.map do |name|
fail "no libv8 object #{name}" unless File.exists?(object = libv8_object(name))
object
Expand Down