Skip to main content

Bloomery — A TOML-native Build System

Partially AI generated README content

Bloomery is a declarative build system driven entirely by plain TOML. There is no embedded scripting language: conditionals are ordinary TOML tables with a reserved on key, file resolution and other operations are tables with a reserved verb key, and everything else is {name}-style interpolation. Reusable molds (build presets) give you sane defaults per language.

Installation

pip install bloomery-build

The distribution is bloomery-build (bloomery was already taken on PyPI), but this installs the bloomery command itself — the examples below use that. Installing from a local checkout works the same way: pip install . If you'd rather not install anything, 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 bloomery-build

New to a project? bloomery init scaffolds a starter bloomery.toml in the current directory — asks for a project name and (optionally) a mold name, then writes [meta]/[variables]/[plugins.command] with sane defaults for you to add [tasks.*] to:

bloomery init

Requires Python 3.8+. Uses the stdlib tomllib on 3.11+; on 3.8–3.10 it pulls in tomli, a small pure-Python TOML parser — the only dependency Bloomery has, and only there because tomllib hasn't shipped yet.

Quick Start

# Build and run
bloomery project.toml

# Run a specific target
bloomery project.toml run

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

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

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

# List available targets
bloomery project.toml --list

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

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

# Print the version
bloomery --version

Project File Structure

project/
├── project.toml           ← Your project build config
├── main.cpp                ← Source files
├── c++.toml                ← 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.toml

Configuration Reference

Project TOML (project.toml)

[meta]
name = "myproject"
version = "1.0"
system = "c++"                # which bundled mold to load

[variables]
compiler = "g++"
debug = true
output = "myapp.exe"

[plugins.command]
prefix = { on = "platform", windows = "cmd /c", default = "" }

[plugins.hooks.build]
post = "echo Done!"            # scoped under [plugins.hooks.<task>]

[variables]
debug_flags = { on = "debug", true = "-g -O0", false = "-O2" }

[tasks.build]
depends = []                    # task names this one depends on
command = "{compiler}"
flags = "-std=c++17 {debug_flags}"
files = { ending = [".cpp", ".cc", ".cxx", ".c"] }
exclude = ["*_test.cpp"]
output = "-o {output}"

[tasks.run]
depends = ["build"]
command = "{output}"

[tasks.clean]
command = { on = "platform", windows = "cmd /c del /q", default = "rm -f" }
flags = "{output}"

A dispatch table has to be the entire value of a field — it can't sit inside a longer string the way you might expect from a templating language. When a field needs to mix literal text with a dispatch, as flags does above, give the dispatch its own named variable and reference it with {debug_flags}; there's no way to write the dispatch inline in flags itself.

Task names are the [tasks.*] keys themselves — bloomery project.toml build looks up [tasks.build] directly. There's no separate alias table; TOML's own key naming does that job.

Mold TOML (c++.toml)

Molds provide reusable build presets. A project references one via meta.system.

[bloomery]
mold = "c++"

[meta]
name = "C++"
version = "0.1"

[definitions]
compiler = "g++"
standard = "17"
flags = "-std=c++{mold.standard}"
files = { ending = [".cpp", ".cc", ".cxx", ".c"] }
output = "-o {input}.exe"

Profiles ([profiles.X])

Profiles overlay a named set of variables on top of [variables]:

[profiles.debug]
debug = true
debug_flags = "-g -O0"

[profiles.release]
debug = false
debug_flags = "-O2 -DNDEBUG"

Activate with --profile debug or --profile release. Profiles are the right tool for "this value differs by build mode" — reach for a dispatch table only for things that aren't a mode choice, like platform, which nothing selects and Bloomery just observes.

The DSL: interpolation + dispatch tables

Every project/mold file is plain TOML — a standard TOML parser reads it correctly with zero knowledge of Bloomery. Two conventions carry all of what would be "metaprogramming" in another build system.

Interpolation

Any string value may contain {...} references:

flags = "{compiler} -Wall"                → g++ -Wall
name  = "{env.USER}_build"                → alice_build
flags = "{mold.flags}"                    → mold's own flags field
output = "{task.compile.outputs}"         → files another task produced

Dispatch tables — the on key

A table with an on key picks a branch by the current value of that variable, with default as the fallback:

output = { on = "platform", windows = "hello.exe", default = "hello" }
flags  = { on = "debug", true = "-g -O0", false = "-O2 -DNDEBUG" }

