mirror of
https://github.com/golang/go
synced 2024-11-22 03:44:39 -07:00
misc/cgo: re-enable testso
The test.bash file generates .so file using gcc, builds the executable using the go tool and then run it with the $LD_LIBRARY_PATH variable pointing to the directory where the .so file lives. Fixes #2982. R=rsc, remyoudompheng CC=golang-dev https://golang.org/cl/5788043
This commit is contained in:
parent
9b73238daa
commit
dc57ed8caf
@ -27,6 +27,7 @@ doc/tmpltohtml
|
||||
doc/articles/wiki/*.bin
|
||||
misc/cgo/life/run.out
|
||||
misc/cgo/stdio/run.out
|
||||
misc/cgo/testso/testso
|
||||
misc/dashboard/builder/builder
|
||||
misc/goplay/goplay
|
||||
misc/osx/*.pkg
|
||||
|
@ -1,22 +0,0 @@
|
||||
# Copyright 2011 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
include ../../../src/Make.inc
|
||||
|
||||
TARG=cgosotest
|
||||
|
||||
CGO_DEPS+=libcgoso.so
|
||||
CGO_LDFLAGS+=-lcgoso -L.
|
||||
CLEANFILES+=out libcgoso.so
|
||||
CGOFILES=\
|
||||
cgoso.go\
|
||||
|
||||
include ../../../src/Make.pkg
|
||||
|
||||
libcgoso.so: cgoso_c.c
|
||||
gcc cgoso_c.c -fPIC -o $@ $(_CGO_CFLAGS_$(GOARCH)) $(_CGO_LDFLAGS_$(GOOS))
|
||||
|
||||
out: install main.go
|
||||
$(GC) $(GCFLAGS) $(GCIMPORTS) main.go
|
||||
$(LD) -o $@ main.$O
|
@ -4,7 +4,10 @@
|
||||
|
||||
package cgosotest
|
||||
|
||||
//void sofunc(void);
|
||||
/*
|
||||
#cgo LDFLAGS: -L. -lcgosotest
|
||||
void sofunc(void);
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func Test() {
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
void sofunc(void)
|
||||
{
|
||||
extern void goCallback(void);
|
||||
|
@ -2,9 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import "cgosotest"
|
||||
import "."
|
||||
|
||||
func main() {
|
||||
cgosotest.Test()
|
||||
|
@ -4,6 +4,7 @@
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
set -e
|
||||
gomake out
|
||||
LD_LIBRARY_PATH=. ./out
|
||||
gomake clean
|
||||
gcc -fPIC -g -shared -o libcgosotest.so cgoso_c.c
|
||||
go build main.go
|
||||
LD_LIBRARY_PATH=. ./main
|
||||
rm -f libcgosotest.so main
|
||||
|
@ -55,12 +55,10 @@ xcd() {
|
||||
go test
|
||||
) || exit $?
|
||||
|
||||
$BROKEN ||
|
||||
[ "$CGO_ENABLED" != 1 ] ||
|
||||
[ "$GOHOSTOS" == windows ] ||
|
||||
[ "$GOHOSTOS" == darwin ] ||
|
||||
(xcd ../misc/cgo/testso
|
||||
"$GOMAKE" clean
|
||||
./test.bash
|
||||
) || exit $?
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user