]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: permit C files if the package uses SWIG
authorIan Lance Taylor <iant@golang.org>
Sat, 16 May 2015 00:12:20 +0000 (17:12 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 26 May 2015 03:58:10 +0000 (03:58 +0000)
They will be compiled and added to the archive, just as though the
package used cgo.  In effect all SWIG packages now use cgo anyhow.

Change-Id: I5d5a28ed0ec4295f24036b2834218bc980f080d0
Reviewed-on: https://go-review.googlesource.com/10146
Reviewed-by: Minux Ma <minux@golang.org>
src/cmd/go/pkg.go

index 7a71471340f8fd52b8f86d8302580a88f14556ec..601c30362ff2592e65950dda5b5ae392f730c948 100644 (file)
@@ -673,10 +673,10 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
        p.Target = p.target
 
        // The gc toolchain only permits C source files with cgo.
-       if len(p.CFiles) > 0 && !p.usesCgo() && buildContext.Compiler == "gc" {
+       if len(p.CFiles) > 0 && !p.usesCgo() && !p.usesSwig() && buildContext.Compiler == "gc" {
                p.Error = &PackageError{
                        ImportStack: stk.copy(),
-                       Err:         fmt.Sprintf("C source files not allowed when not using cgo: %s", strings.Join(p.CFiles, " ")),
+                       Err:         fmt.Sprintf("C source files not allowed when not using cgo or SWIG: %s", strings.Join(p.CFiles, " ")),
                }
                return p
        }