-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
87 lines (73 loc) · 2.8 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# This Makefile is an easy way to run common operations.
# Execute commands like this:
# * make
# * make install
# * make generate
# * make test
# * make test-all
# * make update-children
# * make update-all
# Load the environment variables.
include .env
.PHONY: default
default: generate
################################################################################
# Common
################################################################################
# Install dependencies.
.PHONY: install
install: protoc-install tidy
# Test the repo.
.PHONY: test
test:
go test -race ./...
# Test all the code.
.PHONY: test-all
test-all:
go test -race ./...
cd ../plugin && go test -race ./...
cd ../ambient-template && go test -race ./...
cd ../amb && go test -race ./...
cd ../away && go test -race ./...
################################################################################
# Update dependencies
################################################################################
# Update dependencies of other repos using Ambient.
.PHONY: update-children
update-children:
cd ../plugin && go get github.com/ambientkit/ambient@$(shell cd ../ambient && git rev-parse HEAD) && go mod tidy -compat=1.17
cd ../ambient-template && go get github.com/ambientkit/ambient@$(shell cd ../ambient && git rev-parse HEAD) && go mod tidy -compat=1.17
cd ../ambient-template && go get github.com/ambientkit/plugin@$(shell cd ../plugin && git rev-parse HEAD) && go mod tidy -compat=1.17
cd ../amb && go get github.com/ambientkit/ambient@$(shell cd ../ambient && git rev-parse HEAD) && go mod tidy -compat=1.17
cd ../amb && go get github.com/ambientkit/plugin@$(shell cd ../plugin && git rev-parse HEAD) && go mod tidy -compat=1.17
# Update all Go dependencies.
.PHONY: update-all
update-all: update-all-go tidy
# Update all Go dependencies.
.PHONY: update-all-go
update-all-go:
go get -u -f -d ./...
# Run go mod tidy.
.PHONY: tidy
tidy:
go mod tidy -compat=1.17
################################################################################
# gRPC
################################################################################
# Install protoc to project bin folder to allow generating a Go file from proto file.
.PHONY: protoc-install
protoc-install:
mkdir -p ./bin
curl -s -o protoc.zip -L https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-osx-x86_64.zip
unzip -q protoc.zip -d tempdir
rm protoc.zip
cp tempdir/bin/protoc ./bin/
cp -r tempdir/include ./bin/
rm -r tempdir
GOBIN=$(shell pwd)/bin go install github.com/golang/protobuf/protoc-gen-go@latest
# Generate the Go code, grpc code, and tidy.
.PHONY: generate
generate:
go generate ./...
@PATH="${PATH}:$(shell pwd)/bin" && protoc -I pkg/grpcp/protobuf/ pkg/grpcp/protobuf/*.proto --go_out=plugins=grpc:pkg/grpcp/protodef/
go mod tidy -compat=1.17