mirror of
https://github.com/mappu/miqt.git
synced 2025-01-03 14:18:37 +00:00
genbindings: fixup header paths and header include guards
This commit is contained in:
parent
0c275047c3
commit
a991feb589
@ -67,7 +67,7 @@ func emitParametersCABI2CppForwarding(params []CppParameter, selfType string) (p
|
|||||||
func emitBindingHeader(src *CppParsedHeader, filename string) (string, error) {
|
func emitBindingHeader(src *CppParsedHeader, filename string) (string, error) {
|
||||||
ret := strings.Builder{}
|
ret := strings.Builder{}
|
||||||
|
|
||||||
includeGuard := strings.ToUpper(strings.Replace(filename, `.`, `_`, -1)) + "_H"
|
includeGuard := "GEN_" + strings.ToUpper(strings.Replace(filename, `.`, `_`, -1))
|
||||||
|
|
||||||
ret.WriteString(`#ifndef ` + includeGuard + `
|
ret.WriteString(`#ifndef ` + includeGuard + `
|
||||||
#define ` + includeGuard + `
|
#define ` + includeGuard + `
|
||||||
|
@ -62,7 +62,7 @@ func emitParametersGo2CABIForwarding(params []CppParameter) (preamble string, fo
|
|||||||
return preamble, strings.Join(tmp, ", ")
|
return preamble, strings.Join(tmp, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func emitGo(src *CppParsedHeader) (string, error) {
|
func emitGo(src *CppParsedHeader, headerName string) (string, error) {
|
||||||
|
|
||||||
ret := strings.Builder{}
|
ret := strings.Builder{}
|
||||||
ret.WriteString(`package miqt
|
ret.WriteString(`package miqt
|
||||||
@ -71,7 +71,8 @@ func emitGo(src *CppParsedHeader) (string, error) {
|
|||||||
|
|
||||||
#cgo CFLAGS: -fPIC
|
#cgo CFLAGS: -fPIC
|
||||||
#cgo pkg-config: Qt5Widgets
|
#cgo pkg-config: Qt5Widgets
|
||||||
#include "binding.h"
|
#include "gen_` + headerName + `"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
@ -57,7 +57,7 @@ func main() {
|
|||||||
// Emit 3 code files from the intermediate format
|
// Emit 3 code files from the intermediate format
|
||||||
outputName := filepath.Join(*outDir, "gen_"+strings.TrimSuffix(filepath.Base(*inputHeader), `.h`))
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user