blob: 0cf7eb68e0c18fa8cbf814a209df37bacf8abdc5 (
plain) (
tree)
|
|
TEST = $(wildcard test/*.cc)
# -- INTERNALS -----------------------------------------------------------------
BINS = $(TEST:test/%.cc=build/%)
DEPS = $(TEST:test/%.cc=build/%.d)
RUNS = $(TEST:test/%.cc=run/%)
# -- FLAGS ---------------------------------------------------------------------
DEPS_GEN = -MMD
SANITIZER = -fsanitize=address -fsanitize=undefined -fsanitize=leak -fno-omit-frame-pointer
STD ?= 14
CXXFLAGS = -Og -g -Wall -Wextra -Werror -I. -std=c++$(STD) $(DEPS_GEN) $(SANITIZER)
LDFLAGS = $(SANITIZER)
# -- RULES ---------------------------------------------------------------------
default: lint build $(BINS)
run: $(RUNS)
run/%: build build/%
@echo "==> run $*"
build/$*
build/%: build/%.o
$(CXX) -o $@ $< $(LDFLAGS)
build/%.o: test/%.cc
$(CXX) -c -o $@ $< $(CXXFLAGS)
build:
mkdir -p build
lint:
clang-format --dry-run -Werror $(shell find -name '*.cc' -o -name '*.h')
clang-tidy test/*.cc -- $(CXXFLAGS)
clean:
$(RM) -r build
$(RM) compile_commands.json events.json
# Since DEPS files contain rules, include at the end.
-include $(DEPS)
# -- SPECIAL RULES -------------------------------------------------------------
# Generate compile database using bear(1).
bear:
bear intercept -- $(MAKE) build $(BINS)
bear citnames
define VARTEST
var-$(1)-$(2):
@echo "==> VARTEST CXX=$(1) STD=$(2)"
$(MAKE) clean build CXX=$(1) STD=$(2) $(BINS)
endef
STD_LIST := 14 17 20
CXX_LIST := g++ clang++
# Generate targets for {compiler,std} variant build tests.
$(foreach C,$(CXX_LIST),$(foreach S,$(STD_LIST),$(eval $(call VARTEST,$(C),$(S)))))
# Generate umbrella target to run all variant tests.
vartest: $(foreach C,$(CXX_LIST),$(foreach S,$(STD_LIST),var-$(C)-$(S)))
|