feat(incremental): rebuild when an #included header changes
The staleness check compared an artifact against its own source and its module imports. Headers were in neither set: the scanner reads `import` lines, and a .cppm or .cpp keeps its mtime when a header it includes is edited — so the build reported nothing to do and left objects compiled against the previous contents. Same silent mixed-layout binary as issue 27, reached through #include instead of import. Ask the compiler what it actually opened. Every C++ and C compile now passes -MD -MF <artifact>.d, and Check reads that depfile back through NewestPrerequisite, comparing every prerequisite's mtime against the artifact. A missing depfile (an object from a crafter-build that wrote none) or a prerequisite that no longer exists reads as "rebuild": neither is evidence of freshness. The parser unescapes make syntax rather than splitting on whitespace, since clang wraps depfiles onto continuation lines and escapes spaces in filenames.
This commit is contained in:
parent
672aabf215
commit
1d0d8e1e28
6 changed files with 111 additions and 8 deletions
|
|
@ -27,6 +27,18 @@ namespace Crafter {
|
|||
// module sources, wasi-runtime/, etc). Honors CRAFTER_BUILD_HOME; otherwise
|
||||
// derives <prefix>/share/crafter-build from the running executable's path.
|
||||
export CRAFTER_API fs::path GetCrafterBuildHome();
|
||||
// Newest mtime among the prerequisites a compiler recorded in `depFile`
|
||||
// (clang's `-MD -MF <artifact>.d`). This is how a build step learns which
|
||||
// headers its source pulled in: the module scanner only reads `import`
|
||||
// lines, so an `#include`d file is invisible to it until the compiler
|
||||
// reports what it actually opened.
|
||||
//
|
||||
// Returns file_time_type::max() when freshness cannot be proven — no
|
||||
// depfile (nothing has compiled this artifact since depfiles were emitted,
|
||||
// including every object left over from an older crafter-build) or a
|
||||
// prerequisite that no longer exists. Callers compare the result against
|
||||
// their artifact's mtime, so max() reads as "rebuild".
|
||||
fs::file_time_type NewestPrerequisite(const fs::path& depFile);
|
||||
// Wildcard name matching ('*', '?') shared by the test and lint verbs.
|
||||
bool MatchGlob(std::string_view glob, std::string_view name);
|
||||
// Empty `globs` matches everything.
|
||||
|
|
|
|||
Loading…
Reference in a new issue