From 346956ca4bae0792c03c35b54b75bdea5350814c Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 9 Oct 2025 01:04:24 -0500 Subject: common protobuf makefile --- Makefile | 38 ++++++-------------------------------- generate.go | 16 ++++++++++++++++ generate.off | 17 ----------------- 3 files changed, 22 insertions(+), 49 deletions(-) create mode 100644 generate.go delete mode 100644 generate.off diff --git a/Makefile b/Makefile index 3485f90..143f2da 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,8 @@ -# You must use the current protoc-gen-go -# -# go-clone --go-src google.golang.org/protobuf -# cd ~/go/src/google.golang.org/protobuf/cmd/protoc-gen-go -# go install +all: set.pb.go goimports vet + @echo This GO code passes the compile checks - -all: forgeConfig.pb.go patch.pb.go set.pb.go goimports vet +set.pb.go: set.proto + make generate generate: clean go mod init @@ -14,37 +11,14 @@ generate: clean go-generate: rm -f *.pb.go *.patch - go get go.wit.com/apps/autogenpb -forgeConfig.pb.go: forgeConfig.proto - autogenpb --proto forgeConfig.proto +goimports: + goimports -w *.go vet: @GO111MODULE=off go vet - @echo this go library package builds okay - -# autofixes your import headers in your golang files -goimports: - goimports -w *.go clean: rm -f *.pb.go *.patch -rm -f go.* go-mod-clean purge - -# patchset.pb.go: patchset.proto -# autogenpb --proto patchset.proto - -patch.pb.go: patch.proto - autogenpb --proto patch.proto - -set.pb.go: set.proto - autogenpb --proto set.proto - -protoc-test: - cd ~/go/src && protoc \ - --proto_path=. \ - --go_out=. \ - --go_opt=Mgo.wit.com/lib/protobuf/forgepb/patchset.proto=go.wit.com/lib/protobuf/forgepb \ - --go_opt=Mgo.wit.com/lib/protobuf/httppb/httpRequest.proto=go.wit.com/lib/protobuf/httppb \ - go.wit.com/lib/protobuf/forgepb/patchset.proto diff --git a/generate.go b/generate.go new file mode 100644 index 0000000..936e322 --- /dev/null +++ b/generate.go @@ -0,0 +1,16 @@ +// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 + +package forgepb + +// NOTE: it would be helpful if go.mod doesn't exist, that go generate +// would automatically run go mod init and go mod tidy +// This would allow directives like 'go install go.wit.com/apps/autogenpb' +// Then this process could be fully automated +// +//go:generate make go-generate +//go:generate autogenpb --proto forgeConfig.proto +//go:generate autogenpb --proto patch.proto +//go:generate autogenpb --proto set.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 6158d14..0000000 --- a/generate.off +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 - -package forgepb - -// 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 go install -v go.wit.com/apps/autogenpb -//go:generate autogenpb --proto forgeConfig.proto -//go:generate autogenpb --proto patch.proto -//go:generate autogenpb --proto set.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