Commit graph

618 commits

Author SHA1 Message Date
12e8b908f6
docs(packaging): add the 6.3.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 15m13s
6.3.0
6.3.0 holds a build to as many steps at once as the machine has
hardware threads, where every stale shader, asset to compress, C, CUDA
and C++ unit got a thread of its own and nothing bounded how many ran
at once. It makes the object of a module interface unit that an earlier
build left with its BMI alone, or with the object of before an edit,
and it refuses interface units of one configuration that import each
other, whose first build hung.

A minor, by the version rule: the notes have New and Fixes and nothing
Breaking, and Jorijn's "6.3.0, that's internal and not user facing"
settled it. What he was asked about: the range takes Compile() off
Module, ModulePartition and Implementation, and the `compiled` flag off
the first two, all of which interfaces/ exports. They are what Build()
itself compiled a unit with, and none of the 35 project.cpp files of
this checkout and the ones beside it reads the flag or calls Compile().
2026-11-13 17:59:56 +01:00
621438de5f
docs: say how many steps a build runs at once
The README says in "Writing a project.cpp" that a build runs at most as
many of its steps at once as the machine has hardware threads, which
steps those are, and that an ExternalDependency's CMake build and the
tests are not among them. Under Tests, --jobs= is named as what counts
the tests, and --jobs=1 as one test at a time where it said "serial
mode": the steps of that one test's build still run side by side.
2026-11-13 17:59:56 +01:00
f9d0ec24fe
test(incremental): an interface unit without its object is built again
IncrementalInterfaceObject builds a module with a partition and a
program that prints what the module's function returns, without
optimisation, so that what it prints says which object was linked. It
edits the primary interface, builds, and puts the object of before the
edit back dated two seconds before the new BMI. A build with the
program still there has to make the object again and link the program
again; after the old object is put back once more and the program
deleted, a build has to make the object again and the program print the
edited value. Then it deletes both objects and the program and builds:
both objects have to be back. A last build of the intact tree has to
leave the objects as they are.

On 5b75df3 the old object is never made again, and the build without
the program links it: the program prints 11 where the source says 12.
The build without the objects fails at the link with "no such file or
directory" for each of the two.
2026-11-13 17:59:56 +01:00
6087ce81db
test(build): build many units at once and count the threads it takes
JobLimit makes two projects and one more for every 32 hardware threads
and builds them from nothing at once, each from a thread of its own, as
RunTests builds its tests, while it counts the threads of its own
process. A project is 69 sources: 64 that import nothing, half C and
half C++, then a module of two partitions, one importing the other,
with its implementation unit, and a main.cpp that imports the module.
It is the same size on every machine, so that no command of its build
grows with the machine. The builds together may add as many threads as
the machine has hardware threads, and have to add at least two where
there are two; every program is then run and has to print 995: what
its 64 C and C++ functions return and the module's Top(), which is
built on the two partitions' functions. On 5b75df3 it fails: on a
machine with 56 hardware threads, "3 builds of 207 sources in all ran
on 205 threads at once". The count sees the steps that are jobs. A link
is none: its Build() runs it through RunBuildCommand from a thread that
was there before the count, which does not tell whether the link waited
for a worker.

JobGroup drives pools of its own, of one to four workers. Twelve jobs on
three workers run three at once and no more; a job starts after the
ones it was added after, in a graph of four jobs and in one of 300; the
first error keeps a job that comes after it and the jobs added later
from starting, and so does Fail(); what a job throws is its error; a
chain gets through one worker; Run() runs its work on a worker, on the
calling thread when that is one, where a JobGroup is refused; and
leaving a group's scope waits for the job that runs and starts no
other. It also holds the process's pool to a worker per hardware thread.
2026-11-13 17:59:55 +01:00
913310da86
feat(build): run a build's steps on one worker per hardware thread
Build() started a thread for every stale shader, asset, C, CUDA and C++
unit, and Module::Compile one more for every stale partition, and
nothing bounded how many of them ran their step at once. Jorijn asked
for the amount of parallelism to be limited by the amount of threads
instead of just starting one per file; the threads are taken here to be
the machine's hardware threads.

The new :Jobs partition holds the two pieces. JobPool is worker threads
behind one queue, started as jobs need them up to a fixed number, and
JobPool::Process() is the pool of the process: at most a worker per
hardware thread, one where std:🧵:hardware_concurrency does not
know. JobGroup is the jobs of one build on a pool. A job starts once
the jobs it was added after have finished; the first job to fail keeps
the ones that have not started from starting, and Wait() returns its
error. No job waits for another job, and a JobGroup made on a worker of
its own pool throws: a worker that waited for a job still in the queue
would hold the thread that job needs.

Build() adds what it did on those threads to a JobGroup instead, and
the group's first error replaces the buildCancelled and buildError pair
the threads set. The module units no longer block on the `compiled`
flag of the units they import: Schedule() replaces Compile() on Module,
ModulePartition and Implementation and adds a unit's jobs after the jobs
that write the BMIs it imports. An interface unit is two jobs, its BMI
and then its object from the BMI, so the units importing it start when
the first is done, as they did when one thread ran both commands and
raised the flag in between. A primary interface now waits for the BMIs
of its partitions and no longer for their objects. Each of the two jobs
has a progress line, "Precompiling X.cppm" and "Compiling X.cppm" for
every interface unit, where a module and its partitions shared one
"Compiling interface X".

RunBuildCommand runs its command on a worker of the process's pool: on
the calling thread when that is one, otherwise it waits for one. A link,
an archive, the std module's precompile and project.cpp's compile are
steps under the limit that way. The threads Build() starts per
dependency and per external dependency stay: one of the first runs the
dependency's own Build(), or waits for the thread that does, and one of
the second runs git and cmake.

With the BMI and the object as two jobs, a build that fails between them
has written the BMI and skips the object, and Check, which reads
staleness off the BMI, would call the unit built from then on.
Schedule() therefore adds the object job alone for a unit whose BMI is
up to date and whose object is missing or older than the BMI. A build
interrupted between the two commands, or one whose second command
failed, left the same behind before, and it stayed: the link took the
object of the source before the edit, or failed on the missing one.

ImportCycleError is now what keeps Schedule() from following a round of
imports without end.

The limit is on steps. Outside it, as AGENTS.template.md lists: an
ExternalDependency's cmake --build, which keeps its own --parallel of
as many jobs as there are hardware threads; the tests RunTests runs,
--jobs= of them at once as before; the Crafter.Build modules
EnsureCrafterBuildPcms precompiles one after another; and the threads a
step starts for itself, which lld does for a link and Crafter.Asset's
GDeflate compressor for an asset. The pool is one process's. The --help
text says what a build runs at once and that test --jobs= counts tests.

ConcurrentDependencyReset read the `compiled` flag, which is gone. It
asserts on `checked` and `scheduled` instead, the state a reset from
another build's thread would clear now, with a unit scheduled twice as
the result, and the comment in its fixture says what the implementation
unit comes after now. TransitiveInterfaceChange's comment names
Schedule() where it named Compile() as what honours a partition's
imports. Two comments in :Platform that spoke of worker threads, a word
that now means the pool's, name the threads they mean. The bug-prover
lens's section said shaders compile on a thread of their own each, and
describes the pool now.
2026-11-13 17:59:55 +01:00
eff9868b68
docs: interface units that import each other stop the build
The README says in "Writing a project.cpp" that a unit is built after
the modules and partitions it imports, that interface units of one
configuration that import each other are refused with an error naming
them, and that the imports are read from the source text without
compiling it, so one in a string literal, in a comment that spans lines
or under #if 0 counts too and can make such a round in a project the
compiler accepts.
2026-11-13 17:59:55 +01:00
ee331377a4
test(build): interface units that import each other are refused
ImportCycle builds three fixtures as static libraries, each on a fresh
copy outside the checkout: two partitions that import each other, a
partition that imports its own module, and two modules that import each
other. Each build has to return an error that holds its round,
"Ring:First -> Ring:Second -> Ring:First", "Own -> Own:Part -> Own" and
"East -> West -> East", and leave neither a build nor a bin directory.

