Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: go mod vendor #131

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix: go mod vendor #131

wants to merge 3 commits into from

Conversation

cmgsj
Copy link

@cmgsj cmgsj commented Feb 11, 2025

Fixes #61

Inspired by:

Changes:

  • Generate gokeep.go files to (like .gitkeep) to force Go tooling to keep non-Go (.c and .h) files when vendoring.
  • Generate parser/build_cgo.go file importing all gokeep packages.
  • Make the above steps reproducible by running scripts/gokeep.sh on make update_source.

@lfittl
Copy link
Member

lfittl commented Feb 11, 2025

Thanks for the contribution! - I'm definitely open to making this work, so we can drop the extra effort with vendoring the library.

Make update_source reproducible using git patch gokeep.patch.

I don't think that's the right approach, since Postgres major releases will bring different include folders, and so we'd have to update that patch each time.

What if instead we came up with a list of all include directories (through bash scripting) and then auto-generated the relevant keep files during the extract source step?

We could have each of the nested files use this template:

//go:build required
// +build required

// package gokeep prevents go tooling from stripping the c dependencies.
package gokeep

And then only have the list of imports at the top-level build_cgo.go file (which would take a string substitution of the list of nested files to be imported).

Do you want to adjust the PR to work like that?

@cmgsj
Copy link
Author

cmgsj commented Feb 11, 2025

//go:build required
// +build required

// package gokeep prevents go tooling from stripping the c dependencies.
package gokeep

Yeah, that makes sense, I'll update my PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vendoring with go mod vendor leads to "fatal error: 'pg_query.h' file not found"
2 participants