From 1cc657a1ae2d496c0467a7c33257aa3cd2bfc3a8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 3 Jun 2020 08:42:26 +0200 Subject: Add versioning for ad hoc C++ recipes This will allow us to deal with backward-incompatible changes to cxx_rule interface and semantics. --- libbuild2/parser.cxx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'libbuild2/parser.cxx') 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 // // % [] // [if|switch ...] - // {{ [] + // {{ [ ...] // ... // }} // @@ -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 (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 << "'"; -- cgit v1.1