]> Cypherpunks repositories - gostls13.git/commitdiff
gotest: allow make test of cgo packages (without make install)
authorRuss Cox <rsc@golang.org>
Wed, 25 Aug 2010 22:00:42 +0000 (18:00 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 25 Aug 2010 22:00:42 +0000 (18:00 -0400)
R=r
CC=golang-dev, stevvooe
https://golang.org/cl/1995051

src/Make.pkg
src/cmd/gotest/gotest

index 4d6400814523e2bef9302ae70eab17e598a922a9..239820b1521957348db541ccafacf4b86e141753 100644 (file)
@@ -138,12 +138,16 @@ _CGO_LDFLAGS_darwin=-dynamiclib -Wl,-undefined,dynamic_lookup
 _cgo_defun.$O: _cgo_defun.c
        $(CC) $(CFLAGS) $(RUNTIME_CFLAGS) _cgo_defun.c
 
-_cgo_.so: $(GCC_OFILES) $(CGO_DEPS)
+$(CGOTARG).so: $(GCC_OFILES) $(CGO_DEPS)
        $(HOST_CC) $(_CGO_CFLAGS_$(GOARCH)) -o $@ $(GCC_OFILES) $(CGO_LDFLAGS)  $(_CGO_LDFLAGS_$(GOOS))
 
-$(pkgdir)/$(CGOTARG).so: _cgo_.so
-       @test -d $(QUOTED_GOROOT)/pkg && mkdir -p $(pkgdir)/$(dir)
-       cp _cgo_.so "$@"
+$(pkgdir)/$(CGOTARG).so: $(CGOTARG).so
+       @test -d $(QUOTED_GOROOT)/pkg && mkdir -p $(pkgdir)
+       cp $(CGOTARG).so "$@"
+
+ifneq ($(CGOFILES),)
+testpackage: $(CGOTARG).so
+endif
 
 # Generic build rules.
 # These come last so that the rules above can override them
index 7cc931b2cb285729b6bbce038ddf7ddb33541c3e..463242e3a75a27079baaa61b4a581fc8736575a9 100755 (executable)
@@ -174,4 +174,10 @@ importpath=$(gomake -s importpath)
 
 $GC _testmain.go
 $GL _testmain.$O
+
+# Set dynamic linker library path, no matter what it's called,
+# to include the current directory while running $O.out,
+# so that cgo libraries can be tested without installation.
+LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH \
+DYLD_LIBRARY_PATH=.:$DYLD_LIBRARY_PATH \
 $E ./$O.out "$@"