Skip to main content

Project Scaffolding

The scaffolding system generates a complete project structure from templates, giving new components a working build system, CI configuration, and standard project files from the start. The generated files implement the component protocol defined in ADR-0004 — Workspace and Component Protocol and the build system conventions from ADR-0005 — CMake as the Build System.

Usage

Create a directory, initialize a Git repository, and run make init:

mkdir mylib && cd mylib
git init
make -C /path/to/ideal-cmake-modules init NAME=mylib DESC="A sample library"

Variables

VariableDefaultDescription
DESC(required)Short description
DIRWorking directoryOutput directory
MAINTAINERCarlos Prado Garcia <cpradog@cpradog.com>Package maintainer
NAME(required)Component name
REPO_NAMEideal-<NAME>Repository name in sr.ht
REPO_URLhttps://git.sr.ht/~cpradog/<REPO_NAME>/Repository URL

Override defaults by passing them on the command line:

make -C /path/to/ideal-cmake-modules init NAME=mylib DESC="My library" REPO_NAME=my-custom-repo

Generated files

FileDescription
.build.ymlSourceHut CI manifest
.clangdClangd language server configuration
.editorconfigEditor formatting settings (UTF-8, 2-space indent, 120 cols)
.gitignoreGit ignore rules for build artifacts
CMakeLists.txtProject definition with IdealCmakeModules dependency
CMakePresets.jsonConfigure, build, and test presets for all standard workflows
LICENSEEUPL-1.2 with Ideal Plugin Exception
MakefileGNU Make wrapper around CMake presets
README.mdProject README with build instructions

Makefile targets

The generated Makefile provides targets that wrap the corresponding CMake presets and build targets:

TargetDescription
buildConfigure and build (default)
testRun the test suite
tidyRun clang-tidy with auto-fix
checkRun tidy and tests
coverageBuild and generate coverage report
pot-updateExtract translatable strings into .pot
po-updateUpdate all .po files from the template
docsGenerate documentation
push-docsDeploy documentation to portal
installInstall to configured prefix
uninstallUninstall
distCreate source tarball
apkBuild APK package
cleanClean build artifacts
distcleanRemove all generated files

Pass PRESET= to select a build preset (default release), and V=1 for verbose output.

Presets

The CMakePresets.json defines configure, build, and test presets for all standard workflows. All presets inherit from a hidden base preset that sets the build directory to build/<preset> and disables all optional features by default.

PresetBuild typeTestingFeatures
asanDebugOnAddressSanitizer, UndefinedBehaviorSanitizer
ciDebugOnDocumentation
coverageDebugOnCode coverage instrumentation
debugDebugOnFull debug symbols
devRelWithDebInfoOnOptimized with debug info
docsReleaseOffDocumentation generation
releaseReleaseOffOptimized release build (default)
tsanDebugOnThreadSanitizer
ubsanDebugOnUndefinedBehaviorSanitizer

Select a preset by passing PRESET= to Make:

make build PRESET=dev
make test PRESET=dev
make build PRESET=asan
make test PRESET=asan

The default preset is release.

CI pipeline

The .build.yml manifest defines a SourceHut CI pipeline that runs on Alpine Linux edge. The pipeline is divided into two phases.

The first phase runs on every push:

StepDescription
buildBuilds the project with make build PRESET=ci
testRuns the test suite with make test PRESET=ci
build_docsGenerates documentation and validates links

The second phase only runs on release branches (main and stable/*). All other branches stop after the first phase.

StepDescription
versionDetermines the next version from conventional commits
distCreates a source tarball and uploads it as a CI artifact
deploy_docsPublishes documentation to the portal repository
packageBuilds an APK package and publishes it to the Ideal APK repository

The version step uses the version bump script to derive the next version from the commit history. On main, prerelease versions are tagged with an rc suffix. On stable/* branches, only non-breaking changes are allowed. If the computed version matches the current tag, the pipeline stops — there is nothing to release.

What's next

After running make init:

  1. Add your source code under src/ and headers under include/.
  2. Edit CMakeLists.txt to define your targets.
  3. Build with make build.