forked from shieldproject/shield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
149 lines (118 loc) · 4.64 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Run me to verify that all tests pass and all binaries are buildable before pushing!
# If you do not, then Travis will be sad.
BUILD_TYPE?=build
# Everything; this is the default behavior
all: format shieldd shield shield-agent shield-schema shield-migrate shield-crypt shield-report plugins test
# go fmt ftw
format:
go list ./... | grep -v vendor | xargs go fmt
# Running Tests
test: go-tests api-tests plugin-tests
plugin-tests: plugins
go build ./plugin/mock
./t/plugins
@rm -f mock
go-tests: shield
export PATH=$$PATH:test/bin; go list ./... | grep -v vendor | xargs go test
api-tests: shieldd shield-schema shield-crypt shield-agent shield-report
./t/api
# Running Tests for race conditions
race:
ginkgo -race *
# Building Shield
shield: shieldd shield-agent shield-schema shield-crypt shield-report
shield-crypt:
go $(BUILD_TYPE) ./cmd/shield-crypt
shieldd:
go $(BUILD_TYPE) ./cmd/shieldd
shield-agent:
go $(BUILD_TYPE) ./cmd/shield-agent
shield-schema:
go $(BUILD_TYPE) ./cmd/shield-schema
shield-migrate:
go $(BUILD_TYPE) ./cmd/shield-migrate
shield-report:
go $(BUILD_TYPE) ./cmd/shield-report
shield: cmd/shield/help.go
go $(BUILD_TYPE) ./cmd/shield
help.all: cmd/shield/main.go
grep case $< | grep '{''{{' | cut -d\" -f 2 | sort | xargs -n1 -I@ ./shield @ -h > $@
# Building Plugins
plugin: plugins
plugins:
go $(BUILD_TYPE) ./plugin/dummy
for plugin in $$(cat plugins); do \
go $(BUILD_TYPE) ./plugin/$$plugin; \
done
demo: clean shield plugins
./demo/build
(cd demo && docker-compose up)
docs: docs/API.md
docs/API.md: docs/API.yml
perl ./docs/regen.pl <$+ >$@~
mv $@~ $@
clean:
rm -f shield shieldd shield-agent shield-schema shield-crypt shield-migrate shield-report
rm -f $$(cat plugins) dummy
# Assemble the CLI help with some assistance from our friend, Perl
HELP := $(shell ls -1 cmd/shield/help/*)
cmd/shield/help.go: $(HELP) cmd/shield/help.pl
./cmd/shield/help.pl $(HELP) > $@
# Run tests with coverage tracking, writing output to coverage/
coverage: agent.cov db.cov plugin.cov supervisor.cov timespec.cov
%.cov:
@mkdir -p coverage
@go test -coverprofile coverage/$@ ./$*
report:
go tool cover -html=coverage/$(FOR).cov
fixmes: fixme
fixme:
@grep -rn FIXME * | grep -v vendor/ | grep -v README.md | grep --color FIXME || echo "No FIXMES! YAY!"
dev:
./bin/testdev
# Deferred: Naming plugins individually, e.g. make plugin dummy
init:
go get github.com/kardianos/govendor
go install github.com/kardianos/govendor
save-deps:
govendor add +external
ARTIFACTS := artifacts/shield-server-linux-amd64
LDFLAGS := -X main.Version=$(VERSION)
release:
@echo "Checking that VERSION was defined in the calling environment"
@test -n "$(VERSION)"
@echo "OK. VERSION=$(VERSION)"
@echo "Compiling SHIELD Linux Server Distribution..."
export GOOS=linux GOARCH=amd64
for plugin in $$(cat plugins); do \
go build -ldflags="$(LDFLAGS)" -o "$(ARTIFACTS)/plugins/$$plugin" ./plugin/$$plugin; \
done
go build -ldflags="$(LDFLAGS)" -o "$(ARTIFACTS)/crypter/shield-crypt" ./cmd/shield-crypt
go build -ldflags="$(LDFLAGS)" -o "$(ARTIFACTS)/agent/shield-agent" ./cmd/shield-agent
go build -ldflags="$(LDFLAGS)" -o "$(ARTIFACTS)/agent/shield-report" ./cmd/shield-report
CGO_ENABLED=1 go build -ldflags="$(LDFLAGS)" -o "$(ARTIFACTS)/daemon/shield-schema" ./cmd/shield-schema
CGO_ENABLED=1 go build -ldflags="$(LDFLAGS)" -o "$(ARTIFACTS)/daemon/shield-migrate" ./cmd/shield-migrate
CGO_ENABLED=1 go build -ldflags="$(LDFLAGS)" -o "$(ARTIFACTS)/daemon/shieldd" ./cmd/shieldd
@echo "Compiling SHIELD CLI For Linux and macOS..."
GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o artifacts/shield-linux-amd64 ./cmd/shield
GOOS=darwin GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o artifacts/shield-darwin-amd64 ./cmd/shield
mkdir -p "$(ARTIFACTS)/cli"
cp artifacts/shield-linux-amd64 "$(ARTIFACTS)/cli/shield"
@echo "Assembling Linux Server Distribution..."
rm -f artifacts/*.tar.gz
cd artifacts && for x in shield-server-*; do \
cp -a ../web2/htdocs $$x/webui; \
mkdir -p $$x/webui/cli/linux; cp ../artifacts/shield-linux-amd64 $$x/webui/cli/linux/shield; \
mkdir -p $$x/webui/cli/mac; cp ../artifacts/shield-darwin-amd64 $$x/webui/cli/mac/shield; \
cp ../bin/shield-pipe $$x/daemon; \
tar -czvf $$x.tar.gz $$x; \
rm -r $$x; \
done
JAVASCRIPTS := web2/src/js/jquery.js
JAVASCRIPTS += web2/src/js/lib.js
JAVASCRIPTS += web2/src/js/sticky-nav.js
JAVASCRIPTS += web2/src/js/shield.js
web2/htdocs/shield.js: $(JAVASCRIPTS)
cat $+ >$@
web2: web2/htdocs/shield.js
.PHONY: plugins dev web2 shield shieldd shield-schema shield-agent shield-crypt shield-report demo