-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·100 lines (80 loc) · 3.34 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
#!/bin/bash
echo "installing required tools..."
go install github.com/mna/pigeon
if [ $? -ne 0 ]; then
echo "...error"
fi
go install github.com/czcorpus/manabuild@latest
if [ $? -eq 0 ]; then
echo "...done"
else
echo "...error"
fi
echo "generating parser code..."
go generate ./cmd/service/fcs.go
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
.PHONY: clean tools
all: test-and-build
build:
@echo "building the project without running unit tests"
@go generate ./cmd/service/fcs.go
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go build -o mquery-sru ./cmd/service
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 ./... | grep -v "github.com/czcorpus/mquery-sru/cmd/testing" | tr '\n' ' ')
@go generate ./cmd/service/fcs.go
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go build -o mquery-sru ./cmd/service
tools:
@echo "installing local dependencies"
@go install github.com/mna/pigeon
@go install github.com/czcorpus/manabuild@latest
manatee-src:
manabuild -no-build
generate:
@echo "generating query parser code"
@go generate ./cmd/service/fcs.go
install:
@mkdir -p /opt/mquery-sru
@cp -f mquery-sru /opt/mquery-sru
@cp -n conf.sample.json /opt/mquery-sru/conf.json
@cp -rf assets /opt/mquery-sru
@mkdir -p /opt/mquery-sru/handler/v12
@mkdir -p /opt/mquery-sru/handler/v20
@cp -rf handler/v12/templates /opt/mquery-sru/handler/v12
@cp -rf handler/v20/templates /opt/mquery-sru/handler/v20
@cp -rn scripts /opt/mquery-sru
@ln -sf /opt/mquery-sru/scripts/systemd/mquery-sru-server.service /etc/systemd/system/mquery-sru-server.service
@ln -sf /opt/mquery-sru/scripts/systemd/mquery-sru-worker-all.target /etc/systemd/system/mquery-sru-worker-all.target
@ln -sf /opt/mquery-sru/scripts/systemd/mquery-sru-worker@.service /etc/systemd/system/mquery-sru-worker@.service
@systemctl enable mquery-sru-server
@systemctl enable mquery-sru-worker-all.target
clean:
@systemctl disable mquery-sru-server
@systemctl disable mquery-sru-worker-all.target
@rm -rf /etc/systemd/system/mquery-sru-server.service
@rm -rf /etc/systemd/system/mquery-sru-worker-all.target
@rm -rf /etc/systemd/system/mquery-sru-worker@.service
@rm -rf /opt/mquery-sru
test:
@echo "running unit tests"
@CGO_CXXFLAGS="${CGO_CXXFLAGS}" CGO_CPPFLAGS="${CGO_CPPFLAGS}" CGO_LDFLAGS="${CGO_LDFLAGS}" go test $(go list ./... | grep -v "github.com/czcorpus/mquery-sru/cmd/testing" | 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 ./... | grep -v "github.com/czcorpus/mquery-sru/cmd/testing" | 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."