|
1 | 1 | .SILENT: |
| 2 | +.PHONY: docs-html docs-serve default build test format format-check packages |
2 | 3 |
|
3 | | -.PHONY: poetry-install docs-html docs-serve default build test format format-check packages |
4 | | - |
5 | | -default: docs-html |
| 4 | +# If given no other target, runs the build |
| 5 | +default: build |
6 | 6 |
|
| 7 | +# The absolute path that refers to this Makefile |
7 | 8 | THIS_FILE := $(realpath $(lastword $(MAKEFILE_LIST))) |
| 9 | +# The directory that contains this Makefile (the repository root directory) |
8 | 10 | THIS_DIR := $(shell dirname $(THIS_FILE)) |
9 | | -POETRY := poetry -C $(THIS_DIR) |
10 | 11 |
|
11 | | -BUILD_DIR := $(THIS_DIR)/_build/auto |
12 | | -_poetry_stamp := $(BUILD_DIR)/.poetry-install.stamp |
13 | | -poetry-install: $(_poetry_stamp) |
14 | | -$(_poetry_stamp): $(THIS_DIR)/poetry.lock $(THIS_DIR)/pyproject.toml |
15 | | - $(POETRY) install --with=dev |
16 | | - mkdir -p $(BUILD_DIR) |
17 | | - touch $@ |
| 12 | +# Directory where we will scribble build files |
| 13 | +BUILD_DIR ?= $(THIS_DIR)/_build/auto |
| 14 | + |
| 15 | +# uv commands used in this file |
| 16 | +UV_RUN := uv run |
| 17 | +DOCS_RUN := $(UV_RUN) --isolated --group=docs |
| 18 | +FORMAT_RUN := $(UV_RUN) --isolated --group=format |
| 19 | +# Build is not isolated, because CMake caches paths to certain files |
| 20 | +BUILD_RUN := $(UV_RUN) --group=build |
| 21 | +# Run CMake within the uv environment |
| 22 | +CMAKE_RUN := $(BUILD_RUN) cmake |
18 | 23 |
|
19 | 24 | SPHINX_JOBS ?= auto |
20 | 25 | SPHINX_ARGS := -W -j "$(SPHINX_JOBS)" -aT -b dirhtml |
21 | 26 |
|
22 | 27 | DOCS_SRC := $(THIS_DIR)/docs |
23 | 28 | DOCS_OUT := $(BUILD_DIR)/docs/dev/html |
24 | | -docs-html: poetry-install |
25 | | - $(POETRY) run sphinx-build $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT) |
| 29 | +docs-html: |
| 30 | + $(DOCS_RUN) sphinx-build $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT) |
26 | 31 |
|
27 | | -docs-serve: poetry-install |
28 | | - $(POETRY) run sphinx-autobuild $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT) |
| 32 | +docs-serve: |
| 33 | + $(DOCS_RUN) sphinx-autobuild $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT) |
29 | 34 |
|
30 | | -CONFIG ?= RelWithDebInfo |
31 | 35 | build: |
32 | | - cmake -S . -B "$(BUILD_DIR)" -G "Ninja" -D CMAKE_BUILD_TYPE=$(CONFIG) |
33 | | - cmake --build "$(BUILD_DIR)" --config $(CONFIG) |
| 36 | + $(CMAKE_RUN) \ |
| 37 | + -S "$(THIS_DIR)" \ |
| 38 | + -B "$(BUILD_DIR)" \ |
| 39 | + --fresh \ |
| 40 | + -D CMAKE_CROSS_CONFIGS="Debug" \ |
| 41 | + -D CMAKE_DEFAULT_CONFIGS=all \ |
| 42 | + -G "Ninja Multi-Config" |
| 43 | + $(CMAKE_RUN) --build "$(BUILD_DIR)" |
34 | 44 |
|
35 | 45 | test: build |
36 | | - cmake -E chdir "$(BUILD_DIR)" ctest -C "$(CONFIG)" --output-on-failure -j8 |
37 | | - |
38 | | -all_sources := $(shell find $(THIS_DIR)/src/ $(THIS_DIR)/include/ $(THIS_DIR)/tests/ $(THIS_DIR)/docs/ -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp') |
39 | | -format-check: poetry-install |
40 | | - $(POETRY) run python tools/include-fixup.py --check |
41 | | - $(POETRY) run $(MAKE) _format-check |
42 | | -_format-check: |
43 | | - $(POETRY) run clang-format --dry-run $(all_sources) |
44 | | - |
45 | | -format: poetry-install |
46 | | - $(POETRY) run $(MAKE) _format |
47 | | -_format: |
48 | | - $(POETRY) run python tools/include-fixup.py |
49 | | - $(POETRY) run clang-format --verbose -i $(all_sources) |
| 46 | + $(CMAKE_RUN) -E chdir "$(BUILD_DIR)" \ |
| 47 | + ctest -C Debug -j4 --output-on-failure |
| 48 | + |
| 49 | +format-check: |
| 50 | + $(UV_RUN) --group format tools/format.py --mode=check |
| 51 | + |
| 52 | +format: |
| 53 | + $(UV_RUN) --group format tools/format.py |
50 | 54 |
|
51 | 55 | packages: |
52 | 56 | bash $(THIS_DIR)/tools/earthly.sh -a +build-multi/ _build/pkgs |
0 commit comments