aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-17 15:43:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:25 +0200
commitfc27ec48c9d63879e4b0f049060e943233cb540d (patch)
tree28e062c8674ad194268100bf48475aecaca4c056 /build2/cc
parent8b564b5b8f6d597a9fb76734e759f78c4b1c91da (diff)
Cleanup match_result mess
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/compile4
-rw-r--r--build2/cc/compile.cxx20
-rw-r--r--build2/cc/link4
-rw-r--r--build2/cc/link.cxx10
4 files changed, 25 insertions, 13 deletions
diff --git a/build2/cc/compile b/build2/cc/compile
index 2be2e86..584da7c 100644
--- a/build2/cc/compile
+++ b/build2/cc/compile
@@ -27,10 +27,10 @@ namespace build2
compile (data&&);
virtual match_result
- match (action, target&, const string& hint) const;
+ match (action, target&, const string& hint) const override;
virtual recipe
- apply (action, target&, const match_result&) const;
+ apply (action, target&) const override;
target_state
perform_update (action, target&) const;
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index 6587d8c..e180798 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -35,6 +35,14 @@ namespace build2
{
}
+ struct match_data
+ {
+ prerequisite_member src;
+ };
+
+ static_assert (sizeof (match_data) <= target::data_size,
+ "insufficient space");
+
match_result compile::
match (action a, target& t, const string&) const
{
@@ -53,11 +61,14 @@ namespace build2
for (prerequisite_member p: reverse_group_prerequisite_members (a, t))
{
if (p.is_a (x_src))
- return p;
+ {
+ t.data (match_data {p}); // Save in the target's auxilary storage.
+ return true;
+ }
}
l4 ([&]{trace << "no " << x_lang << " source file for target " << t;});
- return nullptr;
+ return false;
}
// Append or hash library options from a pair of *.export.* variables
@@ -180,11 +191,12 @@ namespace build2
}
recipe compile::
- apply (action a, target& xt, const match_result& mr) const
+ apply (action a, target& xt) const
{
tracer trace (x, "compile::apply");
file& t (static_cast<file&> (xt));
+ const match_data& md (t.data<match_data> ());
scope& bs (t.base_scope ());
scope& rs (*bs.root_scope ());
@@ -297,7 +309,7 @@ namespace build2
// t.prerequisite_targets since we used standard search() and match()
// above.
//
- file& src (mr.as_target<file> ());
+ file& src (*md.src.search ().is_a<file> ());
// Make sure the output directory exists.
//
diff --git a/build2/cc/link b/build2/cc/link
index cd8c10e..ea30320 100644
--- a/build2/cc/link
+++ b/build2/cc/link
@@ -25,10 +25,10 @@ namespace build2
link (data&&);
virtual match_result
- match (action, target&, const string& hint) const;
+ match (action, target&, const string& hint) const override;
virtual recipe
- apply (action, target&, const match_result&) const;
+ apply (action, target&) const override;
target_state
perform_update (action, target&) const;
diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx
index 5ab9d91..7722c4f 100644
--- a/build2/cc/link.cxx
+++ b/build2/cc/link.cxx
@@ -109,11 +109,11 @@ namespace build2
// it will most definitely need to be compiled but we can't do that.
//
else if (p.is_a<cc> ())
- return nullptr;
+ return false;
}
if (!(seen_x || seen_c || seen_obj || seen_lib))
- return nullptr;
+ return false;
// We will only chain a C source if there is also an X source or we were
// explicitly told to.
@@ -121,7 +121,7 @@ namespace build2
if (seen_c && !seen_x && hint < x)
{
l4 ([&]{trace << "C prerequisite without " << x_lang << " or hint";});
- return nullptr;
+ return false;
}
// Set the library type.
@@ -173,7 +173,7 @@ namespace build2
}
}
- return &t;
+ return true;
}
auto link::
@@ -316,7 +316,7 @@ namespace build2
}
recipe link::
- apply (action a, target& xt, const match_result&) const
+ apply (action a, target& xt) const
{
tracer trace (x, "link::apply");