From c106259517d7693ea8e24564bc890fe575d5edcd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Jan 2015 14:11:14 +0200 Subject: Implement rule chaining for cxx::link --- build/rule.cxx | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'build/rule.cxx') diff --git a/build/rule.cxx b/build/rule.cxx index c116538..b73b053 100644 --- a/build/rule.cxx +++ b/build/rule.cxx @@ -4,6 +4,7 @@ #include +#include // move() #include using namespace std; @@ -14,24 +15,45 @@ namespace build // default_path_rule // - recipe default_path_rule:: - match (target& t, bool, std::string&) const + void* default_path_rule:: + match (target& t, const string&) const { // @@ TODO: // // - need to assign path somehow. Get (potentially several) // extensions from target type? Maybe target type should // generate a list of potential paths that we can try here. + // What if none of them exist, which one do we use? Should + // there be a default extension, perhaps configurable via + // a variable? // 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)); + { + path p (t.directory / path (pt.name)); + + // @@ TMP: derive file name by appending target name as an extension? + // + const string& e (pt.ext != nullptr ? *pt.ext : pt.type ().name); + + if (!e.empty ()) + { + p += '.'; + p += e; + } + + pt.path (move (p)); + } - return pt.mtime () != timestamp_nonexistent ? &update : nullptr; + return pt.mtime () != timestamp_nonexistent ? &t : nullptr; + } + + recipe default_path_rule:: + select (target&, void*) const + { + return &update; } target_state default_path_rule:: -- cgit v1.1