2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00
2026-10-29 07:37:29 -05:00

blossom

blossom builds Sakura projects, as chinook builds C ones. A blossomfile in a project's folder says who the project is, what it requires, and its targets and tests. blossom reads it and those of what it requires, then runs sakura for each step: one command a program.

blossom build                  # check the project's libraries, then build its programs
blossom check                  # check each target, writing nothing
blossom run -- 3 4             # run the project's program on the machine, given `3 4`
blossom test --only geometry   # build, then run the tests whose names hold `geometry`
blossom clean --all            # remove .blossom
blossom install --prefix ~/.local
blossom package -f tar,deb     # write packages into .blossom/<key>/dist
blossom pull binary            # clone a requirement, or with no name, all of them
blossom libraries              # print the --lib of each library the project reads

Building blossom

Until blossom has built itself once, the compiler builds it, given the standard library it reads, checked out beside this repository:

sakurac build -O2 -o blossom --lib std=../std \
  entry.sakura models/*.sakura management/*.sakura pipeline/*.sakura

After that, blossom build builds it from its blossomfile, and blossom test runs its tests: those of its parts, and those of its commands, which run the blossom just built on projects made in a folder of each test's own. The command tests run git, sh, and tar, so they run on Linux.

Commands

Command Does
build [PROJECT] Checks the project's libraries, then builds each program into .blossom/<key>/bin, where it isn't up to date
check [PROJECT] Checks each target, libraries and programs, writing nothing
run [TARGET] [-- ARG...] Runs a program on the machine, sakura run: the one named, or the project's only one
test [PROJECT] [--only TEXT] Builds, then runs each test, or those whose names hold the text, showing what they write
clean [PROJECT] [--all] Removes the outputs of these option values, .blossom/<key>, or with --all, all of .blossom
install [PROJECT] [--prefix DIR] [--destdir DIR] Builds, then installs into ~/.local or the prefix, under the destination folder where given
package [PROJECT] [-f FORMAT[,FORMAT]] [--prefix DIR] Installs into .blossom/<key>/stage, then writes tar, zip, deb, arch, or rpm packages into dist
pull [REQUIREMENT...] [--project DIR] [--update] Clones what the project requires, or the requirements named, and what their libraries read, where the store is missing them; with --update, clones them again
libraries [PROJECT] Prints the --lib of each library the project holds or reads, a line each, with its folder absolute, then --missing for each requirement the store is missing

Each takes:

  • -o NAME=VALUE, giving the project's option a value;
  • --target linux-x86_64|windows-x86_64, building every target for that system;
  • -j N, given to sakura;
  • -v, printing each command run.

Each step says how it went, a line each, with what sakura and the tests write passed on as they write it:

[1/3] Checked hello.geometry
[2/3] Built hello (.blossom/3f2a9c01d4e5b677/bin/hello)
3 passed, 0 failed, 0 skipped
[3/3] Tested hello.tests (3 passed)
Tested malunal/hello@1.0.0

A step that fails says Failed NAME, and a program reading a library that failed to check says Skipped NAME. blossom ends with 0 where everything worked, 1 where a build, a test, or a clone failed, and 2 where the command or a blossomfile is wrong, with the file and the line. run ends with the program's own status.

pull clones what a project requires, as a build would, without building anything. A requirement is named as its blossomfile writes it, with or without @REF, or by the last part of its path:

  • binary names https://git.malunal.studio/sakura/binary@v1.0.0;
  • shapes names ../shapes.

What a requirement's libraries read is pulled with it. It says where each requirement is, whether it was there already, cloned, or with --update cloned again, which a branch that moved wants. A tag doesn't move. A clone made again takes the old one's place only once it's whole:

$ blossom pull
Cloning https://git.malunal.studio/sakura/binary@v1.0.0
[1/2] Present https://git.malunal.studio/sakura/std@v1.0.0 (/home/me/.cache/blossom/...)
[2/2] Cloned https://git.malunal.studio/sakura/binary@v1.0.0 (/home/me/.cache/blossom/...)
Pulled what malunal/hello@1.0.0 requires

libraries is for tools, as the Sakura extension for VS Code, which gives each library to its language server. Each line is a --lib as sakura takes it:

  • the project's own libraries come first;
  • then those its targets and tests read through deps, each followed by what it reads in turn.

It clones nothing. Each remote the store is missing gets a line --missing REMOTE@REF after them, and the libraries it holds are left out until pull clones it. It needs no sakura, since it runs none, and otherwise refuses what a build refuses:

$ blossom libraries
--lib hello::geometry=/home/me/hello/geometry
--lib std::io=/home/me/.cache/blossom/git.malunal.studio/sakura/std@v1.0.0/io
--missing https://git.malunal.studio/sakura/binary@v1.0.0

The blossomfile

YAML, in the project's folder:

name: hello                      # required; the identity is gpid/name@semv
gpid: malunal                    # required
semv: 1.0.0                      # required; a version, as 1.2.0 or 1.2.0-alpha

options:                         # NAME: value, any scalar; ${NAME} anywhere after; -o NAME=VALUE
  level: 2                       # ${bin} is given too: this option set's .blossom/<key>/bin
  debug: false

requires:
- https://git.malunal.studio/sakura/std@v1.0.0    # REMOTE@REF; `main` without a ref
- ../shapes                                        # a folder, relative to this file
- remote: https://git.malunal.studio/sakura/binary # a block, where it's given options
  branch: v1.0.0
  options:
    strict: true

targets:
- name:  hello                   # a program
  type:  program
  level: ${level}                # -O: 0, 1, or 2; 2 unless given
  petal: ${debug}                # -g, writing hello.petal beside it
  target: windows-x86_64         # --target; the system blossom runs on unless given
  deps:  [std.io, std.yaml, hello.geometry]    # libraries it reads; `std` alone is what the compiler finds
  srcs:  [main.sakura, util/**/*.sakura]       # files, folders (each .sakura in them), globs
  opts:  [--inline, "24"]        # given to `sakura build` as written

