Quickstart guide

To use ZenMake you need ZenMake and buildconf file in the root of your project.

Let’s consider an example with this structure:

testproject
├── buildconf.py
├── prog
│   └── test.cpp
└── shlib
    ├── util.cpp
    └── util.h

For this project buildconf.py can be like that:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 tasks = {
     'util' : {
         'features' : 'cxxshlib',
         'source'   : 'shlib/**/*.cpp',
         'includes' : '.',
     },
     'program' : {
         'features' : 'cxxprogram',
         'source'   : 'prog/**/*.cpp',
         'includes' : '.',
         'use'      : 'util',
     },
 }

 buildtypes = {
     'debug' : {
         'toolchain' : 'clang++',
         'cxxflags'  : '-O0 -g',
     },
     'release' : {
         'toolchain' : 'g++',
         'cxxflags'  : '-O2',
     },
     'default' : 'debug',
 }
Lines Description
1 Section with build tasks
2,7 Names of build tasks. By default they are used as target names. Resulting target names will be adjusted depending on a platform. For example, on Windows ‘program’ will result to ‘program.exe’.
3 Mark build task as a C++ shared library.
4 Specify all *.cpp files in the directory ‘shlib’ recursively.
5,10 Specify the path for C/C++ headers relative to the project root directory. In this example, this parameter is optional as ZenMake adds the project root directory itself. But it’s an example.
8 Mark build task as a C++ executable.
9 Specify all *.cpp files in the directory ‘prog’ recursively.
11 Specify task ‘util’ as dependency to task ‘program’.
15 Section with build types.
16,19 Names of build types. They can be almost any.
17 Specify Clang C++ compiler for debug.
18 Specify C++ compiler flags for debug.
21 Specify g++ compiler (from gcc) for release.
22 Specify C++ compiler flags for release.
24 Special case: specify default build type that is used when no build type was specified for ZenMake command.

In case of using YAML the file buildconf.yaml with the same values as above would look like this:

tasks:
  util :
    features : cxxshlib
    source   : 'shlib/**/*.cpp'
    includes : '.'
  program :
    features : cxxprogram
    source   : 'prog/**/*.cpp'
    includes : '.'
    use      : util

buildtypes:
  debug :
    toolchain : clang++
    cxxflags  : -O0 -g
  release :
    toolchain : g++
    cxxflags  : -O2
  default : debug

Once you have the config, run zenmake in the root of the project and ZenMake does the build:

$ zenmake
* Project name: 'testproject'
* Build type: 'debug'
Setting top to                           : /tmp/testproject
Setting out to                           : /tmp/testproject/build
Checking for 'g++'                       : /usr/bin/g++
[1/4] Compiling shlib/util.cpp
[2/4] Compiling prog/test.cpp
[3/4] Linking build/debug/libutil.so
[4/4] Linking build/debug/program
'build' finished successfully (0.433s)

Running ZenMake without any parameters in a directory with buildconf.py or buildconf.yaml is the same as running zenmake build. Otherwise it’s the same as zenmake help.

Get the list of all commands with a short description using zenmake help or zenmake --help. To get help on selected command you can use zenmake help <selected command> or zenmake <selected command> --help

For example to build release of the project above such a command can be used:

$ zenmake build -b release
* Project name: 'testproject'
* Build type: 'release'
Setting top to                           : /tmp/testproject
Setting out to                           : /tmp/testproject/build
Checking for program 'g++, c++'          : /usr/bin/g++
Checking for program 'ar'                : /usr/bin/ar
[1/4] Compiling shlib/util.cpp
[2/4] Compiling prog/test.cpp
[3/4] Linking build/release/libutil.so
[4/4] Linking build/release/program
'build' finished successfully (0.449s)

One of the effective and simple ways to learn something is to use real examples. Examples of projects can be found in the repository here.