I'm attempting to migrate a C application I have been working on to use Rake insead of GNU Make. The file tree is something like:
project
├── LICENSE.md
├── Makefile
├── Rakefile
├── README.md
└── src
├── debug.h
├── main.c
├── queue.c
├── queue.h
└── ui
├── ui.c
└── ui.h
I want to build each file in a separate build
directory and generate the dependencies of each .c
file with either gcc
or clang
in a deps directory.
I cannot seem to find any examples of how to write a Rakefile to compile a C project. Does anyone have a link or some advice to help me get started?
EDIT: I have a temporary Rakefile that accomplishes some of the tasks I want it to eventually do. I would like to detect if clang is installed and use clang or gcc.
Here is my current Rakefile https://github.com/Rostepher/spoticli/blob/master/Rakefile
Use Ceedling!
https://github.com/ThrowTheSwitch/Ceedling
It's an automated unit test framework for C, but does a great job of simply building as well. You should be able to get what your looking for by editing a YAML config file, and you'll get Rake tasks for building out-of-the box. Of course you can create your own custom Rake tasks as well.
As a bonus you can create mocks with CMock and automated unit tests with Unity.
It's super easy to install from a gem:
> gem install ceedling
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With