- name: hello.geometry           # a library: the module hello::geometry
  type: library
  root: ./hello.geometry         # ./<name> unless given
  deps: [std.math]               # libraries its modules import

tests:
- name: hello.tests              # the keys of targets, and these
  type: program
  runs: machine                  # machine, by `sakura run`, unless native: built, then run
  checks: true                   # `--checks`; on unless given, on the machine
  deps: [hello.geometry]
  srcs: [tests/**/*.sakura]      # tests/**/*.sakura unless given
  args: [--only, geometry]       # what the test is given

exports:                         # the libraries other projects may read
- hello.geometry

install:                         # beside the programs and the exported libraries
- !include ./share               # to <prefix>/share
- !include ./docs:share/doc/hello  # to <prefix>/share/doc/hello

package:
  lic:  MIT
  desc: Says hello.
  auth: Me <me@example.com>
  url:  https://example.com/hello
  • Every key is checked: one blossom doesn't know, or one written twice in a mapping, which YAML would keep only one of, is refused by its line.
  • A library's name is its module's, with . for ::. Its folder is given to sakura with --lib, as --lib hello::geometry=hello.geometry, and the compiler reads only the modules a program imports. Two projects giving a library one name is refused, as is a program reading a library another project doesn't export.
  • install's steps are each tagged with what they do. !include SOURCE copies a file or folder to its own place under the prefix, and !include SOURCE:DEST to DEST. A step without a tag, with one blossom doesn't know, or reaching outside the project or the prefix, is refused.

Requirements

  • A remote is what git clones, as https://host/path, git@host:path, or file:///path, and is cloned once, git clone -b REF --depth 1, into the store: ~/.cache/blossom/<host>/<path>@<ref>, or $XDG_CACHE_HOME/blossom/..., and %LOCALAPPDATA%\blossom\... on Windows. A clone stopped halfway is never taken for one, and where git fails, what it says is shown. The store can be removed at any time: what's missing is cloned again. pull clones without building, and pull --update clones again what the store holds.
  • A folder is read where it is, relative to the blossomfile naming it.
  • One project, two sets of option values, is refused, since each set builds outputs of its own.
  • What a requirement requires is read only where its libraries read what it doesn't hold itself, so what only its tests or programs need is never fetched for those requiring it.

Outputs and building again

Each project's outputs go to .blossom/<key>, the key being the hash of its identity, its option values, and --target, so each set builds apart. A program is built again only where:

  • its executable is missing;
  • the command building it changed, which is kept beside it in <name>.command, with the sakura that ran it and when that was written;
  • a file sakura read building it, as --deps lists them in <name>.deps, or the blossomfile, is newer than it.

A library's check is kept the same way, in .blossom/<key>/check.

Tests

A test runs on the machine, sakura run --checks ... -- ARGS, unless it says runs: native, where it's built, then run. It passes where it ends with 0. Each runs in the project's folder, with SAKURA naming the sakura blossom runs, so a test can run the compiler as blossom does.

Installing and packaging

install builds, then copies each program to <prefix>/bin, with its .petal, each exported library to <prefix>/share/sakura/<name>, as source another project's --lib reads, then does each step of install.

package installs into .blossom/<key>/stage, then writes each package into dist, dating every entry SOURCE_DATE_EPOCH, where it's set, so the same stage writes the same bytes:

  • tar, compressed by gzip, and zip, its files stored, each under a folder of the project's name, version, and target. tar unless asked, or zip for Windows;
  • deb and arch, under --prefix, /usr unless given, compressed by gzip, xz, and zstd, with the digests each lists;
  • rpm, built by rpmbuild from a spec blossom writes.

The config

config in ~/.config/blossom, or $XDG_CONFIG_HOME/blossom, and %APPDATA%\blossom on Windows, is optional:

sakura: /opt/sakura/bin/sakurac  # the sakura to run
std: /opt/sakura/std             # the standard library it's given, as --lib std=DIR

Without sakura, blossom runs the sakurac beside it, or else the first on PATH. Without std, sakura finds its own.

S
Description
A build tool for the Sakura programming language.
Readme MIT
412 KiB
0 Stars 1 Watchers 0 Forks
2026-11-14 21:31:45 +00:00