aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-06-03 08:42:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-06-03 08:42:26 +0200
commit1cc657a1ae2d496c0467a7c33257aa3cd2bfc3a8 (patch)
tree062e0eada1230ef19b0f51b2e77c00f2dd49a266 /libbuild2/parser.cxx
parentbc3c8492f129d9295c9ef6c325bf2c99e88ca73e (diff)
Add versioning for ad hoc C++ recipes
This will allow us to deal with backward-incompatible changes to cxx_rule interface and semantics.
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 65a42fe..dada34d 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -1048,7 +1048,7 @@ namespace build2
//
// % [<attrs>]
// [if|switch ...]
- // {{ [<lang>]
+ // {{ [<lang> ...]
// ...
// }}
//
@@ -1130,7 +1130,26 @@ namespace build2
{
// C++
//
- ar.reset (new adhoc_cxx_rule (loc, st.value.size ()));
+
+ // Parse recipe version.
+ //
+ if (tt == type::newline || tt == type::eos)
+ fail (t) << "expected c++ recipe version instead of " << t;
+
+ location nloc (get_location (t));
+ names ns (parse_names (t, tt, pattern_mode::ignore));
+
+ uint64_t v;
+ try
+ {
+ v = convert<uint64_t> (move (ns));
+ }
+ catch (const invalid_argument& e)
+ {
+ fail (nloc) << "invalid c++ recipe version value: " << e;
+ }
+
+ ar.reset (new adhoc_cxx_rule (loc, st.value.size (), v));
}
else
fail (lloc) << "unknown recipe language '" << *lang << "'";