From 9eb074163b94db809f3b9dc5ae42889cbe79a3ed Mon Sep 17 00:00:00 2001 From: myaaaaaaaaa <103326468+myaaaaaaaaa@users.noreply.github.com> Date: Sun, 22 Oct 2023 00:04:15 -0400 Subject: [PATCH] Place khrplatform.h side-by-side with generated Go files --- main.go | 4 +++- type.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 4fbb0f7..91e5096 100644 --- a/main.go +++ b/main.go @@ -76,7 +76,9 @@ func generate(name string, args []string) { if err := pkg.GeneratePackage(*outDir); err != nil { log.Fatalln("error generating package:", err) } - if err := copyIncludes(filepath.Join(*xmlDir, "include"), *outDir); err != nil { + // Place khrplatform.h side-by-side with the Go source files to prevent + // `go mod vendor` from stripping away directories without any Go code. + if err := copyIncludes(filepath.Join(*xmlDir, "include/KHR"), *outDir); err != nil { log.Fatalln("error copying includes:", err) } break diff --git a/type.go b/type.go index 6e42f52..e7c5acb 100644 --- a/type.go +++ b/type.go @@ -158,5 +158,11 @@ func (t Typedef) CTypedef() string { if strings.Contains(t.CDefinition, "GLsync") { return "typedef uintptr_t GLsync;" } + + // Place khrplatform.h side-by-side with the Go source files to prevent + // `go mod vendor` from stripping away directories without any Go code. + if strings.Contains(t.CDefinition, "#include") { + return strings.ReplaceAll(t.CDefinition, "KHR/", "") + } return t.CDefinition }