aboutsummaryrefslogtreecommitdiff
path: root/build/bin
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-03 15:47:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-03 15:47:35 +0200
commitabb7bf1045fde14f6ef87c8941ee22af233af397 (patch)
tree734b8e605c00f79e00687ec4912366b88fbbb050 /build/bin
parent0db17bfec8b3b6c436f3c9c346d17d98458c3654 (diff)
match_only rework, part 2
Diffstat (limited to 'build/bin')
-rw-r--r--build/bin/rule.cxx71
-rw-r--r--build/bin/target3
-rw-r--r--build/bin/target.cxx9
3 files changed, 46 insertions, 37 deletions
diff --git a/build/bin/rule.cxx b/build/bin/rule.cxx
index 8df1ee0..8507497 100644
--- a/build/bin/rule.cxx
+++ b/build/bin/rule.cxx
@@ -37,44 +37,12 @@ namespace build
// members as our prerequisites.
//
match_result lib_rule::
- match (action a, target& t, const std::string&) const
- {
- // Search and match prerequisite libraries and add them to the
- // prerequisite targets. While we never execute this list
- // ourselves (see perform() below), this is necessary to make
- // the exported options machinery work for the library chains
- // (chaining is the reason why we have to do match, recursively).
- // See the cxx.export.*-related code in cxx/compile.cxx for
- // details.
- //
- for (prerequisite& p: group_prerequisites (t))
- {
- if (p.is_a<lib> ())
- {
- target& pt (search (p));
- match_only (a, pt);
- t.prerequisite_targets.push_back (&pt);
- }
- else if (p.is_a<liba> () || p.is_a<libso> ())
- {
- //@@ TMP: C++ link rule hasn't been converted to support
- // match_only().
- //
- target& pt (search (p));
- build::match (a, pt);
- t.prerequisite_targets.push_back (&pt);
- pt.dependents--; // No intent to execute.
- }
- }
-
- return t;
- }
-
- recipe lib_rule::
- apply (action a, target& xt, const match_result&) const
+ match (action a, target& xt, const std::string&) const
{
lib& t (static_cast<lib&> (xt));
+ // @@ We have to re-query it on each match_only()!
+
// Get the library type to build. If not set for a target, this
// should be configured at the project scope by init_lib().
//
@@ -87,12 +55,20 @@ namespace build
fail << "unknown library type: " << type <<
info << "'static', 'shared', or 'both' expected";
+ // Search and pre-match the members. The pre-match here is part
+ // of the "library meta-information protocol" that could be used
+ // by the module that actually builds the members. The idea is
+ // that pre-matching members may populate our prerequisite_targets
+ // with prerequisite libraries from which others can extract the
+ // meta-information about the library, such as the options to use
+ // when linking it, etc.
+ //
if (ar)
{
if (t.a == nullptr)
t.a = &search<liba> (t.dir, t.name, t.ext, nullptr);
- build::match (a, *t.a);
+ match_only (a, *t.a);
}
if (so)
@@ -100,9 +76,30 @@ namespace build
if (t.so == nullptr)
t.so = &search<libso> (t.dir, t.name, t.ext, nullptr);
- build::match (a, *t.so);
+ match_only (a, *t.so);
}
+ return match_result (t, &type);
+ }
+
+ recipe lib_rule::
+ apply (action a, target& xt, const match_result& mr) const
+ {
+ lib& t (static_cast<lib&> (xt));
+
+ const string& type (*static_cast<const string*> (mr.cpvalue));
+
+ bool ar (type == "static" || type == "both");
+ bool so (type == "shared" || type == "both");
+
+ // Now we do full match.
+ //
+ if (ar)
+ build::match (a, *t.a);
+
+ if (so)
+ build::match (a, *t.so);
+
return &perform;
}
diff --git a/build/bin/target b/build/bin/target
index 946d7f6..729f119 100644
--- a/build/bin/target
+++ b/build/bin/target
@@ -86,6 +86,9 @@ namespace build
liba* a {nullptr};
libso* so {nullptr};
+ virtual void
+ reset (action_type);
+
public:
virtual const target_type& type () const {return static_type;}
static const target_type static_type;
diff --git a/build/bin/target.cxx b/build/bin/target.cxx
index 4e48d16..5a1bb92 100644
--- a/build/bin/target.cxx
+++ b/build/bin/target.cxx
@@ -154,6 +154,15 @@ namespace build
false
};
+ // lib
+ //
+ void lib::
+ reset (action_type)
+ {
+ // Don't clear prerequisite_targets since it is "given" to our
+ // members to implement "library meta-information protocol".
+ }
+
static target*
lib_factory (dir_path d, string n, const string* e)
{