aboutsummaryrefslogtreecommitdiff
path: root/libbpkg/manifest.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbpkg/manifest.cxx')
-rw-r--r--libbpkg/manifest.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx
index 64daa11..ee71596 100644
--- a/libbpkg/manifest.cxx
+++ b/libbpkg/manifest.cxx
@@ -673,6 +673,25 @@ namespace bpkg
if (nv.value != "1")
bad_value ("unsupported format version");
+ auto add_build_constraint = [&bad_value, this] (bool e, string&& v)
+ {
+ string c (split_comment (v));
+ size_t p (v.find ('/'));
+
+ string nm (p != string::npos ? v.substr (0, p) : move (v));
+ optional<string> tg (p != string::npos
+ ? optional<string> (string (v, p + 1))
+ : nullopt);
+
+ if (nm.empty ())
+ bad_value ("empty build configuration name pattern");
+
+ if (tg && tg->empty ())
+ bad_value ("empty build target pattern");
+
+ build_constraints.emplace_back (e, move (nm), move (tg), move (c));
+ };
+
for (nv = p.next (); !nv.empty (); nv = p.next ())
{
string& n (nv.name);
@@ -915,6 +934,14 @@ namespace bpkg
requirements.push_back (move (ra));
}
+ else if (n == "build-include")
+ {
+ add_build_constraint (false, move (v));
+ }
+ else if (n == "build-exclude")
+ {
+ add_build_constraint (true, move (v));
+ }
else if (n == "depends")
{
// Allow specifying ?* in any order.
@@ -1270,6 +1297,11 @@ namespace bpkg
: (r.buildtime ? "* " : "")) +
add_comment (concatenate (r, " | "), r.comment));
+ for (const auto& c: build_constraints)
+ s.next (c.exclusion ? "build-exclude" : "build-include",
+ add_comment (!c.target ? c.config : c.config + "/" + *c.target,
+ c.comment));
+
if (location)
s.next ("location", location->posix_string ());