star-mesh

Define and load a binary data format for meshes
git clone git://git.meso-star.fr/star-mesh.git
Log | Files | Refs | README | LICENSE

commit 660a8610887894c0b79308a1f7dcf00902fe0d4e
parent 5b1f6075dc25ac5fa1d5cf9515f24ab9a76c10e3
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 12 Apr 2023 12:37:37 +0200

Build the test_smsh_load binary in the POSIX Make

Until now, we had forgotten to manage this test in POSIX Make.

Diffstat:
M.gitignore | 1+
MMakefile | 38++++++++++++++++++++++----------------
Amake.sh | 49+++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 16 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -7,6 +7,7 @@ test* !test*.[ch] .pkg +.test tags smsh.pc smsh.5 diff --git a/Makefile b/Makefile @@ -88,7 +88,7 @@ uninstall: ################################################################################ # Miscellaneous targets ################################################################################ -all: build_library build_test smsh.5 +all: build_library build_tests smsh.5 clean: clean_test @rm -f $(OBJ) $(TEST_OBJ) libsmsh.so .test .pkg smsh.pc smsh.5 @@ -96,32 +96,38 @@ clean: clean_test distclean: clean @rm -f $(DEP) $(TEST_DEP) +lint: + @shellcheck -o all make.sh + ################################################################################ # Tests ################################################################################ -TEST_OBJ = src/test_smsh.o -TEST_DEP = src/test_smsh.d - -test: build_test - @printf "test_smsh "; \ - if ./test_smsh > /dev/null 2>&1; then \ - printf "\e[1;32mOK\e[m\n"; \ - else \ - printf "\e[1;31mErreur\e[m\n"; \ - fi +TEST_SRC =\ + src/test_smsh.c\ + src/test_smsh_load.c + +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +test: build_tests + @$(SHELL) make.sh run_test $(TEST_SRC) + +build_tests: build_library $(TEST_DEP) .test + @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin -build_test: build_library $(TEST_DEP) - @$(MAKE) -fMakefile -fsrc/test_smsh.d test_smsh +.test: Makefile make.sh + @echo "Setup tests" + @$(SHELL) make.sh config_test $(TEST_SRC) > $@ clean_test: - @rm -f test_smsh + @$(SHELL) make.sh clean_test $(TEST_SRC) $(TEST_OBJ) $(TEST_DEP): config.mk -src/test_smsh.o: +$(TEST_OBJ): config.mk @echo "CC $@" @$(CC) $(CFLAGS) $(RSYS_INC) -c $(@:.o=.c) -o $@ -test_smsh: src/test_smsh.o libsmsh.so config.mk +test_smsh test_smsh_load: src/test_smsh.o libsmsh.so config.mk @echo "LD $@" @$(CC) $(CFLAGS) -o $@ src/$@.o -L$$(pwd) -lsmsh $(RSYS_LIB) diff --git a/make.sh b/make.sh @@ -0,0 +1,49 @@ +#!/bin/sh -e + +# Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +config_test() +{ + for i in "$@"; do + test=$(echo "${i}" | sed 's/src\/\(.\{1,\}\).c$/\1/') + test_list="${test_list} ${test}" + printf "%s: %s\n" "${test}" "src/${test}.o" + done + printf "test_bin: %s\n" "${test_list}" +} + +run_test() +{ + for i in "$@"; do + test=$(echo "${i}" | sed 's/src\/\(.\{1,\}\).c$/\1/') + printf "%s " "${test}" + if ./"${test}" > /dev/null 2>&1; then + printf "\e[1;32mOK\e[m\n" + else + printf "\e[1;31mErreur\e[m\n" + fi + done +} + +clean_test() +{ + for i in "$@"; do + test=$(echo "${i}" | sed 's/src\/\(.\{1,\}\).c$/\1/') + rm -f "${test}" + done +} + +"$@"