@@ -356,7 +356,7 @@ build:
356356 # this will fail but is needed to generate the .c file that then allows go build to work
357357 - $(PYTHON) build.py >/dev/null 2>&1
358358 # generate %[1]s_go.h from %[1]s.go -- unfortunately no way to build .h only
359- $(GOBUILD) -buildmode=c-shared -o %[1]s_go$(LIBEXT) >/dev/null 2>&1
359+ $(GOBUILD) -buildmode=c-shared -o %[1]s_go$(LIBEXT)
360360 # use pybindgen to build the %[1]s.c file which are the CPython wrappers to cgo wrappers..
361361 # note: pip install pybindgen to get pybindgen if this fails
362362 $(PYTHON) build.py
@@ -457,6 +457,9 @@ var thePyGen *pyGen
457457// before e.g., thePyGen is present.
458458var NoWarn = false
459459
460+ // NoMake turns off generation of Makefiles
461+ var NoMake = false
462+
460463// GenPyBind generates a .go file, build.py file to enable pybindgen to create python bindings,
461464// and wrapper .py file(s) that are loaded as the interface to the package with shadow
462465// python-side classes
@@ -538,11 +541,15 @@ func (g *pyGen) genPre() {
538541 g .gofile = & printer {buf : new (bytes.Buffer ), indentEach : []byte ("\t " )}
539542 g .leakfile = & printer {buf : new (bytes.Buffer ), indentEach : []byte ("\t " )}
540543 g .pybuild = & printer {buf : new (bytes.Buffer ), indentEach : []byte ("\t " )}
541- g .makefile = & printer {buf : new (bytes.Buffer ), indentEach : []byte ("\t " )}
544+ if ! NoMake {
545+ g .makefile = & printer {buf : new (bytes.Buffer ), indentEach : []byte ("\t " )}
546+ }
542547 g .genGoPreamble ()
543548 g .genLeaksPreamble ()
544549 g .genPyBuildPreamble ()
545- g .genMakefile ()
550+ if ! NoMake {
551+ g .genMakefile ()
552+ }
546553 oinit , err := os .Create (filepath .Join (g .odir , "__init__.py" ))
547554 g .err .Add (err )
548555 err = oinit .Close ()
@@ -562,11 +569,13 @@ func (g *pyGen) genOut() {
562569 g .pybuild .Printf ("\n mod.generate(open('%v.c', 'w'))\n \n " , g .outname )
563570 g .gofile .Printf ("\n \n " )
564571 g .genLeaksPostamble ()
565- g .makefile .Printf ("\n \n " )
566572 g .genPrintOut (g .outname + ".go" , g .gofile )
567573 g .genPrintOut ("patch-leaks.go" , g .leakfile )
568574 g .genPrintOut ("build.py" , g .pybuild )
569- g .genPrintOut ("Makefile" , g .makefile )
575+ if ! NoMake {
576+ g .makefile .Printf ("\n \n " )
577+ g .genPrintOut ("Makefile" , g .makefile )
578+ }
570579}
571580
572581func (g * pyGen ) genPkgWrapOut () {
@@ -611,10 +620,12 @@ func (g *pyGen) genGoPreamble() {
611620 if err != nil {
612621 panic (err )
613622 }
623+ // this is critical to avoid pybindgen errors:
624+ exflags := " -Wno-error -Wno-implicit-function-declaration -Wno-int-conversion"
614625 pkgcfg := fmt .Sprintf (`
615626#cgo CFLAGS: %s
616627#cgo LDFLAGS: %s
617- ` , pycfg .cflags , pycfg .ldflags )
628+ ` , pycfg .cflags + exflags , pycfg .ldflags )
618629
619630 return pkgcfg
620631 }()
@@ -688,7 +699,13 @@ func CmdStrToMakefile(cmdstr string) string {
688699 spidx := strings .Index (cmdstr [oidx :], " " )
689700 cmdstr = cmdstr [:oidx ] + cmdstr [oidx + spidx + 1 :]
690701 }
691- return cmdstr
702+ cmds := strings .Fields (cmdstr )
703+ ncmds := make ([]string , 0 , len (cmds )+ 1 )
704+ ncmds = append (ncmds , cmds [:2 ]... )
705+ ncmds = append (ncmds , "-no-make" )
706+ ncmds = append (ncmds , cmds [2 :]... )
707+
708+ return strings .Join (ncmds , " " )
692709}
693710
694711func (g * pyGen ) genMakefile () {
0 commit comments