// 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 }