Skip to main content

Bloomery — A Metaprogrammable Build System

Partially AI generated

Bloomery is a declarative, INI-based build system with a powerful metaprogramming DSL. Configure builds using simple .ini files, leverage reusable molds (templates), and express complex build logic with directives like conditionals, loops, shell substitution, and variable interpolation.

Installation

pip install .

This installs a bloomery command. The examples below use it; if you'd rather not install, python -m bloomery works identically everywhere.

To track the git checkout instead, so updates are just a pull:

bloomery install     # pip install -e the checkout (clones one if needed)
bloomery update      # git pull it
bloomery uninstall   # pip uninstall

Requires Python 3.8+ and has no runtime dependencies.

Quick Start

# Build and run
bloomery project.ini

# Run a specific target
bloomery project.ini run

# Force a full rebuild
bloomery project.ini --clean

# Dry run (show commands, don't execute)
bloomery project.ini --dry-run

# Override a variable
bloomery project.ini -D debug=false

# List available targets
bloomery project.ini --list

# Verbose mode (show directive resolution)
bloomery project.ini --verbose

# Use a build profile
bloomery project.ini --profile release

# Build independent tasks in parallel (0 = one job per CPU)
bloomery project.ini -j4

# Print the version
bloomery --version

Project File Structure

project/
├── project.ini           ← Your project build config
├── main.cpp              ← Source files
├── c++.ini               ← Optional: a local mold overriding the bundled one
└── .bloomery_cache.json  ← Auto-generated build cache

A runnable example lives in examples/hello-cpp/:

cd examples/hello-cpp
bloomery project.ini

Configuration Reference

Project INI (project.ini)

[Meta]
Name = myproject
Version = 1.0
Author = You
System = c++              ; Which mold to load

[Variables]
compiler = g++            ; Project-level variables
debug = true
output = myapp.exe

[Plugins.Command]
Prefix = <if(platform=windows)>cmd /c<end>

[Plugins.Hooks]
PostBuild = echo Done!         ; Pre<Task> / Post<Task> / OnFail<Task>

[Tasks]
build = Build             ; alias = SectionName
run = Run
clean = Clean

[Tasks.Build]
Depends =                  ; Comma-separated task dependencies
Command = {compiler}
Flags = -std=c++17 <if(var(debug))>-g -O0<else>-O2<end>
Files = <files ending (.cpp|.cc|.cxx|.c)>
Exclude = *_test.cpp       ; Glob patterns to exclude (optional)
Output = -o {output}

[Tasks.Run]
Depends = Build
Command = {output}

[Tasks.Clean]
Command = <if(platform=windows)>cmd /c del /q<else>rm -f<end>
Flags = {output}

Mold INI (c++.ini)

Molds provide reusable build presets. A project references a mold via Meta.System.

[Bloomery]
Mold = c++

[Meta]
Name = C++
Version = 0.1

[Definitions]              ; Default values that tasks can inherit
Compiler = g++
Standard = 17
Flags = -std=c++<var(standard)>
Files = <files ending (.cpp|.cc|.cxx|.c)>
Output = -o <input>.exe

Profiles ([Profiles.X])

Profiles let you define variable sets for different build modes:

[Profiles.debug]
debug = true
optimize = false

[Profiles.release]
debug = false
optimize = true

Activate with --profile debug or --profile release.

Metaprogramming DSL

Variables

[Variables]
myvar = hello

; Directives
Flags = <var(myvar)>                      → hello
Command = <env(PATH)>                     → system PATH value
Output = -o <shell(date +%Y%m%d)>.exe    → -o 20260620.exe

Interpolation

Flags = {compiler} -Wall                 → g++ -Wall
Name = {env.USER}_build                  → alice_build

Conditional — <if>

; Platform condition
Command = <if(platform=windows)>g++.exe<else>g++<end>

; Variable truthiness
Flags = <if(var(debug))>-g -O0<else>-O2<end>

; Variable equality
Flags = <if(var(mode)=safe)>-fsanitize=address<end>

; Negation
Flags = <if(!var(debug))>-DNDEBUG<end>

; File existence
Flags = <if(exists(config.h))>-DHAVE_CONFIG<end>

; Environment variable
Flags = <if(env(CI))>-DCI_BUILD<end>

; elif chain
Flags = <if(var(level)=1)>-O1<elif(var(level)=2)>-O2<elif(var(level)=3)>-O3<else>-O0<end>

Loops — <for>

; Literal list
Defines = <for(d in DEBUG|VERBOSE)>-D{d}<end>     → -DDEBUG -DVERBOSE

; File iteration
Check = <for(f in files: .cpp)>echo {f}<end>

; Numeric range
Ids = <for(i in range(1,5))>-DID_{i}<end>         → -DID_1 -DID_2 -DID_3 -DID_4

File Resolution

; By extension (in project directory)
Files = <files ending (.cpp|.cc|.cxx|.c)>

