Commit graph Crafter.Build/tests
Author SHA1 Message Date
93f1c8d9b9
fix(test): run each test's command with a TMPDIR of its own
Tests stage their fixtures under fixed names in the temp directory,
fs::temp_directory_path() / "crafter-build-<name>", and two runs at
once staged into the same ones: natively every process shares the
machine's /tmp, and every sandbox of crafter-build's Flatpak shares the
one the app has, whatever checkout it runs in. A test of one run could
find what it had staged removed or written over by the same test of the
other run, which removes the directory as it starts and stages its copy
anew.

RunTests now makes a directory for the run in the temp directory, a
PrivateDirectory, and runs each test with TMPDIR naming <run>/<name>,
so that fs::temp_directory_path() in the test names it and the fixed
names are the run's alone. The second test of one name in a run, as two
configurations or two targets may each have one, gets <name>-2, so that
removing one's directory does not take the other's. RunSingleTest takes
the directory as a new last parameter and puts TMPDIR into the env
prefix of the test's command, beside a Wayland test's WAYLAND_DISPLAY.
env's command is sh, which execs the test's words, as for a Wayland
test's: env takes a word with an '=' in it ahead of its command for an
assignment, a binary's path among them, and with no command left it
printed its environment and exited 0, a pass for a test that never ran.

What a test that passes or skips leaves is removed when it ends. What
one that fails, crashes or times out leaves is kept for a look, its log
says where, as does what is printed of a test that fails or crashes,
and the run's directory then outlives the run, unlocked, for a later
run to remove a minute after, or, where the run was killed, a minute
after its last change to it; PrivateDirectory gains Keep() for that. A
test's logs, build/test-logs/<name>.log and <name>.compositor.log, are
named as its TMPDIR is, <name>-2 for a later test of one name, so that
two failing tests of one name each keep their own, and with it where
what each left is kept: with one log for both, the second's was written
over the first's. The README's line on the logs says so. The directory
is dated as it is let go of, since the removal of abandoned directories
goes by its date, which is that of what was last made or removed in it:
for the run of a test that fails after a minute, as one that times out
at the default 60 s does, a minute old already, and the next run would
remove it at once. The removal now reads a directory's date only once
it holds the directory's lock: a date read before could be one the
holder replaced as it let go.

The directory is the run's, not a pass's: every pass of a sweep over
targets shares it, so it is made and its surroundings swept once, and
let go of once the last pass is done. A pass that made one of its own
would have made it once the passes before had let go of theirs, and
making it would have removed any of those that had not changed for a
minute: a kept one, after a pass of that long, while its test's output
said where it was. RunTests becomes the wrapper that holds the run's
directory around RunTestsWith, the passes it recurses into, and the
directory is kept the moment a test keeps something in it, by the
worker that ran the test, so that a later pass that throws, as one does
for a target whose runner CRAFTER_BUILD_RUNNER_ gives wrong, or a
worker that cannot be started does not take it with it; Keep() may be
called from several workers at once.

TMPDIR reaches the test where its runner hands it on, as running it
directly and qemu-user do. Under wine a Windows test does not get
TMPDIR, and takes the Wine prefix's TMP, TEMP and temp directory, and
wasmtime gives a test no environment at all; RunSingleTest's comment
says so. A test under `host` gets its TMPDIR as any test does, so that
comment and HostDisplay's now say that `host` leaves the test the
display, not the whole environment, as it is.

In the runner rather than in each of the 74 tests whose main.cpp uses
the temp directory at this commit: a project's own tests are covered
the same way, where their runner hands them TMPDIR. Of the 74 only
SysrootStdModule has to change. It builds against a sysroot it stages
there, and the std module's cache directory is keyed on the sysroot's
path, which is a new one every run now, so every run left one more
directory, with its lock, in the real cache; it keeps its cache in its
scratch directory now, as the tests that have crafter-build fetch a
repository they stage do. AGENTS.template.md says what changes for the
tests: HostFlatpak, whose /tmp is no longer the temp directory a test
is given, is a second test that writes elsewhere, and under
`crafter-build test` a staged copy goes with the test's TMPDIR rather
than at the test's next run.
2026-11-28 11:05:51 +01:00
67e97d0a2a
test: a test's headless compositor, from its start to its cleanup
HeadlessCompositor drives RunSingleTest with itself in every part. The
harness starts it again as the compositor, which listens on a
wayland-7 socket in the XDG_RUNTIME_DIR it is given and records its
environment, and as the test, which records its own and connects.

A test that sets wayland passes against its compositor and runs with
WAYLAND_DISPLAY naming the compositor's socket, without DISPLAY and
WAYLAND_SOCKET, and with the XDG_RUNTIME_DIR of the process that runs
it. The compositor gets a directory of its own in that one, or in /tmp
where that process has none, and none of the WAYLAND_DISPLAY,
WAYLAND_SOCKET and DISPLAY that process has, each given a value of the
session's in the driver, and afterwards it has been sent SIGTERM, is
gone and so is its directory. The compositor's timeout(1) is the
test's, the wait for its socket and 30 s more, and none for a test with
no time limit; and a test whose binary's path has an '=' in it runs as
any other. A test that does not set wayland, and one run under `host`,
keep that display. Without an override CRAFTER_BUILD_COMPOSITOR names
the compositor, and an override wins over it. A compositor sh cannot
find fails the test with status 127, named, and a line on how a test
that may run without it is skipped; one that ends before it listens
fails it with its status and what it printed, checked on a word the
command does not hold, without running the test; a failing test keeps
what its compositor printed; a compositor killed while the test runs is
reported as ended. A stand-in crafter-build killed in the middle of a
test has its compositor sent SIGTERM and gone, and the directory it
leaves is removed when the next is made, once dated past the minute,
while one changed a moment ago and one that is held stay.

