From dd9eb44ae37597d51538a80a2e2aa683697f866f Mon Sep 17 00:00:00 2001 From: cmgsj Date: Mon, 10 Feb 2025 20:03:25 -0500 Subject: [PATCH 1/3] run make update_source --- pg_query.pb.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pg_query.pb.go b/pg_query.pb.go index d3f74f7b..3ddd8f4c 100644 --- a/pg_query.pb.go +++ b/pg_query.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.25.1 +// protoc v5.29.3 // source: pg_query.proto package pg_query From 3f6e18395ce2b99819d14829b65a41b28a1be195 Mon Sep 17 00:00:00 2001 From: cmgsj Date: Mon, 10 Feb 2025 20:22:25 -0500 Subject: [PATCH 2/3] add build_cgo and gokeep --- Makefile | 1 + gokeep.patch | 470 ++++++++++++++++++ parser/build_cgo.go | 17 + parser/include/gokeep.go | 13 + parser/include/postgres/access/gokeep.go | 5 + parser/include/postgres/archive/gokeep.go | 5 + parser/include/postgres/catalog/gokeep.go | 5 + parser/include/postgres/commands/gokeep.go | 5 + parser/include/postgres/common/gokeep.go | 5 + parser/include/postgres/datatype/gokeep.go | 5 + parser/include/postgres/executor/gokeep.go | 5 + parser/include/postgres/foreign/gokeep.go | 5 + parser/include/postgres/gokeep.go | 35 ++ parser/include/postgres/jit/gokeep.go | 5 + parser/include/postgres/lib/gokeep.go | 5 + parser/include/postgres/libpq/gokeep.go | 5 + parser/include/postgres/mb/gokeep.go | 5 + parser/include/postgres/nodes/gokeep.go | 5 + parser/include/postgres/optimizer/gokeep.go | 5 + parser/include/postgres/parser/gokeep.go | 5 + .../include/postgres/partitioning/gokeep.go | 5 + .../include/postgres/port/atomics/gokeep.go | 5 + parser/include/postgres/port/gokeep.go | 12 + .../postgres/port/win32/arpa/gokeep.go | 5 + parser/include/postgres/port/win32/gokeep.go | 12 + .../postgres/port/win32/netinet/gokeep.go | 5 + .../include/postgres/port/win32/sys/gokeep.go | 5 + .../postgres/port/win32_msvc/gokeep.go | 5 + .../postgres/port/win32_msvc/sys/gokeep.go | 5 + parser/include/postgres/portability/gokeep.go | 5 + parser/include/postgres/postmaster/gokeep.go | 5 + parser/include/postgres/regex/gokeep.go | 5 + parser/include/postgres/replication/gokeep.go | 5 + parser/include/postgres/rewrite/gokeep.go | 5 + parser/include/postgres/storage/gokeep.go | 5 + parser/include/postgres/tcop/gokeep.go | 5 + parser/include/postgres/tsearch/gokeep.go | 5 + parser/include/postgres/utils/gokeep.go | 5 + parser/include/protobuf-c/gokeep.go | 5 + parser/include/protobuf/gokeep.go | 5 + parser/include/xxhash/gokeep.go | 5 + 41 files changed, 730 insertions(+) create mode 100644 gokeep.patch create mode 100644 parser/build_cgo.go create mode 100644 parser/include/gokeep.go create mode 100644 parser/include/postgres/access/gokeep.go create mode 100644 parser/include/postgres/archive/gokeep.go create mode 100644 parser/include/postgres/catalog/gokeep.go create mode 100644 parser/include/postgres/commands/gokeep.go create mode 100644 parser/include/postgres/common/gokeep.go create mode 100644 parser/include/postgres/datatype/gokeep.go create mode 100644 parser/include/postgres/executor/gokeep.go create mode 100644 parser/include/postgres/foreign/gokeep.go create mode 100644 parser/include/postgres/gokeep.go create mode 100644 parser/include/postgres/jit/gokeep.go create mode 100644 parser/include/postgres/lib/gokeep.go create mode 100644 parser/include/postgres/libpq/gokeep.go create mode 100644 parser/include/postgres/mb/gokeep.go create mode 100644 parser/include/postgres/nodes/gokeep.go create mode 100644 parser/include/postgres/optimizer/gokeep.go create mode 100644 parser/include/postgres/parser/gokeep.go create mode 100644 parser/include/postgres/partitioning/gokeep.go create mode 100644 parser/include/postgres/port/atomics/gokeep.go create mode 100644 parser/include/postgres/port/gokeep.go create mode 100644 parser/include/postgres/port/win32/arpa/gokeep.go create mode 100644 parser/include/postgres/port/win32/gokeep.go create mode 100644 parser/include/postgres/port/win32/netinet/gokeep.go create mode 100644 parser/include/postgres/port/win32/sys/gokeep.go create mode 100644 parser/include/postgres/port/win32_msvc/gokeep.go create mode 100644 parser/include/postgres/port/win32_msvc/sys/gokeep.go create mode 100644 parser/include/postgres/portability/gokeep.go create mode 100644 parser/include/postgres/postmaster/gokeep.go create mode 100644 parser/include/postgres/regex/gokeep.go create mode 100644 parser/include/postgres/replication/gokeep.go create mode 100644 parser/include/postgres/rewrite/gokeep.go create mode 100644 parser/include/postgres/storage/gokeep.go create mode 100644 parser/include/postgres/tcop/gokeep.go create mode 100644 parser/include/postgres/tsearch/gokeep.go create mode 100644 parser/include/postgres/utils/gokeep.go create mode 100644 parser/include/protobuf-c/gokeep.go create mode 100644 parser/include/protobuf/gokeep.go create mode 100644 parser/include/xxhash/gokeep.go diff --git a/Makefile b/Makefile index a2b1912a..75d4f5d2 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ update_source: clean $(LIBDIR) # Other support files rm -fr testdata cp -a $(LIBDIR)/testdata testdata + git apply gokeep.patch clean: -@ $(RM) -r $(LIB_TMPDIR) diff --git a/gokeep.patch b/gokeep.patch new file mode 100644 index 00000000..51791219 --- /dev/null +++ b/gokeep.patch @@ -0,0 +1,470 @@ +diff --git a/parser/include/gokeep.go b/parser/include/gokeep.go +new file mode 100644 +index 0000000..c04672b +--- /dev/null ++++ b/parser/include/gokeep.go +@@ -0,0 +1,13 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep ++ ++import ( ++ // Prevent go tooling from stripping out the c source files. ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf-c" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/xxhash" ++) +diff --git a/parser/include/postgres/access/gokeep.go b/parser/include/postgres/access/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/access/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/archive/gokeep.go b/parser/include/postgres/archive/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/archive/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/catalog/gokeep.go b/parser/include/postgres/catalog/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/catalog/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/commands/gokeep.go b/parser/include/postgres/commands/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/commands/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/common/gokeep.go b/parser/include/postgres/common/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/common/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/datatype/gokeep.go b/parser/include/postgres/datatype/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/datatype/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/executor/gokeep.go b/parser/include/postgres/executor/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/executor/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/foreign/gokeep.go b/parser/include/postgres/foreign/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/foreign/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/gokeep.go b/parser/include/postgres/gokeep.go +new file mode 100644 +index 0000000..7959e27 +--- /dev/null ++++ b/parser/include/postgres/gokeep.go +@@ -0,0 +1,35 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep ++ ++import ( ++ // Prevent go tooling from stripping out the c source files. ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/access" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/archive" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/catalog" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/commands" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/common" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/datatype" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/executor" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/foreign" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/jit" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/lib" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/libpq" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/mb" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/nodes" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/optimizer" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/parser" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/partitioning" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/portability" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/postmaster" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/regex" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/replication" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/rewrite" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/storage" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tcop" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tsearch" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/utils" ++) +diff --git a/parser/include/postgres/jit/gokeep.go b/parser/include/postgres/jit/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/jit/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/lib/gokeep.go b/parser/include/postgres/lib/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/lib/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/libpq/gokeep.go b/parser/include/postgres/libpq/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/libpq/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/mb/gokeep.go b/parser/include/postgres/mb/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/mb/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/nodes/gokeep.go b/parser/include/postgres/nodes/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/nodes/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/optimizer/gokeep.go b/parser/include/postgres/optimizer/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/optimizer/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/parser/gokeep.go b/parser/include/postgres/parser/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/parser/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/partitioning/gokeep.go b/parser/include/postgres/partitioning/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/partitioning/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/port/atomics/gokeep.go b/parser/include/postgres/port/atomics/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/port/atomics/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/port/gokeep.go b/parser/include/postgres/port/gokeep.go +new file mode 100644 +index 0000000..afee5cd +--- /dev/null ++++ b/parser/include/postgres/port/gokeep.go +@@ -0,0 +1,12 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep ++ ++import ( ++ // Prevent go tooling from stripping out the c source files. ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/atomics" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32_msvc" ++) +diff --git a/parser/include/postgres/port/win32/arpa/gokeep.go b/parser/include/postgres/port/win32/arpa/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/port/win32/arpa/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/port/win32/gokeep.go b/parser/include/postgres/port/win32/gokeep.go +new file mode 100644 +index 0000000..ea04b25 +--- /dev/null ++++ b/parser/include/postgres/port/win32/gokeep.go +@@ -0,0 +1,12 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep ++ ++import ( ++ // Prevent go tooling from stripping out the c source files. ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/arpa" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/netinet" ++ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/sys" ++) +diff --git a/parser/include/postgres/port/win32/netinet/gokeep.go b/parser/include/postgres/port/win32/netinet/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/port/win32/netinet/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/port/win32/sys/gokeep.go b/parser/include/postgres/port/win32/sys/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/port/win32/sys/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/port/win32_msvc/gokeep.go b/parser/include/postgres/port/win32_msvc/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/port/win32_msvc/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/port/win32_msvc/sys/gokeep.go b/parser/include/postgres/port/win32_msvc/sys/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/port/win32_msvc/sys/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/portability/gokeep.go b/parser/include/postgres/portability/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/portability/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/postmaster/gokeep.go b/parser/include/postgres/postmaster/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/postmaster/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/regex/gokeep.go b/parser/include/postgres/regex/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/regex/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/replication/gokeep.go b/parser/include/postgres/replication/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/replication/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/rewrite/gokeep.go b/parser/include/postgres/rewrite/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/rewrite/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/storage/gokeep.go b/parser/include/postgres/storage/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/storage/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/tcop/gokeep.go b/parser/include/postgres/tcop/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/tcop/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/tsearch/gokeep.go b/parser/include/postgres/tsearch/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/tsearch/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/postgres/utils/gokeep.go b/parser/include/postgres/utils/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/postgres/utils/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/protobuf-c/gokeep.go b/parser/include/protobuf-c/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/protobuf-c/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/protobuf/gokeep.go b/parser/include/protobuf/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/protobuf/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep +diff --git a/parser/include/xxhash/gokeep.go b/parser/include/xxhash/gokeep.go +new file mode 100644 +index 0000000..66d9b71 +--- /dev/null ++++ b/parser/include/xxhash/gokeep.go +@@ -0,0 +1,5 @@ ++//go:build required ++// +build required ++ ++// package gokeep prevents go tooling from stripping the c dependencies. ++package gokeep diff --git a/parser/build_cgo.go b/parser/build_cgo.go new file mode 100644 index 00000000..dba8a548 --- /dev/null +++ b/parser/build_cgo.go @@ -0,0 +1,17 @@ +//go:build required +// +build required + +package parser + +// This file exists purely to prevent the golang toolchain from stripping +// away the c source directories and files when `go mod vendor` is used +// to populate a `vendor/` directory of a project depending on `github.com/pganalyze/pg_query_go/v6`. +// +// How it works: +// - every directory which only includes c source files receives a dummy.go file. +// - every directory we want to preserve is included here as a _ import. +// - this file is given a build to exclude it from the regular build. +import ( + // Prevent go tooling from stripping out the c source files. + _ "github.com/pganalyze/pg_query_go/v6/parser/include" +) diff --git a/parser/include/gokeep.go b/parser/include/gokeep.go new file mode 100644 index 00000000..c04672b7 --- /dev/null +++ b/parser/include/gokeep.go @@ -0,0 +1,13 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep + +import ( + // Prevent go tooling from stripping out the c source files. + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf-c" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/xxhash" +) diff --git a/parser/include/postgres/access/gokeep.go b/parser/include/postgres/access/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/access/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/archive/gokeep.go b/parser/include/postgres/archive/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/archive/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/catalog/gokeep.go b/parser/include/postgres/catalog/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/catalog/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/commands/gokeep.go b/parser/include/postgres/commands/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/commands/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/common/gokeep.go b/parser/include/postgres/common/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/common/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/datatype/gokeep.go b/parser/include/postgres/datatype/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/datatype/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/executor/gokeep.go b/parser/include/postgres/executor/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/executor/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/foreign/gokeep.go b/parser/include/postgres/foreign/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/foreign/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/gokeep.go b/parser/include/postgres/gokeep.go new file mode 100644 index 00000000..7959e27c --- /dev/null +++ b/parser/include/postgres/gokeep.go @@ -0,0 +1,35 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep + +import ( + // Prevent go tooling from stripping out the c source files. + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/access" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/archive" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/catalog" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/commands" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/common" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/datatype" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/executor" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/foreign" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/jit" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/lib" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/libpq" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/mb" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/nodes" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/optimizer" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/parser" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/partitioning" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/portability" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/postmaster" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/regex" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/replication" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/rewrite" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/storage" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tcop" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tsearch" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/utils" +) diff --git a/parser/include/postgres/jit/gokeep.go b/parser/include/postgres/jit/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/jit/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/lib/gokeep.go b/parser/include/postgres/lib/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/lib/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/libpq/gokeep.go b/parser/include/postgres/libpq/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/libpq/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/mb/gokeep.go b/parser/include/postgres/mb/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/mb/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/nodes/gokeep.go b/parser/include/postgres/nodes/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/nodes/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/optimizer/gokeep.go b/parser/include/postgres/optimizer/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/optimizer/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/parser/gokeep.go b/parser/include/postgres/parser/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/parser/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/partitioning/gokeep.go b/parser/include/postgres/partitioning/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/partitioning/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/port/atomics/gokeep.go b/parser/include/postgres/port/atomics/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/port/atomics/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/port/gokeep.go b/parser/include/postgres/port/gokeep.go new file mode 100644 index 00000000..afee5cd7 --- /dev/null +++ b/parser/include/postgres/port/gokeep.go @@ -0,0 +1,12 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep + +import ( + // Prevent go tooling from stripping out the c source files. + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/atomics" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32_msvc" +) diff --git a/parser/include/postgres/port/win32/arpa/gokeep.go b/parser/include/postgres/port/win32/arpa/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/port/win32/arpa/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/port/win32/gokeep.go b/parser/include/postgres/port/win32/gokeep.go new file mode 100644 index 00000000..ea04b25e --- /dev/null +++ b/parser/include/postgres/port/win32/gokeep.go @@ -0,0 +1,12 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep + +import ( + // Prevent go tooling from stripping out the c source files. + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/arpa" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/netinet" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/sys" +) diff --git a/parser/include/postgres/port/win32/netinet/gokeep.go b/parser/include/postgres/port/win32/netinet/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/port/win32/netinet/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/port/win32/sys/gokeep.go b/parser/include/postgres/port/win32/sys/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/port/win32/sys/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/port/win32_msvc/gokeep.go b/parser/include/postgres/port/win32_msvc/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/port/win32_msvc/sys/gokeep.go b/parser/include/postgres/port/win32_msvc/sys/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/port/win32_msvc/sys/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/portability/gokeep.go b/parser/include/postgres/portability/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/portability/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/postmaster/gokeep.go b/parser/include/postgres/postmaster/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/postmaster/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/regex/gokeep.go b/parser/include/postgres/regex/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/regex/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/replication/gokeep.go b/parser/include/postgres/replication/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/replication/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/rewrite/gokeep.go b/parser/include/postgres/rewrite/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/rewrite/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/storage/gokeep.go b/parser/include/postgres/storage/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/storage/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/tcop/gokeep.go b/parser/include/postgres/tcop/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/tcop/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/tsearch/gokeep.go b/parser/include/postgres/tsearch/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/tsearch/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/postgres/utils/gokeep.go b/parser/include/postgres/utils/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/postgres/utils/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/protobuf-c/gokeep.go b/parser/include/protobuf-c/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/protobuf-c/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/protobuf/gokeep.go b/parser/include/protobuf/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/protobuf/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep diff --git a/parser/include/xxhash/gokeep.go b/parser/include/xxhash/gokeep.go new file mode 100644 index 00000000..66d9b71f --- /dev/null +++ b/parser/include/xxhash/gokeep.go @@ -0,0 +1,5 @@ +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the c dependencies. +package gokeep From 28b737f13abacf18a010d0f21fa807e77c5ec12b Mon Sep 17 00:00:00 2001 From: cmgsj Date: Mon, 10 Feb 2025 21:48:30 -0500 Subject: [PATCH 3/3] use bash script to create gokeep files dynamically --- Makefile | 2 +- gokeep.patch | 470 ------------------ parser/build_cgo.go | 49 +- parser/include/gokeep.go | 10 +- parser/include/postgres/access/gokeep.go | 2 +- parser/include/postgres/archive/gokeep.go | 2 +- parser/include/postgres/catalog/gokeep.go | 2 +- parser/include/postgres/commands/gokeep.go | 2 +- parser/include/postgres/common/gokeep.go | 2 +- parser/include/postgres/datatype/gokeep.go | 2 +- parser/include/postgres/executor/gokeep.go | 2 +- parser/include/postgres/foreign/gokeep.go | 2 +- parser/include/postgres/gokeep.go | 32 +- parser/include/postgres/jit/gokeep.go | 2 +- parser/include/postgres/lib/gokeep.go | 2 +- parser/include/postgres/libpq/gokeep.go | 2 +- parser/include/postgres/mb/gokeep.go | 2 +- parser/include/postgres/nodes/gokeep.go | 2 +- parser/include/postgres/optimizer/gokeep.go | 2 +- parser/include/postgres/parser/gokeep.go | 2 +- .../include/postgres/partitioning/gokeep.go | 2 +- .../include/postgres/port/atomics/gokeep.go | 2 +- parser/include/postgres/port/gokeep.go | 9 +- .../postgres/port/win32/arpa/gokeep.go | 2 +- parser/include/postgres/port/win32/gokeep.go | 9 +- .../postgres/port/win32/netinet/gokeep.go | 2 +- .../include/postgres/port/win32/sys/gokeep.go | 2 +- .../postgres/port/win32_msvc/gokeep.go | 2 +- .../postgres/port/win32_msvc/sys/gokeep.go | 2 +- parser/include/postgres/portability/gokeep.go | 2 +- parser/include/postgres/postmaster/gokeep.go | 2 +- parser/include/postgres/regex/gokeep.go | 2 +- parser/include/postgres/replication/gokeep.go | 2 +- parser/include/postgres/rewrite/gokeep.go | 2 +- parser/include/postgres/storage/gokeep.go | 2 +- parser/include/postgres/tcop/gokeep.go | 2 +- parser/include/postgres/tsearch/gokeep.go | 2 +- parser/include/postgres/utils/gokeep.go | 2 +- parser/include/protobuf-c/gokeep.go | 2 +- parser/include/protobuf/gokeep.go | 2 +- parser/include/xxhash/gokeep.go | 2 +- scripts/gokeep.sh | 36 ++ 42 files changed, 118 insertions(+), 567 deletions(-) delete mode 100644 gokeep.patch create mode 100755 scripts/gokeep.sh diff --git a/Makefile b/Makefile index 75d4f5d2..524d39a8 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ update_source: clean $(LIBDIR) # Other support files rm -fr testdata cp -a $(LIBDIR)/testdata testdata - git apply gokeep.patch + bash scripts/gokeep.sh clean: -@ $(RM) -r $(LIB_TMPDIR) diff --git a/gokeep.patch b/gokeep.patch deleted file mode 100644 index 51791219..00000000 --- a/gokeep.patch +++ /dev/null @@ -1,470 +0,0 @@ -diff --git a/parser/include/gokeep.go b/parser/include/gokeep.go -new file mode 100644 -index 0000000..c04672b ---- /dev/null -+++ b/parser/include/gokeep.go -@@ -0,0 +1,13 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -+ -+import ( -+ // Prevent go tooling from stripping out the c source files. -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf-c" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/xxhash" -+) -diff --git a/parser/include/postgres/access/gokeep.go b/parser/include/postgres/access/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/access/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/archive/gokeep.go b/parser/include/postgres/archive/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/archive/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/catalog/gokeep.go b/parser/include/postgres/catalog/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/catalog/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/commands/gokeep.go b/parser/include/postgres/commands/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/commands/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/common/gokeep.go b/parser/include/postgres/common/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/common/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/datatype/gokeep.go b/parser/include/postgres/datatype/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/datatype/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/executor/gokeep.go b/parser/include/postgres/executor/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/executor/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/foreign/gokeep.go b/parser/include/postgres/foreign/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/foreign/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/gokeep.go b/parser/include/postgres/gokeep.go -new file mode 100644 -index 0000000..7959e27 ---- /dev/null -+++ b/parser/include/postgres/gokeep.go -@@ -0,0 +1,35 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -+ -+import ( -+ // Prevent go tooling from stripping out the c source files. -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/access" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/archive" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/catalog" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/commands" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/common" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/datatype" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/executor" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/foreign" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/jit" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/lib" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/libpq" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/mb" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/nodes" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/optimizer" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/parser" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/partitioning" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/portability" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/postmaster" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/regex" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/replication" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/rewrite" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/storage" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tcop" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tsearch" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/utils" -+) -diff --git a/parser/include/postgres/jit/gokeep.go b/parser/include/postgres/jit/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/jit/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/lib/gokeep.go b/parser/include/postgres/lib/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/lib/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/libpq/gokeep.go b/parser/include/postgres/libpq/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/libpq/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/mb/gokeep.go b/parser/include/postgres/mb/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/mb/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/nodes/gokeep.go b/parser/include/postgres/nodes/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/nodes/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/optimizer/gokeep.go b/parser/include/postgres/optimizer/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/optimizer/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/parser/gokeep.go b/parser/include/postgres/parser/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/parser/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/partitioning/gokeep.go b/parser/include/postgres/partitioning/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/partitioning/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/port/atomics/gokeep.go b/parser/include/postgres/port/atomics/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/port/atomics/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/port/gokeep.go b/parser/include/postgres/port/gokeep.go -new file mode 100644 -index 0000000..afee5cd ---- /dev/null -+++ b/parser/include/postgres/port/gokeep.go -@@ -0,0 +1,12 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -+ -+import ( -+ // Prevent go tooling from stripping out the c source files. -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/atomics" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32_msvc" -+) -diff --git a/parser/include/postgres/port/win32/arpa/gokeep.go b/parser/include/postgres/port/win32/arpa/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/port/win32/arpa/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/port/win32/gokeep.go b/parser/include/postgres/port/win32/gokeep.go -new file mode 100644 -index 0000000..ea04b25 ---- /dev/null -+++ b/parser/include/postgres/port/win32/gokeep.go -@@ -0,0 +1,12 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -+ -+import ( -+ // Prevent go tooling from stripping out the c source files. -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/arpa" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/netinet" -+ _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/sys" -+) -diff --git a/parser/include/postgres/port/win32/netinet/gokeep.go b/parser/include/postgres/port/win32/netinet/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/port/win32/netinet/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/port/win32/sys/gokeep.go b/parser/include/postgres/port/win32/sys/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/port/win32/sys/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/port/win32_msvc/gokeep.go b/parser/include/postgres/port/win32_msvc/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/port/win32_msvc/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/port/win32_msvc/sys/gokeep.go b/parser/include/postgres/port/win32_msvc/sys/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/port/win32_msvc/sys/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/portability/gokeep.go b/parser/include/postgres/portability/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/portability/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/postmaster/gokeep.go b/parser/include/postgres/postmaster/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/postmaster/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/regex/gokeep.go b/parser/include/postgres/regex/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/regex/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/replication/gokeep.go b/parser/include/postgres/replication/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/replication/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/rewrite/gokeep.go b/parser/include/postgres/rewrite/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/rewrite/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/storage/gokeep.go b/parser/include/postgres/storage/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/storage/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/tcop/gokeep.go b/parser/include/postgres/tcop/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/tcop/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/tsearch/gokeep.go b/parser/include/postgres/tsearch/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/tsearch/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/postgres/utils/gokeep.go b/parser/include/postgres/utils/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/postgres/utils/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/protobuf-c/gokeep.go b/parser/include/protobuf-c/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/protobuf-c/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/protobuf/gokeep.go b/parser/include/protobuf/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/protobuf/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep -diff --git a/parser/include/xxhash/gokeep.go b/parser/include/xxhash/gokeep.go -new file mode 100644 -index 0000000..66d9b71 ---- /dev/null -+++ b/parser/include/xxhash/gokeep.go -@@ -0,0 +1,5 @@ -+//go:build required -+// +build required -+ -+// package gokeep prevents go tooling from stripping the c dependencies. -+package gokeep diff --git a/parser/build_cgo.go b/parser/build_cgo.go index dba8a548..dc45f708 100644 --- a/parser/build_cgo.go +++ b/parser/build_cgo.go @@ -3,15 +3,52 @@ package parser -// This file exists purely to prevent the golang toolchain from stripping -// away the c source directories and files when `go mod vendor` is used +// This file exists purely to prevent the Golang toolchain from stripping +// away the C source directories and files when `go mod vendor` is used // to populate a `vendor/` directory of a project depending on `github.com/pganalyze/pg_query_go/v6`. // // How it works: -// - every directory which only includes c source files receives a dummy.go file. -// - every directory we want to preserve is included here as a _ import. -// - this file is given a build to exclude it from the regular build. +// - Every directory which only includes C source files receives a gokeep.go file. +// - Every directory we want to preserve is included here as a _ import. +// - This file is given a build tag to exclude it from the regular build. import ( - // Prevent go tooling from stripping out the c source files. + // Prevent Go tooling from stripping out the C source files. _ "github.com/pganalyze/pg_query_go/v6/parser/include" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/access" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/archive" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/catalog" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/commands" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/common" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/datatype" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/executor" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/foreign" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/jit" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/lib" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/libpq" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/mb" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/nodes" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/optimizer" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/parser" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/partitioning" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/atomics" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/arpa" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/netinet" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/sys" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32_msvc" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32_msvc/sys" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/portability" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/postmaster" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/regex" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/replication" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/rewrite" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/storage" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tcop" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tsearch" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/utils" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf-c" + _ "github.com/pganalyze/pg_query_go/v6/parser/include/xxhash" ) diff --git a/parser/include/gokeep.go b/parser/include/gokeep.go index c04672b7..efc76888 100644 --- a/parser/include/gokeep.go +++ b/parser/include/gokeep.go @@ -1,13 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep - -import ( - // Prevent go tooling from stripping out the c source files. - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/protobuf-c" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/xxhash" -) diff --git a/parser/include/postgres/access/gokeep.go b/parser/include/postgres/access/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/access/gokeep.go +++ b/parser/include/postgres/access/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/archive/gokeep.go b/parser/include/postgres/archive/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/archive/gokeep.go +++ b/parser/include/postgres/archive/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/catalog/gokeep.go b/parser/include/postgres/catalog/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/catalog/gokeep.go +++ b/parser/include/postgres/catalog/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/commands/gokeep.go b/parser/include/postgres/commands/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/commands/gokeep.go +++ b/parser/include/postgres/commands/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/common/gokeep.go b/parser/include/postgres/common/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/common/gokeep.go +++ b/parser/include/postgres/common/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/datatype/gokeep.go b/parser/include/postgres/datatype/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/datatype/gokeep.go +++ b/parser/include/postgres/datatype/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/executor/gokeep.go b/parser/include/postgres/executor/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/executor/gokeep.go +++ b/parser/include/postgres/executor/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/foreign/gokeep.go b/parser/include/postgres/foreign/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/foreign/gokeep.go +++ b/parser/include/postgres/foreign/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/gokeep.go b/parser/include/postgres/gokeep.go index 7959e27c..efc76888 100644 --- a/parser/include/postgres/gokeep.go +++ b/parser/include/postgres/gokeep.go @@ -1,35 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep - -import ( - // Prevent go tooling from stripping out the c source files. - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/access" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/archive" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/catalog" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/commands" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/common" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/datatype" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/executor" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/foreign" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/jit" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/lib" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/libpq" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/mb" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/nodes" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/optimizer" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/parser" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/partitioning" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/portability" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/postmaster" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/regex" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/replication" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/rewrite" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/storage" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tcop" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/tsearch" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/utils" -) diff --git a/parser/include/postgres/jit/gokeep.go b/parser/include/postgres/jit/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/jit/gokeep.go +++ b/parser/include/postgres/jit/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/lib/gokeep.go b/parser/include/postgres/lib/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/lib/gokeep.go +++ b/parser/include/postgres/lib/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/libpq/gokeep.go b/parser/include/postgres/libpq/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/libpq/gokeep.go +++ b/parser/include/postgres/libpq/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/mb/gokeep.go b/parser/include/postgres/mb/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/mb/gokeep.go +++ b/parser/include/postgres/mb/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/nodes/gokeep.go b/parser/include/postgres/nodes/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/nodes/gokeep.go +++ b/parser/include/postgres/nodes/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/optimizer/gokeep.go b/parser/include/postgres/optimizer/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/optimizer/gokeep.go +++ b/parser/include/postgres/optimizer/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/parser/gokeep.go b/parser/include/postgres/parser/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/parser/gokeep.go +++ b/parser/include/postgres/parser/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/partitioning/gokeep.go b/parser/include/postgres/partitioning/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/partitioning/gokeep.go +++ b/parser/include/postgres/partitioning/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/port/atomics/gokeep.go b/parser/include/postgres/port/atomics/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/port/atomics/gokeep.go +++ b/parser/include/postgres/port/atomics/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/port/gokeep.go b/parser/include/postgres/port/gokeep.go index afee5cd7..efc76888 100644 --- a/parser/include/postgres/port/gokeep.go +++ b/parser/include/postgres/port/gokeep.go @@ -1,12 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep - -import ( - // Prevent go tooling from stripping out the c source files. - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/atomics" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32_msvc" -) diff --git a/parser/include/postgres/port/win32/arpa/gokeep.go b/parser/include/postgres/port/win32/arpa/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/port/win32/arpa/gokeep.go +++ b/parser/include/postgres/port/win32/arpa/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/port/win32/gokeep.go b/parser/include/postgres/port/win32/gokeep.go index ea04b25e..efc76888 100644 --- a/parser/include/postgres/port/win32/gokeep.go +++ b/parser/include/postgres/port/win32/gokeep.go @@ -1,12 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep - -import ( - // Prevent go tooling from stripping out the c source files. - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/arpa" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/netinet" - _ "github.com/pganalyze/pg_query_go/v6/parser/include/postgres/port/win32/sys" -) diff --git a/parser/include/postgres/port/win32/netinet/gokeep.go b/parser/include/postgres/port/win32/netinet/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/port/win32/netinet/gokeep.go +++ b/parser/include/postgres/port/win32/netinet/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/port/win32/sys/gokeep.go b/parser/include/postgres/port/win32/sys/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/port/win32/sys/gokeep.go +++ b/parser/include/postgres/port/win32/sys/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/port/win32_msvc/gokeep.go b/parser/include/postgres/port/win32_msvc/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/port/win32_msvc/gokeep.go +++ b/parser/include/postgres/port/win32_msvc/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/port/win32_msvc/sys/gokeep.go b/parser/include/postgres/port/win32_msvc/sys/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/port/win32_msvc/sys/gokeep.go +++ b/parser/include/postgres/port/win32_msvc/sys/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/portability/gokeep.go b/parser/include/postgres/portability/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/portability/gokeep.go +++ b/parser/include/postgres/portability/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/postmaster/gokeep.go b/parser/include/postgres/postmaster/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/postmaster/gokeep.go +++ b/parser/include/postgres/postmaster/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/regex/gokeep.go b/parser/include/postgres/regex/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/regex/gokeep.go +++ b/parser/include/postgres/regex/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/replication/gokeep.go b/parser/include/postgres/replication/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/replication/gokeep.go +++ b/parser/include/postgres/replication/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/rewrite/gokeep.go b/parser/include/postgres/rewrite/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/rewrite/gokeep.go +++ b/parser/include/postgres/rewrite/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/storage/gokeep.go b/parser/include/postgres/storage/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/storage/gokeep.go +++ b/parser/include/postgres/storage/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/tcop/gokeep.go b/parser/include/postgres/tcop/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/tcop/gokeep.go +++ b/parser/include/postgres/tcop/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/tsearch/gokeep.go b/parser/include/postgres/tsearch/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/tsearch/gokeep.go +++ b/parser/include/postgres/tsearch/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/postgres/utils/gokeep.go b/parser/include/postgres/utils/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/postgres/utils/gokeep.go +++ b/parser/include/postgres/utils/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/protobuf-c/gokeep.go b/parser/include/protobuf-c/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/protobuf-c/gokeep.go +++ b/parser/include/protobuf-c/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/protobuf/gokeep.go b/parser/include/protobuf/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/protobuf/gokeep.go +++ b/parser/include/protobuf/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/parser/include/xxhash/gokeep.go b/parser/include/xxhash/gokeep.go index 66d9b71f..efc76888 100644 --- a/parser/include/xxhash/gokeep.go +++ b/parser/include/xxhash/gokeep.go @@ -1,5 +1,5 @@ //go:build required // +build required -// package gokeep prevents go tooling from stripping the c dependencies. +// package gokeep prevents go tooling from stripping the C dependencies. package gokeep diff --git a/scripts/gokeep.sh b/scripts/gokeep.sh new file mode 100755 index 00000000..b9858a62 --- /dev/null +++ b/scripts/gokeep.sh @@ -0,0 +1,36 @@ +#!/bin/bash -e + +c_dir="parser/include" + +go_module="$(go list -m)" +go_imports="" + +while IFS='' read -r c_dir; do + go_imports+=" _ \"${go_module}/${c_dir}\""$'\n' + cat <"${c_dir}/gokeep.go" +//go:build required +// +build required + +// package gokeep prevents go tooling from stripping the C dependencies. +package gokeep +EOF +done < <(find ${c_dir} -type f \( -name '*.c' -o -name '*.h' \) -exec dirname {} \; | sort -u) + +cat <"parser/build_cgo.go" +//go:build required +// +build required + +package parser + +// This file exists purely to prevent the Golang toolchain from stripping +// away the C source directories and files when \`go mod vendor\` is used +// to populate a \`vendor/\` directory of a project depending on \`${go_module}\`. +// +// How it works: +// - Every directory which only includes C source files receives a gokeep.go file. +// - Every directory we want to preserve is included here as a _ import. +// - This file is given a build tag to exclude it from the regular build. +import ( + // Prevent Go tooling from stripping out the C source files. +${go_imports}) +EOF