-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (127 loc) · 9.39 KB
/
Makefile
File metadata and controls
155 lines (127 loc) · 9.39 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# ArcticDB Development Makefile
#
# Override defaults by creating a Makefile.local (gitignored).
# See Makefile.local.example for Man group configuration.
-include Makefile.local
# ── Defaults (overridable in Makefile.local or env) ──────────────────────────
RELEASE_PRESET ?= linux-release
DEBUG_PRESET ?= linux-debug
PROXY_CMD ?=
CMAKE_JOBS ?= 16
PROTOC_VERS ?=
VENV_DIR ?= ~/venvs
VENV_NAME ?= dev-venv
TMPDIR_OVERRIDE ?=
# ── Environment plumbing ─────────────────────────────────────────────────────
# Prepend TMPDIR=... when TMPDIR_OVERRIDE is set
_TMPDIR_ENV := $(if $(TMPDIR_OVERRIDE),TMPDIR=$(TMPDIR_OVERRIDE))
# Set ARCTICDB_PROTOC_VERS=... when PROTOC_VERS is set
_PROTOC_ENV := $(if $(PROTOC_VERS),ARCTICDB_PROTOC_VERS=$(PROTOC_VERS))
# Combined environment prefix for commands that need both
_ENV := $(strip $(_TMPDIR_ENV) $(_PROTOC_ENV))
_VENV_PYTHON := $(VENV_DIR)/$(VENV_NAME)/bin/python
_VENV_PIP := $(VENV_DIR)/$(VENV_NAME)/bin/pip
# ── Phony targets ────────────────────────────────────────────────────────────
.PHONY: help setup protoc venv activate lint lint-check \
build build-debug configure configure-debug \
test-cpp test-cpp-debug symlink symlink-debug \
test-py build-and-test-py build-and-test-py-debug \
wheel bench-cpp bench-py install-editable
# ── help ─────────────────────────────────────────────────────────────────────
help: ## Show this help
@echo "ArcticDB Development Targets"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | \
awk -F ':.*## ' '{printf " %-20s %s\n", $$1, $$2}'
@echo ""
@echo "Variables (set in Makefile.local or on command line):"
@echo " RELEASE_PRESET $(RELEASE_PRESET)"
@echo " DEBUG_PRESET $(DEBUG_PRESET)"
@echo " PROXY_CMD $(or $(PROXY_CMD),(unset))"
@echo " CMAKE_JOBS $(CMAKE_JOBS)"
@echo " PROTOC_VERS $(or $(PROTOC_VERS),(unset))"
@echo " VENV_DIR $(VENV_DIR)"
@echo " TMPDIR_OVERRIDE $(or $(TMPDIR_OVERRIDE),(unset))"
# ── protoc ───────────────────────────────────────────────────────────────────
protoc: ## Generate protobuf stubs
$(_ENV) $(PROXY_CMD) $(_VENV_PYTHON) setup.py protoc --build-lib python
# ── venv ─────────────────────────────────────────────────────────────────────
venv: ## Create a dev venv (NAME=<name> required, CLEAN=1 to replace existing)
ifdef CLEAN
rm -rf $(VENV_DIR)/$(VENV_NAME)
endif
./build_tooling/create_venv.sh $(if $(PROXY_CMD),--proxy-cmd $(PROXY_CMD)) $(VENV_DIR)/$(VENV_NAME)
activate: ## Print venv activate path (NAME=<name> required). Use: source $$(make activate NAME=x)
@echo $(VENV_DIR)/$(VENV_NAME)/bin/activate
# ── setup ────────────────────────────────────────────────────────────────────
setup: ## Full setup from scratch (CLEAN=1 to replace existing venv)
$(PROXY_CMD) git submodule update --init --recursive
$(MAKE) venv $(if $(CLEAN),CLEAN=1)
. $(VENV_DIR)/$(VENV_NAME)/bin/activate && \
$(MAKE) protoc && \
$(MAKE) build-debug && \
$(MAKE) activate
# ── lint ─────────────────────────────────────────────────────────────────────
install-linters:
$(PROXY_CMD) $(_VENV_PYTHON) build_tooling/format.py --install-tools
lint: ## Run formatters (in-place)
$(_VENV_PYTHON) build_tooling/format.py --in-place --type all
lint-check: ## Check formatting (no changes)
$(_VENV_PYTHON) build_tooling/format.py --check --type all
# ── configure ────────────────────────────────────────────────────────────────
configure: ## CMake configure (release)
$(_TMPDIR_ENV) $(PROXY_CMD) cmake -DTEST=ON --preset $(RELEASE_PRESET) cpp
configure-debug: ## CMake configure (debug)
$(_TMPDIR_ENV) $(PROXY_CMD) cmake -DTEST=ON --preset $(DEBUG_PRESET) cpp
# ── build ────────────────────────────────────────────────────────────────────
build: configure ## Build arcticdb_ext (release) and symlink
cmake --build cpp/out/$(RELEASE_PRESET)-build -j $(CMAKE_JOBS) --target arcticdb_ext
$(MAKE) symlink
build-debug: configure-debug ## Build arcticdb_ext (debug) and symlink
cmake --build cpp/out/$(DEBUG_PRESET)-build -j $(CMAKE_JOBS) --target arcticdb_ext
$(MAKE) symlink-debug
# ── test-cpp ─────────────────────────────────────────────────────────────────
test-cpp: ## Build and run C++ unit tests (release, FILTER= for gtest_filter)
$(_TMPDIR_ENV) $(PROXY_CMD) cmake -DTEST=ON --preset $(RELEASE_PRESET) cpp
cmake --build cpp/out/$(RELEASE_PRESET)-build -j $(CMAKE_JOBS) --target test_unit_arcticdb
cpp/out/$(RELEASE_PRESET)-build/arcticdb/test_unit_arcticdb $(if $(FILTER),--gtest_filter=$(FILTER))
test-cpp-debug: ## Build and run C++ unit tests (debug, FILTER= for gtest_filter)
$(_TMPDIR_ENV) $(PROXY_CMD) cmake -DTEST=ON --preset $(DEBUG_PRESET) cpp
cmake --build cpp/out/$(DEBUG_PRESET)-build -j $(CMAKE_JOBS) --target test_unit_arcticdb
cpp/out/$(DEBUG_PRESET)-build/arcticdb/test_unit_arcticdb $(if $(FILTER),--gtest_filter=$(FILTER))
# ── symlink ──────────────────────────────────────────────────────────────────
_EXT_SUFFIX := $(shell python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
symlink: ## Symlink release arcticdb_ext into python/
ln -sf ../cpp/out/$(RELEASE_PRESET)-build/arcticdb/arcticdb_ext$(_EXT_SUFFIX) python/arcticdb_ext$(_EXT_SUFFIX)
@echo "Created python/arcticdb_ext$(_EXT_SUFFIX) -> release build"
symlink-debug: ## Symlink debug arcticdb_ext into python/
ln -sf ../cpp/out/$(DEBUG_PRESET)-build/arcticdb/arcticdb_ext$(_EXT_SUFFIX) python/arcticdb_ext$(_EXT_SUFFIX)
@echo "Created python/arcticdb_ext$(_EXT_SUFFIX) -> debug build"
# ── test-py ──────────────────────────────────────────────────────────────────
# TYPE selects the test subdirectory (unit, integration, hypothesis, stress).
# FILE overrides TYPE to run a specific file or test (strips leading python/ if present).
# ARGS passes extra arguments to pytest.
TYPE ?= unit
FILE ?=
_TEST_TARGET = $(if $(FILE),$(patsubst python/%,%,$(FILE)),tests/$(TYPE))
test-py: ## Run Python tests (TYPE=unit|integration|..., FILE= path, ARGS= extra pytest args)
cd python && $(_VENV_PYTHON) -m pytest $(_TEST_TARGET) $(ARGS)
build-and-test-py: build ## Release build + symlink + run Python tests
$(MAKE) test-py
build-and-test-py-debug: build-debug ## Debug build + symlink + run Python tests
$(MAKE) test-py
# ── wheel ────────────────────────────────────────────────────────────────────
wheel: ## Build a pip wheel
$(_ENV) $(PROXY_CMD) ARCTIC_CMAKE_PRESET=$(RELEASE_PRESET) CMAKE_BUILD_PARALLEL_LEVEL=$(CMAKE_JOBS) \
$(_VENV_PIP) wheel . --no-deps -w dist/
# ── bench-cpp ────────────────────────────────────────────────────────────────
bench-cpp: ## Build and run C++ benchmarks (release, FILTER= for benchmark_filter)
$(_TMPDIR_ENV) $(PROXY_CMD) cmake -DTEST=ON --preset $(RELEASE_PRESET) cpp
cmake --build cpp/out/$(RELEASE_PRESET)-build -j $(CMAKE_JOBS) --target benchmarks
cpp/out/$(RELEASE_PRESET)-build/arcticdb/benchmarks $(if $(FILTER),--benchmark_filter=$(FILTER))
# ── install-editable ─────────────────────────────────────────────────────────
install-editable: ## Install arcticdb in editable mode
$(PROXY_CMD) $(_VENV_PIP) install -e . --no-deps
# ── bench-py ─────────────────────────────────────────────────────────────────
bench-py: install-editable ## Run ASV Python benchmarks (BENCH= for --bench filter)
$(_VENV_PYTHON) -m asv run --python=same -v --show-stderr $(if $(BENCH),--bench $(BENCH))