-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
42 lines (31 loc) · 1.34 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
42
.PHONY: clean proto test lint wasirun
GO ?= go
GOPATH ?= $(shell $(GO) env GOPATH)
wasirun = $(GOPATH)/bin/wasirun
packages.dir = $(filter-out examples/,$(filter-out testdata/,$(wildcard */)))
packages.test = $(packages.dir:/=.test)
test: proto wasirun $(packages.test)
@for pkg in $(packages.test); do \
tmp=$$(mktemp); \
$(wasirun) --dir=/ --dns-server=127.0.0.1:5453 $$pkg > $$tmp; \
if (($$?)); then cat $$tmp; exit 1; else printf "ok\tgithub.com/stealthrocket/net/$$pkg\n"; fi \
done
# go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
grpc.proto = $(wildcard grpc/*.proto)
grpc.pb.go = $(grpc.proto:.proto=_grpc.pb.go)
# go install github.com/containerd/ttrpc/cmd/protoc-gen-go-ttrpc@latest
ttrpc.proto = $(wildcard ttrpc/*.proto)
ttrpc.pb.go = $(ttrpc.proto:.proto=_ttrpc.pb.go)
clean:
rm -f *.test
proto: $(grpc.pb.go) $(ttrpc.pb.go)
wasirun: $(wasirun)
$(wasirun):
$(GO) install github.com/stealthrocket/wasi-go/cmd/wasirun@latest
%.test: %/
cd $< && GOARCH=wasm GOOS=wasip1 $(GO) test -c -o ../$(notdir $@)
%_grpc.pb.go: %.proto
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative $<
%_ttrpc.pb.go: %.proto
protoc --go_out=. --go_opt=paths=source_relative --go-ttrpc_out=. --go-ttrpc_opt=paths=source_relative $<