From e34b4f47bd675b7d1ce5f9cbad7038d29599b2ce Mon Sep 17 00:00:00 2001 From: jake-g00dwin Date: Fri, 29 May 2026 23:34:47 -0700 Subject: [PATCH] updated root template dir files. --- .template_files/modules/CMakeLists.txt | 41 ++++++++++++++++++-- .template_files/modules/module_name.c | 1 + .template_files/modules/module_name.cpp | 16 -------- .template_files/modules/module_name.h | 31 +++++++++++---- .template_files/modules/test_module_name.cpp | 6 +-- 5 files changed, 66 insertions(+), 29 deletions(-) delete mode 100644 .template_files/modules/module_name.cpp diff --git a/.template_files/modules/CMakeLists.txt b/.template_files/modules/CMakeLists.txt index b27bc02..b7f1928 100644 --- a/.template_files/modules/CMakeLists.txt +++ b/.template_files/modules/CMakeLists.txt @@ -1,7 +1,42 @@ +# File: src/module_name/CMakeLists.txt add_library(module_name STATIC module_name.c ) -target_include_directories(module_name PUBLIC - ${CMAKE_CURRENT_LIST_DIR} -) +# Current list dir: The directory where the cmake config file is. +# Source Dir: The dir where the root/main cmake config file is. + +if(NOT UNIT_TESTING) + target_include_directories(module_name PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_SOURCE_DIR}/inc/ + ) + target_link_libraries(module_name + RegEdit + ) + + #These get defined in the toolchain files. + target_compile_options(module_name PUBLIC + ${OBJECT_GEN_FLAGS} + ${C_FLAGS_ARCH} + ) + +else() + target_include_directories(module_name PUBLIC + ${CMAKE_CURRENT_LIST_DIR} + #First we include any module specific test dependencies. + ${CMAKE_SOURCE_DIR}/tests/module_name/mocks/ + ${CMAKE_SOURCE_DIR}/tests/module_name/fakes/ + ${CMAKE_SOURCE_DIR}/tests/module_name/stubs/ + #Next comes the shared and non-module specific test depencencies. + ${CMAKE_SOURCE_DIR}/tests/shared/mocks/ + ${CMAKE_SOURCE_DIR}/tests/shared/fakes/ + ${CMAKE_SOURCE_DIR}/tests/shared/stubs/ + #Finally we include the local stuff, which has likely been overridden. + ${CMAKE_CURRENT_SOURCE_DIR} + ) + #Place Mocked/Regular dependencies here for unit testing. + target_link_libraries(module_name + MockRegEdit + ) +endif() diff --git a/.template_files/modules/module_name.c b/.template_files/modules/module_name.c index 119b0bc..6d3ec52 100644 --- a/.template_files/modules/module_name.c +++ b/.template_files/modules/module_name.c @@ -6,6 +6,7 @@ */ #include "module_name.h" +#include "RegEdit.h" // dumb test function int add_two(int a) diff --git a/.template_files/modules/module_name.cpp b/.template_files/modules/module_name.cpp deleted file mode 100644 index 16fcd81..0000000 --- a/.template_files/modules/module_name.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Author: username - * Date: todays_date - * filename: module_name.cpp - * description: module_purpose - */ - -#include "module_name.h" - -// dumb test function -int add_two(int a) -{ - int b = a; - b += 2; - return b; -} diff --git a/.template_files/modules/module_name.h b/.template_files/modules/module_name.h index 024b7cf..c7e4131 100644 --- a/.template_files/modules/module_name.h +++ b/.template_files/modules/module_name.h @@ -1,14 +1,31 @@ -/* +/** + * @brief Module description + * @details This file is an + * @author Jake G + * @date todays_date + * @copyright None * @file module_name.h - * @Author Jake Goodwin - * @Date todays_date - * @brief module_purpose */ -#ifndef module_name -#define module_name +//#pragma once +#ifndef module_name_H +#define module_name_H +#ifdef __cplusplus +extern "C" +{ +#endif + + +#include +#include +#include int add_two(int a); -#endif //module_name + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif //module_name_H diff --git a/.template_files/modules/test_module_name.cpp b/.template_files/modules/test_module_name.cpp index 82c2303..d06f275 100644 --- a/.template_files/modules/test_module_name.cpp +++ b/.template_files/modules/test_module_name.cpp @@ -12,7 +12,7 @@ extern "C" #include "module_name.h" } -TEST_GROUP(test_module_name) +TEST_GROUP(FirstTestGroup) { void setup() { @@ -24,12 +24,12 @@ TEST_GROUP(test_module_name) } }; -TEST(test_module_name, FirstTest) +TEST(FirstTestGroup, FirstTest) { FAIL("Fail me!"); } -TEST(test_module_name, SecondTest) +TEST(FirstTestGroup, SecondTest) { STRCMP_EQUAL("hello", "world"); LONGS_EQUAL(1, 2);