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

bring in the basic extension template and test suite

This commit is contained in:
Charles Lowell 2011-11-10 10:12:41 -06:00
parent 112ed41c6d
commit 8201268a84
14 changed files with 117 additions and 3 deletions

2
.gitignore vendored
View file

@ -9,6 +9,8 @@ _yardoc
coverage
doc/
lib/bundler/man
lib/v8/*.bundle
lib/v8/*.so
pkg
rdoc
spec/reports

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "spec/redjs"]
path = spec/redjs
url = git@github.com:cowboyd/redjs.git

View file

@ -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

25
ext/vm/extconf.rb Normal file
View file

@ -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')

16
ext/vm/rr.h Normal file
View file

@ -0,0 +1,16 @@
#include <stdio.h>
#include <v8.h>
namespace rr {
/**
* Represents an outgoing reference to
*/
class Stub {
Stub();
};
class Scion {
Scion();
};
}

5
ext/vm/scion.cc Normal file
View file

@ -0,0 +1,5 @@
#include "rr.h"
rr::Scion::Scion() {
};

5
ext/vm/stub.cc Normal file
View file

@ -0,0 +1,5 @@
#include "rr.h"
rr::Stub::Stub() {
}

12
ext/vm/vm.cc Normal file
View file

@ -0,0 +1,12 @@
#include "rr.h"
extern "C" {
void Init_vm();
}
extern "C" {
void Init_vm() {
v8::Locker locker;
}
}

View file

@ -1,5 +1,4 @@
require "v8/version"
module V8
end
require 'v8/vm'
require 'v8/context'

10
lib/v8/context.rb Normal file
View file

@ -0,0 +1,10 @@
module V8
class Context
def initialize
@native = CC::Context::New()
end
def eval(*args)
end
end
end

1
spec/redjs Submodule

@ -0,0 +1 @@
Subproject commit 1ebcd2a5766cec58f93d80308682ff7858320d3e

3
spec/redjs_helper.rb Normal file
View file

@ -0,0 +1,3 @@
require 'spec_helper'
include V8

6
spec/spec_helper.rb Normal file
View file

@ -0,0 +1,6 @@
require 'v8'
def rputs(msg)
puts "<pre>#{ERB::Util.h(msg)}</pre>"
$stdout.flush
end

View file

@ -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