Without PR_SET_PDEATHSIG the two checks on the killed crafter-build
fail, and without the removal of abandoned directories the one on its
directory does; with the test's own words as env's command, the check
on the binary whose path has an '=' fails, with a limit of its own for
the compositor of a test with none the one on that limit does, without
what the compositor printed in the failure the one on that, with
WAYLAND_SOCKET left to the compositor and the test the ones on it, and
without the command in the failure of a compositor sh cannot find the
one on that, which looks for the harness's words, not sh's. No weston
is needed, so the suite runs it in the native loop and in the Flatpak's
build sandbox alike. The driver makes its compositors' directories in a
directory of its own in $XDG_RUNTIME_DIR, or in /tmp where that is not
a directory, rather than in the temp directory, since a socket's path
holds 107 bytes and a temp directory's path can use them up; its check
without an XDG_RUNTIME_DIR has the harness make that compositor's
directory in /tmp itself, as crafter-build does where there is none.
The driver's directory is a PrivateDirectory, now exported for it, so
that one a killed driver left goes when a later one is made, once it
has not changed for a minute, and AGENTS.template.md's line on where
tests write now says that what a test runs writes caches of its own,
crafter-build's builds and wasmtime the modules the wasm tests run, and
names this test as the one that writes anywhere else.
2026-11-28 11:05:51 +01:00
fe25d7aeff
test(lint): the ast and ast-module cases pass only when their rule ran
RunLint calls a rule that reads the AST only on a file it could parse,
so when the parse failed, the checks inside the "ast" and "ast-module"
rules went untried, and the test, which read nothing of the run but
those checks, passed. That is how the "ast" case, whose file includes
<string>, passed in crafter-build's Flatpak with #46 open: lint printed
"'string' file not found" for that file, and the test exited 0. Both
cases now also check that their rule ran and that the run had no error.
2026-11-27 16:16:38 +01:00
043b1a3015
test(lint): a compiler installed in a directory of its own
LintCompilerHeaders stages an installation of its own: the toolchain's
compiler copied into install/bin, beside links to the rest of the real
installation, and one header more in its c++/v1, crafter_issue46.h.
The toolchain it points the build at with CRAFTER_BUILD_LLVM_DIR has a
bin/clang++ that links to that copy, and no include directory. The
compiler runs from install/bin, so the compile of a file that includes
<algorithm> and crafter_issue46.h finds both, and the build's scan of
the file and lint's parse of it have to as well.

Without the lint fix the parse fails on crafter_issue46.h on a host
whose /usr has a libc++, and on <algorithm> in crafter-build's Flatpak,
whose /usr has none. It fails in the same two ways with argv[0] taken
from the compile command, llvm/bin/clang++. Without the scan fix the
scan, given llvm/bin/clang++ as well, fails the same two ways, and the
build with it, which the test's first check reports. The compiler is
copied because a link would lead clang back to the real installation,
and the copy is of the clang++ in the directory `clang++ --version`
names, so that a wrapper on PATH that runs the compiler is not copied
in its place. The test takes CRAFTER_BUILD_LIBCXX_DIR out of its
environment, which would have every compile take that libc++ in place
of the staged one, and the std module the staged toolchain builds goes
to a cache of its own. It skips where it cannot stage the compiler:
where no clang++ is found, the compiler's installation has no libc++
headers of its own, no llvm-ar or clang-scan-deps is beside the
compiler, or the copy names no resource directory it has.

A second configuration on the same toolchain passes
-no-canonical-prefixes, with which the compiler takes itself to be in
llvm/bin, as written, and reads the clang++.cfg the test writes there,
which adds a directory only it names; its file includes the one header
that directory holds, and none of the C++ standard library, which llvm/
has no include directory for. Given install/bin/clang++ whatever the
command's prefix flags, the scan fails on that header, and the build
with it, and so does the parse. The test takes CLANG_NO_DEFAULT_CONFIG
out of its environment as well, which would have clang read no
configuration file, and where the compile with the flag still does not
read the file beside the link, as where a user or system configuration
directory holds a clang++.cfg, or a <triple>-clang++.cfg, that clang
finds first, it leaves the second configuration out and skips, unless
the first configuration failed.
2026-11-27 16:16:38 +01:00
15e9831203
test(build): one project loaded with its flags in two orders is built once
DuplicateModule builds its project once more with --wide --reorder, with
which P gives M the list that A passes on, in the other order. The
loader takes the two orders for two lists and makes two configurations
of M, which VariantId, taking the project's own flags sorted, builds
into one directory, and a pass builds that directory once. The case
checks that the two are two configurations with one directory, and then,
in two passes, that the graph builds and that P's main.cpp and A's
interface have their edges to the module of the configuration of M that
the pass built. The first pass builds whichever asks first, and the
other has no modules. The second builds the other one first and records
it for the directory, as BuildAll records a configuration it builds,
before it builds the graph, so that both configurations of M then have
modules, the first still those it read in the first pass.

On the engine of the range's base the graph is refused as "module M is
built twice for P": every configuration had its modules from the
listing, and the refusal told the builds apart by their configurations.
On an engine that reads a dependency's modules off the configuration it
is listed as, the range's fix without BuildResult::built, the first pass
builds and A's interface has no edge to M, P's M being the one built and
A's having no modules, and the second pass is refused as a graph with
two builds of M.
2026-11-27 09:25:53 +01:00
08a506d34b
test(build): a source's declaration and imports, as its compile reads them
SourceScan builds copies of six fixtures and checks what the build read
in their sources, by the modules and units it gives each configuration,
and runs the program where what it does depends on that:

- text, three of the four inputs of #45: `import  Base;` and
  `import Spaced ;` are imports, and an import in a comment that spans
  lines or under #if 0 is none. A build with nothing changed then
  rewrites none of the scans, and one that cannot be read is taken
  again.
- quoted, the fourth: an implementation source whose string literal
  holds "export module std;" is a unit of no module, and the build
  succeeds.
- partition: a .cppm that declares an implementation partition
  (`module X:Impl;`) is the partition Impl of X, and the implementation
  unit that imports it has its edge to it.
- define: an #ifdef on a define that the test sets after listing the
  source decides whether the source imports a module.
- switch: an #if on a header of the library the app is built on decides
  it. The header is edited, and the source is scanned again; then the
  app is built on another library, whose header of that name says the
  other thing, so that only the command the scan was taken with has
  changed.
