◆ load_rule()
static void load_rule |
( |
std::istream & |
in, |
|
|
std::string const & |
first |
|
) |
| |
|
static |
Read a rule starting with target first, if nonempty. Store into generic_rules or specific_rules depending on its genericity.
Definition at line 1586 of file remake.cpp.
1588 DEBUG_open <<
"Reading rule for target " << first <<
"... ";
1593 std::cerr <<
"Failed to load rules: syntax error" << std::endl;
1601 if (!first.empty()) targets.push_front(first);
1602 else if (targets.empty())
goto error;
1603 else DEBUG <<
"actual target: " << targets.front() << std::endl;
1604 bool generic =
false;
1606 for (string_list::const_iterator i = targets.begin(),
1607 i_end = targets.end(); i != i_end; ++i)
1609 if (i->empty())
goto error;
1610 if ((i->find(
'%') != std::string::npos) !=
generic)
1612 if (i == targets.begin())
generic =
true;
1616 std::swap(rule.
targets, targets);
1618 if (in.get() !=
':')
goto error;
1620 bool assignment =
false;
1654 if (!
skip_eol(in,
true))
goto error;
1657 std::ostringstream buf;
1661 if (!in.good())
break;
1662 if (c ==
'\t' || c ==
' ')
1664 in.get(*buf.rdbuf());
1665 if (in.fail() && !in.eof()) in.clear();
1667 else if (c ==
'\r' || c ==
'\n')
1678 if (rule.
targets.front() ==
".PHONY")
1680 for (string_list::const_iterator i = rule.
deps.begin(),
1681 i_end = rule.
deps.end(); i != i_end; ++i)
1691 if (assignment)
goto error;
1696 if (!rule.
script.empty())
1698 if (assignment)
goto error;
1705 std::swap(rule.
targets, targets);
1707 std::swap(rule.
targets, targets);
Referenced by load_rules().
◆ load_rules()
static void load_rules |
( |
std::string const & |
remakefile | ) |
|
|
static |
Load rules from remakefile. If some rules have dependencies and non-generic targets, add these dependencies to the targets.
Definition at line 1720 of file remake.cpp.
1726 std::cerr <<
"Failed to load rules: syntax error" << std::endl;
1729 std::ifstream in(remakefile.c_str());
1732 std::cerr <<
"Failed to load rules: no Remakefile found" << std::endl;
1745 while (in.get() !=
'\n') {}
1749 if (c ==
' ' || c ==
'\t')
goto error;
1753 if (name.empty())
goto error;
1756 DEBUG <<
"Assignment to variable " << name << std::endl;
1760 *(name ==
".OPTIONS" ? &options : &
variables[name]);
1761 if (tok ==
Equal) dest.swap(value);
1762 else dest.splice(dest.end(), value);
1763 if (!
skip_eol(in,
true))
goto error;
1771 for (string_list::const_iterator i = options.begin(),
1772 i_end = options.end(); i != i_end; ++i)
1777 std::cerr <<
"Failed to load rules: unrecognized option" << std::endl;
Referenced by server_mode().
◆ register_scripted_rule()
static void register_scripted_rule |
( |
rule_t const & |
rule | ) |
|
|
static |
Register a specific rule with a nonempty script:
- Check that none of the targets already has an associated rule.
- Create a single shared rule and associate it to all the targets.
- Merge the prerequisites of all the targets into a single set and add the prerequisites of the rule to it. (The preexisting prerequisites, if any, come from a previous run.)
Definition at line 1556 of file remake.cpp.
1559 for (string_list::const_iterator i = rule.targets.begin(),
1560 i_end = rule.targets.end(); i != i_end; ++i)
1562 std::pair<rule_map::iterator, bool> j =
1564 if (j.second)
continue;
1565 std::cerr <<
"Failed to load rules: " << *i
1566 <<
" cannot be the target of several rules" << std::endl;
1572 dep->
deps.insert(rule.deps.begin(), rule.deps.end());
1573 for (string_list::const_iterator i = rule.targets.begin(),
1574 i_end = rule.targets.end(); i != i_end; ++i)
Referenced by load_rule().
◆ register_transparent_rule()
static void register_transparent_rule |
( |
rule_t const & |
rule, |
|
|
string_list const & |
targets |
|
) |
| |
|
static |
Register a specific rule with an empty script:
- Check that none of the targets already has an associated rule with a nonempty script.
- Create a new rule with a single target for each target, if needed.
- Add the prerequisites of rule to all these associated rules.
Definition at line 1513 of file remake.cpp.
1515 assert(rule.script.empty());
1516 for (string_list::const_iterator i = targets.begin(),
1517 i_end = targets.end(); i != i_end; ++i)
1519 std::pair<rule_map::iterator, bool> j =
1530 std::cerr <<
"Failed to load rules: " << *i
1531 <<
" cannot be the target of several rules" << std::endl;
1538 for (string_list::const_iterator i = targets.begin(),
1539 i_end = targets.end(); i != i_end; ++i)
1543 dep->
deps.insert(rule.deps.begin(), rule.deps.end());
Referenced by load_rule().
static std::string first_target
std::list< std::string > string_list
static bool propagate_vars
static void load_rule(std::istream &in, std::string const &first)
static bool skip_eol(std::istream &in, bool multi=false)
static dependency_map dependencies
string_list targets
Files produced by this rule.
static void register_transparent_rule(rule_t const &rule, string_list const &targets)
static bool read_words(input_generator &in, string_list &res)
std::string script
Shell script for building the targets.
@ Todo
Target is missing or obsolete.
static std::string read_word(std::istream &in, bool detect_equal=true)
static rule_list generic_rules
static rule_map specific_rules
static void merge_rule(rule_t &dest, rule_t const &src)
assign_map assigns
Assignment of variables.
static void normalize_list(string_list &l, std::string const &w, std::string const &p)
static variable_map variables
static void skip_empty(std::istream &in)
static void register_scripted_rule(rule_t const &rule)
string_list deps
Dependencies used for an implicit call to remake at the start of the script.
static int expect_token(std::istream &in, int mask)
static void skip_spaces(std::istream &in)
string_list wdeps
Like deps, except that they are not registered as dependencies.