lib/libv8.rb in libv8-freebsd-3.3.10.4 vs lib/libv8.rb in libv8-freebsd-3.11.8.3

- old
+ new

@@ -1,15 +1,61 @@ -require 'pathname' +require 'rbconfig' -require 'libv8/version' - +require 'libv8/arch' module Libv8 - LIBRARY_PATH = Pathname(__FILE__).dirname.join('libv8', 'build', 'v8').to_s - def self.library_path - LIBRARY_PATH + + module_function + + def config + Config::MAKEFILE_CONFIG end - - INCLUDE_PATH = Pathname(__FILE__).dirname.join('libv8', 'v8', 'include').to_s - def self.include_path - INCLUDE_PATH + + def libv8_object(name) + filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}" + unless File.exists? filename + filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}" + end + return filename + end + + def libv8_profile + base = "#{libv8_source_path}/out/#{Libv8::Arch.libv8_arch}" + debug = "#{base}.debug" + File.exists?(debug) ? debug : "#{base}.release" + end + + def libv8_base + libv8_object :base + end + + def libv8_snapshot + libv8_object :snapshot + end + + def libv8_nosnapshot + libv8_object :nosnapshot + end + + def libv8_objects(*names) + names = [:base, :snapshot] if names.empty? + names.map do |name| + fail "no libv8 object #{name}" unless File.exists?(object = libv8_object(name)) + object + end + end + + def libv8_ldflags + "-L#{libv8_base} -L#{libv8_snapshot}" + end + + def libv8_include_flags + "-I#{libv8_include_path}" + end + + def libv8_include_path + "#{libv8_source_path}/include" + end + + def libv8_source_path + File.expand_path "../../vendor/v8", __FILE__ end end