Closed jclc closed 5 years ago
As a sidenote, the conventional method of having autogenerated code in Go projects is through go generate directives, eg. just a file with the contents:
// +build ignore
package vulkan
//go:generate <your command and args>
I'd make a PR for this issue, but I don't know what commands I need to run to generate vulkan.go. With go generate directives, you just run go generate
in the package directory.
Another thing I noticed is that #cgo CFLAGS: -I. -DVK_NO_PROTOTYPES
is duplicated in vulkan.go, vulkan_ios.go, vulkan_darwin.go and vulkan_android.go.
when the Linux source file was deleted, the cgo directive for linking with dl was also removed, preventing building.
Oops, I just got it back, only for this purpose. I could put the platform specific cflags / ldflags into the YAML manifest, but then it will copy those values across all generated files. And users sometimes contribute useful changes to these variables, I don't want to change them in 6-8 places and force them to run the generator. So as inspired by the GLFW repo https://github.com/go-gl/glfw I put these into platform-specific files.
the conventional method of having autogenerated code in Go projects is through go generate directives
Yes, but this case is different. go generate is useful when you have 1:1 mapping of source and generated files, for example models.go
contains go generate directive, and it generates models.gen.go
. My c-for-go generator works differently, there is a manifest and a lot of files generated.
but I don't know what commands I need to run to generate
It's https://github.com/vulkan-go/vulkan/blob/master/Makefile
I noticed is that #cgo CFLAGS: -I. -DVK_NO_PROTOTYPES is duplicated
Removed from four files (incl. vulkan_linux.go)
First of all, love the refactoring; the repository is looking much nicer now without the different source files for each of the desktop platforms. We should strive for as little platform-specific code as possible. However, when the Linux source file was deleted, the cgo directive for linking with dl was also removed, preventing building.
A simple solution is to just add
#cgo linux LDFLAGS: -ldl
in vulkan.go, but that file is autogenerated. Could the line just be added in the generator? I'm not familiar with the bindings generator. Adding a new file just for that one directive would be a little ugly in my opinion, but maybe it would be the better choice? Otherwise you'd have to regen the bindings every time you change the build/link flags.