Commit 4b687611 authored by jan.koester's avatar jan.koester
Browse files

normalize paths

parent f6c89bb1
Loading
Loading
Loading
Loading
+5 −2
Changes for executor.cpp: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ Executor::Executor(Makefile& mf, Parser& parser) : mf_(mf), parser_(parser) {}

// ======================== Rule Lookup ========================

const Rule* Executor::find_rule(const std::string& target, std::string& stem) {
const Rule* Executor::find_rule(const std::string& target_in, std::string& stem) {
    std::string target = Parser::normalize_target(target_in);
    const Rule* r = mf_.find_explicit_rule(target);
    if (r && !r->recipes.empty()) {
        // Static pattern rule: derive the stem by matching the target pattern.
@@ -140,6 +141,7 @@ std::vector<std::string> Executor::expand_prereqs(const std::string& target,
            }
            std::string expanded = parser_.expand(ep, mf_);
            auto words = Parser::split_words(expanded);
            for (auto& w : words) w = Parser::normalize_target(w);
            prereqs.insert(prereqs.end(), words.begin(), words.end());
        }
    };
@@ -313,7 +315,8 @@ int Executor::execute_rule(const std::string& target, const Rule* rule,

// ======================== Sequential Build ========================

int Executor::build_sequential(const std::string& target) {
int Executor::build_sequential(const std::string& target_in) {
    std::string target = Parser::normalize_target(target_in);
    auto it = visited_.find(target);
    if (it != visited_.end()) return it->second;

+4 −1
Changes for parser.cpp: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -792,10 +792,11 @@ bool Parser::try_parse_rule(const std::string& line, Makefile& mf, Rule*& curren
            }
        }
        if (c2 != std::string::npos) {
            std::string tpat = expand(trim(rhs_raw.substr(0, c2)), mf);
            std::string tpat = normalize_target(expand(trim(rhs_raw.substr(0, c2)), mf));
            std::string ppat = expand(trim(rhs_raw.substr(c2 + 1)), mf);
            if (tpat.find('%') != std::string::npos) {
                auto pprereqs = split_words(ppat);
                for (auto& p : pprereqs) p = normalize_target(p);
                Rule rule;
                rule.targets = targets;
                rule.prerequisites = pprereqs;
@@ -865,6 +866,8 @@ bool Parser::try_parse_rule(const std::string& line, Makefile& mf, Rule*& curren
    } else {
        prereqs = split_words(prereqs_str);
    }
    for (auto& p : prereqs) p = normalize_target(p);
    for (auto& p : order_only) p = normalize_target(p);

    // Special targets
    if (targets.size() == 1) {