◆ 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 1628 of file remake.cpp.
1630 DEBUG_open <<
"Reading rule for target " << first <<
"... ";
1635 std::cerr <<
"Failed to load rules: syntax error" << std::endl;
1642 if (!first.empty()) targets.push_front(first);
1643 else if (targets.empty())
goto error;
1644 else DEBUG <<
"actual target: " << targets.front() << std::endl;
1645 bool generic =
false;
1647 for (string_list::const_iterator i = targets.begin(),
1648 i_end = targets.end(); i != i_end; ++i)
1650 if (i->empty())
goto error;
1651 if ((i->find(
'%') != std::string::npos) !=
generic)
1653 if (i == targets.begin())
generic =
true;
1658 if (in.get() !=
':')
goto error;
1660 bool assignment =
false, static_pattern =
false;
1694 if (rule.
targets.empty())
goto error;
1695 for (string_list::const_iterator i = rule.
targets.begin(),
1696 i_end = rule.
targets.end(); i != i_end; ++i)
1698 if (i->find(
'%') == std::string::npos)
goto error;
1701 static_pattern =
true;
1714 if (!
skip_eol(in,
true))
goto error;
1717 std::ostringstream buf;
1721 if (!in.good())
break;
1722 if (c ==
'\t' || c ==
' ')
1724 in.get(*buf.rdbuf());
1725 if (in.fail() && !in.eof()) in.clear();
1727 else if (c ==
'\r' || c ==
'\n')
1738 if (rule.
targets.front() ==
".PHONY")
1740 for (string_list::const_iterator i = rule.
deps.begin(),
1741 i_end = rule.
deps.end(); i != i_end; ++i)
1751 if (assignment)
goto error;
1756 if (!static_pattern)
1758 if (!rule.
script.empty() && assignment)
goto error;
1763 for (string_list::const_iterator i = targets.begin(),
1764 i_end = targets.end(); i != i_end; ++i)
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 1777 of file remake.cpp.
1783 std::cerr <<
"Failed to load rules: syntax error" << std::endl;
1786 std::ifstream in(remakefile.c_str());
1789 std::cerr <<
"Failed to load rules: no Remakefile found" << std::endl;
1802 while (in.get() !=
'\n') {}
1806 if (c ==
' ' || c ==
'\t')
goto error;
1810 if (name.empty())
goto error;
1813 DEBUG <<
"Assignment to variable " << name << std::endl;
1817 *(name ==
".OPTIONS" ? &options : &
variables[name]);
1818 if (tok ==
Equal) dest.swap(value);
1819 else dest.splice(dest.end(), value);
1820 if (!
skip_eol(in,
true))
goto error;
1828 for (string_list::const_iterator i = options.begin(),
1829 i_end = options.end(); i != i_end; ++i)
1834 std::cerr <<
"Failed to load rules: unrecognized option" << std::endl;
Referenced by server_mode().
◆ register_rule()
static void register_rule |
( |
rule_t const & |
rule | ) |
|
|
static |
Register a specific rule.
Definition at line 1603 of file remake.cpp.
1605 if (!rule.script.empty())
Referenced by load_rule().
◆ 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 1574 of file remake.cpp.
1577 for (string_list::const_iterator i = rule.targets.begin(),
1578 i_end = rule.targets.end(); i != i_end; ++i)
1580 std::pair<rule_map::iterator, bool> j =
1582 if (j.second)
continue;
1583 std::cerr <<
"Failed to load rules: " << *i
1584 <<
" cannot be the target of several rules" << std::endl;
1590 dep->
deps.insert(rule.deps.begin(), rule.deps.end());
1591 for (string_list::const_iterator i = rule.targets.begin(),
1592 i_end = rule.targets.end(); i != i_end; ++i)
Referenced by register_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 1531 of file remake.cpp.
1533 assert(rule.script.empty());
1534 for (string_list::const_iterator i = targets.begin(),
1535 i_end = targets.end(); i != i_end; ++i)
1537 std::pair<rule_map::iterator, bool> j =
1548 std::cerr <<
"Failed to load rules: " << *i
1549 <<
" cannot be the target of several rules" << std::endl;
1556 for (string_list::const_iterator i = targets.begin(),
1557 i_end = targets.end(); i != i_end; ++i)
1561 dep->
deps.insert(rule.deps.begin(), rule.deps.end());
Referenced by register_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.
static void register_rule(rule_t const &rule)
@ 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)
static void instantiate_rule(std::string const &target, rule_t const &src, rule_t &dst)
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.
std::string stem
Stem used to instantiate the rule, if any.
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.