A branch can itself be another dispatch table, a list, or a plain string — resolution recurses. -D debug=false on the command line, or an override from [profiles.X], both just change what a dispatch reads; nothing about the mechanism cares where the value came from.

Reserved-key tables — files, shell, exists

A handful of other reserved keys cover the rest of what used to be tag directives:

files = { ending = [".cpp", ".cc"] }             # by extension, project dir
files = { in = "lib", ending = [".cpp"] }        # ...scoped to a directory
files = { matching = "src/**.cpp" }              # by glob, recursive
greeting = { shell = "date +%Y%m%d" }            # captured stdout
has_cfg  = { exists = "config.h" }               # "true" / "false"
defines  = { prefix = "-D", items = ["A", "B"] } # → "-DA -DB"

Every value here is resolved recursively too, so items can itself be a dispatch table, another reserved-key table, or an interpolated string.

Incremental Builds

Header dependencies

Bloomery hashes file contents to decide what to rebuild. Files 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:

headers = { ending = [".h", ".hpp"] }     # explicit: hashed, never passed to the compiler

flags   = "-c -MMD -MF obj/{stem}.d"      # automatic: read the compiler's own
depfile = "obj/{stem}.d"                  # dependency output

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 = { 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.toml            # 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.mold_path (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.toml 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} only; they are not copied into the variable namespace, so a mold key named files cannot shadow a project variable of the same name. A mold's own definitions cross-reference each other the same way — flags = "-std=c++{mold.standard}" inside the mold's own [definitions].

Special variables

Name Description
{platform} Current OS: windows, linux, or macos — seeded automatically
{input} Primary source file's stem (auto-set from files)
{stem} Current file's stem, in a mode = "per-file" task

These are ordinary variables, not special syntax — {platform} and a dispatch { on = "platform", ... } both just read the same value.

Architecture

bloomery/
├── context.py     — Context: raw variables, platform, mold, per-task fork
├── evaluator.py   — Evaluator: dispatch tables, reserved keys, {interp}
├── cache.py       — BuildCache + depfile parsing
├── dag.py         — TaskDAG: dependency graph, topo sort, parallel waves
├── plugins.py     — PluginManager: command prefix, hooks
├── runner.py      — TaskRunner: field resolution → cache → execute
├── config.py      — parse_toml, profiles, mold search/inheritance
├── cli.py         — argparse, main(), task execution loop
├── selfmanage.py  — install/update/uninstall/init, the cli() entry point
├── errors.py      — BloomeryError and its subclasses
├── molds/         — Bundled build presets (c, c++, rust, python)
└── storage/       — bloomery init's starter template

Each module is a few hundred lines with a single job; __init__.py re-exports the public API so from bloomery import Evaluator still works regardless of which file it actually lives in.

There is no parser to speak of — tomllib does that — and no multi-pass resolution loop. A value is walked once, recursively; a dispatch branch or reserved-key argument that's itself a table is just another recursive call, not more text to re-scan.

Comparison with Make/CMake

Feature Bloomery Make CMake
Config format TOML Makefile CMakeLists.txt
Metaprogramming None — dispatch tables + interpolation Shell commands CMake language
Templates/Molds ✅ .toml molds ❌ ✅ Toolchain files
Conditional builds { on = "var", ... } ifeq if()
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} seeded automatically ❌ (manual) ✅ Built-in
Learn curve TOML + two reserved-key conventions Makefile syntax CMake language

Development

pip install -e ".[dev]"
pytest

Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.

Metadata

Release files for bloomery-build 0.2.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.2.0
File Size Uploaded Provenance Actions
bloomery_build-0.2.0.tar.gz 35.5 kB Without provenance Details for bloomery_build-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 61.4 kB

Release files / bloomery_build-0.2.0.tar.gz

Download URL bloomery_build-0.2.0.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b0e6f18a3563118641ccdca654c0240bd3d0dcddbd5e5e0edff7da6672f94514
BLAKE2b-256 checksum
How to use checksums
25510faa424ebf8a5595af9a09726f5371155f8bb01cb0bfcf2571616ec1b7fa
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.2.0-py3-none-any.whl

Download URL bloomery_build-0.2.0-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f642760afe3fd38e6c4ff55e834fcdb613fca3b13d480abcd647ecf1ea7f33e0
BLAKE2b-256 checksum
How to use checksums
2d123a0b8e35e5d3059bdeb7fdc2259a9384e80687e93aba58f0df01cb285958
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.2.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