; By glob pattern (recursive)
Files = <files matching (src/**.cpp)>

; Directory-scoped + extension
Files = <files in (lib; .cpp|.cc)>

; Exclude patterns (separate field)
Exclude = *_test.cpp *_bench.cpp

Incremental Builds

Header dependencies

Bloomery hashes file contents to decide what to rebuild. Files that the compiler reads via #include never appear on the command line, so they must be declared — otherwise editing a header leaves you with a stale binary. There are two ways:

; Explicit: hashed, but never passed to the compiler
Headers = <files ending (.h|.hpp)>

; Automatic: read the compiler's own dependency output
Flags   = -MMD -MF obj/<stem>.d
DepFile = obj/<stem>.d

DepFile is preferred — it tracks exactly the headers each file actually included, transitively, instead of over-invalidating on every header.

Per-file compilation

Mode = per-file runs one command per input with its own cache entry, so editing one source recompiles only that source. <stem> is the current file's name without its extension, and {task.X.outputs} lets a link step consume what a compile step produced:

[Tasks.Compile]
Mode = per-file
Command = {compiler}
Flags = -c -MMD -MF obj/<stem>.d
Files = <files ending (.cpp)>
Output = -o obj/<stem>.o
DepFile = obj/<stem>.d

[Tasks.Link]
Depends = Compile
Command = {compiler}
Files = {task.Compile.outputs}
Output = -o {output}
$ bloomery project.ini            # after editing only main.cpp
[RUN]  Compile [main.cpp]: ...
[SKIP] Compile [util.cpp] (up to date)
[RUN]  Link: ...

Per-file tasks are also what make -j worthwhile — independent tasks in the same dependency level run concurrently.

Molds

Molds are looked up by Meta.System in this order, first match winning:

  1. The project directory
  2. Meta.MoldPath (paths relative to the project)
  3. $BLOOMERY_MOLD_PATH
  4. ~/.bloomery/molds/
  5. The molds bundled with Bloomery — currently c, c++, rust, python

So System = c works with no local file, and dropping a c.ini beside your project overrides the bundled one. A mold that can't be found is an error listing every path searched.

Molds may build on one another:

[Bloomery]
Mold = c++
Extends = c        ; inherit any [Definitions] not defined here

Mold definitions are reached with <mold(Field)> or {mold.Field}; they are not copied into the variable namespace, so a mold key named Files cannot shadow a project variable of the same name.

Mold References

; Use mold's default for the current field
Flags = <mold()> -Wall

; Use mold's specific field
Command = <mold(Compiler)>

; Explicitly no mold contribution (empty)
Files = <mold(none)> <files matching (vendor/**.c)>

Special Directives

Directive Description
<platform> Current OS: windows, linux, or macos
<exists(path)> 'true' if file exists, else 'false'
<input> Primary source file stem (auto-set from Files)
<stem> Current file's stem, in a Mode = per-file task
<shell(cmd)> Captured stdout of shell command

Architecture

bloomery/
├── core.py              — Everything below
├── molds/               — Bundled build presets (c, c++, rust, python)
│
├── Context              — Evaluation state (variables, platform, mold)
├── DirectiveEngine      — Metaprogramming template resolver
│   ├── resolve()        — Main entry point
│   ├── Control flow      — <if>/<elif>/<else>/<end>, <for>/<end>
│   ├── Simple directives — <var>, <env>, <shell>, <mold>, <files…>
│   ├── Interpolation     — {expr}
│   └── Condition eval     — Platform, var, env, exists checks
├── BuildCache           — Content-based incremental builds + header deps
├── TaskDAG              — Dependency graph, topological sort, parallel waves
├── PluginManager        — Command prefix, hooks
└── TaskRunner           — Field resolution → cache → execute

Comparison with Make/CMake

Feature Bloomery Make CMake
Config format INI Makefile CMakeLists.txt
Metaprogramming Built-in DSL Shell commands CMake language
Templates/Molds ✅ .ini molds ❌ ✅ Toolchain files
Conditional builds <if(platform=…)> ifeq if()
Loops <for(var in list)> foreach foreach
Incremental builds Content-hash cache Mtime checks CMake cache
Header tracking DepFile / Headers -MMD + include ✅ Automatic
Parallel builds -j N -j N --parallel N
Cross-platform <platform> + <if> ❌ (manual) ✅ Built-in
Learn curve INI + directives Makefile syntax CMake language

Extending Bloomery

Custom Directive Handlers

from bloomery import DirectiveEngine, Context

ctx = Context(variables={"lib": "mylib"})
engine = DirectiveEngine(ctx)

def handle_lib(args):
    return f"-l{args or ctx.get_var('lib')}"

engine.register_handler("lib", handle_lib)
result = engine.resolve("<lib(boost)>")   # → "-lboost"

Custom Hooks

[Plugins.Hooks]
PreBuild = echo "Starting build..."
PostBuild = echo "Build complete!"
OnFailBuild = echo "Build failed!" && exit 1

Development

pip install -e ".[dev]"
pytest

Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.

Metadata

Release files for bloomery-build 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bloomery-build 0.1.0
File Size Uploaded Provenance Actions
bloomery_build-0.1.0.tar.gz 39.7 kB Without provenance Details for bloomery_build-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bloomery-build 0.1.0
File Interpreter ABI Platform Actions
bloomery_build-0.1.0-py3-none-any.whl Python 3 none any Details for bloomery_build-0.1.0-py3-none-any.whl

Total release size: 64.8 kB

Release files / bloomery_build-0.1.0.tar.gz

Download URL bloomery_build-0.1.0.tar.gz
Size 39.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c726ff7ee5126e85d1fa7183d5241b57883476a6e90efd972e25dde18ccb5914
BLAKE2b-256 checksum
How to use checksums
7feb09f73af366df7ccfc1f7e0dd7cf7e3596ce6ca5377f13c626a91330d0725
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / bloomery_build-0.1.0-py3-none-any.whl

Download URL bloomery_build-0.1.0-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b944311b78b076e64141afb6422cd748f773f8c4ff8c1cef9974a0e93f48b919
BLAKE2b-256 checksum
How to use checksums
6c48ae1cb9e71f2d1562905a23d9b2842e3ab84239fc93f31707e2efec46fabe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for bloomery-build 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page