genbindings: fixup header paths and header include guards

This commit is contained in:
mappu 2024-08-08 18:54:36 +12:00
parent 0c275047c3
commit a991feb589
3 changed files with 5 additions and 4 deletions

View File

@ -67,7 +67,7 @@ func emitParametersCABI2CppForwarding(params []CppParameter, selfType string) (p
func emitBindingHeader(src *CppParsedHeader, filename string) (string, error) {
ret := strings.Builder{}
includeGuard := strings.ToUpper(strings.Replace(filename, `.`, `_`, -1)) + "_H"
includeGuard := "GEN_" + strings.ToUpper(strings.Replace(filename, `.`, `_`, -1))
ret.WriteString(`#ifndef ` + includeGuard + `
#define ` + includeGuard + `

View File

@ -62,7 +62,7 @@ func emitParametersGo2CABIForwarding(params []CppParameter) (preamble string, fo
return preamble, strings.Join(tmp, ", ")
}
func emitGo(src *CppParsedHeader) (string, error) {
func emitGo(src *CppParsedHeader, headerName string) (string, error) {
ret := strings.Builder{}
ret.WriteString(`package miqt
@ -71,7 +71,8 @@ func emitGo(src *CppParsedHeader) (string, error) {
#cgo CFLAGS: -fPIC
#cgo pkg-config: Qt5Widgets
#include "binding.h"
#include "gen_` + headerName + `"
#include <stdlib.h>
*/
import "C"

View File

@ -57,7 +57,7 @@ func main() {
// Emit 3 code files from the intermediate format
outputName := filepath.Join(*outDir, "gen_"+strings.TrimSuffix(filepath.Base(*inputHeader), `.h`))
goSrc, err := emitGo(parsed)
goSrc, err := emitGo(parsed, filepath.Base(*inputHeader))
if err != nil {
panic(err)
}