-
Notifications
You must be signed in to change notification settings - Fork 19
/
makefile
133 lines (111 loc) · 3.71 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
# Copyright 2013-2023 Aerospike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
OS = $(shell uname)
SOURCE_ROOT = $(realpath .)
BUILD_ROOT = $(SOURCE_ROOT)/build/
SYMLINK_ASADM = /usr/local/bin/asadm
SYMLINK_ASINFO = /usr/local/bin/asinfo
INSTALL_USER = aerospike
INSTALL_GROUP = aerospike
ifneq (,$(filter $(OS),Darwin))
INSTALL_ROOT = /usr/local/aerospike/bin/
else
INSTALL_ROOT = /opt/aerospike/bin/
endif
SHELL := /bin/bash
define make_build
mkdir -p $(BUILD_ROOT)tmp
mkdir -p $(BUILD_ROOT)bin
make clean
cp -f *.spec $(BUILD_ROOT)tmp/
cp -f *.py $(BUILD_ROOT)tmp/
cp -rf asinfo/* $(BUILD_ROOT)tmp/
rsync -aL lib $(BUILD_ROOT)tmp/
$(if $(filter $(OS),Darwin),
(git describe && sed -i "" s/[$$][$$]__version__[$$][$$]/`git describe`/g $(BUILD_ROOT)tmp/asadm.py) || true ,
(sed -i'' "s/[$$][$$]__version__[$$][$$]/`git describe`/g" $(BUILD_ROOT)tmp/asadm.py) || true
)
$(if $(filter $(OS),Darwin),
(git describe && sed -i "" s/[$$][$$]__version__[$$][$$]/`git describe`/g $(BUILD_ROOT)tmp/asinfo.py) || true ,
(sed -i'' "s/[$$][$$]__version__[$$][$$]/`git describe`/g" $(BUILD_ROOT)tmp/asinfo.py) || true
)
endef
.PHONY: default
default: one-dir
.PHONY: one-file
one-file: init
$(call make_build)
pipenv run bash -c "(cd $(BUILD_ROOT)tmp && pyinstaller pyinstaller-build.spec --distpath $(BUILD_ROOT)bin -- --one-file)"
@echo Check $(BUILD_ROOT)bin for asadm and asinfo executables
# For macOS but can be used for any OS.
.PHONY: one-dir
one-dir: init
$(call make_build)
pipenv run bash -c "(cd $(BUILD_ROOT)tmp && pyinstaller pyinstaller-build.spec --distpath $(BUILD_ROOT)bin)"
mv $(BUILD_ROOT)bin/asinfo/asinfo $(BUILD_ROOT)bin/asadm/asinfo
rm -r $(BUILD_ROOT)bin/asinfo
@echo Check $(BUILD_ROOT)bin for bundle
.PHONY: init
init:
pipenv install --dev
# pipenv check
pipenv graph
UNIT_TEST_CMD=pytest --disable-warnings test/unit
E2E_TEST_CMD=pytest --disable-warnings test/e2e/live_cluster
COVERAGE_CONF=$(SOURCE_ROOT)/tox.ini
.PHONY: unit
unit:
$(UNIT_TEST_CMD)
.PHONY: integration
integration:
FEATKEY=$(FEATKEY) $(E2E_TEST_CMD)
.PHONY: unit-cov
unit-cov:
coverage run --module $(UNIT_TEST_CMD)
.PHONY: integration-cov
integration-cov:
COVERAGE_PROCESS_START=$(COVERAGE_CONF) FEATKEY=$(FEATKEY) coverage run --module $(E2E_TEST_CMD)
.PHONY: coverage
coverage:
coverage erase
make unit-cov
make integration-cov
coverage combine
.PHONY: install
install: uninstall
install -d -m 755 $(INSTALL_ROOT)
ifneq ($(wildcard $(BUILD_ROOT)bin/asadm/*),)
@echo "Asadm and Asinfo were built in one-dir mode"
cp -r $(BUILD_ROOT)bin/asadm $(INSTALL_ROOT)asadm
ln -sf $(INSTALL_ROOT)asadm/asadm $(SYMLINK_ASADM)
ln -sf $(INSTALL_ROOT)asadm/asinfo $(SYMLINK_ASINFO)
else
@echo "Asadm and Asinfo were built in one-file mode"
install -m 755 $(BUILD_ROOT)bin/asadm $(INSTALL_ROOT)asadm
install -m 755 $(BUILD_ROOT)bin/asinfo $(INSTALL_ROOT)asinfo
ln -sf $(INSTALL_ROOT)asadm $(SYMLINK_ASADM)
ln -sf $(INSTALL_ROOT)asinfo $(SYMLINK_ASINFO)
endif
.PHONY: uninstall
uninstall:
rm -r $(INSTALL_ROOT)asadm || true
rm -r $(INSTALL_ROOT)asinfo || true
rm $(SYMLINK_ASADM) || true
rm $(SYMLINK_ASINFO) || true
.PHONY: clean
clean:
rm -rf $(BUILD_ROOT)tmp/*
rm -rf $(BUILD_ROOT)bin/*
rm -f `find . -type f -name '*.pyc' | xargs`
pipenv clean