From 10604d850510e46b2ee625548abe5eb9a1172a0d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 21 Jul 2015 09:39:57 +0200 Subject: Add alias{} target type, use as base for dir{} --- build/context.cxx | 9 +++++---- build/rule | 2 +- build/rule.cxx | 6 +++--- build/target | 21 +++++++++++++++++---- build/target.cxx | 18 ++++++++++++++---- 5 files changed, 40 insertions(+), 16 deletions(-) (limited to 'build') diff --git a/build/context.cxx b/build/context.cxx index bd6143a..9b22478 100644 --- a/build/context.cxx +++ b/build/context.cxx @@ -30,7 +30,7 @@ namespace build // Builtin rules. // - static dir_rule dir_; + static alias_rule alias_; static fsdir_rule fsdir_; static file_rule file_; @@ -67,6 +67,7 @@ namespace build target_type_map& tts (global_scope->target_types); tts.insert (); + tts.insert (); tts.insert (); tts.insert (); } @@ -76,9 +77,9 @@ namespace build { rule_map& rs (global_scope->rules); - rs.insert (default_id, "dir", dir_); - rs.insert (update_id, "dir", dir_); - rs.insert (clean_id, "dir", dir_); + rs.insert (default_id, "alias", alias_); + rs.insert (update_id, "alias", alias_); + rs.insert (clean_id, "alias", alias_); rs.insert (default_id, "fsdir", fsdir_); rs.insert (update_id, "fsdir", fsdir_); diff --git a/build/rule b/build/rule index fbcf06b..5b0149b 100644 --- a/build/rule +++ b/build/rule @@ -67,7 +67,7 @@ namespace build perform_update (action, target&); }; - class dir_rule: public rule + class alias_rule: public rule { public: virtual match_result diff --git a/build/rule.cxx b/build/rule.cxx index 6db0f4f..03c86c8 100644 --- a/build/rule.cxx +++ b/build/rule.cxx @@ -133,15 +133,15 @@ namespace build return target_state::unchanged; } - // dir_rule + // alias_rule // - match_result dir_rule:: + match_result alias_rule:: match (action, target& t, const string&) const { return t; } - recipe dir_rule:: + recipe alias_rule:: apply (action a, target& t, const match_result&) const { search_and_match_prerequisites (a, t); diff --git a/build/target b/build/target index d164f72..e07f6e0 100644 --- a/build/target +++ b/build/target @@ -889,11 +889,10 @@ namespace build static const target_type static_type; }; - // Directory alias/action target. Note that it is not mtime-based. - // Rather it is meant to represent a group of targets. For actual - // filesystem directory (creation), see fsdir. + // Alias target. It represents a list of targets (its prerequisites) + // as a single "name". // - class dir: public target + class alias: public target { public: using target::target; @@ -903,6 +902,20 @@ namespace build static const target_type static_type; }; + // Directory target. Note that this is not a filesystem directory + // but rather an alias target with the directory name. For actual + // filesystem directory (creation), see fsdir. + // + class dir: public alias + { + public: + using alias::alias; + + public: + virtual const target_type& type () const {return static_type;} + static const target_type static_type; + }; + // While a filesystem directory is mtime-based, the semantics is // not very useful in our case. In particular, if another target // depends on fsdir{}, then all that's desired is the creation of diff --git a/build/target.cxx b/build/target.cxx index 63bb2fe..f9662fa 100644 --- a/build/target.cxx +++ b/build/target.cxx @@ -297,9 +297,8 @@ namespace build static target* search_alias (const prerequisite_key& pk) { - // For an alias/action we don't want to silently create a target - // since it will do nothing and it most likely not what the author - // intended. + // For an alias we don't want to silently create a target since it + // will do nothing and it most likely not what the user intended. // target* t (search_existing_target (pk)); @@ -368,11 +367,22 @@ namespace build false }; + const target_type alias::static_type + { + typeid (alias), + "alias", + &target::static_type, + &target_factory, + nullptr, // Should never need. + &search_alias, + false + }; + const target_type dir::static_type { typeid (dir), "dir", - &target::static_type, + &alias::static_type, &target_factory, nullptr, // Should never need. &search_alias, -- cgit v1.1