From: Moritz Poldrack <git@moritz.sh>
Signed-off-by: Moritz Poldrack <git@moritz.sh>
---
- leverage make for generating source files automatically
- make using alternative go compilers easier (for example go-gcc)
- add GO_FLAGS to allow for supplying additional flags to go build
Makefile | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index ed9a7a4..8305cff 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,31 @@
+GO := $(shell which go || echo go)
+GO_FLAGS := -trimpath
+go_src := $(shell $(GO) list -f '{{$$Dir := .Dir}}{{range .GoFiles}}{{$$Dir}}/{{.}} {{end}}' ./...)
+go_src += go.mod go.sum graph client
+
all: abused abused-keygen abused-bootstrap
-abused:
- go build -o abused ./cmd/abused/
+abused: $(go_src)
+ $(GO) build $(GO_FLAGS) -o $@ ./cmd/$@
-abused-bootstrap:
- go build -o abused-bootstrap ./cmd/abused-bootstrap/
+abused-keygen: $(go_src)
+ $(GO) build $(GO_FLAGS) -o $@ ./cmd/$@
-abused-keygen:
- go build -o abused-keygen ./cmd/abused-keygen/
+abused-bootstrap: $(go_src)
+ $(GO) build $(GO_FLAGS) -o $@ ./cmd/$@
server: abused
./abused
-.PHONY: abused abused-keygen abused-bootstrap
+graph: gqlgen.yml graph/schema.graphqls
+ $(GO) run github.com/99designs/gqlgen generate --config gqlgen.yml
+ @touch graph
+
+client: client/queries.graphql graph/schema.graphqls
+ $(GO) run git.sr.ht/~emersion/gqlclient/cmd/gqlclientgen \
+ -s ../graph/schema.graphqls \
+ -q queries.graphql \
+ -o $@
+ @touch client
+
.PHONY: all server
--
2.43.2
Are these features supported outside of GNU make?