From 8d1e4087074460e053b89d51a4cac674ce35bbe9 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 9 Oct 2025 01:04:34 -0500 Subject: common protobuf makefile --- Makefile | 66 +++++++++--------------------------------------------------- generate.go | 14 +++++++++++++ generate.off | 14 ------------- 3 files changed, 23 insertions(+), 71 deletions(-) create mode 100644 generate.go delete mode 100644 generate.off diff --git a/Makefile b/Makefile index 2bfbfeb..dcba6f2 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: repo.pb.go goimports vet + @echo This GO code passes the compile checks - -all: gitTag.pb.go goDep.pb.go repo.pb.go goimports vet +repo.pb.go: repo.proto + make generate generate: clean go mod init @@ -15,58 +12,13 @@ generate: clean go-generate: rm -f *.pb.go *.patch -vet: - @GO111MODULE=off go vet - @echo this go library package builds okay - -# autofixes your import headers in your golang files goimports: goimports -w *.go -# dump autogenerated files and potential patches +vet: + @GO111MODULE=off go vet + clean: - rm -f *.pb.go go.* *.patch + rm -f *.pb.go *.patch + -rm -f go.* go-mod-clean purge - -#refs.pb.go: refs.proto -# cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/lib/protobuf/gitpb \ -# --go_opt=Mrefs.proto=go.wit.com/lib/protobuf/gitpb \ -# refs.proto - -gitTag.pb.go: gitTag.proto - autogenpb --proto gitTag.proto --mutex-name "john" - -goDep.pb.go: goDep.proto - autogenpb --proto goDep.proto - -repo.pb.go: repo.proto - autogenpb --proto repo.proto - -protoc-bad: - cd ~/go/src && protoc \ - --proto_path=. \ - --proto_path=go.wit.com/lib/protobuf/gitpb \ - --go_out=. \ - --go_opt=Mgo.wit.com/lib/protobuf/gitpb/repo.proto=go.wit.com/lib/protobuf/gitpb \ - --go_opt=MgitTag.proto=go.wit.com/lib/protobuf/gitpb \ - --go_opt=MgoDep.proto=go.wit.com/lib/protobuf/gitpb \ - go.wit.com/lib/protobuf/gitpb/repo.proto - -protoc-good: - cd ~/go/src && protoc \ - --proto_path=. \ - --go_out=go.wit.com/lib/protobuf/gitpb \ - --go_opt=Mrepo.proto=go.wit.com/lib/protobuf/gitpb \ - --go_opt=MgitTag.proto=go.wit.com/lib/protobuf/gitpb \ - --go_opt=MgoDep.proto=go.wit.com/lib/protobuf/gitpb \ - go.wit.com/lib/protobuf/gitpb/repo.proto - -protoc-todo-move-to-this: - # I think I should seperate these dirs. ONLY ONE .proto FILE PER DIRECTORY - # - httppb.HttpRequest httpRequest = 4; // correct syntax - 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..f868e90 --- /dev/null +++ b/generate.go @@ -0,0 +1,14 @@ +package gitpb + +// 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 repo.proto +//go:generate autogenpb --proto goDep.proto +//go:generate autogenpb --proto gitTag.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 f868e90..0000000 --- a/generate.off +++ /dev/null @@ -1,14 +0,0 @@ -package gitpb - -// 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 repo.proto -//go:generate autogenpb --proto goDep.proto -//go:generate autogenpb --proto gitTag.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