aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-21 09:39:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-21 09:39:57 +0200
commit10604d850510e46b2ee625548abe5eb9a1172a0d (patch)
tree0a301d0d69afe2123a406afeeff03f7fe89c4433 /build
parentcb8399da1f0b1c5f28e443c98bfc3cb4e12b8cbf (diff)
Add alias{} target type, use as base for dir{}
Diffstat (limited to 'build')
-rw-r--r--build/context.cxx9
-rw-r--r--build/rule2
-rw-r--r--build/rule.cxx6
-rw-r--r--build/target21
-rw-r--r--build/target.cxx18
5 files changed, 40 insertions, 16 deletions
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<file> ();
+ tts.insert<alias> ();
tts.insert<dir> ();
tts.insert<fsdir> ();
}
@@ -76,9 +77,9 @@ namespace build
{
rule_map& rs (global_scope->rules);
- rs.insert<dir> (default_id, "dir", dir_);
- rs.insert<dir> (update_id, "dir", dir_);
- rs.insert<dir> (clean_id, "dir", dir_);
+ rs.insert<alias> (default_id, "alias", alias_);
+ rs.insert<alias> (update_id, "alias", alias_);
+ rs.insert<alias> (clean_id, "alias", alias_);
rs.insert<fsdir> (default_id, "fsdir", fsdir_);
rs.insert<fsdir> (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<alias>,
+ nullptr, // Should never need.
+ &search_alias,
+ false
+ };
+
const target_type dir::static_type
{
typeid (dir),
"dir",
- &target::static_type,
+ &alias::static_type,
&target_factory<dir>,
nullptr, // Should never need.
&search_alias,