Before the refusal the test ran into its timeout: the first of those
builds never returned.
2026-11-13 17:59:55 +01:00
e87dc4f015
fix(build): refuse interface units that import each other
Two partitions that import each other, a partition that imports its own
module, and two modules of one configuration that import each other
cannot be built in any order. Build() compiles each stale unit on a
thread that first waits for the units its unit imports, and a primary
interface waits for every stale partition of its module as well, so a
build that found every unit of such a round stale, as a first build of
them does, hung: every thread waiting, no compiler running, no error.

ImportCycleError follows the imports of a configuration's interface
units at the top of that configuration's Build(), before it makes a
directory or builds a dependency, and Build() returns an error naming
the units of the first round it finds in the order they wait in,
"Ring:First -> Ring:Second -> Ring:First". A primary interface counts
as coming after each partition of its module, whether it imports that
one or not, since that is how it is built. A configuration built on the
one refused has started its own build by then: the check reads the
imports ResolvePendingImports has just placed, which are that Build()'s
to read while it runs.

The imports are the ones the source scanner reads, and it reads one in a
string literal, in a comment that spans lines or under #if 0 as it
reads any other (issue #45), so the units the error names are where to
look for one of those too. The error says so, since the compiler sees
no round in such a project, and AGENTS.template.md has it under Gotchas.
2026-11-13 17:59:55 +01:00
5b75df3b19
docs(packaging): add the 6.2.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 14m29s
6.2.0
6.2.0 makes CUDA sources compile in the Flatpak: crafter-build finds
nvcc itself, under CUDA_PATH, /opt/cuda or the host's /usr/local/cuda,
or in an absolute entry of PATH, where it used to run whatever the
sandbox's PATH gave, which never holds the host's toolkit, and it links
that toolkit's static CUDA runtime itself where the toolkit's lib64
holds it. The GPU architecture CUDA sources compile for is configurable
and native by default, and a .cu compiles again when a header it
includes changes.

A minor, by the version rule: the notes have New and Fixes and nothing
Breaking, and Jorijn's "6.2.0 is fine" settled it. The default
architecture moves from sm_89, which carries its PTX, to native, which
carries none, so a program built for native has no PTX for a GPU of a
newer architecture. That is under New rather than Breaking because no
Flatpak release compiled a .cu with the PATH its manifest sets: each ran
a bare nvcc in the sandbox, whose PATH, /app/bin:/usr/bin, holds no
toolkit, so a project had to set another PATH itself to compile one. A
program for other machines takes another architecture, such as
--cuda-arch=all-major, as the notes say. A project that names -lcudart
in cfg.linkFlags keeps building, with its shared runtime first on the
link line. VariantId changes for no configuration without CUDA sources
but one built with --cuda-arch=, which was a project argument and is
crafter-build's own now; a configuration with CUDA sources builds once
in new bin/ and build/ directories, keyed by its architecture, for
native by crafter-build's reading of the machine's GPUs, and by its
nvcc.
2026-11-11 19:34:52 +01:00
df79dcd46d
docs: a CUDA section in the README
cfg.cuda had no section of its own, only mentions in passing. The new
one says how sources are listed and linked, where the toolkit is found
and what the Flatpak sees of it, what cfg.cudaArch picks, and what nvcc
is not given: the include paths, defines and compile flags of the C and
C++ compiles, and -g. The Flatpak output section's advice for other
machines names a --cuda-arch= other than native, such as all-major,
beside --march=x86-64-v3.
2026-11-11 19:34:52 +01:00
99653194ba
test(cuda): build a .cu without link flags, and through a library
CudaCompile's builds name no CUDA library now, but for the last. The
toolkit it names through CUDA_PATH has a lib64 beside its nvcc with the
real toolkit's libcudart_static.a, so the executable links only if
crafter-build links the runtime, and the recorded link names that
archive. Another build puts the .cu in a static library and the C++ unit
in an executable built on it, which links only if the library hands the
runtime on. That lib64 also holds a libcheckpoint.so and a libm.so that
are no libraries, as Arch's lib64 holds a real libcheckpoint.so and a
libOpenCL.so: another build links an executable with CUDA sources on a
library of the project's named checkpoint, and clang++ adds -lm to every
C++ link, so a link that searched the toolkit's lib64 would stop on one
of them wherever its -L stood. The last names -L<lib64> -lcudart, as a
project with CUDA sources had to, and has that -lcudart ahead of the
static archive, so the shared runtime is the one the linker takes. The
test skips where the real toolkit's lib64 holds no static runtime, since
crafter-build then links none. Before crafter-build linked the runtime,
the link failed on an undefined CUDA runtime symbol.

ToolchainResolve checks where the runtime is looked for, on staged
toolkits, so that it runs in CI: the archive in the lib64 beside nvcc's
bin, none where that lib64 holds none, none where it links to itself,
which a look that threw would have stopped the test on, and none without
an nvcc.

CudaCompile is the only check of the runtime link itself, and it skips
without such a toolkit, so AGENTS.template.md's note on when to run it
names the link as well as the compile, and gives the lookup to
ToolchainResolve.
2026-11-11 19:34:52 +01:00
22ea97406d
feat(cuda): link the CUDA runtime of the toolkit that compiles the .cu
A program with CUDA sources needs the CUDA runtime, which cfg.linkFlags
had to name: -L/opt/cuda/lib64 -lcudart for Arch's toolkit, a path into
it. In the Flatpak that holds for /opt/cuda but not for the host's
/usr/local/cuda, which is under /run/host there, at a path crafter-build
resolves for nvcc and a project.cpp does not know. Jorijn chose to have
crafter-build link it.

A configuration with CUDA sources links the static runtime of the
toolkit whose nvcc compiles them, by its path, with the -lrt -lpthread
-ldl that nvcc's own link line puts after it. ResolveToolchain finds it
with nvcc, as Toolchain::cudaRuntime: libcudart_static.a in the lib64
beside nvcc's bin, looked for without starting a process, so a test can
stage a toolkit for it as for nvcc, and crafter-build --version prints
it. The static one, so no run path into the toolkit ends up in the
program; libcuda.so.1, which the runtime loads, comes with the driver.
By its path, not through a -L of the lib64, which would put the
toolkit's libraries, such as Arch's libcheckpoint.so, in the way of a
project's own of the same name. It goes into BuildResult::runtimeLibs,
which a configuration hands its consumers as it does libs and every link
puts after them, so whatever is built on a library with CUDA sources
links the runtime too, and a -lcudart a project names itself comes
first.

Where that lib64 holds none, as where a distribution keeps the toolkit's
libraries in its own directories, cudaRuntime is empty and nothing is
linked, as before: a -lcudart_static the linker could not find would
fail the link even of a project that names its own -lcudart. The archive
is looked for without throwing, so a lib64 that cannot be looked into,
through a link loop or for want of permission, counts as one without it.
2026-11-11 19:34:52 +01:00
6b2da3b1d6
test(cuda): a changed header compiles the .cu again
CudaCompile's .cu includes a header of its own now. After the unchanged
build, the test makes the header newer than the object and builds once
more, which has to run nvcc again. Before nvcc wrote a depfile, it did
not, and the object built from the old header stayed.
2026-11-11 19:34:52 +01:00
c2338d1122
fix(cuda): rebuild a .cu when a header it includes changes
A .cu was compiled again only when it was newer than its object, so one
whose header changed kept the object built from the old header. The C
and C++ paths ask the compiler for a depfile and check every
prerequisite in it; nvcc was left out because its -MD and -MF had never
been run here.

They work with CUDA 13.4 as they do with clang: the depfile lists the
.cu and every header it read, the toolkit's and the system's included.
nvcc puts a space before the rule's colon, which NewestPrerequisite
reads as a target token like any other. An object from before has no
depfile and is compiled once more.
2026-11-11 19:34:52 +01:00
ad021ee652
test(cuda): build a .cu with the toolkit CUDA_PATH names, and with none
CudaCompile puts an nvcc on PATH that fails, names a toolkit through
CUDA_PATH whose nvcc writes down its arguments and runs the real one,
and builds an executable from a C++ unit and a .cu: with the default
architecture, then with another one, which compiles the unchanged .cu
again in a directory of its own, then with nothing changed, which
compiles nothing. With the bare "nvcc" of before, the first build runs
the nvcc on PATH and fails.

It needs a real toolkit, which it looks for as crafter-build does, with
ResolveToolchain and the inputs GetToolchain() gives it, and it skips
without one. Nothing in CI installs one, so AGENTS.template.md says to
run it in the native loop.

CudaMissing needs none, so CI runs it: with CUDA_PATH naming an empty
directory, a build with a .cu fails with "cannot compile kernel.cu: no
nvcc at <directory>/bin/nvcc (CUDA_PATH)", and a build without CUDA
sources in the same process still succeeds. With the bare "nvcc" of
before, that build ran whatever nvcc PATH held, and where PATH held
none, as in the Flatpak, failed with "sh: line 1: nvcc: command not
found". AGENTS.template.md names it beside CudaCompile.
2026-11-11 19:34:52 +01:00
967dd12b06
feat(cuda): make the GPU architecture configurable, native by default
nvcc ran with -arch=sm_89 for every build, which is code for that one
architecture and its PTX, whatever GPU the program was for. Jorijn asked
for the architecture to be configurable, and native when nothing sets
it, as the CPU's is.

cfg.cudaArch is nvcc's -arch now, and it defaults to "native": nvcc
compiles for the GPUs it sees, and where it sees none it warns and uses
its own default architecture. Like -march=native it is for a program
that runs where it is built, since it carries no PTX, and
`crafter-build bundle` warns of a bundle whose CUDA code, in the program
or a library it is built on, is compiled for native, as it warns of
-march=native. ApplyStandardArgs sets it from --cuda-arch= and
CRAFTER_BUILD_CUDA_ARCH as it sets march from --march= and
CRAFTER_BUILD_MARCH; AddTest and AddMarchVariants give their tests the
parent's, as they give them its sysroot and debug flag; and
ForceHostTooling gives host tooling the host's, as it gives it the
host's march, since project.so runs it on the machine that loads it.

A .cu is compiled again only when it is newer than its object, so the
architecture keys VariantId, and so does the nvcc that compiles it, by
what it is rather than where: Toolchain::nvccStamp, its canonical path,
size and time, read without a process, changes when CUDA_PATH names
another toolkit and when an update replaces the one at the same path, as
a package does at /opt/cuda. native is keyed as well, by
Toolchain::cudaNativeKey: the NVIDIA display devices sysfs lists, by PCI
address and device ID, and CUDA_VISIBLE_DEVICES and CUDA_DEVICE_ORDER,
which choose and number them, each empty value apart from an unset one,
read without a process. It is crafter-build's reading of the machine,
not nvcc's. The word alone would keep an object compiled for a GPU the
machine no longer has, after a GPU change or on another machine that
shares the checkout, and that object carries no PTX for the GPU it has
now, where sm_89's carried its PTX. Only a configuration with CUDA
sources is keyed, so every other one keeps the directory it had, but for
one built with --cuda-arch=, which was a project argument, hashed as
one, and is crafter-build's own now.
2026-11-11 19:34:52 +01:00
2fd45133a0
test(cuda): resolve nvcc on staged toolkits
ToolchainResolve stages toolkit roots, a PATH and a host root, and
checks the order (CUDA_PATH, then the roots, then PATH), that a
CUDA_PATH without an nvcc is an error and not a fallback, that a
relative one names an absolute nvcc, that a file
that cannot be run is no nvcc and a relative PATH entry no place to
look, what the error says when there is none, and that a toolkit
resolves under the host root through a link: /usr/local/cuda in the
host's /usr to an absolute path, named with a trailing slash too,
through /etc/alternatives and to a relative path, and a link outside
the host's /usr that leads into it. A link to itself finds nothing.
2026-11-11 19:34:52 +01:00
fdba70d176
fix(cuda): look for nvcc instead of leaving it to PATH
cfg.cuda compiled with a bare "nvcc", which the shell looked up on PATH.
In crafter-build's Flatpak PATH is /app/bin:/usr/bin, as its manifest
sets it, which never holds the host's toolkit, so with it every build
with CUDA sources stopped at "sh: line 1: nvcc: command not found",
although the sandbox sees /opt/cuda through --filesystem=host.

ResolveToolchain now finds nvcc as it finds clang++: CUDA_PATH, which is
exclusive as CRAFTER_BUILD_LLVM_DIR is, else /opt/cuda (Arch's package)
or /usr/local/cuda (NVIDIA's installer and packages), else the absolute
entries of PATH, which it searches itself so that a build without a
toolkit can say where it looked. A relative CUDA_PATH is made absolute
there, once, as CRAFTER_MINGW_DIR is, since nvcc runs later from
whatever working directory a build is in. The sandbox shows the host's
/usr and /etc under /run/host, with its own runtime at /usr, and
NVIDIA's /usr/local/cuda is a link, to /usr/local/cuda-<version> or
through /etc/alternatives. A link to an absolute path names a path of
the host, /opt/cuda pointing at /usr/local/cuda-<version> too, and the
sandbox would look it up in its own root, so where the path of a
toolkit, CUDA_PATH, /opt/cuda or /usr/local/cuda, is such a link,
HostPath follows it, and the link its target is in turn, each taken as
the host's; a link partway along that path, or inside the toolkit, is
the kernel's to resolve, in the sandbox's root.

A missing toolkit is reported by the build that has a .cu to compile and
not by GetToolchain(), so no other build fails for want of one.
crafter-build --version prints the nvcc it found, whether or not the
compiler could be resolved.
2026-11-11 19:34:52 +01:00
ff3cc20e70
docs(packaging): add the 6.1.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 13m51s
6.1.0
6.1.0 lets a program crafter-build builds run outside its sandbox: an
executable can be packaged as a Flatpak of its own, installed with
`crafter-build install` or bundled into a file with
`crafter-build bundle`, with flatpak-builder modules and data under
/app/share where it needs them. The Flatpak gains the
org.freedesktop.Flatpak permission those two verbs run the host's
flatpak with. It also fixes programs built on a shared library on Linux,
which did not start, compiles that took headers from what a build left
in a dependency's bin/ or build/, `format --check format`, which rewrote
the sources, and wasm tests declared with AddTest, which never ran.

A minor, by the version rule: the notes have New and Fixes and nothing
Breaking. Default still builds an executable as linked, and VariantId
and the bin/ layout change for nothing that is not packaged as a
Flatpak, but for a build given --packaging=, which moves to other bin/
and build/ directories: the argument was a project arg, hashed into
VariantId, and is a standard arg now, for dependencies too. `install`,
`bundle` and `--packaging=` were project args until this range made them
two verbs and a standard arg, and no sibling project.cpp reads any of
them: the only `install` in one is the name of a `run` script, which
`run` takes before any verb. `test test`, `lint lint` and
`format format` now take the second word as a glob. The include walk
leaves out every directory named bin or build now, and that is under
Fixes rather than Breaking: those are the names crafter-build gives what
it writes, and in the Crafter repositories and the dependencies
crafter-build has cloned, the one #include that needs a header found
only there is glslang's, in a source its own CMake build compiles, not
crafter-build. The permission is listed under New, and `flatpak update`
lists it before it asks to proceed.
2026-11-09 01:55:31 +01:00
79b24a93b8
docs: cfg.flatpak.share in the README
The README's Flatpak section shows share entries in its picture of the
bin directory and in the cfg.flatpak example, and says what they are
for, that files/share is kept to what is listed, that the ../share
lookup works under -r as well, that flatpak exports what it exports of
them by its own rules, and what build-export checks of that, that an
entry may not take a field's file, that the app's desktop entry is
checked whichever placed it, and which directories an entry may not
copy: those that hold what the build writes or lie in it.
AGENTS.template.md lists them among what FlatpakApp holds.
2026-11-09 01:55:31 +01:00
e0ac8ee600
feat: install a Flatpak's data under /app/share
A program packaged as a Flatpak could only have its files beside it in
files/bin, where cfg.files goes. One that finds its data at <its
directory>/../share/<name>, as Crafter.Review finds its process/
directory, had no way to get it there: files/share belongs to the
writer, which removes anything it did not put there, and a module of
flatpak-builder's would have placed it only in the installed app, never
under -r. cfg.flatpak.share lists files and directories of the project
and the path under /app/share each goes to. The writer copies them into
files/share with the desktop entry, metainfo and icons, keeps them while
they are listed and removes them once they are not, as it does those. -r
runs the program from files/bin, so the same ../share lookup finds them
there. What is exported of them is flatpak build-finish's to decide, by
its own rules, as for any app's files: the app's D-Bus services, MIME
types, search providers and KRunner plugins, which have no field of
their own, are placed like any other file. A library's are not passed on
to the programs built on it, since data a library needs at run time
already goes through cfg.files. A dependency that packages its own
executable has the sources rebased by the loader, as its cfg.files are.
Share entries change files/share and not what is compiled, so they are
not keyed into VariantId, which its test checks.

Every file bound for files/share, the desktop entry, metainfo and icons
included, now goes through one placement check, which refuses two files
for one path, a field's file among them, and a file where another needs
a directory, naming both. A target that is absolute or leaves share/ is
refused too. Any other place is open to a share entry, a second desktop
entry, an add-on's metainfo and any icon included, as for any app's
files: flatpak build-export refuses an exported icon that is not a
square image and a D-Bus service that is not a key file, warns of the
app's own desktop entry where desktop-file-validate rejects it or its
Icon= is not the app's, and exports a second desktop entry, a MIME
package or metainfo as it is. The app's own desktop entry,
applications/<app-id>.desktop, is held to cfg.flatpak.desktopFile's
checks whichever placed it: its Icon= and desktop-file-validate are
keyed to that place now, not to the field. A source directory that holds
what the build writes is refused as well, since it would be copied into
itself, growing each time the app is built or exported: files/, and the
app's directory, where install and bundle put another copy of files/ and
the exported app, compared as written and where links lead, so that the
project's own directory is refused where its bin/ is a link elsewhere
too. So is one that lies in them, the build's own output, which the next
build, install or bundle writes again. The loader leaves an empty source
empty, as it does an empty desktop file.

FlatpakShareLarge holds the writer to comparing an entry with its copy
at constant memory, which the program's data, gigabytes of it in a game,
needs on every build: it rewrites a files/ holding a 32 MiB entry, with
nothing changed, in a child process whose address space may grow by 16
MiB, with a stand-in llvm-readelf, since the real one, which a write
starts for the libraries, would not fit under that limit, and a change
in the entry's last byte, in the short block a comparison reads last, is
still copied.
2026-11-09 01:55:31 +01:00
52a767fadc
docs: install, bundle and modules for the Flatpak output
The README's Flatpak section brings in `crafter-build install` and
`bundle` after -r, where the sentence on what build-finish writes was,
says how they make the app, crafter-build writing the build directory's
metadata and the host's flatpak build-finish adding the command and the
permissions to it and writing export/, and where that directory is, for
trying the app on the host without installing it, says where the repo
and remote live and how two installs of one app-id take turns on the
remote, where `install` takes the runtime from, what to install where no
installation has it and that an app with modules needs the Sdk too, how
they ask the host whether it sees the project's bin/ and build/ and
refuse a project it does not and who in the sandbox holds the permission
they run with, and describes cfg.flatpak.runtime,
cfg.flatpak.permissions, which install and bundle print and build-finish
judges, and cfg.flatpak.modules; it names install and bundle among the
invocations that write AGENTS.md. AGENTS.template.md names what :Flatpak
holds now, and says that org.freedesktop.Flatpak is the whole sandbox's
while crafter-build's own code uses it only in the host helper, why the
trust model allows it, how a test reaches the host without touching the
user's installation, and the trap in probing a tool with `command -v`
through RunCommandWithTimeout, whose `timeout` cannot run a shell
builtin, and lists the locks install keeps on the user's remotes among
what goes in ~/.cache/crafter.build/, found by HOME, so that native and
Flatpak crafter-builds share them.
2026-11-09 01:55:31 +01:00
71540b24aa
feat(flatpak): let crafter-build run the host's flatpak
install and bundle run the host's flatpak and flatpak-builder, and the
only way out of the sandbox to them is the Flatpak session helper, so
the manifest grants --talk-name=org.freedesktop.Flatpak. crafter-build's
own code uses it only through HostCommand, for the host's flatpak and
flatpak-builder, but the permission is the whole sandbox's: every
project.cpp crafter-build loads, its scripts, its dependencies' builds
and the programs -r and test start can run host commands through
flatpak-spawn --host as well. --filesystem=host already lets all of
them arrange that, by writing ~/.bashrc or a systemd user unit; the
permission makes it immediate, it does not make it possible. `flatpak
update` lists it among the app's new permissions before it asks to
proceed.

The run flatpak and run install scripts of project.cpp still refuse
inside the Flatpak, now for the reason that holds there: they run
flatpak themselves, which the sandbox does not have.
2026-11-09 01:55:31 +01:00
eff250abb7
feat: install and bundle a Flatpak through the host's flatpak
An executable packaged as a Flatpak came out as the files/ of one, which
only flatpak build-finish makes an app of, and getting it installed or
onto another machine took flatpak commands on the host, typed by hand.
Two verbs do it where the host's flatpak can be reached:
`crafter-build install` builds the project and installs its app for this
user, and `crafter-build bundle` builds it into bin/<variant>.flatpak, a
single file for `flatpak install --user` that names Flathub's repository
for the runtime. Inside crafter-build's Flatpak they need the
org.freedesktop.Flatpak permission, which its manifest does not grant in
this commit. Both put the app into the project's repo first, in
build/flatpak-apps/<app-id>/ (FlatpakAppDir), one per app rather than
per variant, since flatpak-builder's state there is its cache. Every
variant exports into it, so the export and the install or bundle made
from it hold a lock there, and another crafter-build exporting meanwhile
waits rather than leave this one installing or bundling its program. The
user remote an install re-points is every checkout's that builds the
app-id, so re-pointing it and installing from it hold a second lock,
which every crafter-build installing there takes, natively or in the
Flatpak, whatever its XDG_CACHE_HOME: in
~/.cache/crafter.build/flatpak-remotes/, found by HOME, for the user's
own installation, which flatpak hides from the sandbox behind a tmpfs of
the sandbox's own, and in the directory of a private one,
FLATPAK_USER_DIR, one lock for all of them where the sandbox shares that
directory with the host. Without modules, the host's flatpak
build-finish finishes build/flatpak-apps/<app-id>/build-dir, made afresh
each time from a metadata naming the app, its runtime and the Sdk and a
tree of hard links to the build's files/, copies where a link cannot be
made, across filesystems or on one without links, vfat or exFAT: it
writes the command, the sandbox's permissions and export/ by flatpak's
own rules, those of whichever flatpak the host runs, and refuses a
permission it does not know, and flatpak build-export puts the result
into the repo. When cfg.flatpak.modules names flatpak-builder module
files for what the app needs in /app besides the program,
flatpak-builder does both, from a manifest that lists them and copies
the built program in last, so nothing is compiled twice. That manifest
keeps share/locale in the app ("separate-locales": false):
flatpak-builder would split it into a .Locale extension by default,
which a bundle, holding the app alone, leaves out. The loader rebases a
dependency's module files as it does its cfg.files. install uses a user
remote named after the app-id, re-pointed at the repo each time, and
says how to remove both. The app's tree in
build/flatpak-apps/<app-id>/build-dir, where flatpak-builder installs a
module's files too, is left out of the include walk with every other
build/, so the headers a module installed reach no compile.

cfg.flatpak gets the runtime, the Platform or the Sdk at the branch
crafter-build runs on, and the sandbox's permissions, finish-args as
Flatpak spells them, which any configuration may declare: an executable
gets its dependencies' first and its own last, so it can take one back.
The build reads neither, and a change to either links nothing. install
and bundle print the permissions, with where each came from, and hand
them to build-finish, the one judge of what they mean, so a refusal can
be traced to the configuration that declared it. FlatpakPermissions
checks the order everywhere, and that a change to one neither moves the
build to another directory nor links anything, and, where the host's
flatpak runs, what build-finish makes of them and that it refuses a
socket it does not have; FlatpakBundle that build-finish exports the
desktop entry and the icon, and that the build's own files/ is left as
it was; VariantId's test has the runtime, permissions and modules move
no directory.

The host's flatpak and flatpak-builder are reached only through
HostCommand in :Platform, which builds the command lines of
RunHostFlatpak, RunHostFlatpakBuilder and HostFlatpakUnavailable's
probes: flatpak-spawn --host --watch-bus inside crafter-build's Flatpak,
started in the host's / and passing FLATPAK_USER_DIR on, and the command
itself natively. flatpak-spawn would otherwise start a command in
crafter-build's own working directory, which the host need not have, and
from /app, say, every host command would fail. HostFlatpakUnavailable
says why the host cannot be reached: no org.freedesktop.Flatpak
permission, no session bus (CI's build sandbox has neither), a host that
does not see the project's bin/ and build/ where crafter-build does, as
it does not in the sandbox's own /tmp, /var, /usr, /etc and /app or
where a link leads into one, or no flatpak natively. That, and an
executable that is not packaged as a Flatpak, install and bundle refuse
as soon as the project is loaded, before anything is built;
FlatpakVerbRefusal shows the second. The host is asked rather than the
sandbox's paths modelled, which an override sharing a directory inside
the sandbox's own would defeat: its flatpak is started in a directory
just made in each of bin/ and build/ under a name no other has, which it
enters only where it sees that very directory, and the directory is
removed again. --help gets a section on both, and its Clean section says
the repo an install points at goes with build/. FlatpakModules runs
flatpak-builder only with a flatpak-builder program on the host,
crafter-build falling back to the org.flatpak.Builder app, whose
`flatpak run` would write ~/.var/app in the real home, and with the
Platform and Sdk it builds the app with. The library's install function
is InstallFlatpakApp because project.cpp files define an InstallFlatpak
script of their own under `using namespace Crafter`, this repository's
included, and a library InstallFlatpak would make the name an overload
set, which the scripts table's std::function cannot be built from;
BundleFlatpakApp is named to match. JsonQuote writes the manifest's
strings, and variants.json's, which escaped quotes and backslashes only.
FlatpakExport, FlatpakManifestText, ExportFlatpak and FlatpakPermission,
which only :Clang uses, stay out of the API a project.cpp compiles
against, as RecordFlatpakPlaced does, so their names cannot meet a
project's own under `using namespace Crafter`; ExportFlatpak's comment
names the app's lock, which its callers hold, beside
HostFlatpakUnavailable.
2026-11-09 01:55:31 +01:00
4b1585c709
test(cli): format --check with a rule name writes nothing
`crafter-build format --check format` read the second `format` as the
verb again, which set the mode back to applying and recorded no glob, so
it ran every transform and rewrote the project's sources, and exited 0,
though `--check` writes nothing. FormatCheckGlob drives Run() on a
staged project whose one rule, named "format", would change its
main.cpp, and holds the run to exiting 1, the check with a file to
change, with main.cpp as it was. It fails before the verb enum of the
commit before this one and passes with it.
2026-11-09 01:55:30 +01:00
2c3d0b0d1f
refactor: one verb per invocation, as an enum
Run() kept a flag per verb: test, lint, clean and format were each
recognised only when the others' flags were clear, so a verb added among
them meant another condition in each of their branches, while run took
the words after it in a branch ahead of them all. One Verb now records
the first verb on the command line. A verb word after it is taken as
that verb takes any other word: a glob after test, lint and format, the
script's name after run, a project arg after clean, as it already was
for two different verbs. Only a repeated word changes: `test test`,
`lint lint` and `format format` now take the second word as a glob
instead of reading it as the verb again. That fixes
`format --check format`: the second `format` set the mode back to
applying and recorded no glob, so the run applied every rule and rewrote
the project's sources, though --check writes nothing.
2026-11-09 01:55:30 +01:00
194af206cc
docs: the Flatpak output in the README and --help
A section on packaging a program as a Flatpak: how to ask for it, what
its bin directory holds and what flatpak build-finish adds to it, what
cfg.flatpak describes, what cannot be a Flatpak and why, and -march for
other machines. It also says where a program finds its files once
installed, which is not the working directory -r gives it. --help lists
the standard flags with --packaging= among them, says how -r runs a
program, one for the host in its own directory, a wasm32 one under
wasmtime or wasmer and one built for the browser served from its
directory, and names CRAFTER_BUILD_FLATPAK_INFO. The package script
example tars ProgramDir(), the program and its files.
2026-11-09 01:55:30 +01:00
27031ed8e3
feat: lay an executable out as the files/ of a Flatpak
A Linux executable built by the Flatpak crafter-build links the libc++,
libc++abi and libunwind in its /app/lib and the Sdk's glibc, so it runs
inside crafter-build's sandbox and practically nowhere else: a host
needs glibc 2.38 or newer and all three LLVM libraries, which not even
Arch has. A program built here is meant to run in a Flatpak, so it can
now be laid out as one: with cfg.packaging = Packaging::Flatpak, or
--packaging=flatpak where the project.cpp crafter-build was pointed at
calls ApplyStandardArgs, its BinDir() holds files/, what becomes /app in
the app's sandbox, and -r runs the program there against the libraries
the app carries.

The program is linked into files/bin, where its shaders, files and
assets land too (ProgramDir()), with $ORIGIN/../lib as its one run path,
and the new :Flatpak partition writes the rest of files/: files/lib with
the LLVM runtime libraries, located one by one through clang, and
whatever else the program needs, read with llvm-readelf, that the
directories of the shared libraries it is built on hold, the ones an
unpackaged link records as run paths, or the toolchain's own lib dir,
/app/lib in crafter-build's Flatpak, which the link searches too; and
the desktop entry, metainfo and icons under the app-id in files/share,
the entry refused when its Icon= is not the app-id or
desktop-file-validate, where there is one, rejects it, and an icon that
is not an .svg or a square .png. The metadata and export/ of a build
directory are flatpak build-finish's to write, and crafter-build keeps
no copy of its rules: what a permission means and what the host sees of
an app change with flatpak's releases, and a copy would have to follow
every one. The writer copies a file only when its content differs,
compared a block at a time so that a large file costs no more memory
than a small one, and writes one only when what it would write differs,
never deciding by an mtime, which ostree sets to 0 for every file of
/app, and works the program's libraries out on every write, which reads
only their dynamic sections, since a library replaced in place, as by a
toolchain update, can need others, which FlatpakLibraryChange checks; it
prunes from files/bin each top-level entry an earlier build put there
and this one does not, reporting those the program wrote there itself.

What cannot be a Flatpak is refused before anything is built, saying
why: a Windows or wasm executable, a build against a sysroot or for
musl, another architecture than the runtime's, a build against
CRAFTER_BUILD_LIBCXX_DIR, whose libc++ the Flatpak would not carry, and
a build by a native crafter-build, which links the host's glibc: a
native process knows no Flatpak runtime, from /.flatpak-info, unless
CRAFTER_BUILD_FLATPAK_INFO, the tests' hook, names a file with one.
Default stays the executable as linked for now, RunTests runs every test
as linked, whatever its Configuration asks for, and RunLint works out
its compile command so, and a forwarded --packaging= leaves a
dependency's executables alone, since consumers run them by path. A
dependency that packages its own executable gets its desktop file,
metainfo and icons rebased by the loader as its cfg.files are, so they
are its own whatever directory the consumer builds from. Only a Flatpak
is keyed into VariantId, so every other configuration keeps its
directory, but for one given --packaging=, which was a project arg,
hashed into VariantId, and is a standard arg now, a dependency's
included. The app-id and what a Flatpak is installed as are not keyed:
they change files/share, never what is compiled. The asset name map,
kept three times, twice in Build() and once for the browser runtime's
files.json, is one function now, CompressedAssetName; CompressAsset, in
Crafter.Build-Asset.cpp, keeps the list of the extensions it loads,
which has to agree with it. Each copy a Flatpak build makes into the
program's directory, of its shaders, assets, cfg.files and what its
dependencies forward, records the top-level name it places there, the
names of what a directory holds for one copied into it itself ("data/",
"data/."), and those are what the writer keeps in files/bin; a build
that fails after copying adds them to the writer's record all the same,
so the next write removes what no build places any more.

SharedLibraryRuns now also packages its program as a Flatpak, whose
files/lib has to carry libgreet.so for it to start.
2026-11-08 22:48:42 +01:00
7283610128
docs: how a dependency's headers reach its consumers
The README's Dependencies section never said how a dependency's headers
reach the projects built on it, so the fix's rule had nowhere to be
stated: its directory and every include/ in its tree are on their
include path, except under a directory named bin or build, and a header
kept under one of those needs an -I of its own in cfg.compileFlags.
2026-11-07 19:24:12 +01:00
da714a0121
test: the include walk leaves out every bin/ and build/
IncludeWalkOutputs stages a library at a project's root, a program
beside it and one in a directory below it, a project of its own beside
the library with a project.cpp, and an include/ in the bin/ or build/ of
each, as a flatpak-builder tree leaves one. The include flags of both
programs hold the library's include/ and none of the others. Before the
fix every one of them was on the include path.
2026-11-07 19:24:12 +01:00
703c700dc0
fix: leave bin/ and build/ out of the include walk
GetCompileCommand put every directory named include in a dependency's
tree on the include path, bin/ and build/ included, so what a build had
left there came before the system's headers in every C++ and C compile
built on the dependency. In this repository build.sh leaves glslang's
CMake tree in build/glslang/build, and the `run flatpak` script leaves
flatpak-builder's /app tree in build/flatpak/build-dir, whose include/
holds the bundled LLVM's headers, clang-c/ and libc++'s among them:
crafter.build-lib's path is the repository's root, so crafter.build-exe
and every test took them. The walk now leaves out every directory named
bin or build, the names crafter-build gives what it writes, wherever it
sits. Leaving out only the bin/ and build/ of the configurations in the
compile's graph would not do: a dependency's tree holds the outputs of
configurations outside it too, a program in a directory below it or a
project of its own beside it, as Crafter.Graphics' examples are. Of the
#include lines in the Crafter repositories and in the dependencies
crafter-build has cloned, the one that needs a header found only under
such a directory is glslang's own, in a source its CMake build compiles.
2026-11-07 19:24:12 +01:00
0cf2f629eb
test: a program built on a shared library starts
SharedLibraryRuns builds an executable on a LibraryDynamic dependency
and runs it, from its fixture and again from a directory whose name
holds a comma. Before the fix it failed at start with "libgreet.so:
cannot open shared object file".
2026-11-07 19:24:12 +01:00
bc98c87f01
fix: let a program find the shared libraries it is built on
The link of an executable built on a LibraryDynamic dependency took
lib<name>.so from the library's bin dir and recorded nowhere to find it
at run time: no run path pointed there and nothing copied it beside the
program, which mingw does for a DLL. The program failed at start with
"cannot open shared object file". A shared library now hands its bin dir
up as a run path, as a CMake external does with its build directory, and
a program linked against it records it. Run paths reach the linker
through -Xlinker, quoted for the shell (RunPathFlags), in a program's
link and in project.so's: unlike the external cache's directories, the
bin dir is the project's own, and clang splits a -Wl, value at every
comma its name may hold.
2026-11-07 19:24:12 +01:00
aa6b555395
refactor: carry run paths as directories, not -Wl,-rpath flags
ExternalOutputs put an -Wl,-rpath,<dir> per library directory of a CMake
external into its link flags, and the flags travelled up the dependency
graph in BuildResult::libs to every link that consumed them: an
executable's or a shared library's, and that of the project.so
LoadProject links against a project file's pragma dependencies. Whether
a program should record those directories depends on how it is packaged:
a Flatpak has to load its libraries from its own files/lib instead, and
has to know the directories to copy them from. ExternalBuildResult and
BuildResult now carry them as runPaths, merged up the graph beside libs,
and all three links turn each into an -Wl,-rpath as before, so the link
commands differ only in the order of their flags. PragmaSharedExternal
holds project.so's link to them.
2026-11-07 19:24:12 +01:00
06ee1da796
test: a pragma dependency built on a shared CMake external loads
PragmaSharedExternal loads a project file whose #pragma crafter
dependency is a library built on a CMake external that makes a shared
library, and calls into that library while project.cpp loads.
LoadProject links project.so against what each pragma dependency's build
reports, and project.so loads only when that includes where the shared
library is. It passes as the tree stands, and holds project.so to
recording where a pragma dependency's shared CMake external is: without
that run path, LoadProject fails with "libsharedext.so: cannot open
shared object file".
2026-11-07 19:24:12 +01:00
5a63dd81b8
refactor: route an executable's outputs through ProgramDir()
Build() put an executable and the files it reads at run time (its
shaders, cfg.files, assets, and what its dependencies forward to it) in
BinDir() directly, and ExpectedOutput(), -r and the wasm variant copies
each spelled the same directory again. A Flatpak keeps its program in
files/bin of the build directory instead, so those places now ask
Configuration::ProgramDir(), which for every configuration is still its
bin dir. Nothing moves yet.
2026-11-07 19:24:12 +01:00
3044ac34a1
test: a wasm test declared with AddTest runs under wasmtime
WasmTestRuns declares a wasm32-wasip1 test on a fixture project and runs
it through RunTests, which builds it and hands it to the wasmtime runner
its target derives. The test has to pass and print its own output.
Before the fix every such test failed with "failed to open wasm module",
because RunTests left the .wasm off. It skips where the WASI sysroot
with exceptions or wasmtime is missing, as WasmHelloRuns does, so it
runs in the Flatpak and skips on a development box without them.
2026-11-07 03:25:13 +01:00
5d843f3967
fix(test): run the binary the link wrote, .wasm included
RunTests worked each test binary's path out with a rule of its own,
TestBinaryPath: BinDir()/<name>, plus .exe for any triple naming windows
or mingw, and nothing for wasm. The link writes <name>.wasm for a wasm32
executable, so every wasm test declared with AddTest was handed to
wasmtime without its extension and failed with "failed to open wasm
module", inside the Flatpak as well, where wasmtime is bundled. RunTests
now asks ExpectedOutput(), the name the staleness checks and -r read,
which for a wasm32 executable is the <name>.wasm the link writes.
2026-11-07 03:25:13 +01:00
0cc699139c
docs(packaging): add the 6.0.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 12m12s
6.0.0
The release of this push and of everything on master since 5.0.0: lldb,
the Khronos validation layer and the SPIRV-Tools programs in the
Flatpak, --die-with-parent in the README's alias, and the release
.flatpakref with the repository's key in it. Its Breaking item, the end
of beta and of the rolling release, makes it a major.
2026-11-02 17:17:02 +01:00
54aaf078b2
docs: a release is a signed tag pushed with master
The README offered master builds as the `beta` branch, AGENTS.template.md
described the `latest` tag CI force-pushed, a release as a tag pushed
after master, and CI as running on every push to master, and the
repo-better-solution lens told reviewers that users get master through
`beta`.

The README now says that releases go to `stable`, the branch its install
commands pick even while the repo still holds the old `beta` branch.
AGENTS.template.md says that every pushed range adds a release entry and
goes out in one push with a signed tag on the commit master receives,
its last commit or, on the pull-request path, the merge, how to write
the entry, what every run checks before building and what a tag run also
checks, publishes and creates, what follows when one fails, what CI runs
for, and what becomes of `beta`; the lens says users get master through
releases on `stable`. The entry's rules are the owner's: at most three
sections, New, Fixes and Breaking, the most important item first and
nothing after them, and a version that is a major for a Breaking
section, a minor for New items and a patch for Fixes alone. The release
paragraph also gets the blank line that keeps it apart from the one on
local builds.
2026-11-02 17:17:02 +01:00
be81fc098e
feat(ci): drop beta and latest, release signed tags on master
A push to master published the `beta` branch and moved the rolling
`latest` tag and its "Latest master build" prerelease, and a pushed
X.Y.Z tag made the release and published `stable`. The owner wants a
release for every push to master, made by the signed tag that goes with
it, and nothing for a push without one. So `beta`, `latest` and the
branch trigger are gone: the workflow runs for pushed tags, pull
requests and manual runs only, and the `latest` tag and its prerelease
have been deleted from the forge.

`beta` gets no more builds, and its installations would not hear of it:
the release notes ship in stable builds only. The Publish step marks
beta's last build end-of-life, once, with a reason that names stable,
and the next `flatpak update` of a beta installation prints it. The
reason also names the branch, because a non-interactive update prints
only the app's name with it.

Before building, a tag run now checks the tag: it has to be annotated
and signed by the owner as Forgejo verifies it, its commit has to be on
master, its version has to be X.Y.Z and newer than every release the
forge has published, its own included (a later tag whose run still
queues does not count), and the metainfo's newest <release> entry has to
be that version. The tag run checked only the last of these. It reads
the tag from the forge's API, because the checkout fetches a pushed tag
again as a plain ref to its commit, so the job's clone never has the
annotated tag, and Forgejo verifies a signed tag's own signature but
falls back to the commit's for an unsigned one, so the step also
requires that the verdict covers the tag's payload. The metainfo's entry
is read once, as the first <release> element: the Version step takes its
version and renders its notes into release-notes.md with the renderer
the Release notes step had, and stops the run when they come out empty,
so a comment or another attribute order cannot give a release one
entry's version and another's notes. It does so on every run, pull
requests and manual runs included, so a broken entry shows before a
release.

Release runs share a concurrency group, so they queue one behind
another; a pull request still cancels its own outdated run. A failed
release run can be re-run while no newer release exists, since its tag
is still on its commit; a release that an attempt left half made has to
be deleted first. The release step runs without `override`, which would
delete a tag that has moved off the run's commit since the Version step
and tag the old commit instead.

A manual run no longer publishes anything; it used to publish `beta`
and move `latest` from whichever branch it was started on. No step
pushes to git, so the checkout keeps no credentials. git describe in
build.sh, project.cpp and the workflow has no `latest` tag left to
exclude.
2026-11-02 17:17:02 +01:00
2babe94a6a
fix(ci): publish under the lock Crafter.Review's workflow takes
Crafter.Review's workflow publishes its Flatpak into the same repo, the
web root's repo/, and holds an flock on .publish.lock in the web root
while it commits and updates the summary. Its comment says that this
protects both only once Crafter.Build's workflow takes the lock too, and
ours never did, so a publish of each could interleave: a
build-commit-from and a build-update-repo --generate-static-deltas
--prune of each workflow on one repo at the same time.

The Publish step now holds the same lock from its commit to the ref
files it writes into the web root, and the job installs util-linux for
flock, as Crafter.Review's jobs do.

AGENTS.template.md says that the repo is shared and the lock taken.
Neither it nor the workflow's header comment says any longer that the
web root and the signing key are this runner's alone, or that the
organisation-wide `flatpak` runner mounts none of them. That runner,
which serves every Catcrafts repository and refused all of this job's
volumes when it last took it, in October, now mounts the web root and
the key for Crafter.Review's publish job, and the volumes a runner
allows are open to every job it runs. The owner has ruled the sharing
intended. The header also stops saying that a job of ours that lands
there fails before building: that held while the runner refused every
volume, and AGENTS.template.md keeps it as the October history.
2026-11-02 14:56:41 +01:00
2447d6ec4f
fix(ci): attach the flatpakref with the repo's key to releases
The Bundle step copied packaging/flatpak/net.catcrafts.CrafterBuild.flatpakref
into dist/ as the checkout has it, with GPGKey=GPG_KEY_BASE64_PLACEHOLDER,
so all six releases, 2.0.0 to 5.0.0, attach a .flatpakref that does not
install: `flatpak install --from` it stops with "GPG: Unable to export
keys: GPGME: No data" (Flatpak 1.18.4) before it adds the remote. The
copy the publish step writes to the web root has the key filled in, and
installing from it goes ahead.

The key is known only from the publish step on, so the release's copy,
and SHA256SUMS over it, are made there from the web root's file instead
of in the Bundle step.
2026-11-02 14:56:41 +01:00
a1bc96a323
fix(review): name each lens section, as crafter-review 1.0 requires
crafter-review 1.0.1, the released build installed on this machine, and
the newer build installed beside it as //local refuse the config key
lensSections: a lens's repository section is named per lens, as
lenses.<name>.section, instead of being found by listing a directory.
With the key in place `crafter-review config` reports it as a problem,
and freeze and run stop at "preflight: config: unknown key lensSections".

The three files in .review-gates/lenses/ are named under lenses, one
entry each, the migration the Crafter.Review session gave; with them
`crafter-review config` reports no problem.
2026-11-02 14:56:41 +01:00
00f07dae88
docs: push reviewed ranges straight to master
All checks were successful
Flatpak / flatpak (push) Successful in 30m58s
AGENTS.template.md had every change go through a pull request against
master. The owner has made pushing straight to master the default.

The commit and push guidelines say so: an approved range is pushed to
master as a fast-forward, with no merge commit, and a pull request is
opened only when the owner asks for one; when master has moved since
the freeze, the range is rebased, frozen and reviewed again. What
follows from that: the README changes in the same push; without a pull
request CI does not run on a range before it reaches master unless
someone starts it by hand, so the review's gate0 is the check before the
push; and the freeze exception for a merge commit applies only to a pull
request. Design rule 8, the testing note and the release steps lose
their pull-request wording, and the testing note no longer speaks of a
commented-out lint step: ci.yaml has no lint step at all.
2026-11-01 23:21:35 +01:00
03951ff458
docs: update the first local Flatpak build's time and size
AGENTS.template.md and project.cpp gave the first run flatpak as about
25 minutes on a 56-core machine and its state as about 2 GB, figures
written on 2026-10-06, before lldb and the Vulkan and SPIR-V modules
were in the manifest. A first run of this commit's manifest, in a fresh
worktree, took 30 min 36 s with 56 CPU threads, 14 min of it for LLVM
with lldb, and left build/flatpak at 4.1 GB, 3.3 GB of it state/.

The figures become those, and the line on later runs says that they
rebuild only the crafter-build module while the manifest is unchanged.
2026-11-01 22:28:08 +01:00
40dcb18a1e
feat(flatpak): ship the SPIRV-Tools programs
Crafter.Graphics' PushConstantRewrite and UIFusedShader tests require
tool:spirv-val, and the Sdk has no spirv-val, so inside the Flatpak they
are skipped. The spirv-tools module the validation layer needs built
only the libraries, and removed them afterwards.

It now builds the programs as well, spirv-val, spirv-opt, spirv-dis and
the rest, which link SPIRV-Tools statically, and ships them. The
headers, the static libraries, the CMake and pkg-config files and
libSPIRV-Tools-shared.so, which nothing here links, are still removed,
and a post-install step runs spirv-val --version.
2026-11-01 22:28:08 +01:00
c8517a41cf
docs(readme): --die-with-parent in the install alias
flatpak run becomes bubblewrap, and without --die-with-parent the
sandbox outlives it. With crafter-build started through the alias in an
interactive bash or zsh on a terminal, SIGKILL to its flatpak run
process alone left a -r program running and a build writing into bin/
and build/. With the flag, both ended with it.

bubblewrap kills the sandbox when flatpak run or its parent dies, and
for crafter-build typed at the prompt, in the foreground or with &, that
parent is the shell: with the flag, the sandbox also ended when the
shell was SIGKILLed, or exited after a disown. In a (crafter-build -r &)
subshell, flatpak run outlives the subshell and is adopted by another
process, so its sandbox outlived the shell with the flag as well. Ctrl-C
ended the program either way.

The README's alias gets the flag, and the paragraph after it says what
that changes: a program started through the alias, as crafter-build ...
or crafter-build ... & at a bash or zsh prompt, ends with its shell,
even after a disown.
2026-11-01 22:28:08 +01:00
a32b8c898a
docs: debugging inside the Flatpak
The README gets a Debugging section: the debugging tools the sandbox
carries, that a program to debug needs cfg.debug (which --debug sets
where the project calls ApplyStandardArgs), how to start the tools with
--command, why a debugger in one flatpak run cannot see a program that
another one started (each has process IDs of its own), and flatpak
enter as the way into a running program's sandbox, with the ptrace
opt-in that takes where ptrace_scope is 1. It warns off lldb's
gdb-remote from a second sandbox: when a process in lldb's own sandbox
has the remote program's process ID, lldb takes that process's
executable for the program's. And it shows which variables turn the
layer and GPU-AV on from the environment, and that VK_LAYER_PATH and
VK_ADD_LAYER_PATH do not reach the sandbox.

AGENTS.template.md gets the module layout and the rule that the layer
follows the Sdk's Vulkan loader. Its CI section says that a change to a
module's sources or build-commands builds it again and every module
after it, so that a new version of swig or libedit, which come before
LLVM, now rebuilds it too, and loses the cold-run time it gave, written
on 2026-10-03, before any of these modules were in the manifest.
2026-11-01 22:28:08 +01:00
16db37bbe6
feat(flatpak): ship lldb and the Khronos validation layers
Programs that -r and the test runner start run inside the Flatpak's
sandbox, and the Sdk it runs on has gdb but neither lldb nor the Khronos
validation layer: in the sandbox of beta 5.0.0, a vkCreateInstance that
asks for VK_LAYER_KHRONOS_validation returns VK_ERROR_LAYER_NOT_PRESENT.
flatpak run clears VK_LAYER_PATH and VK_ADD_LAYER_PATH, so the layer the
host has cannot stand in.

lldb becomes a project of the llvm module and brings lldb-server,
lldb-dap and lldb-mcp. Its Python, libedit, curses, libxml2 and lzma
support are set ON instead of being left to detection, so a dependency
that goes missing fails the configure step rather than shipping an lldb
without it. The Sdk has neither SWIG nor libedit, so both become modules
before llvm, SWIG as build-only.

The layer is Vulkan-ValidationLayers vulkan-sdk-1.4.357.0, the Vulkan
SDK release of the Sdk's loader (libvulkan.so.1.4.357), built from
Vulkan-Headers, Vulkan-Utility-Libraries, SPIRV-Headers and SPIRV-Tools
at the revisions that release's scripts/known_good.json names. Those
four are built into /app at those revisions and removed afterwards. All
five come after the LLVM and WASI modules, so that bumping them reuses
the cached LLVM and WASI builds. UPDATE_DEPS is turned off: it defaults
to ON, which has update_deps.py clone the dependencies, and of all the
modules only crafter-build's build-args share the network.
2026-11-01 19:20:22 +01:00