Skip to content

KubaTaba1uga/c_project_template

Repository files navigation

Build Linter Unit Tests Unit Tests with Valgrind

C Project Template

Template for new c projects. Includes build system, testing, mocking, logging, readme, license, pipelines.

  1. Getting Started
  2. Prerequisites
  3. Building
  4. Tests
  5. Pipelines
  6. Common tasks
  7. Authors
  8. License

Getting Started

Clone project

git clone https://github.com/KubaTaba1uga/c_project_template.git

Delete template git files

rm -rf c_project_template/.git

Initiate new git files

cd c_project_template
git init

Once you have initialized the repository, create a remote repository somewhere like github.com.

Add the remote URL to your local git repository

git remote add origin <URL>

Commit at least one file

Push changes

git push -u origin master

I recommend installing perequesitest and confirming that all tests are passing before src/, test/ are actually deleted.

Project's name or version can be changed in ./meson.build file.

Prerequisites

Ruby is used by CMock. Python is used by Meson.

Building

Install perequesites by scripts

bash scripts/install_ruby.sh
bash scripts/install_meson.sh

If installing perequesites by scripts has failed, You need to install them manually.

Configure a build for an app and tests

meson setup build

Compile a build

meson compile -C build

Tests

Run all tests

meson test -C build

Style test

New tests units should be grouped by directories. To understand more look on ./test directory.

Hierarchial build is very favoured by Meson, splitting test unit's into seperate directories allow keeping meson.builds short and simple.

Pipelines

Some pipelines are configured out of the box:

  • build.yaml compiles the project
  • linter.yaml makes sure code is inline with .clang-format
  • unit-tests.yaml runs unit tests
  • unit-tests-with-valgrind.yaml checks for memory leaks in tests
  • merge-gatekeeper.yaml makes sure that all pipelines ran successfully before merging pull request

Common tasks

Setting up a build

bash scripts/setup_build.sh

Compiling a build

bash scripts/compile_build.sh

Formatting a code

bash scripts/format_code.sh

Running tests

bash scripts/run_tests.sh

Running tests with valgrind

bash scripts/run_valgrind_tests.sh

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Template for all new C projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published