aboutsummaryrefslogtreecommitdiff
path: root/libbpkg
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-07-29 20:58:19 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-07-29 20:58:44 +0300
commit5fa12c54ad71feb0d493537ceed4d1a1d8208943 (patch)
tree0167a2a59a9987131c988b5436f29f13b3bb9b74 /libbpkg
parent6d28b0449f27781b94a0b6633db728a323efd71e (diff)
Add support for src-url and doc-url package manifest values
Diffstat (limited to 'libbpkg')
-rw-r--r--libbpkg/manifest.cxx73
-rw-r--r--libbpkg/manifest.hxx2
2 files changed, 48 insertions, 27 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx
index b7f744f..64c0b90 100644
--- a/libbpkg/manifest.cxx
+++ b/libbpkg/manifest.cxx
@@ -695,6 +695,28 @@ namespace bpkg
build_constraints.emplace_back (e, move (nm), move (tg), move (c));
};
+ auto parse_url = [&bad_value] (string&& v, const char* what) -> url_type
+ {
+ string c (split_comment (v));
+
+ if (v.empty ())
+ bad_value (string ("empty ") + what + " url");
+
+ return url_type (move (v), move (c));
+ };
+
+ auto parse_email = [&bad_value] (string&& v,
+ const char* what,
+ bool empty = false) -> email_type
+ {
+ string c (split_comment (v));
+
+ if (v.empty () && !empty)
+ bad_value (string ("empty ") + what + " email");
+
+ return email_type (move (v), move (c));
+ };
+
for (nv = p.next (); !nv.empty (); nv = p.next ())
{
string& n (nv.name);
@@ -828,57 +850,49 @@ namespace bpkg
if (!url.empty ())
bad_name ("project url redefinition");
- string c (split_comment (v));
-
- if (v.empty ())
- bad_value ("empty project url");
-
- url = url_type (move (v), move (c));
+ url = parse_url (move (v), "project");
}
else if (n == "email")
{
if (!email.empty ())
bad_name ("project email redefinition");
- string c (split_comment (v));
+ email = parse_email (move (v), "project");
+ }
+ else if (n == "doc-url")
+ {
+ if (doc_url)
+ bad_name ("doc url redefinition");
- if (v.empty ())
- bad_value ("empty project email");
+ doc_url = parse_url (move (v), "doc");
+ }
+ else if (n == "src-url")
+ {
+ if (src_url)
+ bad_name ("src url redefinition");
- email = email_type (move (v), move (c));
+ src_url = parse_url (move (v), "src");
}
else if (n == "package-url")
{
if (package_url)
bad_name ("package url redefinition");
- string c (split_comment (v));
-
- if (v.empty ())
- bad_value ("empty package url");
-
- package_url = url_type (move (v), move (c));
+ package_url = parse_url (move (v), "package");
}
else if (n == "package-email")
{
if (package_email)
bad_name ("package email redefinition");
- string c (split_comment (v));
-
- if (v.empty ())
- bad_value ("empty package email");
-
- package_email = email_type (move (v), move (c));
+ package_email = parse_email (move (v), "package");
}
else if (n == "build-email")
{
if (build_email)
bad_name ("build email redefinition");
- string c (split_comment (v));
-
- build_email = email_type (move (v), move (c));
+ build_email = parse_email (move (v), "build", true);
}
else if (n == "priority")
{
@@ -1272,12 +1286,17 @@ namespace bpkg
}
s.next ("url", add_comment (url, url.comment));
+ s.next ("email", add_comment (email, email.comment));
+
+ if (doc_url)
+ s.next ("doc-url", add_comment (*doc_url, doc_url->comment));
+
+ if (src_url)
+ s.next ("src-url", add_comment (*src_url, src_url->comment));
if (package_url)
s.next ("package-url", add_comment (*package_url, package_url->comment));
- s.next ("email", add_comment (email, email.comment));
-
if (package_email)
s.next ("package-email",
add_comment (*package_email, package_email->comment));
diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx
index ccc52a6..908eb81 100644
--- a/libbpkg/manifest.hxx
+++ b/libbpkg/manifest.hxx
@@ -365,6 +365,8 @@ namespace bpkg
butl::optional<text_file> description;
std::vector<text_file> changes;
url_type url;
+ butl::optional<url_type> doc_url;
+ butl::optional<url_type> src_url;
butl::optional<url_type> package_url;
email_type email;
butl::optional<email_type> package_email;