mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go: Add support for including C++ files in packages
* Add a CXXFiles field to Package, which includes .cc, .cpp and .cxx files. * CXXFiles are compiled using g++, which can be overridden using the CXX environment variable. * Include .hh, .hpp and .hxx files in HFiles. * Add support for CPPFLAGS (used for both C and C++) and CXXFLAGS (used only for C++) in cgo directive. * Changed pkg-config cgo directive to modify CPPFLAGS rather than CFLAGS, so both C and C++ files get any flag returned by pkg-config --cflags. Fixes #1476. R=iant, r CC=bradfitz, gobot, golang-dev, iant, minux.ma, remyoudompheng, seb.binet https://golang.org/cl/8248043
This commit is contained in:
parent
ab5c762a46
commit
84485361f9
7 changed files with 141 additions and 41 deletions
|
|
@ -24,7 +24,7 @@ the C parts of the package. For example:
|
|||
// #include <errno.h>
|
||||
import "C"
|
||||
|
||||
CFLAGS and LDFLAGS may be defined with pseudo #cgo directives
|
||||
CPPFLAGS, CFLAGS, CXXFLAGS and LDFLAGS may be defined with pseudo #cgo directives
|
||||
within these comments to tweak the behavior of gcc. Values defined
|
||||
in multiple directives are concatenated together. Options prefixed
|
||||
by $GOOS, $GOARCH, or $GOOS/$GOARCH are only defined in matching
|
||||
|
|
@ -36,7 +36,7 @@ systems. For example:
|
|||
// #include <png.h>
|
||||
import "C"
|
||||
|
||||
Alternatively, CFLAGS and LDFLAGS may be obtained via the pkg-config
|
||||
Alternatively, CPPFLAGS and LDFLAGS may be obtained via the pkg-config
|
||||
tool using a '#cgo pkg-config:' directive followed by the package names.
|
||||
For example:
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ For example:
|
|||
// #include <png.h>
|
||||
import "C"
|
||||
|
||||
The CGO_CFLAGS and CGO_LDFLAGS environment variables are added
|
||||
The CGO_CPPFLAGS, CGO_CFLAGS, CGO_CXXFLAGS and CGO_LDFLAGS environment variables are added
|
||||
to the flags derived from these directives. Package-specific flags should
|
||||
be set using the directives, not the environment variables, so that builds
|
||||
work in unmodified environments.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue