diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-18 07:14:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-12-18 07:14:53 +0200 |
commit | c0c85b67516653c181fbce7c61c2df3e31e4edd8 (patch) | |
tree | 535467b029b27b190e35064e4babd62825eba6a1 /build/rule.cxx | |
parent | 835ed5f7080a98e9ee80ac08d5585ccdbb63fe0e (diff) |
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
Diffstat (limited to 'build/rule.cxx')
-rw-r--r-- | build/rule.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
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<path_target&> (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<path_target&> (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<const mtime_target*> (&p)) + if (auto mtp = dynamic_cast<const mtime_target*> (&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; |