1
1
#
2
2
# Makefile to perform "live code reloading" after changes to .go files.
3
3
#
4
- # n.b. you must install fswatch (OS X: `brew install fswatch`)
5
- #
6
4
# To start live reloading run the following command:
7
5
# $ make serve
8
6
#
@@ -15,14 +13,10 @@ mb_hash := $(shell git rev-parse --short HEAD)
15
13
PROG = mediagui
16
14
17
15
# targets not associated with files
18
- .PHONY : dependencies default build test coverage clean kill restart serve
19
-
20
- # check we have a couple of dependencies
21
- dependencies :
22
- @command -v fswatch --version > /dev/null 2>&1 || { printf >&2 " fswatch is not installed, please run: brew install fswatch\n" ; exit 1; }
16
+ .PHONY : default build test coverage clean kill restart serve
23
17
24
18
# default targets to run when only running `make`
25
- default : dependencies test
19
+ default : test
26
20
27
21
# clean up
28
22
clean :
@@ -32,27 +26,27 @@ protobuf:
32
26
protoc -I mediaagent/ mediaagent/agent.proto --go_out=plugins=grpc:mediaagent
33
27
34
28
# run formatting tool and build
35
- build : dependencies clean
29
+ build : clean
36
30
go build fmt
37
31
go build -ldflags " -X main.Version=$( mb_version) -$( mb_count) .$( mb_hash) " -v -o ${PROG}
38
32
39
- buildx : dependencies clean
33
+ buildx : clean
40
34
go build fmt
41
35
env GOOS=linux GOARCH=amd64 go build -ldflags " -X main.Version=$( mb_version) -$( mb_count) .$( mb_hash) " -v -o ${PROG}
42
36
43
- agentx : dependencies clean
37
+ agentx : clean
44
38
env GOOS=linux GOARCH=amd64 go build -tags agent -ldflags " -X main.Version=$( mb_version) -$( mb_count) .$( mb_hash) " -v -o agentx agent.go
45
39
46
- agent : dependencies clean
40
+ agent : clean
47
41
go build -tags agent -ldflags " -X main.Version=$( mb_version) -$( mb_count) .$( mb_hash) " -v -o agentx agent.go
48
42
49
- release : dependencies clean
43
+ release : clean
50
44
go build fmt
51
45
go build -ldflags " -X main.Version=$( mb_version) -$( mb_count) .$( mb_hash) " -v -o ${PROG}
52
46
env GOOS=linux GOARCH=amd64 go build -tags agent -ldflags " -X main.Version=$( mb_version) -$( mb_count) .$( mb_hash) " -v -o agentx agent.go
53
47
54
48
# run unit tests with code coverage
55
- test : dependencies
49
+ test :
56
50
go test -v
57
51
58
52
# generate code coverage report
68
62
restart :
69
63
@make kill
70
64
@make build; (if [ " $$ ?" -eq 0 ]; then (env GIN_MODE=debug ./${PROG} & ); fi)
71
-
72
- # watch .go files for changes then recompile & try to start server
73
- # will also kill server after ctrl+c
74
- serve : dependencies
75
- @make restart
76
- @fswatch -o ./* .go ./services/* .go ./lib/* .go ./dto/* .go | xargs -n1 -I{} make restart || make kill
77
65
78
66
publish : build
79
67
cp ./${PROG} ~ /bin
0 commit comments