refactored the cmake function

This commit is contained in:
jakeg00dwin 2024-03-01 11:22:08 -08:00
parent 1788aa2dd7
commit c430835855
1 changed files with 15 additions and 2 deletions

15
otto.sh
View File

@ -24,6 +24,13 @@ does_module_exist () {
fi 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 () { add_new_module () {
read -p "Enter the name of the module:" modname read -p "Enter the name of the module:" modname
@ -53,6 +60,9 @@ 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/test_module_name.c > $modtest_dir/test_${modname}.c
sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt 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:" echo "Resulting files/dirs:"
tree -L 2 $modsrc_dir tree -L 2 $modsrc_dir
tree -L 2 $modtest_dir tree -L 2 $modtest_dir
@ -62,8 +72,11 @@ add_new_module () {
git add ${modsrc_dir} git add ${modsrc_dir}
git add ${modtest_dir}/* git add ${modtest_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 () { del_module () {