-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·121 lines (95 loc) · 3.31 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
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
#!/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
go install github.com/swaggo/swag/cmd/swag@latest
if [ $? -eq 0 ]; then
echo "...done"
else
echo "...error"
fi
swag init -g mquery.go --parseDependency
if [ $? -eq 0 ]; then
echo "...done"
else
echo "...error"
fi
# check system and prepare env variables
WITH_PCRE2=false
for arg in "$@"; do
case $arg in
--with-pcre2)
WITH_PCRE2=true
shift
;;
esac
done
if [ "$WITH_PCRE2" = true ]; then
eval $(manabuild -no-build -with-pcre2)
else
eval $(manabuild -no-build)
fi
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 without running unit tests and without regenerating OpenAPI"
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go build \${LDFLAGS} -o mquery
test-and-build:
@echo "generating OpenAPI documentation"
swag init --parseDependency -g apiserver.go
@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
@go install github.com/swaggo/swag/cmd/swag@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/[email protected] /etc/systemd/system/[email protected]
@systemctl enable mquery-server
@systemctl enable mquery-worker-all.target
uninstall:
@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/[email protected]
@rm -rf /opt/mquery
clean:
rm -rf docs/*
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."