Logo Search packages:      
Sourcecode: undertaker version File versions  Download package

int SatChecker::formatConfigItems ( AssignmentMap  solution,
std::ostream &  out,
const MissingSet &  missingSet 
) [static]

format solutions

This method filters out comparators and block variables from the given AssignmentMap solution. Additionally, CONFIG_ACPI_MODULE and the like lead to the CONFIG_ACPI variable being set to '=m'. This output resembles a partial KConfig selection.

Parameters:
solutionthe found solution to print out
outan output stream on which the solution shall be printed
missingSetset of items that are not available in the model

Definition at line 362 of file SatChecker.cpp.

                                                                                                       {
    typedef std::map<std::string, state> SelectionType;
    SelectionType selection, other_variables;

    for (AssignmentMap::iterator it = solution.begin(); it != solution.end(); it++) {
        static const boost::regex item_regexp("^CONFIG_(.*)$", boost::regex::perl);
        static const boost::regex module_regexp("^CONFIG_(.*)_MODULE$", boost::regex::perl);
        static const boost::regex block_regexp("^B\\d+$", boost::regex::perl);
        static const boost::regex choice_regexp("^CONFIG_CHOICE_.*$", boost::regex::perl);
        const std::string &name = (*it).first;
        const bool &valid = (*it).second;
        boost::match_results<std::string::const_iterator> what;

        if (valid && boost::regex_match(name, what, module_regexp)) {
            const std::string &name = what[1];
            std::string fullname = "CONFIG_" + name;
            if (missingSet.find(fullname) != missingSet.end()) {
                std::cout << "Ignoring 'missing' item " << fullname << std::endl;
                other_variables[fullname] = valid ? yes : no;
            } else
                selection[name] = module;
        } else if (boost::regex_match(name, what, choice_regexp)) {
            other_variables[what[0]] = valid ? yes : no;
            continue;
        } else if (boost::regex_match(name, what, item_regexp)) {
            const std::string &name = what[1];
            if (missingSet.find(what[0]) != missingSet.end()) {
                std::cout << "Ignoring 'missing' item " << what[0] << std::endl;

                other_variables[what[0]] = valid ? yes : no;
                continue;
            }

            // ignore entries if already set (e.g., by the module variant).
            if (selection.find(name) == selection.end())
                selection[name] = valid ? yes : no;
        } else if (boost::regex_match(name, block_regexp))
            // ignore block variables
            continue;
        else
            other_variables[name] = valid ? yes : no;
    }
    for (SelectionType::iterator s = selection.begin(); s != selection.end(); s++) {
        const std::string &item = (*s).first;
        const int &state = (*s).second;
        out << "CONFIG_" << item << "=";
        if (state == no)
            out << "n";
        else if (state == module)
            out << "m";
        else if (state == yes)
            out << "y";
        else
            assert(false);
        out << std::endl;
    }
    for (SelectionType::iterator s = other_variables.begin(); s != other_variables.end(); s++) {
        const std::string &item = (*s).first;
        const int &state = (*s).second;
        out << "# " << item << "=";
        if (state == no)
            out << "n";
        else if (state == yes)
            out << "y";
        else
            assert(false);
        out << std::endl;
    }
    return selection.size();
}

Generated by  Doxygen 1.6.0   Back to index