Update for Go 1.2 release. Add support for linking SWIG code directly
into executable, rather than using a shared library.
This commit is contained in:
parent
39bf2efdc9
commit
1dca0af024
32 changed files with 385 additions and 371 deletions
|
|
@ -6,6 +6,7 @@ LANGUAGE = go
|
|||
GO = @GO@
|
||||
GOGCC = @GOGCC@
|
||||
GO1 = @GO1@
|
||||
GO12 = @GO12@
|
||||
GOC = @GOC@
|
||||
SCRIPTSUFFIX = _runme.go
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ include $(srcdir)/../common.mk
|
|||
%.cpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_cpp)
|
||||
$(run_testcase)
|
||||
$(run_testcase_cpp)
|
||||
|
||||
%.ctest:
|
||||
$(setup)
|
||||
|
|
@ -58,7 +59,22 @@ run_testcase = \
|
|||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@; \
|
||||
elif $(GO12); then \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
||||
run_testcase_cpp = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@ -lstdc++; \
|
||||
elif $(GO12); then \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
|
|
@ -70,7 +86,9 @@ run_multi_testcase = \
|
|||
$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $${f}_wrap.@OBJEXT@; done` -lstdc++; \
|
||||
elif $(GO12); then \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
package main
|
||||
|
||||
import "./director_abstract"
|
||||
|
||||
type MyFoo struct{}
|
||||
|
||||
func (p *MyFoo) Ping() string {
|
||||
return "MyFoo::ping()"
|
||||
}
|
||||
|
||||
func f1() {
|
||||
a := director_abstract.NewDirectorFoo(&MyFoo{})
|
||||
|
||||
if a.Ping() != "MyFoo::ping()" {
|
||||
panic(a.Ping())
|
||||
}
|
||||
|
||||
if a.Pong() != "Foo::pong();MyFoo::ping()" {
|
||||
panic(a.Pong())
|
||||
}
|
||||
}
|
||||
|
||||
type MyExample1 struct{}
|
||||
|
||||
func (p *MyExample1) Color(r, g, b byte) int {
|
||||
return int(r)
|
||||
}
|
||||
|
||||
type MyExample2 struct{}
|
||||
|
||||
func (p *MyExample2) Color(r, g, b byte) int {
|
||||
return int(g)
|
||||
}
|
||||
|
||||
type MyExample3 struct{}
|
||||
|
||||
func (p *MyExample3) Color(r, g, b byte) int {
|
||||
return int(b)
|
||||
}
|
||||
|
||||
func f2() {
|
||||
me1 := director_abstract.NewDirectorExample1(&MyExample1{})
|
||||
if director_abstract.Example1Get_color(me1, 1, 2, 3) != 1 {
|
||||
println(director_abstract.Example1Get_color(me1, 1, 2, 3))
|
||||
panic(0)
|
||||
}
|
||||
|
||||
me2 := director_abstract.NewDirectorExample2(&MyExample2{}, 1, 2)
|
||||
if director_abstract.Example2Get_color(me2, 1, 2, 3) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
me3 := director_abstract.NewDirectorExample3_i(&MyExample3{})
|
||||
if director_abstract.Example3_iGet_color(me3, 1, 2, 3) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package main
|
||||
|
||||
import . "./director_thread"
|
||||
|
||||
type Derived struct {
|
||||
abi Foo
|
||||
} // From Foo
|
||||
func (p *Derived) Do_foo() {
|
||||
p.abi.SetVal(p.abi.GetVal() - 1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// FIXME: This test fails until we fix callbacks from a
|
||||
// different thread.
|
||||
return
|
||||
|
||||
p := &Derived{nil}
|
||||
d := NewDirectorFoo(p)
|
||||
p.abi = d
|
||||
d.Run()
|
||||
|
||||
if d.GetVal() >= 0 {
|
||||
panic(d.GetVal())
|
||||
}
|
||||
|
||||
d.Stop()
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package main
|
||||
|
||||
import "template_typedef_cplx2"
|
||||
import "template_typedef_import"
|
||||
|
||||
func main() {
|
||||
// this is OK
|
||||
|
||||
s := template_typedef_import.NewSin()
|
||||
s.Get_base_value()
|
||||
s.Get_value()
|
||||
s.Get_arith_value()
|
||||
template_typedef_import.My_func_r(s)
|
||||
template_typedef_cplx2.Make_Multiplies_double_double_double_double(s, s)
|
||||
|
||||
z := template_typedef_import.NewCSin()
|
||||
z.Get_base_value()
|
||||
z.Get_value()
|
||||
z.Get_arith_value()
|
||||
template_typedef_import.My_func_c(z)
|
||||
template_typedef_cplx2.Make_Multiplies_complex_complex_complex_complex(z, z)
|
||||
|
||||
// Here we fail
|
||||
d := template_typedef_cplx2.Make_Identity_double()
|
||||
template_typedef_import.My_func_r(d)
|
||||
|
||||
c := template_typedef_cplx2.Make_Identity_complex()
|
||||
template_typedef_import.My_func_c(c)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue