Skip to content

Commit 720690c

Browse files
committed
fix(build.mcpp): an unknown directive is not necessarily a typo
Adding `link-script` in protocol 3 proved the old wording wrong. It said: The program announced protocol 2, which this mcpp also speaks, so an unrecognized directive is a typo rather than newer syntax. The premise does not hold. A build.mcpp's protocol number is substituted at COMPILE time by whichever mcpp is running — it is not carried by the package — so a package written against a newer mcpp arrives at an older one wearing the OLDER engine's number. The two agreeing therefore says nothing about whether the KEY is from the future, and this is exactly the case a board-support package using `mcpp:link-script=` hits on an mcpp that predates it: told its directive is misspelled, when the real answer is `mcpp self update`. An old engine genuinely cannot tell the two apart. Naming both is the only honest thing it can do, and the upgrade is the cheaper one to try first.
1 parent 920b9af commit 720690c

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/build/directives.cppm

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,27 @@ std::optional<std::string> protocol_error(const Directives& d) {
467467
std::string list;
468468
for (auto const& k : d.unknownKeys)
469469
list += (list.empty() ? "" : ", ") + ("mcpp:" + k);
470+
// ⚠️ NOT "so it must be a typo".
471+
//
472+
// That is what this said, and adding `link-script` in protocol 3
473+
// proved it wrong: a package written against a newer mcpp reaches an
474+
// older one with the OLDER engine's protocol number stamped on it —
475+
// the announcement is substituted at build.mcpp compile time by
476+
// whichever engine is running, not carried by the package. So the two
477+
// numbers agreeing says nothing about whether the KEY is from the
478+
// future, and an old mcpp cannot tell the two cases apart. Naming both
479+
// is the only honest thing it can do, and the upgrade is the cheaper
480+
// one to try first.
470481
return std::format(
471482
"build.mcpp emitted directive(s) this mcpp does not know: {}.\n"
472-
" The program announced protocol {}, which this mcpp also "
473-
"speaks, so an unrecognized directive is a typo rather than newer "
474-
"syntax.",
475-
list, d.protocol);
483+
" Either the package was written for a newer mcpp (try "
484+
"`mcpp self update`),\n"
485+
" or the directive is misspelled. This mcpp speaks protocol "
486+
"{}; the protocol number\n"
487+
" cannot distinguish the two, because it is stamped by "
488+
"whichever mcpp compiled\n"
489+
" the program, not by the package.",
490+
list, kProtocolVersion);
476491
}
477492
return std::nullopt;
478493
}

0 commit comments

Comments
 (0)