Loading parser.cpp +13 −2 Changes for parser.cpp: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -73,13 +73,24 @@ std::string Parser::patsubst_word(const std::string& pattern, const std::string& // ======================== Makefile methods ======================== const Rule* Makefile::find_explicit_rule(const std::string& target) const { // A target may have several explicit rules: GNU make merges their // prerequisites but only one rule carries the recipe. Prefer the // recipe-bearing rule so the target is actually built; fall back to the // last prerequisite-only rule otherwise. Kbuild relies on this: the // host-program link rule ("conf: FORCE" with a recipe) is separate from // the multi_depend-generated "conf: conf.o ..." prerequisite rule. const Rule* fallback = nullptr; for (auto it = rules.rbegin(); it != rules.rend(); ++it) { if (it->is_pattern) continue; for (const auto& t : it->targets) { if (t == target) return &(*it); if (t == target) { if (!it->recipes.empty()) return &(*it); if (!fallback) fallback = &(*it); break; } } return nullptr; } return fallback; } const Rule* Makefile::find_pattern_rule(const std::string& target, std::string& stem) const { Loading Loading
parser.cpp +13 −2 Changes for parser.cpp: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -73,13 +73,24 @@ std::string Parser::patsubst_word(const std::string& pattern, const std::string& // ======================== Makefile methods ======================== const Rule* Makefile::find_explicit_rule(const std::string& target) const { // A target may have several explicit rules: GNU make merges their // prerequisites but only one rule carries the recipe. Prefer the // recipe-bearing rule so the target is actually built; fall back to the // last prerequisite-only rule otherwise. Kbuild relies on this: the // host-program link rule ("conf: FORCE" with a recipe) is separate from // the multi_depend-generated "conf: conf.o ..." prerequisite rule. const Rule* fallback = nullptr; for (auto it = rules.rbegin(); it != rules.rend(); ++it) { if (it->is_pattern) continue; for (const auto& t : it->targets) { if (t == target) return &(*it); if (t == target) { if (!it->recipes.empty()) return &(*it); if (!fallback) fallback = &(*it); break; } } return nullptr; } return fallback; } const Rule* Makefile::find_pattern_rule(const std::string& target, std::string& stem) const { Loading