Skip to content

Commit 9fb8b62

Browse files
committed
Merge pull request #14 from Gonk/master
Create and link V8 wrapper as static library
2 parents 2299785 + a6b14d0 commit 9fb8b62

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
*.so
1+
*.a
22
example/example

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
ifndef GOOS
2+
GOOS := `go env GOOS`
3+
endif
4+
15
ifeq ($(GOOS),windows)
26
v8wrap.dll : v8wrap.cc v8.go
37
g++ -shared -o v8wrap.dll -I. -Ic:/mingw/include/v8 v8wrap.cc -lv8 -lstdc++ -lws2_32 -lwinmm
@@ -7,12 +11,19 @@ v8wrap.dll : v8wrap.cc v8.go
711
clean:
812
rm -f *.dll
913
else
10-
libv8wrap.so : v8wrap.cc v8.go
11-
g++ -fPIC -shared -o libv8wrap.so -I. v8wrap.cc -lv8
12-
go build .
14+
.PHONY: go-install
15+
16+
all: libv8wrap.a go-install
17+
18+
libv8wrap.a : v8wrap.cc v8.go
19+
g++ `go env GOGCCFLAGS` -I. -c v8wrap.cc -lv8
20+
ar rvs libv8wrap.a v8wrap.o
21+
rm v8wrap.o
22+
23+
go-install:
1324
go install
1425

1526
clean:
16-
rm -f *.so
27+
rm -f *.a
1728
endif
1829

v8.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package v8
22

33
/*
4-
#cgo LDFLAGS: -L. -lv8wrap -lstdc++
4+
#cgo LDFLAGS: -L. libv8wrap.a -lv8 -lstdc++
55
66
#include <stdlib.h>
77
#include "v8wrap.h"

v8wrap.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class V8Context {
115115
private:
116116
v8::Persistent<v8::ObjectTemplate> global_;
117117
v8::Persistent<v8::Context> context_;
118-
v8::HandleScope handle_scope_;
119118
std::string err_;
120119
};
121120

0 commit comments

Comments
 (0)