aboutsummaryrefslogtreecommitdiff
path: root/build/b.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-02-23 15:56:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-02-23 15:56:03 +0200
commitfefe0657f29b8db782f7a722dd46b074b991cf08 (patch)
tree62008e350c4f6048a68444fe50c47281643d276a /build/b.cxx
parent962cb1040670977085f0a187ecc6730608578151 (diff)
Redo rule match/build logic
Now the rule is fully responsible for searching, matching, and building of prerequisites.
Diffstat (limited to 'build/b.cxx')
-rw-r--r--build/b.cxx79
1 files changed, 1 insertions, 78 deletions
diff --git a/build/b.cxx b/build/b.cxx
index c9322a0..a71a866 100644
--- a/build/b.cxx
+++ b/build/b.cxx
@@ -34,76 +34,6 @@ using namespace std;
namespace build
{
- bool
- match_recursive (target& t)
- {
- // Because we match the target first and then prerequisites,
- // any additional dependency information injected by the rule
- // will be covered as well.
- //
- if (!t.recipe ())
- {
- if (!match (t))
- {
- error << "no rule to update target " << t;
- return false;
- }
- }
-
- for (prerequisite& p: t.prerequisites)
- {
- // Resolve prerequisite to target (prerequisite search). We
- // do this after matching since the rule can alter search
- // paths.
- //
- if (p.target == nullptr)
- search (p);
-
- if (!match_recursive (*p.target))
- {
- info << "required by " << t;
- return false;
- }
- }
-
- return true;
- }
-
- target_state
- update (target& t)
- {
- assert (t.state () == target_state::unknown);
-
- auto g (
- make_exception_guard (
- [](target& t){info << "while building target " << t;},
- t));
-
- for (prerequisite& p: t.prerequisites)
- {
- target& pt (*p.target);
-
- if (pt.state () == target_state::unknown)
- {
- target_state ts (update (pt));
-
- if (ts == target_state::failed)
- return ts;
- }
- }
-
- // @@ Why do we indicate failure via code rather than throw? Now
- // there is no diagnostics via exception_guard above.
-
- const recipe& r (t.recipe ());
-
- target_state ts (r (t));
-
- assert (ts != target_state::unknown);
- t.state (ts);
- return ts;
- }
-
void
dump ()
{
@@ -125,7 +55,6 @@ namespace build
cout << endl;
}
-
}
#include <build/native>
@@ -261,14 +190,11 @@ main (int argc, char* argv[])
// Build.
//
if (default_target == nullptr)
- {
fail << "no default target";
- }
target& d (*default_target);
- if (!match_recursive (d))
- return 1; // Diagnostics has already been issued.
+ match (d);
dump ();
@@ -282,9 +208,6 @@ main (int argc, char* argv[])
case target_state::updated:
break;
case target_state::failed:
- {
- fail << "failed to update target " << d;
- }
case target_state::unknown:
assert (false);
}