This repository was created as an example of a feature of Ceedling-Unity.
With a modification of the module generator of Unity, its posible to use boilerplate files as templates for newly created modules.
A posible folder structure is shown in the next snippet
.
├── boilerplates
├── exampleProject
├── third-party
└── tools
but it can be structured like the following
.
├── boilerplates
├── build
├── doc
├── source
├── third-party
└── tools
At the moment, the boilerplates folder is located at the root but it can be moved to /tools for a more suited place.
The main elements are the source folder, where our code will be located, the build folder where the artifacts and other intermediate files will be created, and the supporting elements of tools, third-party, etc.
Our code can be organized in modules, intialy created with ceedling within the source folder. To do this automatically and according with template files, we can use the module generator feature of Unity.
As a starting point for our yet to be created module files we can use a template determined by us or the organization in wich we work.
For example we can see the header template file for the GICSAFe organization:
/*
* --------------------------------------------------------------------------
*
* GICSAFe-Firmware
* ----------------
*
* Copyright (C) 2019 CONICET-GICSAFe
* All rights reserved. Protected by international copyright laws.
*
* Contact information:
* site: https://github.com/gicsafe-firmware
* e-mail: <someone>@<somewhere>
* ---------------------------------------------------------------------------
*/
/**
* \file module.h
* \brief Specifies this module.
*/
/* -------------------------- Development history -------------------------- */
/*
*/
/* -------------------------------- Authors -------------------------------- */
/*
* RiGr Rick Grimes [email protected]
*/
/* --------------------------------- Notes --------------------------------- */
/* --------------------------------- Module -------------------------------- */
#ifndef __MODULE_H__
#define __MODULE_H__
/* ----------------------------- Include files ----------------------------- */
/* ---------------------- External C language linkage ---------------------- */
#ifdef __cplusplus
extern "C" {
#endif
/* --------------------------------- Macros -------------------------------- */
/* -------------------------------- Constants ------------------------------ */
/* ------------------------------- Data types ------------------------------ */
/* -------------------------- External variables --------------------------- */
/* -------------------------- Function prototypes -------------------------- */
/* -------------------- External C language linkage end -------------------- */
#ifdef __cplusplus
}
#endif
/* ------------------------------ Module end ------------------------------- */
#endif
/* ------------------------------ End of file ------------------------------ */
To adapt the template and create the boilerplate, we only need to replace the ocurrences of:
- the name of the module (in this case the word "module" itself) for the string "%1$s",
- the lists of common included header files for "%2$s" (In this case there was none, but de argument can be inserted in the "Include files" section to comply with the template),
- and finally the name again but in CAPS for "%3$s".
This process results in a file like this:
/*
* --------------------------------------------------------------------------
*
* GICSAFe-Firmware
* ----------------
*
* Copyright (C) 2019 CONICET-GICSAFe
* All rights reserved. Protected by international copyright laws.
*
* Contact information:
* site: https://github.com/gicsafe-firmware
* e-mail: <someone>@<somewhere>
* ---------------------------------------------------------------------------
*/
/**
* \file %1$s.h
* \brief Specifies this module.
*/
/* -------------------------- Development history -------------------------- */
/*
*/
/* -------------------------------- Authors -------------------------------- */
/*
* RiGr Rick Grimes [email protected]
*/
/* --------------------------------- Notes --------------------------------- */
/* --------------------------------- Module -------------------------------- */
#ifndef __%3$s_H__
#define __%3$s_H__
/* ----------------------------- Include files ----------------------------- */
%2$s/* ---------------------- External C language linkage ---------------------- */
#ifdef __cplusplus
extern "C" {
#endif
/* --------------------------------- Macros -------------------------------- */
/* -------------------------------- Constants ------------------------------ */
/* ------------------------------- Data types ------------------------------ */
/* -------------------------- External variables --------------------------- */
/* -------------------------- Function prototypes -------------------------- */
/* -------------------- External C language linkage end -------------------- */
#ifdef __cplusplus
}
#endif
/* ------------------------------ Module end ------------------------------- */
#endif
/* ------------------------------ End of file ------------------------------ */
To create a new module we can navigate to our source folder, where the proyect.yml is located and execute:
$ ceedling module:create[newModule:newModule]
The following files will be created:
.
├── newModule
│ ├── inc
│ │ └── newModule.h
│ ├── src
│ │ └── newModule.c
│ └── test
│ └── test_newModule.c
└── project.yml
To run the test, we can simply call:
$ ceedling test:all
executing the test of all modules.
Or we can call for the execution of the test of a single module with:
$ ceedling test:singleModuleName
All the intermediate files and artifacts will be out of the source folder, in build.