mirror of
https://github.com/golang/go
synced 2024-11-25 07:07:57 -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
|
doc/articles/wiki/*.bin
|
||||||
misc/cgo/life/run.out
|
misc/cgo/life/run.out
|
||||||
misc/cgo/stdio/run.out
|
misc/cgo/stdio/run.out
|
||||||
|
misc/cgo/testso/testso
|
||||||
misc/dashboard/builder/builder
|
misc/dashboard/builder/builder
|
||||||
misc/goplay/goplay
|
misc/goplay/goplay
|
||||||
misc/osx/*.pkg
|
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
|
package cgosotest
|
||||||
|
|
||||||
//void sofunc(void);
|
/*
|
||||||
|
#cgo LDFLAGS: -L. -lcgosotest
|
||||||
|
void sofunc(void);
|
||||||
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
func Test() {
|
func Test() {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
void sofunc(void)
|
void sofunc(void)
|
||||||
{
|
{
|
||||||
extern void goCallback(void);
|
extern void goCallback(void);
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "cgosotest"
|
import "."
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cgosotest.Test()
|
cgosotest.Test()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
# license that can be found in the LICENSE file.
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
gomake out
|
gcc -fPIC -g -shared -o libcgosotest.so cgoso_c.c
|
||||||
LD_LIBRARY_PATH=. ./out
|
go build main.go
|
||||||
gomake clean
|
LD_LIBRARY_PATH=. ./main
|
||||||
|
rm -f libcgosotest.so main
|
||||||
|
@ -55,12 +55,10 @@ xcd() {
|
|||||||
go test
|
go test
|
||||||
) || exit $?
|
) || exit $?
|
||||||
|
|
||||||
$BROKEN ||
|
|
||||||
[ "$CGO_ENABLED" != 1 ] ||
|
[ "$CGO_ENABLED" != 1 ] ||
|
||||||
[ "$GOHOSTOS" == windows ] ||
|
[ "$GOHOSTOS" == windows ] ||
|
||||||
[ "$GOHOSTOS" == darwin ] ||
|
[ "$GOHOSTOS" == darwin ] ||
|
||||||
(xcd ../misc/cgo/testso
|
(xcd ../misc/cgo/testso
|
||||||
"$GOMAKE" clean
|
|
||||||
./test.bash
|
./test.bash
|
||||||
) || exit $?
|
) || exit $?
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user