added template building code into the script

This commit is contained in:
jakeg00dwin 2024-02-29 23:36:42 -08:00
parent afd2bca9b3
commit ed5a879a4e
1 changed files with 28 additions and 0 deletions

28
tdd.sh
View File

@ -6,6 +6,8 @@
CROSS_TC_WIN="$(pwd)/i686-w64-mingw32_toolchain.cmake" CROSS_TC_WIN="$(pwd)/i686-w64-mingw32_toolchain.cmake"
CMAKE_VERBOSE="ON" CMAKE_VERBOSE="ON"
CROSS_COMPILE=1 CROSS_COMPILE=1
TEMPLATE_FILES=".template_files"
MODULE_DIR="${TEMPLATE_FILES}/modules"
clear_cmake_cache () { clear_cmake_cache () {
cd ./build cd ./build
@ -14,6 +16,8 @@ clear_cmake_cache () {
add_new_module () { add_new_module () {
read -p "Enter the name of the module:" modname read -p "Enter the name of the module:" modname
modname_cap=$(echo $modname | sed 's/[a-z]/\U&/g')
modsrc_dir="./src/${modname}" modsrc_dir="./src/${modname}"
modtest_dir="./tests/${modname}" modtest_dir="./tests/${modname}"
@ -22,6 +26,30 @@ add_new_module () {
mkdir $modtest_dir mkdir $modtest_dir
#copy the template files. #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 () { cross_compile () {