Commit 7566e63a authored by jan.koester's avatar jan.koester
Browse files

bugfix

parent fd1fec54
Loading
Loading
Loading
Loading
+8 −4
Changes for main.cpp: 8 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -458,14 +458,19 @@ int main(int argc, char* argv[]) {
        const int kMaxRestarts = 10;
        for (int restart = 0; restart < kMaxRestarts; ++restart) {
            // Candidate makefiles = the unique words of MAKEFILE_LIST (the main
            // makefile plus every file pulled in by include/-include).
            // makefile plus every file pulled in by include/-include). Normalize
            // each name (strip a leading "./") so it matches rule targets, which
            // are stored normalized: an included path is recorded verbatim (e.g.
            // "./gen.mk") but its rule is written as "gen.mk".
            std::vector<std::string> makefiles;
            {
                std::set<std::string> seen;
                auto it = mf.variables.find("MAKEFILE_LIST");
                if (it != mf.variables.end()) {
                    for (const auto& w : makeplus::Parser::split_words(it->second.value))
                        if (seen.insert(w).second) makefiles.push_back(w);
                    for (const auto& w : makeplus::Parser::split_words(it->second.value)) {
                        std::string n = makeplus::Parser::normalize_target(w);
                        if (seen.insert(n).second) makefiles.push_back(n);
                    }
                }
            }

@@ -507,7 +512,6 @@ int main(int argc, char* argv[]) {
                    if (!had || t1 != t0) changed = true;
                }
            }

            if (!changed) break;  // makefiles are up to date; converged

            // A makefile was regenerated: discard the parsed state and re-read