A Pythonic Makefile system for C/C++.


License
MIT
Install
pip install cakebaker==1.2.29

Documentation

CakeBaker

Coverage Status Build Status PyPI version License

Unix-only tool for automatic C/C++ compiling and testing.

Installation using pip3

pip3 install cakebaker

... or install using git-install

git-install.py ychnlgy/CakeBaker

Dependencies

  1. Python3
  2. gcc/g++, clang/clang++ or other C/C++ compilers with -MMD and -g compilation support.
  3. 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

  1. Make the cake.ini configuration file.
bakecake.py --init
  1. Write cake_app.cpp.
#include <iostream>

int main() {
    std::cout << "The cake is baked.\n";
}
  1. Compile cake_app.cpp to cool_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 add cake/.

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/

Customizable default options in cake/cake.ini:

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 in BUILD_ARGS and COMPILE_ARGS as these are automatically used when necessary by CakeBaker during compilation and testing.