This template provides everything you need to start a new C project. It supports essential features, such as:
- Make support for building application, libraries and tests
- Doxygen support for documenting
- Unity support for unit testing
- Codecov support for code coverage
- ClangFormat support for source code formatting
- ClangTidy support for static analysis
- Valgrind support for dynamic analysis
- Google Sanitizers support for address, leak, memory and undefined behavior analysis
- GitHub Actions support for CI/CD
To build the sample project from source, the following tools are needed:
- git
- make
- gcc
- clang
- clang-format
- clang-tidy
- doxygen
- graphviz
- valgrind
On Ubuntu/Debian, you can install them with:
sudo apt-get install git build-essential clang clang-format clang-tidy doxygen graphviz valgrind
On other platforms, please use the corresponding package managing tool to install them before proceeding.
You can get the source by "git clone" this git repository.
git clone https://github.com/jballoffet/c-template.git
To build the sample application execute the following:
cd c-template
make
To run the sample application execute the following:
./bin/app.out
You should see something like this:
Hello World!
foo.c -> foo_function(0): 0
bar.c -> bar_function_abs(-1): 1
bar.c -> bar_function_double(1): 2
libbaz.a -> baz_function(): 3
This template supports Unity framework for unit testing, and includes a few tests to show how to use it. To build and run the tests execute the following:
make test
After the building output, you should see something like this:
Unity test run 1 of 1
...
-----------------------
3 Tests 0 Failures 0 Ignored
OK
To run the tests again without rebuilding, execute:
./bin/test.out
.
├── bin* # Application and tests binaries
├── build* # Compiled files
├── doc* # Generated documentation
├── include # Third-party libraries header files
├── lib # Third-party libraries
├── src # Application source code
├── scripts # Continuous Integration scripts
└── test # Unit testing directory
├── src # Unit tests source code
└── unity # Unity framework directory
├── include # Unity framework header files
└── src # Unity framework source code
The directories marked with an '*' are generated by the build system.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
See also the list of contributors who participated in this project.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the GPLv3 License. See the LICENSE file for details.
Unity is distributed under the MIT license. See LICENSE.txt for details.