9.1 KiB
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
Building blossom
Until blossom has built itself once, the compiler builds it, given the libraries it reads:
sakura build -O2 -o blossom \
--lib std::yaml=../sakura-yaml/std.yaml --lib std::args=../sakura-args/std.args \
--lib malunal::glob=../sakura-glob/malunal.glob \
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 |
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 tosakura;-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.
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/malunal/json@v1.0.0 # REMOTE@REF; `main` without a ref
- ../shapes # a folder, relative to this file
- remote: https://git.malunal.studio/malunal/yaml # 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, malunal.json, hello.geometry] # libraries it reads; std is the compiler's
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: [malunal.json] # 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 tosakurawith--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 SOURCEcopies a file or folder to its own place under the prefix, and!include SOURCE:DESTtoDEST. 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
gitclones, ashttps://host/path,git@host:path, orfile:///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. - 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 thesakurathat ran it and when that was written; - a file
sakuraread building it, as--depslists 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, and SAKURA_STD the
standard library the config names, 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 bygzip, andzip, its files stored, each under a folder of the project's name, version, and target.tarunless asked, orzipfor Windows;debandarch, under--prefix,/usrunless given, compressed bygzip,xz, andzstd, with the digests each lists;rpm, built byrpmbuildfrom 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/sakura # the sakura to run
std: /opt/sakura/std # the standard library it's given, with --std
Without sakura, blossom runs the sakura beside it, or else the first on PATH.
Without std, sakura finds its own.