Advanced
Template files
Target definitions such as programs, libraries and exports can define a list of templates. Templates can be:
- a string to specify the path to the template file (e.g.
'src/main.h.template') - a template definition
Here how to define a template definition:
# Example 1 (in a target definition)
templates = [
'src/version.h.template'
],
#...
# Import
from golemcpp.golem.template import Template
# Example 2 (in a target definition)
templates = [
Template(source='src/version.h.template')
],
#...
# Example 3 (in a target definition)
templates = [
Template(source='manifest-data.json.in'
target='data/manifest.json',
build=False)
],
#...sourcestring to specify the path to the template filetargetstring to specify the path to the output file relative to the output directoryDefault is
None: Removes extensions.templateor.infrom the source if found, otherwise adds.cppto the source.buildboolean to specify if the output file needs to be added to the buildDefault is
None:- If the output file has for extension
'.cpp','.cxx','.c','.cc':- Builds the output file
- If the output file has for extension
'.hpp','.hxx','.h','.hh':- Adds the output directory to the includes
If
False, won’t add the output file to the build, even if the extension matches the extensions mentioned above.If
True:- If the output extension matches the extensions above, it follows the default logic.
- If the output extension doesn’t match the extensions above, builds the output file.
- If the output file has for extension
The template file is processed by replacing pre-defined keys found it the file under the form @KEY@. Here is the list of available keys:
GOLEM_TMPL_VERSION_HASHGOLEM_TMPL_VERSION_REVISIONGOLEM_TMPL_VERSION_MESSAGEGOLEM_TMPL_VERSION_BUILD_NUMBERGOLEM_TMPL_VERSION_SEMVERGOLEM_TMPL_VERSION_SEMVER_LONGGOLEM_TMPL_VERSION_SEMVER_SHORTGOLEM_TMPL_VERSION_SEMVER_MAJORGOLEM_TMPL_VERSION_SEMVER_MINORGOLEM_TMPL_VERSION_SEMVER_PATCHGOLEM_TMPL_VERSION_SEMVER_PRERELEASEGOLEM_TMPL_VERSION_SEMVER_BUILDMETADATAGOLEM_TMPL_VERSIONGOLEM_TMPL_VERSION_SHORTGOLEM_TMPL_VERSION_LONGGOLEM_TMPL_VERSION_MAJORGOLEM_TMPL_VERSION_MINORGOLEM_TMPL_VERSION_PATCHGOLEM_TMPL_VERSION_PRERELEASEGOLEM_TMPL_VERSION_BUILDMETADATAGOLEM_TMPL_VERSION_GIT_DESCRIBE_SHORTGOLEM_TMPL_VERSION_GIT_DESCRIBE_LONGGOLEM_TMPL_VERSION_GIT_TAGGOLEM_TMPL_VERSION_GIT_REVISIONGOLEM_TMPL_VERSION_GIT_MESSAGEGOLEM_TMPL_VERSION_GIT_BRANCHGOLEM_TMPL_VERSION_GIT_BRANCH_MACROGOLEM_TMPL_VERSION_BRANCHGOLEM_TMPL_VERSION_BRANCH_MACROGOLEM_TMPL_DATE_UTC_ISO8601GOLEM_TMPL_PLATFORMGOLEM_TMPL_RUNTIMEGOLEM_TMPL_RUNTIME_VERSIONGOLEM_TMPL_RUNTIME_VERSION_SEMVERGOLEM_TMPL_ARCHITECTUREGOLEM_TMPL_TARGET_ARTIFACT_BASENAME
Build number
When building the project under a CI environment, it is often useful to keep track of the builds independantly from the version set on the project.
To enable the use of the build number, set project.enable_build_number = True.
When enabled, Golem searches for an environment variable BUILD_NUMBER and expects its value to be an integer.
The build number is used for different purposes:
- To generate the filename of packages
- As a replacable key in template files
- To set the buildmetadata component on the SemVer version of the project
Force build options on targets and dependencies
TODO
Examples
To learn with examples have a look at:
Customization of dependencies
TODO
Examples
To learn with examples have a look at: