Recipe file

A C2 project requires a recipe file (named recipe.txt). This file specifies:

  • the target type (executable, shared library or static library)
  • which options are used (compile time flags)
  • which source files are used
  • external dependencies

The recipe is written by the developers, but for big projects, the file could be generated (for example by make menuconfig), especially if there are many different configurations.

The exact format of the recipe file is still in progress, but it currently looks like:

# an example recipe file

config MAX_BUFFERS 500

plugin deps_generator [all-targets private]
plugin refs_generator [all-targets]
plugin git_version [git options go here]

executable hello
  $warnings no-unused

lib graphics static
  $plugin load_file [load_file.yml]
  $export api

Note that the path to each c2 file is relative to the position of the recipe file, not to that of the c2c binary.

Global options

Before all executable/lib targets, global configs may be specified. These have the same syntax as config inside a target (see below), but are applied to all targets.

Target options

Inside a target, the following options are available:

  • *config [name] - specify definitions for the preprocessor, like #define feature1
  • export [modules] - export the modules in libraries and generated headers
  • generate-c - enable generation of C code
  • generate-ir - enable generation of LLVM IR code
  • enable-assert - enables generation of asserts
  • plugin - load a target-specific plugin, or override with target-specific config
  • warnings [list] - enable/disable specific warnings during compilation
  • use [libs] - depend on given libraries