From c0c85b67516653c181fbce7c61c2df3e31e4edd8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Dec 2014 07:14:53 +0200 Subject: Initial support for loading dependency info from buildfiles Also a new iteration on the overall architecture. Now, for the first time, build can read the buildfile and build itself. g++-4.9 -std=c++14 -g -I.. -o bd bd.cxx algorithm.cxx scope.cxx parser.cxx lexer.cxx target.cxx prerequisite.cxx rule.cxx native.cxx cxx/target.cxx cxx/rule.cxx process.cxx timestamp.cxx path.cxx g++-4.9 -std=c++14 -g -I../../.. -o driver driver.cxx ../../../build/lexer.cxx g++-4.9 -std=c++14 -g -I../../.. -o driver driver.cxx ../../../build/lexer.cxx ../../../build/parser.cxx ../../../build/scope.cxx ../../../build/target.cxx ../../../build/native.cxx ../../../build/prerequisite.cxx ../../../build/path.cxx ../../../build/timestamp.cxx --- build/rule.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'build/rule.cxx') diff --git a/build/rule.cxx b/build/rule.cxx index fe4c4b2..b1730e1 100644 --- a/build/rule.cxx +++ b/build/rule.cxx @@ -26,6 +26,11 @@ namespace build path_target& pt (dynamic_cast (t)); + // @@ TMP: derive file name by appending target name as an extension. + // + if (pt.path ().empty ()) + pt.path (t.directory / path (pt.name + '.' + pt.type ().name)); + return pt.mtime () != timestamp_nonexistent ? &update : nullptr; } @@ -37,16 +42,18 @@ namespace build path_target& pt (dynamic_cast (t)); timestamp mt (pt.mtime ()); - for (const target& p: t.prerequisites ()) + for (const prerequisite& p: t.prerequisites) { + const target& pt (*p.target); // Should be resolved at this stage. + // If this is an mtime-based target, then simply compare timestamps. // - if (auto mtp = dynamic_cast (&p)) + if (auto mtp = dynamic_cast (&pt)) { if (mt < mtp->mtime ()) { cerr << "error: no rule to update target " << t << endl - << "info: prerequisite " << p << " is ahead of " << t << + << "info: prerequisite " << pt << " is ahead of " << t << " by " << (mtp->mtime () - mt) << endl; return target_state::failed; @@ -56,10 +63,10 @@ namespace build { // Otherwise we assume the prerequisite is newer if it was updated. // - if (p.state () == target_state::updated) + if (pt.state () == target_state::updated) { cerr << "error: no rule to update target " << t << endl - << "info: prerequisite " << p << " is ahead of " << t << + << "info: prerequisite " << pt << " is ahead of " << t << " because it was updated" << endl; return target_state::failed; -- cgit v1.1