From 8bd89cfca333e58f6990d7d168649dfc79878f31 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 19 Feb 2015 16:10:03 +0200 Subject: Add support for sourcing/including buildfiles, print, dir{} alias --- build/rule.cxx | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'build/rule.cxx') diff --git a/build/rule.cxx b/build/rule.cxx index d40eebf..e145ea8 100644 --- a/build/rule.cxx +++ b/build/rule.cxx @@ -14,9 +14,9 @@ namespace build { rule_map rules; - // default_path_rule + // path_rule // - void* default_path_rule:: + void* path_rule:: match (target& t, const string&) const { // @@ TODO: @@ -51,13 +51,13 @@ namespace build return pt.mtime () != timestamp_nonexistent ? &t : nullptr; } - recipe default_path_rule:: + recipe path_rule:: select (target&, void*) const { return &update; } - target_state default_path_rule:: + target_state path_rule:: update (target& t) { // Make sure the target is not older than any of its prerequisites. @@ -99,4 +99,32 @@ namespace build return target_state::uptodate; } + + // dir_rule + // + void* dir_rule:: + match (target& t, const string&) const + { + return &t; + } + + recipe dir_rule:: + select (target&, void*) const + { + return &update; + } + + target_state dir_rule:: + update (target& t) + { + for (const prerequisite& p: t.prerequisites) + { + auto ts (p.target->state ()); + + if (ts != target_state::uptodate) + return ts; // updated or failed + } + + return target_state::uptodate; + } } -- cgit v1.1