]> Cypherpunks repositories - gostls13.git/commit
cmd/go: install headers for c-archive/c-shared cgo exports
authorIan Lance Taylor <iant@golang.org>
Thu, 7 May 2015 05:06:19 +0000 (22:06 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 7 May 2015 17:39:56 +0000 (17:39 +0000)
commite45aebd6dda1830e0a5f31248de70f03f611ccf2
tree696552ba3f468cc25798d007827fc2d142be380c
parentd4bb72b485cc9aa790e3a176b2e728e2d28d52ed
cmd/go: install headers for c-archive/c-shared cgo exports

When
  using -buildmode=c-archive or c-shared, and
  when installing packages that use cgo, and
  when those packages export some functions via //export comments,
then
  for each such package, install a pkg.h header file that declares the
  functions.

This permits C code to #include the header when calling the Go
functions.

This is a little awkward to use when there are multiple packages that
export functions, as you have to "go install" your c-archive/c-shared
object and then pull it out of the package directory.  When compiling
your C code you have to -I pkg/$GOOS_$GOARCH.  I haven't thought of
any more convenient approach.  It's simpler when only the main package
has exported functions.

When using c-shared you currently have to use a _shared suffix in the
-I option; it would be nice to fix that somehow.

Change-Id: I5d8cf08914b7d3c2b194120c77791d2732ffd26e
Reviewed-on: https://go-review.googlesource.com/9798
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
misc/cgo/testcarchive/main.c
misc/cgo/testcarchive/test.bash
misc/cgo/testcshared/main0.c
misc/cgo/testcshared/test.bash
src/cmd/go/build.go
src/cmd/go/pkg.go