Newer
Older
# https://stackoverflow.com/a/39124162/194894
word-dot = $(word $2,$(subst ., ,$1))
MESON_VERSION=$(shell meson --version)
MESON_MAJOR_VERSION=$(call word-dot, $(MESON_VERSION), 1)
MESON_MINOR_VERSION=$(call word-dot, $(MESON_VERSION), 2)
.PHONY: all build check check-format clean distclean\
doc release debug stresstest test
all: build
export BUILDTYPE ?= debugoptimized
export BUILDDIR = build-$(BUILDTYPE)
NPROC := $(shell nproc)
JOBS := $(shell echo $$(( $(NPROC) + 6)))
LOAD := $(shell echo $$(( $(NPROC) * 2)))
NINJA := $(NINJA_BIN) -j $(JOBS) -l $(LOAD) $(EXTRA_NINJA_ARGS)
build:
[[ -L build ]] || ./tools/prepare-build-dir
$(NINJA) -C $@
release:
rm -f build
$(MAKE) build BUILDTYPE=$@
debug:
rm -f build
$(MAKE) build BUILDTYPE=$@
STATIC_ANALYSIS_NINJA_TARGETS += iwyu
# Meson >= 0.52 will automatically generate a clang-tidy target if a
# .clang-tidy file is found.
# Source version check: https://stackoverflow.com/a/3732456/194894
ifeq ($(shell [ $(MESON_MINOR_VERSION) -ge 52 ] && echo true), true)
STATIC_ANALYSIS_NINJA_TARGETS += clang-tidy
else
$(warning old mesion version $(MESON_VERSION) detected, meson >= 0.52 required for clang-tidy)
endif
.PHONY: fast-static-analysis
fast-static-analysis: all check-format check-license doc
.PHONY: static-analysis
static-analysis: fast-static-analysis
$(NINJA) -C build $(STATIC_ANALYSIS_NINJA_TARGETS)
.PHONY: smoke-test-suite
smoke-test-suite: all
cd build && meson test --suite smoke
.PHONY: smoke-test
smoke-test: smoke-test-suite static-analysis
TEST_NINJA_TARGETS += test
doc: all
$(NINJA) -C build doc/html
check: smoke-test test
test: all
$(NINJA) -C build $(TEST_NINJA_TARGETS)
check-format:
./tools/check-format
.PHONY: check-license
check-license:
./tools/check-license
.PHONY: format
format: all
$(NINJA) -C build clang-format
.PHONY: tidy
tidy: all
$(NINJA) -C build clang-tidy
PHONY: iwyu
iwyu: all
$(NINJA) -C build $@
PHONY: fix-includes
fix-includes: all
./tools/fix-includes
stresstest: test
./stresstest/stresstest.sh build/tests/simplest_fib_test
# TODO: Determine how we can run also jobs from the 'test' stage,
# e.g. test-gcc.
.PHONY: gitlab-runner
gitlab-runner:
gitlab-runner exec docker smoke-test