- missing: an #include of a header that is not there fails the build
  with a message naming the header, and nothing is compiled of the
  source.

On the engine of the range's base, with only this test added, every case
but missing fails. Each of the three inputs of the text case is read the
old way, and its first build fails outright whenever Spaced.cppm, whose
import of Base was missed, is compiled before Base's BMI is there; the
string literal makes the listing throw "Module std not found not found",
and the implementation partition the listing of the partition case, "No
module declaration found"; the import under the #ifdef counts without
the define, and the one under the #if after the edit and after the swap;
and there is no scan to look at. The missing case passes there too, the
compile reporting the header as the scan now does.
2026-11-27 09:25:53 +01:00
3c8f4ddb54
fix(build): read what a source declares and imports with clang-scan-deps
GetInterfacesAndImplementations found the module declarations and the
imports of a configuration's sources by searching their text with
regular expressions, after deleting the comments that fit on one line.
The expressions skipped neither string literals nor comments that span
lines, knew nothing of the preprocessor, and wanted one space after
`import` and none before its semicolon (#45). An implementation source
that held "export module std;" in a string literal was taken for a unit
of a module std, and listing it threw "Module std not found not found".
An import in a comment that spans lines or under #if 0 was followed.
`import  X;` and `import X ;` were missed, so their unit had no edge to
the module it imports and could be compiled before that module's BMI was
written.

What a .cppm or .cpp declares and imports now comes from clang-scan-deps
-format=p1689, which preprocesses the source with the configuration's
C++ compile command, the one Build() compiles every unit of it with:
strings, comments, spacing, macros and #if come out as they do for the
compiler. GetInterfacesAndImplementations only lists the sources, in the
new interfaceSources and implementationSources. Build() reads them
(ReadSources) once the configuration's dependencies and external
dependencies are built: the command takes their include paths, and a
source may include headers of an external dependency, which are not
there before it is fetched. From what it read, Build() makes the
configuration's modules and units, its `interfaces` and
`implementations`, and places each import on a module of the
configuration or of what it is built on, whose own Build() has read its
sources by then. It makes those of its own configuration alone, as the
reset of the units' state did before it.

A build pass builds a directory once, for whichever configuration of it
asks first, and the loader can make two configurations of one directory:
one project loaded along two paths with its args in two orders, which it
keeps apart and VariantId, sorting the args, does not. Only the one that
was built has the modules that build read, so the result of a build now
names the configuration it ran on (BuildResult::built), and a
dependency's modules are looked up through the pass's record of its
directory. 6.4.1 had every configuration's modules from the listing and
took such a graph for one with two builds of a module, which it refused;
it is now built, once, and the units of both sides have their edges.

A scan is kept in the build directory as an object is, in scans/ or, for
a source outside cfg.path, in scans-outside/, as JSON of the command it
was taken with and of what clang-scan-deps wrote, with the dependency
file clang-scan-deps wrote beside it, which lists the source and every
file it included. A build scans a source again unless its scan is newer
than every file that dependency file lists, was taken with the same
command and can be read, so a build with nothing changed runs no
clang-scan-deps. Both files are written beside their places and renamed
into them, as the archive and the list of objects are, for another
crafter-build that may be building the same clone.

A configuration's modules are known only once its build has read its
sources, so the refusals of a module that two configurations of the
graph build (DuplicateModuleError, #41) and of interface units that
import each other (ImportCycleError) now come there: once the
dependencies are built, before any .cppm or .cpp of the configuration is
compiled. They came before the configuration made a directory or built a
dependency. The contributor guide names clang-scan-deps among the
prerequisites and among what :Toolchain resolves, has a test look at the
modules of a configuration only after building it, and has the gotcha
for the new order.

ResolvePendingImports and the pendingImports of the unit classes go.
They placed the imports that a scan at listing time could not, once the
dependencies were wired up, and with the imports placed when the
dependencies are built there is nothing pending. The tests that looked
at a configuration's modules and units before building now look after it
(DependencyLink, ModuleInterface, StaticLib, ConcurrentDependencyReset
and the disabled TransitiveInterfaceChange), IncrementalInterfaceChange
checks the edge that the build of a consumer gives it when its
dependency was assigned after its sources were listed, and ImportCycle
and DuplicateModule check that the refused configuration compiled
nothing of its own. The workarounds for the old scanner are not needed:
MingwSysroot writes its stand-in std module as a plain literal again,
JobLimit writes the declarations of the sources it generates as plain
literals, and Lint's comment on its fixture file no longer gives the
scanner as the reason for it.

The messages of the regex code stay where they still apply. The one for
a source that declares a unit of a module the configuration does not
have loses its doubled "not found", and applies to an implementation
source that declares one, such as an implementation partition
(`module X:P;`). An implementation unit written `module X;` declares no
unit for clang-scan-deps but imports X, and an import needs no module of
the configuration: the compile reports a module no one builds. A .cppm
that declares an implementation partition is built as a partition of its
module, where it was refused as declaring no module.

The Toolchain gains clangScanDeps, resolved as llvm-ar is: in the bin/
of the LLVM prefix, else by name on PATH. The Flatpak has
/app/bin/clang-scan-deps.

Fixes #45
2026-11-27 09:25:53 +01:00
f9bd5333da
test(build): sources of one file name, and where their objects go
SameNamedSources builds configurations whose sources share file names,
on a fresh copy of its fixture outside the checkout, and runs what they
link. `names` is an executable of an a/Thing.cpp and a b/Thing.cpp, the
C sources a/unit.c and b/unit.c, a b/Thing.c beside the b/Thing.cpp and
a Thing.cpp in a directory beside the configuration's own; its program
prints what each returns, the first time and again after a header that
only a/Thing.cpp includes has changed and after b/Thing.cpp and
b/unit.c have. `registry` is a debug executable of an a/Self.cpp and a
b/Self.cpp that register themselves when the program starts, which
prints that each did so once. `things` is a static library of
a/Thing.cpp, b/Thing.cpp, b/Thing.c and the two unit.c, and
`things-app` a program of main.cpp and ../shared/Thing.cpp built on
it, which prints what `names` does. `outside` is a static library of
one C source that lies outside its configuration's directory and is
listed relative to the working directory, built from a working
directory with a space in its name; `llvm-ar t` lists its object.

ObjectPath asks the rule for the objects of sources without building
anything: in the configuration's directory and in directories of it,
of one file name in two directories, a .cpp, a .c and a .cu of one
name in one directory, outside the directory, and under a directory of
the configuration's own that is named objects-outside and holds the
whole path of the source outside. No two of them get one object. A
path spelled with . and .., a relative source, and a source of a
configuration whose path ends in a separator or is ./ are each given
the object of the file they lead to, and a .cppm, a .h and a file
without an extension are refused.

CudaCompile gains a static library of its kernel.cu and a kernel.c
beside it, whose archive lists kernel_source.o and kernel_cuda.o.

Before the fix SameNamedSources failed at the link of `names`, with
duplicate symbols, and of `things-app`, with undefined ones, and its
`registry` printed that one of the two sources had registered twice
and the other not at all. `outside` built before the fix as well, its
object lying in the build directory then: it is there for the path
the fix gives that object.
2026-11-19 11:02:39 +01:00
7f8089474b
fix(build): name a source's object from its path
The object of an implementation unit was named from its file's name
alone, <build dir>/<name>_impl.o, and that of a C or CUDA source
likewise, <name>_source.o. Two sources of one configuration with the
same file name in different directories were therefore compiled into
one object, each over the other, with one dependency file between
them, and the link was given that object twice (issue #50). A build of
an a/Thing.cpp and a b/Thing.cpp that each define a function failed at
the link, with duplicate symbols of one of the two and no word of the
other. A debug build of two such files that define nothing another
file names succeeded, and its program had one file's code twice and
the other's not at all. A .c and a .cu of one name shared an object in
one directory as well.

An object, with its dependency file beside it, is now named from where
its source lies: under <build dir>/objects by the source's path from
the configuration's directory, objects/a/Thing_impl.o for a/Thing.cpp,
or, for a source outside that directory, under
<build dir>/objects-outside by its whole path. A .cu's object ends in
_cuda.o; a .cpp's still ends in _impl.o and a .c's in _source.o. Two
sources then have one object only when their paths are one once . and
.. are taken out of them: any other two differ by path or by ending in
one of the two directories, and the two directories share nothing,
whatever a project calls its own directories. They are directories of
their own, and not the build directory itself, because that one holds
files named after other things: an interface unit's object, the record
of the link and the list of its objects and, for an executable, the
BMIs.

ObjectPath gives that name, exported beside ExpectedOutput for what
looks at an object from outside Build(). Build() names each object by
the same rule, once, as it goes over the sources, and the list it
keeps of them for the link is what the check whether an object is
newer than the output reads as well. Before, each put the name
together for itself: Implementation::Check, Implementation::Schedule,
and Build() where it compiles C and CUDA sources, lists the link's
objects and checks whether to link again. Implementation::Check and
Schedule are given the object, where they put its name together from
the build directory. The job that compiles a source makes the
directory of its object first, since the compiler makes none. The C
compile quotes its source, dependency file and object for the shell,
as the CUDA compile does: the object of a source outside the
configuration's directory holds that source's whole path, and so
directories the command did not name before, the working directory's
among them where the source is listed relative to it.

The progress line of the compile of a .cpp, .c or .cu names the source
by the path its object is named from, "Compiling a/Thing.cpp" where it
was "Compiling Thing.cpp" for both, and so does the error for a .cu
without an nvcc.

What else changes: every implementation unit and every C and CUDA
source has its object in a new place, so an existing build directory
compiles them once more. The objects under the old names stay where
they are, unused; a static library's archive does not keep them, being
written anew. Interface units are as they were: a BMI is found by its
module's name, so two interface files of one name would have to be one
module. A source that a configuration lists twice is also as it was,
compiled twice into its one object, which the link is given twice.

In IncrementalHeaderChange, IncrementalInterfaceChange, StdPcmRebuild
and TransitiveInterfaceChange, the lines that spelled out an object's
old name take it from ObjectPath.

Fixes #50
2026-11-19 11:02:39 +01:00
0d81aca13f
test(build): a link of more objects than one argument holds
LinkManyObjects makes a project six directories deep, each with a name
of 200 characters, with 120 C sources and a main.cpp that adds up what
each of them returns. Every object lies in the project's build
directory, so the test first checks that 120 times the length of that
directory's path is more than 131,072 bytes. It then builds the
sources three ways: as one executable, as a static library and as a
shared library, the libraries each with an executable of main.cpp
built on it. Each of the three programs prints the sum.

It then opens the list the static library's archive step read, builds
the library again with one source fewer, and reads what it had opened:
the 120 lines of the first build, while the list in its place has the
119 of the second.

Before the fix each of the three builds ended with "popen() failed!":
the executable's at its link, the other two at the archive step and
the link of the library. No list was written, so the test found none
to open.
2026-11-19 10:33:33 +01:00
c82b2bb18c
test(build): a source that leaves a static library leaves its archive
StaticLibSourceRemoved builds a static library and a program on it, on
a fresh copy of its fixture outside the checkout. The library has three
sources: lib/first.cpp and lib/second.cpp each define Value(), returning
1 and 2, and lib/extra.cpp defines a function nothing calls. It is
built three times, by configurations of one name and directory: from
the first and the extra source, from the first alone, and from the
second in the first's place, as the project of a renamed source lists
it. The program prints 1, 1 and 2, and `llvm-ar t` lists the archive's
members as first_impl.o and extra_impl.o, then first_impl.o, then
second_impl.o.

While the second and the third build run, a thread of the test looks
for the archive again and again and has to find it every time: the new
archive is moved into the place of the old one, where a build that
removed the old one first would leave whatever links the library at
that moment without it.

Before the fix the second build's archive listed first_impl.o and
extra_impl.o, and the third's those two and second_impl.o, with a
program that printed 1.
2026-11-19 09:20:32 +01:00
5795b666f5
test: several configurations from one project file
BuildAll builds configurations the test makes itself, on a fresh copy of
its fixture outside the checkout. A library, a program built on it and
an unrelated program all come out built, each in the record of the pass
under its PcmDir, and a list that names one configuration twice builds
it from nothing, what the build before left of it being removed first,
and leaves it in the record of the pass once. A library built on another
library of its own name, path and type, so that the two are built into
one directory, builds, with both archives in that directory; returned
beside a program that is built on it, the pair is refused, both by name,
before the program is built or anything is recorded. Two libraries that
are each built on a configuration of the other's directory are refused
by name, and nothing of them is built or recorded. A wasm32 library that
names no sysroot and a program for the host built on it leave the
library in the record once, under the directory it has after the pass,
and its refusal comes back once; it is refused for its -fno-exceptions,
so the case needs no WASI sysroot. Of two programs built on a library
that does not compile and a third that has nothing to do with it, the
third is built, the two are not, and the library's error comes back
once. Two configurations that would be built into one directory are
refused, and neither is built. With a wasm executable that declares a
variant among them, a program of one source is linked no earlier than
the program and library given before it; the wasm one is refused for its
-fno-exceptions before it builds anything, so the case needs no WASI
sysroot.

ProjectConfigurations loads fixture project files staged outside the
checkout. A file with CrafterBuildConfigurations comes back as the three
configurations it returns, with the pointer the file took from the
second to the first intact, and as two when its args say so; LoadProject
refuses it. A file with CrafterBuildProject comes back as a list of one
whose test still depends on that Configuration, and that test builds and
passes. A file with both entry points, one with neither, and ones whose
CrafterBuildConfigurations returns nothing, a null pointer or one
configuration twice are refused, each with a message that says which.
Then crafter-build's verbs, through Run() and RunTests, on the file of
three: a build builds all three; -r refuses to pick between its two
executables, and runs the one executable there is when the file returns
two configurations; RunTests runs the tests of the first and the third
configuration in one run, and when the first declares the third's test
as well, that test fails for both, naming the two, and is not built,
while the first's own test passes, and a list that names the first
configuration twice runs its test once; with a fourth configuration of
the third's name and path, a test run and a build are each refused for
the two that would be built into one directory, and neither writes the
AGENTS.md that a build which is not refused writes from the template the
test puts beside the project file; `run` reaches a script of the first
and of the third configuration and hands each the configuration that
declares it; install refuses the project while none of the three is
packaged, bundle refuses it when two are, and with one packaged
executable beside the library bundle does not take the library for the
app.

SiblingConfigurations loads such a file as another project's sibling. A
spec without `configuration` gets the first, a spec that names one gets
that one, and the three specs share one load: the dependency of the
second is the first as LocalProject returned it. All three are rebased
onto the sibling's directory. A name the sibling does not have throws
with the names it has, and a name that two configurations of another
fixture share throws too, while a spec without a name still gets the
first of those two. Building the second builds the first with it and
leaves the third unbuilt. A file that returns something a sibling keeps
to itself is refused when it is loaded, the configuration and the
sibling named: the library the sibling's program is built on, the
configuration of that program's test, and a helper only that test is
built on, none of which the sibling's file returns. A project that
returns the sibling's third configuration beside one of its own builds
both, cannot run the sibling's script and runs its own, and its test run
leaves the sibling's test alone.

DependencyNotes gains a project of two configurations and a fixture,
outer, that builds against lib: two Direct configurations give what each
of them names; a project a Direct one names is followed when a
Transitive one leads to it; a configuration under None keeps out what
only it is built against; with both under None, AGENTS.md is the
template's text; and a returned configuration of another project is one
of the projects the notes come from, followed further only under
Transitive, which is also what a file that made no configuration gets.
For outer's own AGENTS.md, written from the Configuration LocalProject
returned and outer's project file, outer's own setting selects: lib
under Direct, lib and base under Transitive, nothing under None.
Script runs a script of each of two configurations, each handed the
configuration that declares it, refuses a name both declare without
running anything, and, given a list that names one configuration twice,
runs the script asked for, which a name declared twice would have kept
it from. Lint formats the sources of two configurations in one run,
counts a rule both register as one, and runs a rule only one of them
registers over the sources of both. Of two returned configurations that
register a rule under one name the earlier one's runs, over the sources
of all three, though the configuration returned ahead of both depends
on the later one.
2026-11-15 02:16:07 +01:00
a7aa22220b
test(wasm): a configuration is the same with its WASI sysroot named or not
WasmSysrootKey makes two wasm32 configurations that differ in one thing:
one names no sysroot and the other names the toolchain's WASI sysroot.
They have to be one configuration: the same VariantId, PcmDir and
BuildDir, the same std module key, and the same compile command, which
names the WASI sysroot. A third, with a sysroot of its own, has another
VariantId.

It then builds two programs for the host in one pass, each on the same
wasm32 library, which names no sysroot. The library carries
-fno-exceptions, which a wasm build is refused for before it makes a
directory, so the case does not depend on the machine having a WASI
sysroot. The library's PcmDir has to be the same after the first
program's build as before it, and the pass has to hold the library
once.

Against the engine as it was before the fix the test fails on each of
the three: the two configurations have different VariantIds, the
library's PcmDir changes with the first build, and the pass holds the
library twice.
2026-11-14 23:42:47 +01:00
1440e20231
test(external): a sibling's pointers to its own Configuration hold
SiblingOwnPointers loads a fixture through LocalProject, on a fresh copy
outside the checkout: a library whose project file declares a test with
cfg.AddTest("OwnTest").Dependencies({ &cfg }). The one dependency of
that test has to be the Configuration LocalProject returns. The test
reads the dependency out of that Configuration and compares the two
addresses, without following the dependency.

Against the loader as it was before the fix the test fails: the
dependency is not that Configuration.
2026-11-14 23:42:47 +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
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
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
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
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
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
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
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
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
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
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
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
55ad128b79
test: lint fails when a configuration's std module cannot be built
A host configuration pointed at a sysroot without libc++ cannot get its
std module built, so its files cannot be parsed. With an AST rule
registered, the run has to skip the rule and fail instead of reporting
the files clean, as it did before the fix. The cache is redirected
around this run only: the std module's directory is made before its
build fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 22:59:38 +01:00
0e69e71b11
test: a CMake external configured with other inputs is built from nothing
ExternalReconfigure builds a one-file C library from a local repository
as a CMake external, then plants a file in its build directory to stand
for what an old configure left. Built again with the same inputs, the
directory is kept. With its recorded inputs rewritten the way another
crafter-build's configure would have left them, the next build has to
start from an empty directory and build the library again. Before the
fix the planted file survived the reconfigure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 22:59:23 +01:00
8e759a8410
test: a std module rebuilt in place recompiles the units importing it
StdPcmRebuild builds a project whose main.cpp imports std, then dates
the source before the object and the object before std.pcm, as a std
module rebuilt after the object leaves them, so that nothing else makes
the object stale. The next build has to compile main.cpp again, and the
idle build before it must compile nothing. Without -fmodule-file-deps
the object was only relinked. The test redirects the cache, since
redating a std PCM the real cache shares would rebuild its other users.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 22:59:06 +01:00
5d25495621
fix: key the std module's directory on everything it is compiled with
StdPcmDir named the directory by target, march and toolchain, then
grew a case per target for the rest: the wasm flags, and with the first
fix for #43 the mingw prefix. Every other flag BuildStdPcm passes went
unkeyed, so configurations that differed only there took turns
rebuilding one std PCM in place, under the PCMs built against it: a
project with -mtune=generic against project.cpp's -mtune=native on every
run, or two sysroots for one target. And the mingw prefix was keyed only
when there was one, so a build without a prefix landed in the directory
an older release had filled with a CRAFTER_MINGW_DIR=/usr build, and
relinked its objects.

StdPcmFlags is now the one source of the flags BuildStdPcm compiles
with, and StdPcmKey names the directory by target, march and toolchain
followed by a hash of those flags and, for the mingw target, of the
prefix behind its --sysroot. VariantId hashes StdPcmKey in place of the
mingw prefix: units do not notice a std module that moved directories,
so a build has to move with it. Every std PCM directory and build
directory moves once, as after a compiler update; the old ones stay
until `clean` and the cache is cleared by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 22:58:44 +01:00
06b61e84f9
fix(mingw): view only a prefix that holds a Linux system
The first fix showed clang every mingw prefix through a view of its
mingw-w64 parts. That broke a prefix that holds mingw-w64 alone, where
Windows libraries installed with --prefix land in include/ and lib/:
with CRAFTER_MINGW_DIR=/opt/mingw, <SDL2/SDL.h> and -lSDL2 were no
longer found. Such a prefix is clang's sysroot whole again. Only a
prefix that also holds a Linux system gets the view
(Toolchain::mingwPrefixIsSystem): the host's /usr inside the Flatpak,
whatever its include/ holds, and a prefix whose include/ has a C
library's features.h, which every glibc and musl header includes and
mingw-w64 has no use for, as CRAFTER_MINGW_DIR=/usr has.

MakeMingwSysroot makes the view in the cache, or in
$XDG_RUNTIME_DIR/crafter.build when the cache's filesystem takes no
symbolic links (vfat, exFAT, CIFS without unix extensions): the XDG
spec promises them there, and nothing else in the cache needs them.
Its path is absolute, because CMake runs the compiler from directories
of its own and a relative cache did not resolve from there. The prefix
is resolved once, absolute and lexically normal, so /opt/mingw/ and
/opt/mingw are one prefix and not two builds.

clang names a header by the path it found it at, so every diagnostic
from a viewed mingw-w64 header named a hashed cache directory.
RunBuildCommand now writes paths into the view as paths into the
prefix, as BuildStdPcm did for its manifest messages already.

Also from the review of PR #44: SysrootCompileFlags builds a mingw
command, which can make a view, so it redirects the cache like the
other tests; the manifest filter's comment names what it still keeps
out; the C path asks MingwSysroot() once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 22:58:30 +01:00
b162cc0552
test: a mingw build sees no header from its prefix's include/
MingwSysroot stages a prefix shaped like a Linux system's /usr with a
mingw-w64 cross toolchain in it, without needing a real one: glibc's
<sys/single_threaded.h> in include/, gcc's per-target directory, and a
stand-in mingw-w64 tree whose libstdc++ has an empty std module. A
static library for x86_64-w64-mingw32, so that nothing is linked,
compiles a C++ and a C source that stop with #error when they see the
prefix's include/ or miss mingw-w64's or libstdc++'s headers. Against
the library before the fix, the C++ source stopped on
<sys/single_threaded.h>. The test also checks that the std module is
not cached in the directory older releases built it in against the
prefix itself. It needs only clang, so it runs in CI too, where no
mingw-w64 is installed.

The stand-in std module's source is written through std::format: the
build's import scanner reads string literals as code, and the literal
"export module std;" made the test itself a unit of a module std.

VariantId checks that a prefix gives a mingw configuration a variant of
its own, that two prefixes give two, and that other targets ignore it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 20:48:06 +01:00
ab998081e1
fix: give the mingw target a sysroot that holds mingw-w64 alone
Inside the Flatpak the mingw-w64 prefix is the host's /usr, and it was
clang's --sysroot as is. clang's mingw driver takes a sysroot for a tree
that holds mingw-w64 alone, and adds its include/ to the include path
and its lib/ to the library path. For /usr those are the Linux system's
own: every header mingw-w64 lacks came from glibc, and libstdc++'s
<ext/atomicity.h>, finding <sys/single_threaded.h>, had shared_ptr read
__libc_single_threaded, which nothing on Windows defines. Every program
that used one failed to link, among them every Crafter.Graphics Win32
executable, through Crafter.Asset's GLB loader. CRAFTER_MINGW_DIR=/usr
did the same outside the Flatpak (#43).

The sysroot is now MingwSysroot(): a directory in the cache, one per
prefix, holding only links to the prefix's x86_64-w64-mingw32/, lib/gcc/
and lib64/gcc/ (where openSUSE keeps gcc). Through it clang finds
mingw-w64, gcc's version and libstdc++ exactly as it does through the
mingw gcc on PATH, and nothing else. It is made by the first mingw
compile, link or CMake configure of a process, so no other command
writes to the cache for it and a failure to make it is that build's
error. The Toolchain field is now mingwPrefix, since clang never gets
the prefix itself, and it is made absolute when the toolchain is
resolved, as it ends up in link targets and directory names. Messages
keep naming paths under the prefix rather than under the view.

The prefix is also part of the mingw target's VariantId and of its std
PCM directory. Units do not track the std PCM they import: when the
fixed release built in a directory a broken build had left, the std
module was rebuilt and the objects compiled against glibc's headers
were only relinked, failing as before. As with a compiler update, a new
directory is what gets them rebuilt. It also keeps two releases that
share a cache, as the Flatpak's branches do, from rebuilding one std PCM
under each other's PCMs, and two prefixes apart. Without a prefix both
stay as they were: clang's own discovery has not changed.

Two shorter ways do not work: --sysroot=<prefix>/x86_64-w64-mingw32
loses the directory gcc's version names, so <string> is not found, and
clang ignores --gcc-toolchain and --gcc-install-dir for this target.

Fixes #43

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 20:48:06 +01:00
74e8370b2b
feat(agents): write AGENTS.md from a tracked AGENTS.template.md
The dependency notes were kept in a section of the AGENTS.md beside
project.cpp, the file a project commits, so a build could change a
tracked file at any time: a dependency editing its AGENTS.consumer.md,
an unpinned one moving on, a flag pulling a dependency in or out, each
showed up in the consumer's diff as a change nobody made. Users
reported it as the feature clobbering their diffs.

A project now commits its instructions as AGENTS.template.md, and a
build and a test run write AGENTS.md from it: a first line saying the
file is generated and where to edit, the template's text as written,
then the notes section, after it or where the template's marker lines
put it. AGENTS.md is build output and goes into .gitignore. It is
created when missing, since a fresh clone has none, and otherwise
written as before: only when its text changes, in place and under a
lock, so links, ownership and a read-only file are respected.

The first line is also how a build tells its own AGENTS.md from one
someone wrote. Beside a template the second is easily there, as a
committed AGENTS.md nobody has removed yet; it is never replaced, and
each build warns until it is deleted. An empty file counts as a
build's, since that is what a write cut short leaves of a new one. An
AGENTS.md linked to the template is refused: writing it would write
the committed file again. A template the notes cannot be placed in
leaves no empty AGENTS.md behind.

The in-place mode is removed rather than kept as the fallback for a
project without a template. It is the default that put generated text
into tracked files unasked, the moment any dependency started shipping
notes. Without a template a build no longer touches AGENTS.md. One
that still holds a section from 3.0.0 would go stale silently, under a
preamble promising that every build rewrites it, so it gets a warning
naming the move instead.

MergeDependencyNotes keeps its rules and now runs on the template. The
test changes in this commit rather than its own, because it pinned the
in-place behaviour this removes: it now covers the generated file's
shape, edits and markers in the template, the ownership check, a CRLF
template, a link to the template and the cases without one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 16:53:42 +01:00
70ff11d0a1
feat(wasm): link libsetjmp, so setjmp needs no flag
All checks were successful
Flatpak / flatpak (push) Successful in 17m58s
-mllvm -wasm-enable-sjlj, in every wasm compile because setjmp.h does
not compile without it, turns setjmp and longjmp into calls to
__wasm_setjmp, __wasm_setjmp_test and __wasm_longjmp and a throw of
the __c_longjmp tag, all of which live in wasi-libc's libsetjmp. The
driver does not link it, so a program that used setjmp, or a C library
that handles its errors that way, failed to link with undefined
__wasm_setjmp until the project put -lsetjmp in its linkFlags.

Build() adds it to every wasm link, next to -lunwind. A static archive
contributes only the members something references, so a program
without setjmp gets nothing from it, and every sysroot that passes the
exception check ships it. WasmExceptions drops its own -lsetjmp, and
its C fixture now fails to link without this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 06:29:52 +01:00
2a05b8e6fb
test(wasm): the cases the review found
WasmBuildRefusals checks that -flto in compileFlags and in linkFlags,
-fno-exceptions and a shared library are each refused with their
cause, and that none of them leaves bin/ or build/ behind. With the
check disabled, each of them failed on a missing std.cppm instead,
after the build directories had been made.

WasiSysrootWithoutExceptions also takes its sysroot through missing
and without the target's directory, each with a message of its own,
checks that a refused build leaves nothing behind, and that a static
library passes without libunwind.

WasmExceptions catches an exception thrown inside libc++.a (stoi).
vector::at throws from a header compiled into the fixture, so the
fixture also passed against the libc++ built without exceptions. Its C
source uses setjmp, which the old C flags did not compile. An
exception that escapes main has to end the run as wasmtime's uncaught
exception, where any nonzero exit used to pass, a trap or a timeout
included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 06:10:41 +01:00
45b9f5cbb7
fix(wasm): what the review found
-flto in a wasm configuration's compileFlags or linkFlags reached the
link, where LTO code generation runs without the backend options that
keep exception handling: every landing pad was dropped, and the build
succeeded with throws that escaped their catch blocks. -fno-exceptions
there made every `import std;` fail on the std module built with
exceptions, and a wasm shared library failed to link against the eh/
libc++, which is static archives built without -fPIC. Build() refuses
all three now, each with a line that says why, before it makes a
directory or starts a thread.

The sysroot check sat in BuildStdPcm, which the linter calls as well.
There the error only dropped the compile command, so lint ran no AST
rule on a wasm configuration and reported it clean. It also refused
static libraries, which never link, fired after the shader and
external threads had started, and called a missing sysroot, or one
without the target, "no C++ exception support". It is part of the same
early check now, which first says when the sysroot or the target's
directory is missing, and asks for libunwind only where something
links.

C sources got only the signal.h define. setjmp.h refused to compile in
C, and a C object given -wasm-enable-sjlj through compileFlags used the
legacy exception encoding next to C++ objects in the standard one, a
mix engines refuse to load. They get WasmCompileFlags now, like the C++
units, a variant pass's flags included.

The baseline probes include simd: V8 and SpiderMonkey switch SIMD off
on x86 CPUs without SSE4.1, which virtual machines often present, and
such an engine passed the exception-handling probe only to fail
compiling the module; the manifest tests expect it on every entry. The
Flatpak pins WASI_SDK_EXCEPTIONS=DUAL, which
wasi-sdk 34 defaults to only with clang 23 or newer, and checks that
the eh/ libunwind got installed: the wasm tests skip without it, so CI
would otherwise pass a Flatpak whose every wasm build fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 06:10:41 +01:00
fec206839e
test(wasi-runtime): exit and park, under node
runtime.js had no test that runs it. WasiBrowserRuntimeExit runs the
real file under node, once per scenario, against a module assembled in
the harness. Between _start and the call that ends it the module has
the frames that caught the old exit: a destructor (catch_all_ref, then
throw_ref), a catch (...) and a noexcept function, each reporting when
it runs. An exit has to run none of them and record its status; a park
has to run none of them, nor the code after it, and leave the program
callable with its state intact; an exit from a later call has to end
the program too, a return from main has to give status 0, and a crash
or an exception nothing caught has to stay an error.

With the JS throw put back into proc_exit, the exit from main and the
exit from a later call both end in the noexcept frame's terminate.

It skips without node, or with a node whose engine lacks the
standardized exception handling. The Flatpak has no node, so CI does
not run it; the native loop does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:55:32 +01:00
8862092b63
test(wasm): exceptions in a wasm build, and a sysroot without them
WasmExceptions builds a fixture for wasm32-wasip1 and runs it under
wasmtime. It throws through four frames whose destructors have to run,
catches the exception, catches one that vector::at throws, and with an
argument lets one escape main, which has to fail the run. With the
previous flags the fixture does not compile ("cannot use 'throw' with
exceptions disabled"), and each part of turning exceptions on fails it
in its own way, from a BMI built without them to the legacy encoding
wasmtime refuses.

WasiSysrootWithoutExceptions takes a scratch sysroot through three
states, no libunwind, libunwind under eh/ and libunwind in the
triple's own directory, and checks that only the first stops the
build, with the message naming the library it looked for. It needs no
working wasm toolchain, so it also runs where the others skip.

WasmHelloRuns and WasmExceptions treat a sysroot without the
exception-enabled libraries as missing and skip. The manifest tests
expect the exception-handling probe on every entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:54:48 +01:00
eefd1df3eb
Merge branch 'claude/issue-41': refuse a build that holds two builds of one module
All checks were successful
Flatpak / flatpak (push) Successful in 12m49s
PR #42, fixes #41. Build() now refuses a configuration whose transitive
dependencies hold two configurations exporting a module of the same
name, such as one project loaded along two paths with different arg
lists, before it builds anything, and names both paths. Until now both
builds ended up in the one program, which compiled cleanly and then
read garbage. Merged cleanly on top of claude/forward-project-args;
the suite, with claude/dependency-notes' fixtures, passes under the
new check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:30:36 +01:00
75142276ab
Merge branch 'claude/forward-project-args': sibling projects inherit the args, lint with the lite rules
PR #40. GitProject and LocalProject default their args to the loading
project's own (ProjectArgs()), this tree lints with LintRules' lite
set, and the fixes from the branch's review: a project file gets its
args only for the CrafterBuildProject call, host tooling gets project
cache entries of its own, and `--` ends crafter-build's options.

The conflicts with claude/dependency-notes are all places both sides
added to:
- Platform.cppm and Platform.cpp: PragmaDependencies() beside
  ProjectArgs() and LoadingHostTooling(), all three kept.
- LoadProject: the record PragmaDependencies() reads moves up with the
  frame's dependencies, which this branch sets before dlopen. Left
  where it was, it would have copied preDeps.configs after the vector
  was moved into the frame, and recorded nothing.
- README: the pragma section's new last sentence goes before the new
  "Dependency notes for agents" section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:27:37 +01:00
3d2023cb5c
test: two builds of one module are refused before anything compiles
The fixture is P -> M and P -> A -> M, where M's own flag --wide
changes a struct it exports. Loaded with --wide --split, P gives M its
args without --wide while A passes them on whole: Build(P) has to fail,
name the module and both paths, and leave no bin/ anywhere. Loaded with
--wide alone, both paths give M the same list, there is one M, and the
build has to go through. Before the fix the first case built cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:19:30 +01:00
70b68b98a5
test: -- reaches neither the project args nor the script
`run -- record -- a` has to run the record script with the args `--`
and `a`: the first `--` ends the options, the second comes after the
script's name and is the script's. The project args keep only what
stood before `run`. And `run -- -x` has to look for a script called
-x, since after `--` an option-like word is an operand. Before the fix
the first `--` showed up in the project args, and `-x` joined it there
while the bare `run` listed the scripts and succeeded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:11:41 +01:00
95896a7ddd
test: a project and its pragma dependency load a shared sibling apart
The fixture app has `#pragma crafter dependency "../tool"` and loads
../shared for itself, which the tool loads too; the app is loaded with
no args, the case where the two cache keys used to match. With
CRAFTER_BUILD_MARCH=x86-64-v2, the app's copy of shared has to keep
that march and no -fPIC, and the tool's copy has to be host tooling.
Before the fix the app got the tool's copy back: one Configuration,
with march native and -fPIC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:11:41 +01:00
e6363b95fe
test: specs and ProjectDependency() in a project file's static initialisers
ProjectArgs gets a sibling that makes its own sibling's spec at
namespace scope. Before the fix that spec took the args the file was
first loaded with; now it takes none on every load. The checks go
through one CheckLoaded helper, which prints what each sibling was
given, so a failure says which args a wrong frame handed over.

ProjectDependency loads a fixture whose static initialiser asks for its
pragma dependency, in a child, because a throw there terminates the
process: before the fix it found none. The check that the dependency
gets none of the consumer's args moves into the first load, which now
passes the app an arg it ignores; the separate load could not fail its
own check, and its early return skipped every later one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:11:41 +01:00