From f188c546669021c1c013345453cbab41aa2e65fc Mon Sep 17 00:00:00 2001 From: Jaromil Date: Fri, 12 May 2023 09:49:27 +0200 Subject: [PATCH] improve build system test suite and release builds --- GNUmakefile | 27 +++++++++++++++++++++- test/Makefile | 33 +++++++++++++++++---------- test/{frei0r-info.c => frei0r-meta.c} | 0 test/{frei0r-test.c => frei0r-run.c} | 0 4 files changed, 47 insertions(+), 13 deletions(-) rename test/{frei0r-info.c => frei0r-meta.c} (100%) rename test/{frei0r-test.c => frei0r-run.c} (100%) diff --git a/GNUmakefile b/GNUmakefile index ab3a8b5e..a333c5c2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,28 @@ +all: release-gcc-ninja +debug: debug-gcc -debug: +release-gcc: + mkdir -p build + cd build && cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release .. + cd build && make + +release-gcc-ninja: + mkdir -p build + cd build && cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -G 'Ninja' .. + cd build && ninja + +release-clang: + mkdir -p build + cd build && cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release .. + cd build && make + +release-clang-ninja: + mkdir -p build + cd build && cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -G 'Ninja' .. + cd build && ninja + +debug-gcc: mkdir -p build cd build && cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG='-ggdb -fno-omit-frame-pointer -fsanitize=address' -DCMAKE_C_FLAGS_DEBUG='-ggdb -fno-omit-frame-pointer -fsanitize=address' .. cd build && make @@ -10,3 +32,6 @@ debug-clang-ninja: mkdir -p build cd build && cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG='-ggdb -fno-omit-frame-pointer -fsanitize=address' -DCMAKE_C_FLAGS_DEBUG='-ggdb -fno-omit-frame-pointer -fsanitize=address' -G 'Ninja' .. cd build && ninja + +clean: + rm -rf build diff --git a/test/Makefile b/test/Makefile index a2bdc58c..0a2db26d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,22 +5,34 @@ PLUGINDIR ?= ../build/src CXX ?= g++ DEBUG_FLAGS ?= -O0 -g -ggdb -Wl,-undefined -Wl,dynamic_lookup -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope -all: test-utils +all: frei0r-meta frei0r-run + @echo "Test targets available:" + @echo "scan-meta :: scan all plugins and produce metadata" + @echo "check-asan :: run all tests on all plugins" + @echo "frei0r-meta :: build metadata plugin scanner" + @echo "frei0r-run :: build ASAN test utility" + + # build scan-plugins -frei0r-test: CVFLAGS := $(shell pkg-config --libs --cflags opencv4) -frei0r-test: frei0r-test.c - ${CXX} ${DEBUG_FLAGS} -ggdb -O0 -I../include -o frei0r-test frei0r-test.c ${CVFLAGS} -ldl +frei0r-run: CVFLAGS := $(shell pkg-config --libs --cflags opencv4) +frei0r-run: frei0r-run.c + $(info Build frei0r plugin test run utility) + ${CXX} ${DEBUG_FLAGS} -ggdb -O0 -I../include -o frei0r-run frei0r-run.c ${CVFLAGS} -ldl -test-all-filters: frei0r-test +check-asan: frei0r-run @$(if $(wildcard ${PLUGINDIR}),,>&2 echo "Scan dir not found: ${PLUGINDIR}" && exit 1) - @find ${PLUGINDIR} -type f -name '*.so' -exec ./frei0r-test -t -v ${HOME}/Downloads/frei0r-all.webm -p {} \; + @find ${PLUGINDIR} -type f -name '*.so' -exec ./frei0r-run -t -v ${HOME}/Downloads/frei0r-all.webm -p {} \; # @$(if $(wildcard frei0r-test),,make test-utils) -scan-plugins: +frei0r-meta: frei0r-meta.c + $(info Build frei0r meta-data parsing utility) + ${CC} -o frei0r-meta -ggdb frei0r-meta.c ${INCLUDES} + +scan-meta: frei0r-meta @$(if $(wildcard ${PLUGINDIR}),,>&2 echo "Scan dir not found: ${PLUGINDIR}" && exit 1) - @find ${PLUGINDIR} -type f -name '*.so' -exec ./frei0r-info {} \; > tmp.json + @find ${PLUGINDIR} -type f -name '*.so' -exec ./frei0r-meta {} \; > tmp.json @echo "[" > frei0r-plugin-list.json @head -n -1 tmp.json >> frei0r-plugin-list.json @echo "}\n]" >> frei0r-plugin-list.json @@ -34,10 +46,7 @@ generate-metadata: @$(if $(wildcard ${PLUGINDIR}),,>&2 echo "Scan dir not found: ${PLUGINDIR}" && exit 1) sh extract-plugin-info.sh ${EXTENSION} ${PLUGINDIR} -build: - @${CC} -o frei0r-info -ggdb frei0r-info.c ${INCLUDES} - clean: rm -f *.o - rm -f frei0r-info frei0r-test + rm -f frei0r-run frei0r-meta rm -f *.json diff --git a/test/frei0r-info.c b/test/frei0r-meta.c similarity index 100% rename from test/frei0r-info.c rename to test/frei0r-meta.c diff --git a/test/frei0r-test.c b/test/frei0r-run.c similarity index 100% rename from test/frei0r-test.c rename to test/frei0r-run.c