diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-09-05 09:19:46 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-09-05 09:19:46 +0200 |
commit | aaab4b270cb86c0dd29ac79dc889fabec33b2448 (patch) | |
tree | dd71cc2288d2a15f3b958faa4a54a288eecd2ead | |
parent | 8546868b68642c2c9199825b5043c435b80dc90e (diff) |
Add support for build-time dependencies
-rw-r--r-- | bpkg/manifest | 14 | ||||
-rw-r--r-- | bpkg/manifest.cxx | 44 | ||||
-rw-r--r-- | tests/manifest-roundtrip/manifest | 3 |
3 files changed, 44 insertions, 17 deletions
diff --git a/bpkg/manifest b/bpkg/manifest index 8e9c043..e0b8421 100644 --- a/bpkg/manifest +++ b/bpkg/manifest @@ -295,11 +295,12 @@ namespace bpkg { public: bool conditional; + bool buildtime; std::string comment; - explicit - dependency_alternatives (bool d = false, std::string c = "") - : conditional (d), comment (std::move (c)) {} + dependency_alternatives () = default; + dependency_alternatives (bool d, bool b, std::string c) + : conditional (d), buildtime (b), comment (std::move (c)) {} }; LIBBPKG_EXPORT std::ostream& @@ -311,11 +312,12 @@ namespace bpkg { public: bool conditional; + bool buildtime; std::string comment; - explicit - requirement_alternatives (bool d = false, std::string c = "") - : conditional (d), comment (std::move (c)) {} + requirement_alternatives () = default; + requirement_alternatives (bool d, bool b, std::string c) + : conditional (d), buildtime (b), comment (std::move (c)) {} }; class LIBBPKG_EXPORT package_manifest diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx index d6c6afb..b8b4ac7 100644 --- a/bpkg/manifest.cxx +++ b/bpkg/manifest.cxx @@ -618,7 +618,13 @@ namespace bpkg operator<< (ostream& o, const dependency_alternatives& as) { if (as.conditional) - o << "? "; + o << '?'; + + if (as.buildtime) + o << '*'; + + if (as.conditional || as.buildtime) + o << ' '; bool f (true); for (const dependency& a: as) @@ -875,14 +881,19 @@ namespace bpkg } else if (n == "requires") { - bool cond (!v.empty () && v[0] == '?'); - requirement_alternatives ra (cond, split_comment (v)); + // Allow specifying ?* in any order. + // + size_t m (v.size ()); + size_t cond ((m > 0 && v[0] == '?') || (m > 1 && v[1] == '?') ? 1 : 0); + size_t btim ((m > 0 && v[0] == '*') || (m > 1 && v[1] == '*') ? 1 : 0); + + requirement_alternatives ra (cond != 0, btim != 0, split_comment (v)); string::const_iterator b (v.begin ()); string::const_iterator e (v.end ()); - if (ra.conditional) + if (ra.conditional || ra.buildtime) { - string::size_type p (v.find_first_not_of (spaces, 1)); + string::size_type p (v.find_first_not_of (spaces, cond + btim)); b = p == string::npos ? e : b + p; } @@ -897,14 +908,19 @@ namespace bpkg } else if (n == "depends") { - bool cond (!v.empty () && v[0] == '?'); - dependency_alternatives da (cond, split_comment (v)); + // Allow specifying ?* in any order. + // + size_t m (v.size ()); + size_t cond ((m > 0 && v[0] == '?') || (m > 1 && v[1] == '?') ? 1 : 0); + size_t btim ((m > 0 && v[0] == '*') || (m > 1 && v[1] == '*') ? 1 : 0); + + dependency_alternatives da (cond != 0, btim != 0, split_comment (v)); string::const_iterator b (v.begin ()); string::const_iterator e (v.end ()); - if (da.conditional) + if (da.conditional || da.buildtime) { - string::size_type p (v.find_first_not_of (spaces, 1)); + string::size_type p (v.find_first_not_of (spaces, cond + btim)); b = p == string::npos ? e : b + p; } @@ -1227,14 +1243,20 @@ namespace bpkg s.next ("package-email", add_comment (*package_email, package_email->comment)); + + for (const auto& d: dependencies) s.next ("depends", - (d.conditional ? "? " : "") + + (d.conditional + ? (d.buildtime ? "?* " : "? ") + : (d.buildtime ? "* " : "")) + add_comment (concatenate (d, " | "), d.comment)); for (const auto& r: requirements) s.next ("requires", - (r.conditional ? "? " : "") + + (r.conditional + ? (r.buildtime ? "?* " : "? ") + : (r.buildtime ? "* " : "")) + add_comment (concatenate (r, " | "), r.comment)); if (location) diff --git a/tests/manifest-roundtrip/manifest b/tests/manifest-roundtrip/manifest index 31d6b28..23c2730 100644 --- a/tests/manifest-roundtrip/manifest +++ b/tests/manifest-roundtrip/manifest @@ -20,6 +20,9 @@ email: build-users@codesynthesis.com; Public mailing list, posts by\ non-members are allowed but moderated. package-email: boris@codesynthesis.com; Direct email to the author. depends: libbutl +depends: * build2 +depends: ?* bpkg +requires: ?* linux | windows requires: c++11 : path: c:\windows\\ |