aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-11-08 11:06:09 -0800
committerRuss Cox <rsc@golang.org>2017-11-16 16:27:13 +0000
commitda21113b0c1d1b2979657d78320c31ffcb3c2c92 (patch)
tree6826d91b00f3a243d44d6e342975fc476112b828 /src
parentd9a198c7d0526f00a42f00d90cc4b91802a3354c (diff)
downloadgo-da21113b0c1d1b2979657d78320c31ffcb3c2c92.tar.xz
cmd/go: add dependencies for implicit SWIG imports
This fixes the misc/swig tests. Change-Id: I60c87bbd361fe8b4f69e4507b25dc99a226da3d7 Reviewed-on: https://go-review.googlesource.com/76610 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/internal/load/pkg.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index b2cfc8c26d..27684fa1f3 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -958,13 +958,23 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) {
// Cgo translation adds imports of "runtime/cgo" and "syscall",
// except for certain packages, to avoid circular dependencies.
- if len(p.CgoFiles) > 0 && (!p.Standard || !cgoExclude[p.ImportPath]) {
+ if p.UsesCgo() && (!p.Standard || !cgoExclude[p.ImportPath]) {
addImport("runtime/cgo")
}
- if len(p.CgoFiles) > 0 && (!p.Standard || !cgoSyscallExclude[p.ImportPath]) {
+ if p.UsesCgo() && (!p.Standard || !cgoSyscallExclude[p.ImportPath]) {
addImport("syscall")
}
+ // SWIG adds imports of some standard packages.
+ if p.UsesSwig() {
+ addImport("runtime/cgo")
+ addImport("syscall")
+ addImport("sync")
+
+ // TODO: The .swig and .swigcxx files can use
+ // %go_import directives to import other packages.
+ }
+
// The linker loads implicit dependencies.
if p.Name == "main" && !p.Internal.ForceLibrary {
for _, dep := range LinkerDeps(p) {