-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (44 loc) · 1.69 KB
/
Copy pathMakefile
File metadata and controls
58 lines (44 loc) · 1.69 KB
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
BUILD_DIR=build
CMAKE_BUILD_DIR=$(BUILD_DIR)/cmake
BUILD_TYPE=Release
EXTRA_FLAGS=
VENV=.venv
VENV_ABS_PATH=$(abspath $(VENV))
# https://stackoverflow.com/questions/70675848/makefile-throws-an-error-for-checking-the-os
# https://venthur.de/2021-03-31-python-makefiles.html
# OS agnostic
ifeq ($(OS), Windows_NT)
PYTHON=python
VENV_BIN=$(VENV)/Scripts
COMPILED_OPERATORS=operators.%.pyd
else # Linux
PYTHON=python3
VENV_BIN=$(VENV)/bin
COMPILED_OPERATORS=operators.%.so
endif
all: test_package_cmake test
.PHONY: all clean setup test test_package_cmake test_package_python test_optimizer
clean:
rm -rf $(VENV) $(BUILD_DIR) operators*.c operators*.pyd operators*.so traffic_signaling/*.egg-info
# Create a ready-to-use environment for the optimization
setup: $(VENV) $(COMPILED_OPERATORS)
$(VENV): requirements-test.txt requirements.txt
$(PYTHON) -m venv $(VENV)
$(VENV_BIN)/pip install -r requirements-test.txt
$(VENV_BIN)/pip install -r requirements.txt
$(CMAKE_BUILD_DIR):
mkdir -p $(CMAKE_BUILD_DIR)
# Use Python_ROOT_DIR to ensure that Python from the venv is used
cd $(CMAKE_BUILD_DIR) && \
cmake ../../traffic_signaling -DBUILD_PYBIND_MODULES=ON -DPython_ROOT_DIR=$(VENV_ABS_PATH) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) $(EXTRA_FLAGS) && \
cmake --build . --config $(BUILD_TYPE) -j 4
test_package_cmake: $(VENV) $(CMAKE_BUILD_DIR)
cd $(CMAKE_BUILD_DIR) && \
ctest -C $(BUILD_TYPE) -V --output-on-failure
test_package_python: $(VENV)
$(VENV_BIN)/$(PYTHON) -m unittest discover -s traffic_signaling/tests
$(COMPILED_OPERATORS): $(VENV) operators.py
$(VENV_BIN)/cythonize -3i operators.py
test_optimizer: setup
$(VENV_BIN)/$(PYTHON) -m unittest discover -s tests
test: test_package_python test_optimizer