v8eval 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CMakeLists.txt +24 -0
- data/README.md +1 -2
- data/build.sh +12 -28
- data/ruby/ext/v8eval/Makefile +261 -0
- data/ruby/ext/v8eval/extconf.rb +1 -1
- data/ruby/ext/v8eval/v8eval.h +99 -0
- data/{src → ruby/ext/v8eval}/v8eval.i +2 -1
- data/ruby/ext/v8eval/v8eval_wrap.cxx +2529 -0
- data/ruby/lib/setup/extension_builder.rb +3 -2
- data/ruby/lib/v8eval/Makefile +261 -0
- data/ruby/lib/v8eval/extconf.rb +55 -0
- data/ruby/lib/v8eval/v8eval.h +99 -0
- data/ruby/lib/v8eval/v8eval_wrap.cxx +2529 -0
- data/src/v8eval_go.cxx +9 -0
- data/src/v8eval_go.h +16 -0
- data/src/v8eval_python.cxx +9 -0
- data/src/v8eval_python.h +16 -0
- data/src/v8eval_ruby.cxx +9 -0
- data/src/v8eval_ruby.h +16 -0
- data/v8eval.gemspec +1 -1
- metadata +25 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc796827b31875adb19bac6160324a239cc8183
|
4
|
+
data.tar.gz: f9ca3808367a62bc6fd3faeebcdceec9ae162d49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adbeb2fcbec1a4efc82896284670625bb10b3feb8637324014e2807b45452c1adb55cb0d7e7367c7778941224160a863c7b3d60ca8609389479fdfe0cc3a04b3
|
7
|
+
data.tar.gz: 31330901707a0c19eb9c4761825883ace6feebad783ef7274bc7b096b9b524c8754297a467e39efdac01c0c4675baf14cc2755c5f2edced82f509f272e0d9ed6
|
data/CMakeLists.txt
CHANGED
@@ -40,6 +40,18 @@ add_library(v8eval STATIC
|
|
40
40
|
src/dbgsrv.cxx
|
41
41
|
)
|
42
42
|
|
43
|
+
add_library(v8eval_go STATIC
|
44
|
+
src/v8eval_go.cxx
|
45
|
+
)
|
46
|
+
|
47
|
+
add_library(v8eval_python STATIC
|
48
|
+
src/v8eval_python.cxx
|
49
|
+
)
|
50
|
+
|
51
|
+
add_library(v8eval_ruby STATIC
|
52
|
+
src/v8eval_ruby.cxx
|
53
|
+
)
|
54
|
+
|
43
55
|
set(v8eval-cflags
|
44
56
|
-Wall
|
45
57
|
-Wendif-labels
|
@@ -65,6 +77,18 @@ set_target_properties(v8eval PROPERTIES
|
|
65
77
|
COMPILE_FLAGS "${v8eval-cflags}"
|
66
78
|
)
|
67
79
|
|
80
|
+
set_target_properties(v8eval_go PROPERTIES
|
81
|
+
COMPILE_FLAGS "${v8eval-cflags}"
|
82
|
+
)
|
83
|
+
|
84
|
+
set_target_properties(v8eval_python PROPERTIES
|
85
|
+
COMPILE_FLAGS "${v8eval-cflags}"
|
86
|
+
)
|
87
|
+
|
88
|
+
set_target_properties(v8eval_ruby PROPERTIES
|
89
|
+
COMPILE_FLAGS "${v8eval-cflags}"
|
90
|
+
)
|
91
|
+
|
68
92
|
if(V8EVAL_TEST)
|
69
93
|
add_subdirectory(test)
|
70
94
|
endif(V8EVAL_TEST)
|
data/README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# v8eval
|
2
2
|
|
3
|
-
[](https://travis-ci.org/sony/v8eval)
|
4
3
|
[](http://badge.fury.io/py/v8eval)
|
5
4
|
[](https://badge.fury.io/rb/v8eval)
|
6
5
|
[](http://godoc.org/github.com/sony/v8eval/go/v8eval)
|
7
6
|
|
8
7
|
Multi-language bindings to JavaScript engine V8.
|
9
8
|
|
10
|
-
Currently v8eval provides Go, Python and Ruby bindings to the latest V8
|
9
|
+
Currently v8eval provides Go, Python and Ruby bindings to the latest V8 5.1 and supports Linux and Mac OS X.
|
11
10
|
v8eval uses SWIG and can be extended easily for other languages.
|
12
11
|
|
13
12
|
## Pre-installation
|
data/build.sh
CHANGED
@@ -2,12 +2,15 @@
|
|
2
2
|
|
3
3
|
V8EVAL_ROOT=`cd $(dirname $0) && pwd`
|
4
4
|
|
5
|
-
|
5
|
+
PLATFORM=`uname`
|
6
|
+
if [ $PLATFORM = "Linux" ] ; then
|
7
|
+
NUM_CPU_CORES=`cat /proc/cpuinfo | grep cores | grep -o '[0-9]\+'`
|
8
|
+
|
6
9
|
export CC=$V8EVAL_ROOT/v8/third_party/llvm-build/Release+Asserts/bin/clang
|
7
10
|
export CXX=$V8EVAL_ROOT/v8/third_party/llvm-build/Release+Asserts/bin/clang++
|
8
|
-
|
11
|
+
elif [ $PLATFORM = "Darwin" ]; then
|
12
|
+
NUM_CPU_CORES=`sysctl -n hw.ncpu`
|
9
13
|
|
10
|
-
if [ `uname` = "Darwin" ]; then
|
11
14
|
export CC=`which clang`
|
12
15
|
export CXX=`which clang++`
|
13
16
|
export CPP="`which clang` -E"
|
@@ -17,6 +20,9 @@ if [ `uname` = "Darwin" ]; then
|
|
17
20
|
export CPP_host="`which clang` -E"
|
18
21
|
export LINK_host=`which clang++`
|
19
22
|
export GYP_DEFINES="clang=1 mac_deployment_target=10.10"
|
23
|
+
else
|
24
|
+
echo "unsupported platform: ${PLATFORM}"
|
25
|
+
exit 1
|
20
26
|
fi
|
21
27
|
|
22
28
|
install_depot_tools() {
|
@@ -47,8 +53,8 @@ install_v8() {
|
|
47
53
|
cd $V8EVAL_ROOT
|
48
54
|
fetch v8
|
49
55
|
cd v8
|
50
|
-
git checkout
|
51
|
-
CFLAGS="-fPIC" CXXFLAGS="-fPIC" make x64.release V=1
|
56
|
+
git checkout 5.1.117
|
57
|
+
CFLAGS="-fPIC" CXXFLAGS="-fPIC" make x64.release -j$NUM_CPU_CORES V=1
|
52
58
|
}
|
53
59
|
|
54
60
|
install_libuv() {
|
@@ -77,24 +83,10 @@ build() {
|
|
77
83
|
make VERBOSE=1
|
78
84
|
}
|
79
85
|
|
80
|
-
build_go() {
|
81
|
-
$V8EVAL_ROOT/go/build.sh
|
82
|
-
}
|
83
|
-
|
84
|
-
build_python() {
|
85
|
-
$V8EVAL_ROOT/python/build.sh
|
86
|
-
}
|
87
|
-
|
88
|
-
build_ruby() {
|
89
|
-
$V8EVAL_ROOT/ruby/build.sh
|
90
|
-
}
|
91
|
-
|
92
86
|
docs() {
|
93
87
|
cd $V8EVAL_ROOT/docs
|
94
88
|
rm -rf ./html
|
95
89
|
doxygen
|
96
|
-
|
97
|
-
$V8EVAL_ROOT/python/build.sh docs
|
98
90
|
}
|
99
91
|
|
100
92
|
test() {
|
@@ -104,21 +96,13 @@ test() {
|
|
104
96
|
cd $V8EVAL_ROOT/build
|
105
97
|
cmake -DCMAKE_BUILD_TYPE=Release -DV8EVAL_TEST=ON ..
|
106
98
|
make VERBOSE=1
|
107
|
-
./test/v8eval-test
|
108
|
-
|
109
|
-
cd ..
|
110
|
-
./go/build.sh test || exit 1
|
111
|
-
./python/build.sh test || exit 1
|
112
|
-
./ruby/build.sh test || exit 1
|
99
|
+
./test/v8eval-test
|
113
100
|
}
|
114
101
|
|
115
102
|
# dispatch subcommand
|
116
103
|
SUBCOMMAND="$1";
|
117
104
|
case "${SUBCOMMAND}" in
|
118
105
|
"" ) build ;;
|
119
|
-
"go" ) build_go ;;
|
120
|
-
"python" ) build_python ;;
|
121
|
-
"ruby" ) build_ruby ;;
|
122
106
|
"docs" ) docs ;;
|
123
107
|
"test" ) test ;;
|
124
108
|
* ) echo "unknown subcommand: ${SUBCOMMAND}"; exit 1 ;;
|
@@ -0,0 +1,261 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
# V=0 quiet, V=1 verbose. other values don't work.
|
5
|
+
V = 0
|
6
|
+
Q1 = $(V:1=)
|
7
|
+
Q = $(Q1:0=@)
|
8
|
+
ECHO1 = $(V:1=@:)
|
9
|
+
ECHO = $(ECHO1:0=@echo)
|
10
|
+
NULLCMD = :
|
11
|
+
|
12
|
+
#### Start of system configuration section. ####
|
13
|
+
|
14
|
+
srcdir = .
|
15
|
+
topdir = /usr/local/Cellar/ruby/2.3.0/include/ruby-2.3.0
|
16
|
+
hdrdir = $(topdir)
|
17
|
+
arch_hdrdir = /usr/local/Cellar/ruby/2.3.0/include/ruby-2.3.0/x86_64-darwin15
|
18
|
+
PATH_SEPARATOR = :
|
19
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
20
|
+
prefix = $(DESTDIR)/usr/local/Cellar/ruby/2.3.0
|
21
|
+
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
|
22
|
+
rubyarchprefix = $(rubylibprefix)/$(arch)
|
23
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
24
|
+
exec_prefix = $(prefix)
|
25
|
+
vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
|
26
|
+
sitearchhdrdir = $(sitehdrdir)/$(sitearch)
|
27
|
+
rubyarchhdrdir = $(rubyhdrdir)/$(arch)
|
28
|
+
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
29
|
+
sitehdrdir = $(rubyhdrdir)/site_ruby
|
30
|
+
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
|
31
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
32
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
33
|
+
vendordir = $(DESTDIR)/usr/local/lib/ruby/vendor_ruby
|
34
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
35
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
36
|
+
sitedir = $(DESTDIR)/usr/local/lib/ruby/site_ruby
|
37
|
+
rubyarchdir = $(rubylibdir)/$(arch)
|
38
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
39
|
+
sitearchincludedir = $(includedir)/$(sitearch)
|
40
|
+
archincludedir = $(includedir)/$(arch)
|
41
|
+
sitearchlibdir = $(libdir)/$(sitearch)
|
42
|
+
archlibdir = $(libdir)/$(arch)
|
43
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
44
|
+
mandir = $(datarootdir)/man
|
45
|
+
localedir = $(datarootdir)/locale
|
46
|
+
libdir = $(exec_prefix)/lib
|
47
|
+
psdir = $(docdir)
|
48
|
+
pdfdir = $(docdir)
|
49
|
+
dvidir = $(docdir)
|
50
|
+
htmldir = $(docdir)
|
51
|
+
infodir = $(datarootdir)/info
|
52
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
53
|
+
oldincludedir = $(DESTDIR)/usr/include
|
54
|
+
includedir = $(prefix)/include
|
55
|
+
localstatedir = $(prefix)/var
|
56
|
+
sharedstatedir = $(prefix)/com
|
57
|
+
sysconfdir = $(prefix)/etc
|
58
|
+
datadir = $(datarootdir)
|
59
|
+
datarootdir = $(prefix)/share
|
60
|
+
libexecdir = $(exec_prefix)/libexec
|
61
|
+
sbindir = $(exec_prefix)/sbin
|
62
|
+
bindir = $(exec_prefix)/bin
|
63
|
+
archdir = $(rubyarchdir)
|
64
|
+
|
65
|
+
|
66
|
+
CC = clang
|
67
|
+
CXX = clang++
|
68
|
+
LIBRUBY = $(LIBRUBY_SO)
|
69
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
70
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
71
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation
|
72
|
+
empty =
|
73
|
+
OUTFLAG = -o $(empty)
|
74
|
+
COUTFLAG = -o $(empty)
|
75
|
+
|
76
|
+
RUBY_EXTCONF_H =
|
77
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
78
|
+
cxxflags = $(optflags) $(debugflags) $(warnflags)
|
79
|
+
optflags = -O3 -fno-fast-math
|
80
|
+
debugflags = -ggdb3
|
81
|
+
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens
|
82
|
+
CCDLFLAGS = -fno-common
|
83
|
+
CFLAGS = $(CCDLFLAGS) $(cflags) -fno-common -pipe $(ARCH_FLAG)
|
84
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
85
|
+
DEFS =
|
86
|
+
CPPFLAGS = -I/Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/v8 -I/Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/v8/include -I/Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/uv/include -I/usr/local/Cellar/ruby/2.3.0/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags) -g -O3 -std=c++11
|
87
|
+
CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
|
88
|
+
ldflags = -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -lv8eval -lv8_libplatform -lv8_base -lv8_libbase -lv8_nosnapshot -licui18n -licuuc -licudata -luv
|
89
|
+
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib
|
90
|
+
ARCH_FLAG =
|
91
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
92
|
+
LDSHARED = $(CC) -dynamic -bundle
|
93
|
+
LDSHAREDXX = $(CXX) -dynamic -bundle
|
94
|
+
AR = ar
|
95
|
+
EXEEXT =
|
96
|
+
|
97
|
+
RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
|
98
|
+
RUBY_SO_NAME = ruby.2.3.0
|
99
|
+
RUBYW_INSTALL_NAME =
|
100
|
+
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
|
101
|
+
RUBYW_BASE_NAME = rubyw
|
102
|
+
RUBY_BASE_NAME = ruby
|
103
|
+
|
104
|
+
arch = x86_64-darwin15
|
105
|
+
sitearch = $(arch)
|
106
|
+
ruby_version = 2.3.0
|
107
|
+
ruby = $(bindir)/$(RUBY_BASE_NAME)
|
108
|
+
RUBY = $(ruby)
|
109
|
+
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
|
110
|
+
|
111
|
+
RM = rm -f
|
112
|
+
RM_RF = $(RUBY) -run -e rm -- -rf
|
113
|
+
RMDIRS = rmdir -p
|
114
|
+
MAKEDIRS = mkdir -p
|
115
|
+
INSTALL = /usr/bin/install -c
|
116
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
117
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
118
|
+
COPY = cp
|
119
|
+
TOUCH = exit >
|
120
|
+
|
121
|
+
#### End of system configuration section. ####
|
122
|
+
|
123
|
+
preload =
|
124
|
+
|
125
|
+
libpath = . $(libdir) /Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/build /Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/uv/.libs /usr/local/Cellar/ruby/2.3.0/lib /Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/v8/out/x64.release /usr/local/opt/libyaml/lib /usr/local/opt/openssl/lib /usr/local/opt/readline/lib
|
126
|
+
LIBPATH = -L. -L$(libdir) -L/Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/build -L/Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/uv/.libs -L/usr/local/Cellar/ruby/2.3.0/lib -L/Users/prateekpapriwal/gocodes/src/github.com/sony/v8eval/v8/out/x64.release -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib
|
127
|
+
DEFFILE =
|
128
|
+
|
129
|
+
CLEANFILES = mkmf.log
|
130
|
+
DISTCLEANFILES =
|
131
|
+
DISTCLEANDIRS =
|
132
|
+
|
133
|
+
extout =
|
134
|
+
extout_prefix =
|
135
|
+
target_prefix = /v8eval
|
136
|
+
LOCAL_LIBS =
|
137
|
+
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
|
138
|
+
ORIG_SRCS = v8eval_wrap.cxx
|
139
|
+
SRCS = $(ORIG_SRCS)
|
140
|
+
OBJS = v8eval_wrap.o
|
141
|
+
HDRS = $(srcdir)/v8eval.h
|
142
|
+
TARGET = v8eval
|
143
|
+
TARGET_NAME = v8eval
|
144
|
+
TARGET_ENTRY = Init_$(TARGET_NAME)
|
145
|
+
DLLIB = $(TARGET).bundle
|
146
|
+
EXTSTATIC =
|
147
|
+
STATIC_LIB =
|
148
|
+
|
149
|
+
TIMESTAMP_DIR = .
|
150
|
+
BINDIR = $(bindir)
|
151
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
152
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
153
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
154
|
+
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
155
|
+
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
156
|
+
|
157
|
+
TARGET_SO = $(DLLIB)
|
158
|
+
CLEANLIBS = $(TARGET).bundle
|
159
|
+
CLEANOBJS = *.o *.bak
|
160
|
+
|
161
|
+
all: $(DLLIB)
|
162
|
+
static: $(STATIC_LIB) install-rb
|
163
|
+
.PHONY: all install static install-so install-rb
|
164
|
+
.PHONY: clean clean-so clean-static clean-rb
|
165
|
+
|
166
|
+
clean-static::
|
167
|
+
clean-rb-default::
|
168
|
+
clean-rb::
|
169
|
+
clean-so::
|
170
|
+
clean: clean-so clean-static clean-rb-default clean-rb
|
171
|
+
-$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
|
172
|
+
|
173
|
+
distclean-rb-default::
|
174
|
+
distclean-rb::
|
175
|
+
distclean-so::
|
176
|
+
distclean-static::
|
177
|
+
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
|
178
|
+
-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
179
|
+
-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
180
|
+
-$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
181
|
+
|
182
|
+
realclean: distclean
|
183
|
+
install: install-so install-rb
|
184
|
+
|
185
|
+
install-so: $(DLLIB) $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.v8eval.time
|
186
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
187
|
+
clean-static::
|
188
|
+
-$(Q)$(RM) $(STATIC_LIB)
|
189
|
+
install-rb: pre-install-rb install-rb-default
|
190
|
+
install-rb-default: pre-install-rb-default
|
191
|
+
pre-install-rb: Makefile
|
192
|
+
pre-install-rb-default: Makefile
|
193
|
+
pre-install-rb-default:
|
194
|
+
@$(NULLCMD)
|
195
|
+
$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.v8eval.time:
|
196
|
+
$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
|
197
|
+
$(Q) $(TOUCH) $@
|
198
|
+
|
199
|
+
site-install: site-install-so site-install-rb
|
200
|
+
site-install-so: install-so
|
201
|
+
site-install-rb: install-rb
|
202
|
+
|
203
|
+
.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
|
204
|
+
|
205
|
+
.cc.o:
|
206
|
+
$(ECHO) compiling $(<)
|
207
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
208
|
+
|
209
|
+
.cc.S:
|
210
|
+
$(ECHO) translating $(<)
|
211
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
212
|
+
|
213
|
+
.mm.o:
|
214
|
+
$(ECHO) compiling $(<)
|
215
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
216
|
+
|
217
|
+
.mm.S:
|
218
|
+
$(ECHO) translating $(<)
|
219
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
220
|
+
|
221
|
+
.cxx.o:
|
222
|
+
$(ECHO) compiling $(<)
|
223
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
224
|
+
|
225
|
+
.cxx.S:
|
226
|
+
$(ECHO) translating $(<)
|
227
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
228
|
+
|
229
|
+
.cpp.o:
|
230
|
+
$(ECHO) compiling $(<)
|
231
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
232
|
+
|
233
|
+
.cpp.S:
|
234
|
+
$(ECHO) translating $(<)
|
235
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
|
236
|
+
|
237
|
+
.c.o:
|
238
|
+
$(ECHO) compiling $(<)
|
239
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
240
|
+
|
241
|
+
.c.S:
|
242
|
+
$(ECHO) translating $(<)
|
243
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
|
244
|
+
|
245
|
+
.m.o:
|
246
|
+
$(ECHO) compiling $(<)
|
247
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
248
|
+
|
249
|
+
.m.S:
|
250
|
+
$(ECHO) translating $(<)
|
251
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
|
252
|
+
|
253
|
+
$(DLLIB): $(OBJS) Makefile
|
254
|
+
$(ECHO) linking shared-object v8eval/$(DLLIB)
|
255
|
+
-$(Q)$(RM) $(@)
|
256
|
+
$(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
257
|
+
$(Q) $(POSTLINK)
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
$(OBJS): $(HDRS) $(ruby_headers)
|
data/ruby/ext/v8eval/extconf.rb
CHANGED
@@ -49,7 +49,7 @@ end
|
|
49
49
|
|
50
50
|
dir_config('', header_dirs, lib_dirs)
|
51
51
|
|
52
|
-
$LDFLAGS << ' -lv8eval -lv8_libplatform -lv8_base -lv8_libbase -lv8_nosnapshot -licui18n -licuuc -licudata -luv'
|
52
|
+
$LDFLAGS << ' -lv8eval -lv8eval_ruby -lv8_libplatform -lv8_base -lv8_libbase -lv8_nosnapshot -licui18n -licuuc -licudata -luv'
|
53
53
|
$CPPFLAGS << ' -g -O3 -std=c++11'
|
54
54
|
|
55
55
|
create_makefile('v8eval/v8eval')
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#ifndef V8EVAL_H_
|
2
|
+
#define V8EVAL_H_
|
3
|
+
|
4
|
+
#include <string>
|
5
|
+
|
6
|
+
#include "v8.h"
|
7
|
+
#include "v8-debug.h"
|
8
|
+
|
9
|
+
/// \file
|
10
|
+
namespace v8eval {
|
11
|
+
|
12
|
+
class DbgSrv;
|
13
|
+
|
14
|
+
typedef void (*debugger_cb)(std::string&, void *opq);
|
15
|
+
|
16
|
+
/// \brief Initialize the V8 runtime environment
|
17
|
+
/// \return success or not as boolean
|
18
|
+
///
|
19
|
+
/// This method initializes the V8 runtime environment. It must be called before creating any V8 instance.
|
20
|
+
bool initialize();
|
21
|
+
|
22
|
+
/// \brief Dispose the V8 runtime environment
|
23
|
+
/// \return success or not as boolean
|
24
|
+
///
|
25
|
+
/// This method disposes the V8 runtime environment.
|
26
|
+
bool dispose();
|
27
|
+
|
28
|
+
/// \class _V8
|
29
|
+
///
|
30
|
+
/// _V8 instances can be used in multiple threads.
|
31
|
+
/// But each _V8 instance can be used in only one thread at a time.
|
32
|
+
class _V8 {
|
33
|
+
public:
|
34
|
+
_V8();
|
35
|
+
virtual ~_V8();
|
36
|
+
|
37
|
+
/// \brief Evaluate JavaScript code
|
38
|
+
/// \param src JavaScript code
|
39
|
+
/// \return JSON-encoded result or exception message
|
40
|
+
///
|
41
|
+
/// This method evaluates the given JavaScript code 'src' and returns the result in JSON.
|
42
|
+
/// If some JavaScript exception happens in runtime, the exception message is returned.
|
43
|
+
std::string eval(const std::string& src);
|
44
|
+
|
45
|
+
/// \brief Call a JavaScript function
|
46
|
+
/// \param func Name of a JavaScript function
|
47
|
+
/// \param args JSON-encoded argument array
|
48
|
+
/// \return JSON-encoded result or exception message
|
49
|
+
///
|
50
|
+
/// This method calls the JavaScript function specified by 'func'
|
51
|
+
/// with the JSON-encoded argument array 'args'
|
52
|
+
/// and returns the result in JSON.
|
53
|
+
/// If some JavaScript exception happens in runtime, the exception message is returned.
|
54
|
+
std::string call(const std::string& func, const std::string& args);
|
55
|
+
|
56
|
+
/// \brief Start a debug server associated with the V8 instance
|
57
|
+
/// \param port The TCP/IP port the debugger will listen, at localhost
|
58
|
+
/// \return success or not as boolean
|
59
|
+
///
|
60
|
+
/// After the debugger is successfully started, it will be possible to
|
61
|
+
/// send commands and receive events at the specified port. When the
|
62
|
+
/// debugger is started, the Javascript's "debugger" statement will
|
63
|
+
/// cause the V8 instance to halt and wait for instructions through
|
64
|
+
/// the debugger port.
|
65
|
+
bool enable_debugger(int port);
|
66
|
+
|
67
|
+
/// \brief Stop the debug server, if running.
|
68
|
+
///
|
69
|
+
/// The debug server, if currently running, will be stopped, causing
|
70
|
+
/// connections to remote debuggers to be dropped.
|
71
|
+
void disable_debugger();
|
72
|
+
|
73
|
+
private:
|
74
|
+
static void debugger_message_handler(const v8::Debug::Message& message);
|
75
|
+
v8::Local<v8::Context> new_context();
|
76
|
+
v8::Local<v8::String> new_string(const char* str);
|
77
|
+
v8::Local<v8::Value> json_parse(v8::Local<v8::Context> context, v8::Local<v8::String> str);
|
78
|
+
v8::Local<v8::String> json_stringify(v8::Local<v8::Context> context, v8::Local<v8::Value> value);
|
79
|
+
|
80
|
+
bool debugger_init(debugger_cb cb, void *cbopq);
|
81
|
+
bool debugger_send(const std::string& cmd);
|
82
|
+
void debugger_process();
|
83
|
+
void debugger_stop();
|
84
|
+
|
85
|
+
private:
|
86
|
+
v8::Isolate* isolate_;
|
87
|
+
v8::Persistent<v8::Context> context_;
|
88
|
+
|
89
|
+
DbgSrv* dbg_server_;
|
90
|
+
v8::Isolate* dbg_isolate_;
|
91
|
+
debugger_cb callback_;
|
92
|
+
void* callback_opq_;
|
93
|
+
|
94
|
+
friend class DbgSrv;
|
95
|
+
};
|
96
|
+
|
97
|
+
} // namespace v8eval
|
98
|
+
|
99
|
+
#endif // V8EVAL_H_
|