-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (51 loc) · 1.8 KB
/
Makefile
File metadata and controls
67 lines (51 loc) · 1.8 KB
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
# include .env #if there is a .env file uncomment this line
PROJECTNAME=$(shell basename "$(PWD)")
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
SERVER_FILES = ./grpc-chatapp/server/
CLIENT_FILES = ./grpc-chatapp/client/
GOBIN=./bin
# Redirect error output to a file, so we can show it in development mode.
STDERR=/tmp/.$(PROJECTNAME)-stderr.txt
go-clean:
@echo " > Cleaning build cache"
@GOBIN=$(GOBIN) go clean
help: Makefile
@echo "\nChoose a command run in "$(PROJECTNAME)":\n"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
go-compile-server: go-build-server
go-build-server:
@echo " > Building server binary..."
@GOBIN=$(GOBIN) go build -o $(GOBIN)/server $(SERVER_FILES)
## build-server: Building the Server binary.
build-server:
@-touch $(STDERR)
@-rm $(STDERR)
@-$(MAKE) -s go-compile-server 2> $(STDERR)
@cat $(STDERR) | sed -e '1s/.*/\nError:\n/' | sed 's/make\[.*/ /' | sed "/^/s/^/ /" 1>&2
## run-server: Build and run the Server binary
run-server: build-server
@echo " > Running server binary..."
@-$(GOBIN)/server
go-compile-client: go-build-client
go-build-client:
@echo " > Building client binary..."
@GOBIN=$(GOBIN) go build -o $(GOBIN)/client $(CLIENT_FILES)
## build-client: Building the Client binary.
build-client:
@-touch $(STDERR)
@-rm $(STDERR)
@-$(MAKE) -s go-compile-client 2> $(STDERR)
@cat $(STDERR) | sed -e '1s/.*/\nError:\n/' | sed 's/make\[.*/ /' | sed "/^/s/^/ /" 1>&2
## run-client: Build and run the Client binary
run-client: build-client
@echo " > Running client binary..."
@-$(GOBIN)/client
## exec: Run given command, wrapped with custom GOPATH. e.g; make exec run="go test ./..."
exec:
@GOBIN=$(GOBIN) $(run)
## clean: Clean build files. Runs `go clean` internally.
clean: go-clean