diff --git a/.gitignore b/.gitignore index d87d4be..7d6d41a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ _yardoc coverage doc/ lib/bundler/man +lib/v8/*.bundle +lib/v8/*.so pkg rdoc spec/reports diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..34ac374 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "spec/redjs"] + path = spec/redjs + url = git@github.com:cowboyd/redjs.git diff --git a/Rakefile b/Rakefile index f57ae68..fec90fa 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,23 @@ #!/usr/bin/env rake require "bundler/gem_tasks" + +require "rake/extensiontask" + +# desc "remove all generated artifacts except built v8 objects" +task :clean do + sh "rm -rf lib/v8/vm.bundle lib/v8/vm.so" + sh "rm -rf pkg" +end + +Rake::ExtensionTask.new("vm", eval(File.read("therubyracer.gemspec"))) do |ext| + ext.lib_dir = "lib/v8" + ext.source_pattern = "*.{cc,h}" +end + + +require "rspec/core/rake_task" +RSpec::Core::RakeTask.new(:spec) +task :default => :spec + + + diff --git a/ext/vm/extconf.rb b/ext/vm/extconf.rb new file mode 100644 index 0000000..d273d37 --- /dev/null +++ b/ext/vm/extconf.rb @@ -0,0 +1,25 @@ +require 'mkmf' +begin + require 'libv8' +rescue LoadError + require 'rubygems' + require 'libv8' +end + +have_library('objc') if RUBY_PLATFORM =~ /darwin/ + +#we have to manually prepend the libv8 include path to INCFLAGS +#since find_header() does not actually work as advertized. +#see https://github.com/cowboyd/therubyracer/issues/91 +$INCFLAGS.insert 0, "-I#{Libv8.include_path} " + +$CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall" +$CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g" +$CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic" + +$DEFLIBPATH.unshift(Libv8.library_path) +$LIBS << ' -lv8 -lpthread' + +CONFIG['LDSHARED'] = '$(CXX) -shared' unless RUBY_PLATFORM =~ /darwin/ + +create_makefile('vm') diff --git a/ext/vm/rr.h b/ext/vm/rr.h new file mode 100644 index 0000000..87ccb86 --- /dev/null +++ b/ext/vm/rr.h @@ -0,0 +1,16 @@ +#include +#include + +namespace rr { + +/** +* Represents an outgoing reference to +*/ +class Stub { + Stub(); +}; + +class Scion { + Scion(); +}; +} diff --git a/ext/vm/scion.cc b/ext/vm/scion.cc new file mode 100644 index 0000000..2b8a0f5 --- /dev/null +++ b/ext/vm/scion.cc @@ -0,0 +1,5 @@ +#include "rr.h" + +rr::Scion::Scion() { + +}; \ No newline at end of file diff --git a/ext/vm/stub.cc b/ext/vm/stub.cc new file mode 100644 index 0000000..ee68bc8 --- /dev/null +++ b/ext/vm/stub.cc @@ -0,0 +1,5 @@ +#include "rr.h" + +rr::Stub::Stub() { + +} \ No newline at end of file diff --git a/ext/vm/vm.cc b/ext/vm/vm.cc new file mode 100644 index 0000000..bc02c92 --- /dev/null +++ b/ext/vm/vm.cc @@ -0,0 +1,12 @@ + +#include "rr.h" + +extern "C" { + void Init_vm(); +} + +extern "C" { + void Init_vm() { + v8::Locker locker; + } +} diff --git a/lib/v8.rb b/lib/v8.rb index 049c5b1..4f9d7ad 100644 --- a/lib/v8.rb +++ b/lib/v8.rb @@ -1,5 +1,4 @@ require "v8/version" -module V8 - -end +require 'v8/vm' +require 'v8/context' \ No newline at end of file diff --git a/lib/v8/context.rb b/lib/v8/context.rb new file mode 100644 index 0000000..9591223 --- /dev/null +++ b/lib/v8/context.rb @@ -0,0 +1,10 @@ +module V8 + class Context + def initialize + @native = CC::Context::New() + end + def eval(*args) + + end + end +end \ No newline at end of file diff --git a/spec/redjs b/spec/redjs new file mode 160000 index 0000000..1ebcd2a --- /dev/null +++ b/spec/redjs @@ -0,0 +1 @@ +Subproject commit 1ebcd2a5766cec58f93d80308682ff7858320d3e diff --git a/spec/redjs_helper.rb b/spec/redjs_helper.rb new file mode 100644 index 0000000..250cc00 --- /dev/null +++ b/spec/redjs_helper.rb @@ -0,0 +1,3 @@ +require 'spec_helper' + +include V8 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..217842d --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,6 @@ +require 'v8' + +def rputs(msg) + puts "
#{ERB::Util.h(msg)}
" + $stdout.flush +end diff --git a/therubyracer.gemspec b/therubyracer.gemspec index b7b8e42..88d2881 100644 --- a/therubyracer.gemspec +++ b/therubyracer.gemspec @@ -14,4 +14,10 @@ Gem::Specification.new do |gem| gem.name = "therubyracer" gem.require_paths = ["lib"] gem.version = V8::VERSION + + gem.add_dependency "libv8", "~> 3.7.0" + + gem.add_development_dependency "rake" + gem.add_development_dependency "rake-compiler" + gem.add_development_dependency "rspec", "~> 2.0" end