From c430835855ac5b4c3e01642ca1034b20663d06b3 Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Fri, 1 Mar 2024 11:22:08 -0800 Subject: [PATCH] refactored the cmake function --- otto.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/otto.sh b/otto.sh index 8b12235..ce043f5 100755 --- a/otto.sh +++ b/otto.sh @@ -24,6 +24,13 @@ does_module_exist () { fi } +add_module_to_cmakes () { + local basename="$1" + + cat "add_subdirectory(${basename})" >> ./src/CmakeLists.txt + cat "add_subdirectory(${basename})" >> ./tests/CmakeLists.txt +} + add_new_module () { read -p "Enter the name of the module:" modname @@ -52,7 +59,10 @@ add_new_module () { sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.c > $modtest_dir/test_${modname}.c sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt - + + # Add the module to the cmake lists files. + add_module_to_cmakes "${modname}" + echo "Resulting files/dirs:" tree -L 2 $modsrc_dir tree -L 2 $modtest_dir @@ -62,8 +72,11 @@ add_new_module () { git add ${modsrc_dir} git add ${modtest_dir}/* git add ${modtest_dir} + git add ./src/CMakeLists.txt + git add ./tests/CMakeLists.txt - #del_module + + del_module } del_module () {