Skip to content

Commit b2d5fe0

Browse files
committed
rules-swift: the module's compilation declares its dependency file
The repository requires every rule to pass one: swiftc writes the same Makefile-style file clang does, and without it a bridged header could change with no rebuild.
1 parent 734bf9a commit b2d5fe0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

rules/swift.cppm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,25 @@ inline bool compile(std::span<const std::string> sources, options opt = {}) {
308308
const std::string object = (gen / (module + ".o")).string();
309309
{
310310
const std::string id = "swift-object:" + module;
311+
const std::string dep = (gen / (module + ".d")).string();
311312
const std::string desc = "SWIFTC " + module;
312313
mcpp::action o;
313314
o.id = id.c_str();
314315
o.role = "object"; // joins the link of every image of the package
315316
o.description = desc.c_str();
316317
common(o);
318+
// WHAT THE MODULE READS BESIDES ITS OWN SOURCES, which only the
319+
// compiler knows: a bridging header's own includes, and any header the
320+
// module imports through it. swiftc writes the same Makefile-style
321+
// dependency file clang does, so the engine's depfile handling reads it
322+
// unchanged. Without it a bridged header could change with no rebuild,
323+
// which is what this repository's "every rule declares a depfile"
324+
// check exists to prevent.
325+
// The DRIVER's spelling. `-emit-dependencies-path` is a frontend flag
326+
// and `swiftc` refuses it; `-emit-dependencies` writes the file beside
327+
// the output named by `-o`, which is `dep` below.
328+
o.arg("-emit-dependencies");
329+
o.depfile = dep.c_str();
317330
o.arg("-wmo").arg("-emit-object").arg("-o").arg(object.c_str());
318331
o.output(object.c_str());
319332
o.submit();

0 commit comments

Comments
 (0)