CakeBaker
Unix-only tool for automatic C/C++ compiling and testing.
pip3
Installation usingpip3 install cakebaker
git-install
... or install using git-install.py ychnlgy/CakeBaker
Dependencies
- Python3
-
gcc/g++
,clang/clang++
or other C/C++ compilers with-MMD
and-g
compilation support. - Valgrind - if memory leak testing is required.
How to use the binary:
- This guide assumes you have installed CakeBaker via pip3, which installs
bakecake.py
in your bin directory. - If you installed CakeBaker via GitInstaller, the binary will be in your local directory. Therefore you have to run the binary in one of two ways (to see the version in the following examples):
./bakecake.py --version
python3 bakecake.py --version
Quickstart
- Make the
cake.ini
configuration file.
bakecake.py --init
- Write
cake_app.cpp
.
#include <iostream>
int main() {
std::cout << "The cake is baked.\n";
}
- Compile
cake_app.cpp
tocool_app.exe
.
bakecake.py cake_app.cpp cool_app.exe
Motivation
- Makefiles have crazy syntax. You won't need any for CakeBaker.
- Valgrind displays extra information. Only memory errors are displayed by CakeBaker.
- Batch-testing for C/C++? CakeBaker does it all.
- Object and dependency files and test executables are stored neatly in
cake/
so you don't have to see them. -
.gitignore
is simple: just addcake/
.
Features
- Makefile efficiency: compilation of newly changed files only.
- Auto-discovery of source files from included header files: no Makefile required.
- Pinpoints segmentation faults, memory leaks, out-of-range memory accesses, etc. via Valgrind.
- Need to build on other operating systems? Generate a Makefile:
bakecake.py --makefile main.cpp app.exe
- Testing is easy:
bakecake.py --test tests/foo_test.cpp
- Testing with Valgrind is just as easy:
bakecake.py --test --valgrind tests/foo_test.cpp
- Batch-testing is easy:
bakecake.py --test -r tests/
- Batch-testing with Valgrind is just as easy:
bakecake.py --test --valgrind -r tests/
- Force recompile with:
bakecake.py --clean
bakecake.py cake_app.cpp cool_app.exe
- Store the output in a
cake/stdout.txt
using--silent
:
bakecake.py --silent --test --valgrind -r tests/
cake/cake.ini
:
Customizable default options in BUILD_ARGS = -lluajit
COMPILER = g++
COMPILE_ARGS = -Wall -std=c++11
DEFAULT_OUTPUTFILE = MyApp.exe
DEFAULT_SOURCEFILE = main.cpp
TEST_INCLUDE = *tests/*_test.cpp *tests/test_*.cpp
TEST_OMIT = */cake */.git
Option | Information |
---|---|
BUILD_ARGS |
Linking libraries for compiling all object files together into a final executable. |
COMPILER |
g++ , clang++ , etc. Must support -MMD and -g compilation arguments. |
COMPILE_ARGS |
Arguments for compiling each source file into object files. |
DEFAULT_OUTPUTFILE |
Default argument to bakecake.py (see below for explicit definition). |
DEFAULT_SOURCEFILE |
Default argument to bakecake.py (see below for explicit definition). |
TEST_INCLUDE |
Pattern of source files for batch-testing to compile and run. |
TEST_OMIT |
Pattern of source files for batch-testing to ignore. Omitting is done before including. |
Calling
bakecake.py
is equivalent to calling
bakecake.py DEFAULT_SOURCEFILE DEFAULT_OUTPUTFILE
Notes
- If a source file implements a certain header file, both files should reside in the same directory.
- You should not have to insert
-MMD
or-g
inBUILD_ARGS
andCOMPILE_ARGS
as these are automatically used when necessary by CakeBaker during compilation and testing.