bake supports deriving configs, which allows you to put repetetive settings in a base config.
Derving a config in bake is pretty straight forward, and looks like this:
ExecutableConfig A
LibraryConfig B, extends: A
CustomConfig C, extends: B
ExecutableConfig D, extends: C
Note
The config type of the parent config does not matter, but only settings which are valid in BOTH configs will be inherited. In the example above D gets the dependencies from A, because “Dependency” is valid in all configs, but D does not get the “Files” from A and B, because “Files” is not valid in CustomConfig.
In general it is very easy.
The following example
ExecutableConfig A {
Files "x.cpp"
Files "y.cpp"
ArtifactName "z.exe"
DefaultToolchain GCC {
Linker {
Flags "-O3"
}
}
}
ExecutableConfig B, extends: A {
Files "z.cpp"
IncludeDir "inc"
ArtifactName "a.exe"
DefaultToolchain Diab {
Compiler CPP {
Define "TEST"
}
}
}
results implicitly in:
ExecutableConfig B {
Files "x.cpp"
Files "y.cpp"
Files "z.cpp"
IncludeDir "inc"
ArtifactName "a.exe"
DefaultToolchain Diab {
Compiler CPP {
Define "TEST"
}
Linker {
Flags "-O3"
}
}
}
It is possible to derive from several projects:
ExecutableConfig A
LibraryConfig B
ExecutableConfig C, extends: "A, B"
“extends” defines a comma separated list. The merge will be performed with all parent configs.