Commit 395fcd97 authored by jan.koester's avatar jan.koester
Browse files

bugfix wlidcard

parent b07d4740
Loading
Loading
Loading
Loading
+20 −0
Changes for parser.cpp: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -988,6 +988,26 @@ bool Parser::try_parse_rule(const std::string& line, Makefile& mf, Rule*& curren
    } else {
        prereqs = split_words(prereqs_str);
    }
    // Like GNU make, a prerequisite with wildcard characters stands for the
    // files it matches (kept as written if none does); '%' marks a pattern,
    // not a glob. Kbuild has "xen-hypercalls.h: .../xen*.h".
    auto glob_words = [this](std::vector<std::string>& words) {
        std::vector<std::string> out;
        for (const auto& w : words) {
            if (w.find('%') == std::string::npos &&
                w.find_first_of("*?[") != std::string::npos) {
                auto matches = split_words(func_wildcard(w));
                if (!matches.empty()) {
                    out.insert(out.end(), matches.begin(), matches.end());
                    continue;
                }
            }
            out.push_back(w);
        }
        words.swap(out);
    };
    glob_words(prereqs);
    glob_words(order_only);
    for (auto& p : prereqs) p = normalize_target(p);
    for (auto& p : order_only) p = normalize_target(p);