fix: key the host PCM cache on source content, add clean, hash project args
Three follow-ons to the stale-build report, all cases of an identity not capturing something that changes the output. The host PCM cache under <cache>/crafter.build/<target>-<march>/ is shared by every crafter-build on the machine, and freshness was a per-file mtime comparison. That cannot tell "this PCM is newer than my source" from "this PCM was built from different sources that happen to be newer", so a package install and a working checkout — or two checkouts of different versions — silently compiled their project.cpp against each other's declarations. Invalidation now keys on a stamp over the bytes of every module source, which also covers the case one file's mtime never could: the cached PCMs import each other, so a change to :Interface invalidates :Clang's PCM with Crafter.Build-Clang.cppm untouched. Project args ApplyStandardArgs does not itself interpret are now folded into VariantId. Such a flag typically decides what gets compiled or bundled — the report's example is --no-webgpu dropping entries from cfg.files — and without it both settings shared one bin dir and interleaved their outputs there, leaving a bundle matching neither. Sorted and deduplicated so flag order doesn't split the cache, and inherited by test Configurations. `crafter-build clean` removes the project's bin/ and build/ trees. It deliberately does not load project.cpp: cleaning is most often reached when something is already wrong, and a clean that first needs the project to compile is useless exactly then.
This commit is contained in:
parent
13697cd026
commit
e8fde57582
9 changed files with 439 additions and 15 deletions
|
|
@ -250,6 +250,15 @@ export namespace Crafter {
|
|||
// clobber the baseline's. Not for direct project use — declare
|
||||
// wasmVariants instead.
|
||||
std::vector<std::string> wasmVariantFlags;
|
||||
// The project args ApplyStandardArgs did not interpret — i.e. the
|
||||
// project's own flags, whose effect on the build the framework cannot
|
||||
// see. Hashed into VariantId because such a flag typically decides what
|
||||
// gets compiled or bundled (`--no-webgpu` dropping entries from
|
||||
// cfg.files, say), and without it both flag settings share one bin dir
|
||||
// and interleave their outputs there. Populated by ApplyStandardArgs;
|
||||
// the args it does recognise are excluded, since their effect already
|
||||
// shows up in target/march/mtune/debug/sysroot/type.
|
||||
std::vector<std::string> projectArgs;
|
||||
std::vector<Test> tests;
|
||||
// Lint rules for `crafter-build lint`. Populate via AddLintRule.
|
||||
std::vector<LintRule> lintRules;
|
||||
|
|
@ -315,6 +324,12 @@ export namespace Crafter {
|
|||
compileKey += "|W:";
|
||||
compileKey += f;
|
||||
}
|
||||
// Sorted by ApplyStandardArgs, so flag order on the command line
|
||||
// doesn't split the cache.
|
||||
for (const std::string& a : projectArgs) {
|
||||
compileKey += "|A:";
|
||||
compileKey += a;
|
||||
}
|
||||
std::size_t configHash = std::hash<std::string>{}(compileKey);
|
||||
return std::format("{}-{}-{}-{}-{:08x}", name, target, march, mtune, configHash);
|
||||
}
|
||||
|
|
@ -345,6 +360,16 @@ export namespace Crafter {
|
|||
|
||||
CRAFTER_API int Run(int argc, char** argv);
|
||||
|
||||
// Delete the bin/ and build/ trees beside `projectFile`, returning the paths
|
||||
// that existed and were removed. Backs `crafter-build clean`.
|
||||
//
|
||||
// Deliberately does not load the project: cleaning is most often reached
|
||||
// when something is already wrong, and a clean that first needs project.cpp
|
||||
// to compile (and its git dependencies to be present) is useless exactly
|
||||
// then. That means variant directories are not enumerated — the whole tree
|
||||
// goes, which is what the by-hand `rm -rf bin build` did anyway.
|
||||
CRAFTER_API std::vector<fs::path> CleanProject(const fs::path& projectFile);
|
||||
|
||||
// Add a small index.html + runtime.js pair next to the .wasm output so the
|
||||
// build can be loaded directly in a browser (just `serve` the bin dir and
|
||||
// open it). Opt-in: WASI builds destined for wasmtime/wasmer don't need
|
||||
|
|
|
|||
Loading…
Reference in a new issue