diff options
-rw-r--r-- | DEVELOPMENT.md | 6 | ||||
-rw-r--r-- | Makefile | 23 | ||||
-rw-r--r-- | src/CMakeLists.txt | 5 |
3 files changed, 29 insertions, 5 deletions
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 59c5e9e..0d88a72 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -55,6 +55,12 @@ build/coverage/html: The latest code coverage report for the `master` branch can be found at https://egor-tensin.github.io/cimple/coverage/. +### Static analysis + +Build w/ GCC's `-fanalyzer`: + + make analyzer + ### Flame graphs Some performance analysis can be done by looking at flame graphs. @@ -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' diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ca19416..7bd8e78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,11 @@ if(COVERAGE) add_link_options(--coverage) endif() +option(STATIC_ANALYZER "Enable static analysis") +if(STATIC_ANALYZER) + add_compile_options(-fanalyzer) +endif() + # Valgrind on Ubuntu Focal doesn't like DWARF version 5 debug info generated # by Clang 14. if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") |