From 8e652dd2cb69928ea1596aa3e59845fef6854e2c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 25 Apr 2024 05:11:39 +0200 Subject: add a target to build w/ -fanalyzer --- Makefile | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 342b3ef..608bb09 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,18 @@ include prelude.mk -COMPILER ?= clang -CONFIGURATION ?= debug -DEFAULT_HOST ?= 127.0.0.1 -DEFAULT_PORT ?= 5556 -COVERAGE ?= +COMPILER ?= clang +CONFIGURATION ?= debug +DEFAULT_HOST ?= 127.0.0.1 +DEFAULT_PORT ?= 5556 +COVERAGE ?= +STATIC_ANALYZER ?= $(eval $(call noexpand,COMPILER)) $(eval $(call noexpand,CONFIGURATION)) $(eval $(call noexpand,DEFAULT_HOST)) $(eval $(call noexpand,DEFAULT_PORT)) $(eval $(call noexpand,COVERAGE)) +$(eval $(call noexpand,STATIC_ANALYZER)) src_dir := $(abspath .) build_dir := $(src_dir)/build @@ -40,6 +42,7 @@ build: -D 'DEFAULT_PORT=$(call escape,$(DEFAULT_PORT))' \ -D 'TEST_REPORT_DIR=$(call escape,$(build_dir)/test_report)' \ -D 'COVERAGE=$(call escape,$(COVERAGE))' \ + -D 'STATIC_ANALYZER=$(call escape,$(STATIC_ANALYZER))' \ -D 'FLAME_GRAPHS_DIR=$(call escape,$(build_dir)/flame_graphs)' \ -S '$(call escape,$(src_dir))' \ -B '$(call escape,$(build_dir)/cmake)' @@ -71,6 +74,16 @@ ifndef CI xdg-open '$(call escape,$(build_dir))/html/index.html' &> /dev/null endif +# This a separate target, because CMake is kinda dumb; if you run `make debug` +# and then `make debug COMPILER=gcc STATIC_ANALYZER=1`, it'll run a rebuild, +# but won't include the -fanalyzer option for some reason. +.PHONY: analyzer +analyzer analyzer/%: CONFIGURATION := debug +analyzer analyzer/%: COMPILER := gcc +analyzer analyzer/%: STATIC_ANALYZER := 1 +analyzer analyzer/%: build_dir := $(build_dir)/analyzer +analyzer: build + %/install: % DO cmake --install '$(call escape,$(build_dir))/cmake' -- cgit v1.2.3