From 67eea3ecc975ed1ce2f16b0a684dd5a8e9dfc6e5 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 9 Oct 2025 01:04:00 -0500 Subject: common protobuf makefile --- Makefile | 28 ++++++++++++++++------------ generate.go | 13 +++++++++++++ generate.off | 13 ------------- 3 files changed, 29 insertions(+), 25 deletions(-) create mode 100644 generate.go delete mode 100644 generate.off diff --git a/Makefile b/Makefile index 5aac59a..9056ed1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,16 @@ -all: goimports vet +all: chat.pb.go goimports vet + @echo This GO code passes the compile checks + +# fixes your numbers if you move things around +# THIS TOTALLY BREAKS THE POINT OF PROTOBUF +# To work around that breaking, you must change the version +# also, all the wrapping code must support this. which it doesn't +proto-renumber: clean + autogenpb --renumber --proto chat.proto + make goimports vet + +chat.pb.go: chat.proto + make generate generate: clean go mod init @@ -8,21 +20,13 @@ generate: clean go-generate: rm -f *.pb.go *.patch -# all: clean chat.pb.go book.pb.go goimports vet - goimports: goimports -w *.go -chat.pb.go: chat.proto - autogenpb --proto chat.proto - -book.pb.go: book.proto - autogenpb --proto book.proto +vet: + @GO111MODULE=off go vet clean: rm -f *.pb.go *.patch -rm -f go.* - -vet: - @GO111MODULE=off go vet - @echo this go library package builds okay + go-mod-clean purge diff --git a/generate.go b/generate.go new file mode 100644 index 0000000..fe9787a --- /dev/null +++ b/generate.go @@ -0,0 +1,13 @@ +package chatpb + +// NOTE: it would be helpful if go.mod doesn't exist, that go generate +// would automatically run go mod init and go mod tidy +// and allow directives to 'go get go.wit.com/apps/autogenpb' +// then this process could be fully automated +// +//go:generate make go-generate +//go:generate autogenpb --proto chat.proto +//go:generate autogenpb --proto book.proto +// # go:generate go get golang.org/x/tools # repo seems broken at this time (?) +// # go:generate go install -v golang.org/x/tools/cmd/goimports +//go:generate bash -c "goimports -w *.go" diff --git a/generate.off b/generate.off deleted file mode 100644 index fe9787a..0000000 --- a/generate.off +++ /dev/null @@ -1,13 +0,0 @@ -package chatpb - -// NOTE: it would be helpful if go.mod doesn't exist, that go generate -// would automatically run go mod init and go mod tidy -// and allow directives to 'go get go.wit.com/apps/autogenpb' -// then this process could be fully automated -// -//go:generate make go-generate -//go:generate autogenpb --proto chat.proto -//go:generate autogenpb --proto book.proto -// # go:generate go get golang.org/x/tools # repo seems broken at this time (?) -// # go:generate go install -v golang.org/x/tools/cmd/goimports -//go:generate bash -c "goimports -w *.go" -- cgit v1.2.3