-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
41 lines (31 loc) · 1.2 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
GOPATH := $(shell go env GOPATH)
GOBIN := $(if $(GOPATH),$(GOPATH)/bin,/usr/local/bin)
go_sources := $(shell find cmd encoding gen genid version wasm -name "*.go")
ifdef VERSION
LDFLAGS := -ldflags="-X github.com/knqyf263/go-plugin/version.Version=${VERSION}"
endif
.PHONY: build
build: $(GOBIN)/protoc-gen-go-plugin
$(GOBIN)/protoc-gen-go-plugin: $(go_sources)
go build ${LDFLAGS} -o $(GOPATH)/bin/protoc-gen-go-plugin cmd/protoc-gen-go-plugin/main.go
tinygo_examples := $(shell find examples -path "*/plugin*/*.go")
.PHONY: build.examples
build.examples: $(tinygo_examples:.go=.wasm)
tinygo_tests := $(shell find tests -path "*/plugin*/*.go")
.PHONY: build.tests
build.tests: $(tinygo_tests:.go=.wasm)
%.wasm: %.go $(GOBIN)/protoc-gen-go-plugin
tinygo build -o $@ -scheduler=none --no-debug --target=wasi $<
proto_files := $(shell find . -name "*.proto")
.PHONY: protoc
protoc: $(proto_files:.proto=.pb.go) $(proto_files:.proto=_vtproto.pb.go)
%.pb.go: %.proto $(GOBIN)/protoc-gen-go-plugin
protoc --go-plugin_out=. --go-plugin_opt=paths=source_relative $<;
.PHONY: fmt
fmt: $(proto_files)
@for f in $^; do \
clang-format -i $$f; \
done
.PHONY: test
test: build.tests build.examples
go test -v -short ./...