@@ -356,7 +356,7 @@ build:
356
356
# this will fail but is needed to generate the .c file that then allows go build to work
357
357
- $(PYTHON) build.py >/dev/null 2>&1
358
358
# 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)
360
360
# use pybindgen to build the %[1]s.c file which are the CPython wrappers to cgo wrappers..
361
361
# note: pip install pybindgen to get pybindgen if this fails
362
362
$(PYTHON) build.py
@@ -457,6 +457,9 @@ var thePyGen *pyGen
457
457
// before e.g., thePyGen is present.
458
458
var NoWarn = false
459
459
460
+ // NoMake turns off generation of Makefiles
461
+ var NoMake = false
462
+
460
463
// GenPyBind generates a .go file, build.py file to enable pybindgen to create python bindings,
461
464
// and wrapper .py file(s) that are loaded as the interface to the package with shadow
462
465
// python-side classes
@@ -538,11 +541,15 @@ func (g *pyGen) genPre() {
538
541
g .gofile = & printer {buf : new (bytes.Buffer ), indentEach : []byte ("\t " )}
539
542
g .leakfile = & printer {buf : new (bytes.Buffer ), indentEach : []byte ("\t " )}
540
543
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
+ }
542
547
g .genGoPreamble ()
543
548
g .genLeaksPreamble ()
544
549
g .genPyBuildPreamble ()
545
- g .genMakefile ()
550
+ if ! NoMake {
551
+ g .genMakefile ()
552
+ }
546
553
oinit , err := os .Create (filepath .Join (g .odir , "__init__.py" ))
547
554
g .err .Add (err )
548
555
err = oinit .Close ()
@@ -562,11 +569,13 @@ func (g *pyGen) genOut() {
562
569
g .pybuild .Printf ("\n mod.generate(open('%v.c', 'w'))\n \n " , g .outname )
563
570
g .gofile .Printf ("\n \n " )
564
571
g .genLeaksPostamble ()
565
- g .makefile .Printf ("\n \n " )
566
572
g .genPrintOut (g .outname + ".go" , g .gofile )
567
573
g .genPrintOut ("patch-leaks.go" , g .leakfile )
568
574
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
+ }
570
579
}
571
580
572
581
func (g * pyGen ) genPkgWrapOut () {
@@ -611,10 +620,12 @@ func (g *pyGen) genGoPreamble() {
611
620
if err != nil {
612
621
panic (err )
613
622
}
623
+ // this is critical to avoid pybindgen errors:
624
+ exflags := " -Wno-error -Wno-implicit-function-declaration -Wno-int-conversion"
614
625
pkgcfg := fmt .Sprintf (`
615
626
#cgo CFLAGS: %s
616
627
#cgo LDFLAGS: %s
617
- ` , pycfg .cflags , pycfg .ldflags )
628
+ ` , pycfg .cflags + exflags , pycfg .ldflags )
618
629
619
630
return pkgcfg
620
631
}()
@@ -688,7 +699,13 @@ func CmdStrToMakefile(cmdstr string) string {
688
699
spidx := strings .Index (cmdstr [oidx :], " " )
689
700
cmdstr = cmdstr [:oidx ] + cmdstr [oidx + spidx + 1 :]
690
701
}
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 , " " )
692
709
}
693
710
694
711
func (g * pyGen ) genMakefile () {
0 commit comments