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

fix

parent 51ab8ecb
Loading
Loading
Loading
Loading
+22 −2
Changes for parser.cpp: 22 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -762,10 +762,30 @@ bool Parser::try_parse_rule(const std::string& line, Makefile& mf, Rule*& curren
        }
    }

    // Target-specific variable assignment:  targets: NAME op VALUE
    // Target-specific variable assignment:  targets: [private|export|override] NAME op VALUE
    {
        // Strip leading target-var modifier keywords (GNU make allows any of
        // 'private', 'export', 'override' before the assignment). 'export'
        // additionally marks the variable for the recipe environment.
        std::string tv_rhs = rhs_raw;
        bool tv_export = false;
        for (;;) {
            std::string t = tv_rhs;
            size_t sp = t.find_first_of(" \t");
            if (sp == std::string::npos) break;
            std::string kw = t.substr(0, sp);
            if (kw == "private" || kw == "override") {
                tv_rhs = trim(t.substr(sp + 1));
            } else if (kw == "export") {
                tv_export = true;
                tv_rhs = trim(t.substr(sp + 1));
            } else {
                break;
            }
        }
        std::string tv_name, tv_op, tv_value;
        if (parse_target_var(rhs_raw, tv_name, tv_op, tv_value)) {
        if (parse_target_var(tv_rhs, tv_name, tv_op, tv_value)) {
            if (tv_export) mf.exported.insert(tv_name);
            std::string val = (tv_op == ":=") ? expand(tv_value, mf) : tv_value;
            for (const auto& t : targets) {
                auto& vec = mf.target_vars[t];