From ed5a879a4e8e1db8f5687b608a2f88ea06e96353 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Thu, 29 Feb 2024 23:36:42 -0800 Subject: [PATCH] added template building code into the script --- tdd.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tdd.sh b/tdd.sh index 4772162..787889c 100755 --- a/tdd.sh +++ b/tdd.sh @@ -6,6 +6,8 @@ CROSS_TC_WIN="$(pwd)/i686-w64-mingw32_toolchain.cmake" CMAKE_VERBOSE="ON" CROSS_COMPILE=1 +TEMPLATE_FILES=".template_files" +MODULE_DIR="${TEMPLATE_FILES}/modules" clear_cmake_cache () { cd ./build @@ -14,6 +16,8 @@ clear_cmake_cache () { add_new_module () { read -p "Enter the name of the module:" modname + + modname_cap=$(echo $modname | sed 's/[a-z]/\U&/g') modsrc_dir="./src/${modname}" modtest_dir="./tests/${modname}" @@ -22,6 +26,30 @@ add_new_module () { mkdir $modtest_dir #copy the template files. + echo "copying & customizing template files..." + + sed "s/module_name/${modname}/" $MODULE_DIR/module_name.c > $modsrc_dir/${modname}.c + sed "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h + sed "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt + + sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.c > $modsrc_dir/test_${modname}.c + sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modsrc_dir/CMakeLists.txt + + echo "Resulting files/dirs:" + tree -L 2 $modsrc_dir + tree -L 2 $modtest_dir + + # Now we add the new files to the git tracked files + + + del_module +} + +del_module () { + read -p "Enter the name of the module:" modname + + rm -r ./tests/${modname} + rm -r ./src/${modname} } cross_compile () {