The Syntax of the Project.meta file

Config types

Three config types exist: ExecutableConfig, LibraryConfig and CustomConfig. Some elements are only valid for specific types.

Filter

Every element (except the Project element) in Project.meta has two attributes:

  • default: if set to “off”, this element is not taken into account. Default is “on”.

  • filter: The element can be removed/added explicitly regardless of the “default” attribute with the command line options

    • –do “filter name”

    • –omit “filter name”

Example:

PostSteps {
  CommandLine "$(OutputDir)/$(ArtifactName)", filter: run, default: off
}

The executable is not executed by default unless “run” is specified on command line:

bake ... --do run

Notes

  • Specify the paths always relative to the current project root.

  • Keep the variable substitution in Project.meta in mind.

  • Use double quotes (”) if the strings have spaces or slashes.

  • Use hash marks (#) for comments.

Syntax

Project default: <name> {

  Description <text>

  RequiredBakeVersion minimum: <major.minor.patch>, maximum: <major.minor.patch>

  Responsible {
    Person <name>, email: <adr>
  }

  # 0..n configs
  ExecutableConfig | LibraryConfig | CustomConfig <name>, extends: <parent(s)>,
    mergeInc: yes|no, private: true|false {

    # Valid for all config types

    Description <text>
    IncludeDir <dir>, inherit: true|false, inject: front|back, system: true|false
    Set <variable>, value: <value> | cmd: <line>, env: true|false
    Dependency <project>, config: <name>
    ExternalLibrary <lib>, search: true|false
    UserLibrary <lib>
    ExternalLibrarySearchPath <path>
    PreSteps {
      Makefile <file>, lib: <lib>, target: <target>, pathTo: <paths>, noClean: true|false,
        changeWorkingDir: true|false, echo: on|off, independent: true|false, validExitCodes: <[array]> {
        Flags <flags>
      }
      CommandLine <line>, echo: on|off, independent: true|false, validExitCodes: <[array]>
      Sleep <seconds>, echo: on|off, independent: true|false
      MakeDir <directory>, echo: on|off
      Remove <file or directory>, echo: on|off
      Touch <file or directory>, echo: on|off
      Copy <file or directory>, to: <file or directory>, echo: on|off
      Move <file or directory>, to: <file or directory>, echo: on|off
    }
    PostSteps {
      # Same as for PreSteps
    }
    StartupSteps {
      # Same as for PreSteps
    }
    ExitSteps {
      # Same as for PreSteps
    }
    CleanSteps {
      # Same as for PreSteps
    }
    DefaultToolchain <basedOn>, outputDir: <dir>, outputDirPostfix: <postfix>,
      eclipseOrder: true|false {
      Compiler ASM | CPP | C, command: <cmd>, prefix: <prefix>, keepObjFileEndings: true|false {
        Flags <flags>
        Flags <define>
        InternalDefines <file>
        SrcFileEndings <endings>
      }
      Archiver command: <cmd>, prefix: <prefix> {
        Flags <flags>
      }
      Linker command: <cmd>, prefix: <prefix>, onlyDirectDeps: true|false {
        Flags <flags>
        LibPrefixFlags <flags>
        LibPostfixFlags <flags>
      }
      InternalIncludes <file>
      Docu <cmdLine>
    }
    Toolchain outputDir: <dir>, outputDirPostfix: <postfix> {
      Compiler ASM | CPP | C, command: <cmd>, cuda: true|false, prefix: <prefix> {
        Flags <flags>, add: <flags>, remove: <flags>
        Flags <define> <define>
        SrcFileEndings <file>
      }
      Archiver command: <cmd>, prefix: <prefix> {
        Flags <flags>, add: <flags>, remove: <flags>
      }
      Linker command: <cmd>, prefix: <prefix>, onlyDirectDeps: true|false {
        Flags <flags>, add: <flags>, remove: <flags>
        LibPrefixFlags <flags>, add: <flags>, remove: <flags>
        LibPostfixFlags <flags>, add: <flags>, remove: <flags>
      }
      Docu <cmdLine>
    }
    Prebuild {
        Except <project>, config: <name>
    }
    CompilationDB <filename>
    CompilationCheck include: <pattern> exclude: <pattern> ignore: <pattern>

    # Valid for ExecutableConfig and LibraryConfig

    Files <pattern>, compileOnly: true|false, linkDirectly: true|false {
      Flags <define> <flags>, add: <flags>, remove: <flags>
      Flags <define>
    }
    ExcludeFiles <pattern>
    ArtifactName <name>
    ArtifactExtension <ext>

    # Valid for ExecutableConfig

    LinkerScript <script>
    MapFile <name>


    # Valid for CustomConfig

    Makefile | CommandLine | Sleep | MakeDir | Remove | Touch | Copy | Move ... # zero of one of these

  }
}

Adapt toolchain: <name>, os: <name>, mainProject: <name>, mainConfig: <name> {
  # See Adapt documention for details.
}

Project

A bake project is very similar to a project in Eclipse, Visual Studio, etc.
The name of the project is the directory name of the Project.meta file.

Mandatory: yes, quantity: 1, default: -

default (Project)

Attribute of Project.

Default configuration which is used if not explicitly specified on command line or Dependency definition.

Examples:

# Project.meta:
Dependency canDriver # uses default config of canDriver project
# Command line:
bake -m folder/dir/projABC # builds default config of project projABC

Mandatory: no, quantity: 0..1, default: -

Description

Description of the project or config.

Mandatory: no, quantity: 0..1, default: -

RequiredBakeVersion

If specified, the build will be aborted if bake version is lower than mininum or greater than maximum.
It is possible to define only minimum, only maximum or both version thresholds.
Minor and patch version numbers are optional.

Mandatory: no, quantity: 0..1, default: -

Responsible

Specify all responsible persons of the project.

Mandatory: no, quantity: 0..1, default: -

Person

Person who is responsible for the project.

Mandatory: no, quantity: 0..1, default: -

email

Attribute of Person.

Use always double quotes (”) for the email address.

Mandatory: no, quantity: 0..1, default: -

ExecutableConfig

This is usually the main config of an application.

Mandatory: no, quantity: 0..n, default: -

LibraryConfig

This config is used for a source library. The library will be linked automatically to the executable.

Mandatory: no, quantity: 0..n, default: -

CustomConfig

This config is used for special projects, e.g. for Makefile projects.
It’s valid to leave a CustomConfig completely empty - nothing will be done in that case.

Mandatory: no, quantity: 0..n, default: -

extends

Attribute of ExecutableConfig, LibraryConfig or CustomConfig.

Inherit settings from parent config(s). For more information see docu page Derive configs.

Mandatory: no, quantity: 0..1, default: -

mergeInc

Attribute of ExecutableConfig, LibraryConfig or CustomConfig.

If set to “no”, the IncludeDirs will NEVER be merged.
If set to “yes”, inherited IncludeDirs will merged when compiling this config except for IncludeDirs which configs have mergeInc.
If set to “all”, all IncludeDirs will merged when compiling this config except for IncludeDirs which configs have mergeInc.
If unset, IncludeDirs will not be merged when compiling this config.

See also Merge Includes.

Mandatory: no, quantity: 0..1, default: <unset>

private

Attribute of ExecutableConfig, LibraryConfig or CustomConfig.

If true, the config cannot be referenced directly outside of this project.

Mandatory: no, quantity: 0..1, default: false

IncludeDir

Specifies the include directories for the assembler, C and C++ compiler.

Use always relative paths, not absolute paths due to portability.

Use always “/” and not “\”.

It is possible to work with different workspace roots. Do not include something like this:
IncludeDir “../abc/include”
but
IncludeDir “abc/include”
because it may happen, that abc does not exist in the same root as the current project. The path to abc will be calculated automatically.
To include directories of the current project, the project name can be omitted like this:
IncludeDir “include”
IncludeDir “generated/include”

Mandatory: no, quantity: 0..n, default: -

inherit

Attribute of IncludeDir.

Inherits the include to all projects, which depend on this project.

Mandatory: no, quantity: 0..1, default: false

inject

Attribute of IncludeDir or Dependency.

Injects the element to all childs, either at the front (e.g. for mocking code) or at the back.

Avoid to inject dependencies, it will get a mess.

Mandatory: no, quantity: 0..1, default: -

system

Attribute of IncludeDir.

If supported from the compiler, the system include flag will be used instead of the normal include flag.
For example in gcc “-isystem” instead of “-I” is used.
Note: system include definition overrules normal include definition if both are defined.

Mandatory: no, quantity: 0..1, default: false

Set

Sets a variable for this and all dependent projects.
The variable can be a simple value or the result of a cmd, e.g. “cat myVar.txt”.

Mandatory: no, quantity: 0..n, default: -

env

Attribute of Set.

Stores the variable also in system environment, which makes it available in everything which is executed by bake, e.g. in Pre- and PostSteps.

Mandatory: no, quantity: 0..1, default: false

Dependency

Specifies another project to be built before this project.
The archives, linker libs and search paths are inherited from this project automatically.
If you omit the project, the current project will be used.
If you omit the config name, the default config will be used.
Examples:
Dependency gtest, config: lib
Dependency “my/folder/proj”

Mandatory: no, quantity: 0..n, default: -

config (Dependency)

Attribute of Dependency.

Config name of the dependent project.

Mandatory: no, quantity: 0..1, default: <default config of the dependent project>

ExternalLibrary

Every config can specify libs which have to be linked to the executable.
It’s possible to add a path, e.g.:
ExternalLibrary “xy/z/ab”
In this case the lib “ab” is added to the linker command line as well as the lib search path “xy/z”.
Note, that the linker will look for “libab.a”.’

Mandatory: no, quantity: 0..n, default: -

UserLibrary

A user library will be linked before any other libraries or objects to the executable.
It is also possible to specify an object file.
The library will be searched like an ExternalLibrary, but with the full name, e.g.
UserLibrary “xy/z/libUser.a”
UserLibrary “xy/z/something.o”
will link “libUser.a” and “something.o” before regular objects and libraries.
“xy/z” will be added as an ExternalLibrarySearchPath.

Mandatory: no, quantity: 0..n, default: -

ExternalLibrarySearchPath

The linker looks for libraries in search paths.
Search paths can be defined implicitly by ExternalLibrary/UserLibrary or explicitly by this tag.

Mandatory: no, quantity: 0..n, default: -

PreSteps

PreSteps are executed before compiling files of the config.
The number of steps is not limited.
If a step fails, all further steps of the config will be skipped.

Mandatory: no, quantity: 0..1, default: -

PostSteps

PostSteps are executed after the main task of the project, e.g. linking an executable.
The number of steps is not limited.
If a step fails, all further steps of the config will be skipped.

Mandatory: no, quantity: 0..1, default: -

StartupSteps

StartupSteps of ALL configs are executed before building the first config.
The number of steps is not limited.

Mandatory: no, quantity: 0..1, default: -

ExitSteps

ExitSteps of ALL configs are executed after building complete workspace even if the build has failed.
The number of steps is not limited.

Mandatory: no, quantity: 0..1, default: -

CleanSteps

CleanSteps are executed when calling bake with “-c” or “–rebuild”.
The number of steps is not limited.
If a step fails, all further steps will be skipped.

Mandatory: no, quantity: 0..1, default: -

Makefile

Makefile to be started, e.g.: Makefile “subDir/makefile”

Before executing the makefile, bake sets the environment variables $(BAKE_XX_COMMAND) and $(BAKE_XX_FLAGS), whereas XX is one of CPP, C, ASM, AR or LD.

Mandatory: no, quantity in steps: 0..n, quantity in CustomConfig: 0..1, default: -

lib

Attribute of Makefile.

If the result of the makefile is a library which shall be linked to the executable, name it here.

Mandatory: no, quantity: 0..1, default: -

target

Attribute of Makefile.

The target of the makefile.

Mandatory: no, quantity: 0..1, default: all

pathTo

Attribute of Makefile.

Comma separated list, e.g. “common, abc, xy”.
The makefile can use variables like $(PATH_TO_common). This is very useful if paths to other projects are needed in the makefile.
Remember that more than one workspace root can exist and a hardcoded “../common” is not reliable in that case.
$(PATH_TO_common) will result in the path from the parent directory of the current project to the common project without the common directory itself.
If the current project and the common project have the same parent folder, the string will be empty.
Example:
makefile: c:\workspaceroot\yourProject\makefile
usage in makefile: gcc -I$../../$(PATH_TO_common)common/include …

Mandatory: no, quantity: 0..1, default: -

noClean

Attribute of Makefile.

If project is cleaned (e.g. with command line argument -c), the target “clean” will be executed unless noClean is set to true.

Mandatory: no, quantity: 0..1, default: false

changeWorkingDir

Attribute of Makefile.

If set to false, the working directory will be the project directory instead of the makefile directory.

Mandatory: no, quantity: 0..1, default: true

echo (CommandLine, Makefile, Sleep)

Attribute of Makefile, CommandLine and Sleep.

“on” means the command line is shown in output, “off” means the command line is not shown.

Mandatory: no, quantity: 0..1, default: on

independent

Attribute of Makefile, CommandLine and Sleep.

“true” means the step can be built in parallel to other projects.
“false” means everything before must be completed, the step runs exclusively.

Mandatory: no, quantity: 0..1, default: false

validExitCodes

Attribute of Makefile and CommandLine.

Define it as an array, e.g.:
…, validExitCodes: [200,201,202]

Mandatory: no, quantity: 0..1, default: [0]

Flags (makefile)

Additional makefile flags.

Mandatory: no, quantity: 0..n, default: -j

CommandLine

A command to execute, e.g.:

CommandLine "ddump -Ruv -y 0xFFFFF -oRelease/application.bin Release/application.elf"
CommandLine "echo Hello world!"

The command line string cannot be wrapped into multiple lines. If the command line gets long and unreadable, use an array to split the string, e.g.

CommandLine ["myCommand --which is --very",
             "--long and --can be splitted"]

The array is internally joined to an string again with spaces in between.

Mandatory: no, quantity in steps: 0..n, quantity in CustomConfig: 0..1, default: -

Sleep

Sleep in seconds, floats are allowed.

Mandatory: no, quantity: 0..n, default: 0.0

MakeDir

A file or folder will be created.

Mandatory: no, quantity: 0..n, default: -

Remove

A file or folder will be removed. Wildcards are supported. Examples:

Remove file1
Remove "x/y/*.txt"

Mandatory: no, quantity: 0..n, default: -

Touch

A file or folder will be touched.

Mandatory: no, quantity: 0..n, default: -

Copy

A file or folder will be moved. Wildcards are supported. Examples:

Copy file1, to: file2
Copy "x/y/*.txt", to: "a/b"
Copy "source/*", to: target

Mandatory: no, quantity: 0..n, default: -

Move

A file or folder will be copied. Wildcards are supported. Examples:

Move file1, to: file2
Move "x/y/*.txt", to: "a/b"
Move "source/*", to: target

Mandatory: no, quantity: 0..n, default: -

echo (MakeDir, Remove, Touch, Copy, Move)

Attribute of MakeDir, Remove, Touch, Copy and Move.

“on” means a debug output is shown.

Mandatory: no, quantity: 0..n, default: on

DefaultToolchain

Settings which are valid for all configs unless they will be overwritten.
The attribute “basedOn” specifies the basic toolchain configuration provided by bake, e.g. “GCC”, “Diab”, etc.

Mandatory: in main config, quantity: 1, default: -

Toolchain

Toolchain settings for a specific config.’

Mandatory: no, quantity: 0..1, default: the DefaultToolchain settings from the main config

outputDir

Attribute of DefaultToolchain and Toolchain.

Specifies the output folder.
Use always relative paths, not absolute paths due to portability.
Use always “/” and not “\”.
If the first part of the path is equal to a project name, it is used as a shortcut to this project root.
To avoid this magic, use something like this:
IncludeDir “./abc/include”
Mandatory: no, quantity: 0..1,
default for main config: <project root>/build/<configName>,
default for every other config: <project root>/build/<configName>_<mainProjectName>_<mainConfigName>

outputDirPostfix

Attribute of DefaultToolchain and Toolchain.

Specifies a postfix for the output folder.
It’s intended to be used by special builds like MISRA checks.

Mandatory: no, quantity: 0..1,, default: -

eclipseOrder

Attribute of DefaultToolchain.

If not specified or false, all files are compiled in order of appearance in Project.meta.
If the filename is a glob pattern, files are sorted alphabetically.
If true, files are compiled in alphabetical order within a folder, but the folders are sorted in reverse alphabetical order.
This is only used for backward compatibility. Will be removed in future.

Mandatory: no, quantity: 0..1, default: false

Compiler

Flags and defines can be specified independently for each compiler type (ASM, CPP, C).

Mandatory: no, quantity: 0..3, default: -

Archiver

Settings for the archiver.

Mandatory: no, quantity: 0..1, default: -

Linker

Settings for the linker.

Mandatory: no, quantity: 0..1, default: -

Docu

Command to build the documentation. e.g.: doxygen main.cfg

Mandatory: no, quantity: 0..1, default: -

command

Attribute of Compiler, Archiver, Linker.

Changes the predefined command, e.g. “gcc”.

Mandatory: no, quantity: 0..1, default: -

prefix

Attribute of Compiler, Archiver, Linker.

Wrapper for the command, e.g. a (s)ccache.
If variable is not set, no prefix is used.
You can use the adapt feature to set the variable or overwrite the prefix.

Mandatory: no, quantity: 0..1, default: $(CompilerPrefix), $(ArchiverPrefix) or $(LinkerPrefix)

keepObjFileEndings

Attribute of Compiler.

If false, the original source file endings will be cut off (e.g. file1.cpp to file1.o), otherwise kept (file1.cpp.o).

Mandatory: no, quantity: 0..1, default: false

SrcFileEndings

List of all source file endings with dot and comma separated which are handled by this CPP, C or ASM compiler, e.g. “.cpp, .c, .cxx”. The list must not be empty.

Mandatory: no, quantity: 0..1, default: -

onlyDirectDeps

Attribute of Linker.

If set to true, only first level libraries will be linked (not sub-dependencies from dependencies).

Mandatory: no, quantity: 0..1, default: false

cuda

Attribute of Compiler.

Enables Cuda hack.
Adds some prefixes in front of dependency flags.

Mandatory: no, quantity: 0..1, default: false

Flags (DefaultToolchain)

Default flags.

Mandatory: no, quantity: 0..n, default: -

Flags (Toolchain)

Flags from the DefaultToolchain can be overwritten, extended or (partly) removed.

For removing flags use plain strings or regular expressions which can be interpreted by ruby (both is checked).
Flags will be only removed if matching completely (not only a substring).
Flag strings are always splitted at spaces and computed individually.
Examples:
Flags “-x -y” overwrites the inherited flags
Flags add: “-x -y” adds -x and -y if not exist
Flags remove: “-x -y” removes -x and -y if exist
It is possible to combine the attributes like this:
Flags remove: “-x”, add: “-y”
To remove -g followed by any string, e.g. -g3, the command is:
Flags remove: “-g.*”
An inherited flag string “-abc -g3 -xy” will end up in “-abc -xy”.

Mandatory: no, quantity: 0..n, default: Flags from DefaultToolchain”

Flags (Files)

Flags from the Toolchain can be overwritten, extended or (partly) removed, see above.

Mandatory: no, quantity: 0..n, default: -

Define (DefaultToolchain)

Defines which are valid for all files.

Mandatory: no, quantity: 0..n, default: -

Flags (Toolchain)

Defines which are valid for the files of this config.

Mandatory: no, quantity: 0..n, default: -

Define (Files)

Defines which are valid only for these specific files.

Mandatory: no, quantity: 0..n, default: -

LibPrefixFlags

Linker libs can be prefixed if needed, e.g. with “-Wl,–whole-archive”.

Mandatory: no, quantity: 0..n, default: -

LibPostfixFlags

Linker libs can be postfixed if needed, e.g. with “-Wl,–no-whole-archive”.

Mandatory: no, quantity: 0..n, default: -

InternalDefines

File with list of compiler internal defines.
One define per line.
Empty lines and comments with # are allowed.

Mandatory: no, quantity: 0..1, default: -

InternalIncludes

File with list of compiler internal include folders.
One folder per line.
Empty lines and comments with # are allowed.

Mandatory: no, quantity: 0..1, default: -

Files

Specifies the files to build.
It’s valid to specify a single file, e.g.
Files “src/abc/def.asm”
or a pattern, e.g.
Files “*/**/.cpp”
which builds all files with the ending “.cpp” in all subdirectories.
Note: “..” is not allowed in the file path. All files must be located within the project.

Mandatory: no, quantity: 0..n, default: -

ExcludeFiles

Used to ignore files or directories.
ExcludeFiles has higher priority than Files.

Mandatory: no, quantity: 0..n, default: -

compileOnly

Attribute of Files.

If set to true, the files will not be archived or linked.

Mandatory: no, quantity: 0..1, default: false

linkDirectly

Attribute of Files.

If set to true, the files will not be archived but linked directly to the executable.

Mandatory: no, quantity: 0..1, default: false

Prebuild

If defined, all configs of the workspace will be skipped per default.
Must be activated by the commandline option “–prebuild”.

Mandatory: no, quantity: 0..1, default: No project/config is skipped

Except

Defines a project which shall not be skipped. If project name is omitted, the current project is used.

Mandatory: no, quantity: 0..n, default: Every project is skipped

config (Except)

Attribute of Except.

Defines a config which shall not be skipped. If omitted, all configs of the appropriate project are not skipped.

Mandatory: no, quantity: 0..1, default: Every config is skipped

CompilationDB

Generates a compilation database in json.
Example:
CompilationDB “$(ProjectDir)/db.json”

Mandatory: no, quantity: 0..1, default: None. If CompilationDB is specified without an explicit filename, $(WorkspaceDir)/compile_commands.json is used.

CompilationCheck

Checks if files are included or excluded in build.
Priority if files are mentioned multiple times: ignore > exclude > include.
In case a check fails, bake will print a warning.
Examples:
CompilationCheck include: “include/*.h”, ignore: “include/ignoreThis.h”
CompilationCheck include: “$(ProjectDir, anotherLib)/src/important”

Mandatory: no, quantity: 0..n, default: -

LinkerScript

Specifies the name including path of the linker script.

Mandatory: no, quantity: 0..1, default: -

MapFile

A mapfile will be written by the linker.
If name attribute is omitted, the mapfile will be “$(OutputDir)/$(ArtifactNameBase).map”.

Mandatory: no, quantity: 0..1, default: No mapfile will be written

ArtifactName

The artifact name inclusive file ending.
The artifact will be placed in the output directory.

Mandatory: no, quantity: 0..1, default executable: project name + toolchain dependent file ending, default library: ‘lib’ + project name + ‘.a’

ArtifactExtension

The artifact extension, e.g. “exe”.
If ArtifactName is also specified, ArtifactExtension has no effect.

Mandatory: no, quantity: 0..1, default: toolchain dependent file ending