aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-18 08:53:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-18 08:53:59 +0200
commit832c50a8f3c3ac71313e2c54ffeca3aab460e63d (patch)
tree777cb01a8a939a289d55dc332e8683dc076799d3
parent50e725ae23124a10d56a615fb8b0ae80d0d2b4d3 (diff)
Delay checking for ad hoc C++ recipe support until match
-rw-r--r--libbuild2/parser.cxx10
-rw-r--r--libbuild2/rule-adhoc-cxx.cxx19
2 files changed, 20 insertions, 9 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 6d34a11..21b5794 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -1143,14 +1143,7 @@ namespace build2
{
// C++
//
-#if defined(BUILD2_BOOTSTRAP) || defined(LIBBUILD2_STATIC_BUILD)
- fail (loc) << "ad hoc c++ recipe" <<
-#ifdef BUILD2_BOOTSTRAP
- info << "running bootstrap build system";
-#else
- info << "running statically-linked build system";
-#endif
-#else
+
// Parse recipe version and optional fragment separator.
//
if (tt == type::newline || tt == type::eos)
@@ -1195,7 +1188,6 @@ namespace build2
ar.reset (
new adhoc_cxx_rule (loc, st.value.size (), ver, move (sep)));
-#endif // BUILD2_BOOTSTRAP || LIBBUILD2_STATIC_BUILD
}
else
fail (lloc) << "unknown recipe language '" << *lang << "'";
diff --git a/libbuild2/rule-adhoc-cxx.cxx b/libbuild2/rule-adhoc-cxx.cxx
index 547bb69..1159a17 100644
--- a/libbuild2/rule-adhoc-cxx.cxx
+++ b/libbuild2/rule-adhoc-cxx.cxx
@@ -61,6 +61,24 @@ namespace build2
<< ind << string (braces, '}');
}
+#if defined(BUILD2_BOOTSTRAP) || defined(LIBBUILD2_STATIC_BUILD)
+ bool adhoc_cxx_rule::
+ match (action, target&, const string&) const
+ {
+ // Note that we wait until match() (instead of, say, failing in the
+ // parser) to allow the presence of ad hoc C++ recipes for other
+ // operations.
+ //
+ fail (loc) << "ad hoc c++ recipe" <<
+#ifdef BUILD2_BOOTSTRAP
+ info << "running bootstrap build system" << endf;
+#else
+ info << "running statically-linked build system" << endf;
+#endif
+ }
+
+#else
+
// From module.cxx.
//
void
@@ -637,6 +655,7 @@ namespace build2
return impl->match (a, t, hint);
}
+#endif // BUILD2_BOOTSTRAP || LIBBUILD2_STATIC_BUILD
recipe adhoc_cxx_rule::
apply (action a, target& t) const