-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·85 lines (65 loc) · 2.72 KB
/
configure
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
#!/bin/bash
echo "installing required tools..."
if [ $? -ne 0 ]; then
echo "...error"
fi
go install github.com/czcorpus/manabuild@latest
if [ $? -eq 0 ]; then
echo "...done"
else
echo "...error"
fi
# check system and prepare env variables
eval $(manabuild -no-build)
cat > Makefile <<EOF
# Makefile content generated by configure
VERSION=\`git describe --tags\`
BUILD=\`date +%FT%T%z\`
HASH=\`git rev-parse --short HEAD\`
LDFLAGS=-ldflags "-w -s -X main.version=\${VERSION} -X main.buildDate=\${BUILD} -X main.gitCommit=\${HASH}"
.PHONY: clean tools
all: test-and-build
build:
@echo "building the project without running unit tests"
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go build \${LDFLAGS} -o mquery
test-and-build:
@echo "running unit tests and building the project"
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go test $(go list ./... | tr '\n' ' ')
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go build \${LDFLAGS} -o mquery
tools:
@echo "installing local dependencies"
@go install github.com/czcorpus/manabuild@latest
manatee-src:
manabuild -no-build
install:
@mkdir -p /opt/mquery
@cp -f mquery /opt/mquery
@cp -n conf.sample.json /opt/mquery/conf.json
@cp -rn scripts /opt/mquery
@ln -sf /opt/mquery/scripts/systemd/mquery-server.service /etc/systemd/system/mquery-server.service
@ln -sf /opt/mquery/scripts/systemd/mquery-worker-all.target /etc/systemd/system/mquery-worker-all.target
@ln -sf /opt/mquery/scripts/systemd/mquery-worker@.service /etc/systemd/system/mquery-worker@.service
@systemctl enable mquery-server
@systemctl enable mquery-worker-all.target
clean:
@systemctl disable mquery-server
@systemctl disable mquery-worker-all.target
@rm -rf /etc/systemd/system/mquery-server.service
@rm -rf /etc/systemd/system/mquery-worker-all.target
@rm -rf /etc/systemd/system/mquery-worker@.service
@rm -rf /opt/mquery
test:
@echo "running unit tests"
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go test $(go list ./... | tr '\n' ' ')
rtest:
@echo "running unit tests with the -race setting"
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go test -race $(go list ./... | tr '\n' ' ')
itest:
@echo "running integration tests"
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go test -v ./cmd/testing --args http://localhost:8989/
build-docker-itest:
docker-compose -f docker-compose-itest.yml build
run-docker-itest:
docker-compose -f docker-compose-itest.yml up
EOF
echo "Configuration successful. Run make to build the project."