Commit ab615675 authored by jan.koester's avatar jan.koester
Browse files

more features

parent fd108a12
Loading
Loading
Loading
Loading
+20 −0
Changes for parser.cpp: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1056,6 +1056,26 @@ std::string Parser::expand_with_automatic(const std::string& input, const Makefi
        auto_vars["*F"] = sp.filename().string();
    }

    // 'F'/'D' modifiers for the list automatic variables '$^' and '$?'
    // (e.g. '$(^F)' is the notdir of every prerequisite). GNU make applies
    // notdir/dir word-by-word.
    auto list_modifier = [](const std::vector<std::string>& words, bool dir) {
        std::string out;
        for (size_t i = 0; i < words.size(); i++) {
            if (i > 0) out += ' ';
            fs::path p(words[i]);
            if (dir)
                out += p.parent_path().empty() ? "." : p.parent_path().string();
            else
                out += p.filename().string();
        }
        return out;
    };
    auto_vars["^F"] = list_modifier(all_prereqs, false);
    auto_vars["^D"] = list_modifier(all_prereqs, true);
    auto_vars["?F"] = list_modifier(newer_prereqs, false);
    auto_vars["?D"] = list_modifier(newer_prereqs, true);

    return do_expand(input, mf, &auto_vars);
}