Thanks for confirming, I realised this by digging into the go build code. // Run SWIG on one SWIG input file. 3553 func (b *builder) swigOne(p *Package, file, obj string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) { 3554 cgoCPPFLAGS, cgoCFLAGS, cgoCXXFLAGS, _, _ := b.cflags(p, true) 3555 var cflags []string 3556 if cxx { 3557 cflags = stringList(cgoCPPFLAGS, pcCFLAGS, cgoCXXFLAGS) 3558 } else { 3559 cflags = stringList(cgoCPPFLAGS, pcCFLAGS, cgoCFLAGS) 3560 } 3561 3562 n := 5 // length of ".swig" 3563 if cxx { 3564 n = 8 // length of ".swigcxx" 3565 } 3566 base := file[:len(file)-n] 3567 goFile := base + ".go" 3568 gccBase := base + "_wrap." 3569 gccExt := "c" 3570 if cxx { 3571 gccExt = "cxx" 3572 } 3573 3574 _, gccgo := buildToolchain.(gccgoToolchain) 3575 3576 // swig 3577 args := []string{ 3578 "-go", 3579 "-cgo", 3580 "-intgosize", intgosize, 3581 "-module", base, 3582 "-o", obj + gccBase + gccExt, 3583 "-outdir", obj, 3584 } 3585 3586 for _, f := range cflags { 3587 if len(f) > 3 && f[:2] == "-I" { 3588 args = append(args, f) 3589 } 3590 } 3591 3592 if gccgo { 3593 args = append(args, "-gccgo") 3594 if pkgpath := gccgoPkgpath(p); pkgpath != "" { 3595 args = append(args, "-go-pkgpath", pkgpath) 3596 } 3597 } 3598 if cxx { 3599 args = append(args, "-c++") 3600 } 3601 3602 out, err := b.runOut(p.Dir, p.ImportPath, nil, "swig", args, file) 3603 if err != nil { 3604 if len(out) > 0 { 3605 if bytes.Contains(out, []byte("-intgosize")) || bytes.Contains(out, []byte("-cgo")) { 3606 return "", "", errors.New("must have SWIG version >= 3.0.6") 3607 } 3608 b.showOutput(p.Dir, p.ImportPath, b.processOutput(out)) // swig error 3609 return "", "", errPrintedOutput 3610 } 3611 return "", "", err 3612 } 3613 if len(out) > 0 { 3614 b.showOutput(p.Dir, p.ImportPath, b.processOutput(out)) // swig warning 3615 } 3616 3617 return obj + goFile, obj + gccBase + gccExt, nil 3618 }
On Monday, October 17, 2016 at 5:50:44 PM UTC+1, Ian Lance Taylor wrote: > > On Mon, Oct 17, 2016 at 4:11 AM, <andrew...@miracl.com <javascript:>> > wrote: > > > > I have a follow-up question, how can I instrument my go code so that I > can > > set the include path that is used to resolve '%include' statements in my > > swig code. Currently I have relative paths in my swig file, and I would > like > > to put '/usr/include' on the search path for the swig compilation. Is > this > > possible? > > There is no general support for passing arguments to SWIG, but any -I > options found in the CGO_CFLAGS environment variable (see > https://golang.org/cmd/cgo) will be passed to SWIG. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.