diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-07-05 21:44:50 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-07-10 22:24:59 +0300 |
commit | 98f8d3031eb4b55fcedb753fdd4473b081023db9 (patch) | |
tree | fd6787e635e59582b5b7bb57476e2a1bb2c7ee4c | |
parent | 9617f1789d76ab7d07d82b040e41d8bc26754b0b (diff) |
Add support for build include/exclude manifest values
-rw-r--r-- | libbpkg/manifest.cxx | 32 | ||||
-rw-r--r-- | libbpkg/manifest.hxx | 28 | ||||
-rw-r--r-- | tests/manifest/testscript | 4 |
3 files changed, 64 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 ()); diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 1420cdb..ccc52a6 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -321,6 +321,33 @@ namespace bpkg : conditional (d), buildtime (b), comment (std::move (c)) {} }; + class build_constraint + { + public: + // If true, then the package should not be built for matching + // configurations by automated build bots. + // + bool exclusion; + + // Filesystem wildcard patterns for the build configuration name and + // target. + // + std::string config; + butl::optional<std::string> target; + + std::string comment; + + build_constraint () = default; + build_constraint (bool e, + std::string n, + butl::optional<std::string> t, + std::string c) + : exclusion (e), + config (std::move (n)), + target (std::move (t)), + comment (std::move (c)) {} + }; + class LIBBPKG_EXPORT package_manifest { public: @@ -344,6 +371,7 @@ namespace bpkg butl::optional<email_type> build_email; std::vector<dependency_alternatives> dependencies; std::vector<requirement_alternatives> requirements; + std::vector<build_constraint> build_constraints; // The following values are only valid in the manifest list. // diff --git a/tests/manifest/testscript b/tests/manifest/testscript index 870d48d..43dfdb1 100644 --- a/tests/manifest/testscript +++ b/tests/manifest/testscript @@ -41,6 +41,9 @@ requires: ? ; libc++ standard library if using Clang on Mac OS X. requires: zlib; Most Linux/UNIX systems already have one; or get it at\ www.zlib.net. + build-exclude: *; Only supported on Linux and FreeBSD. + build-include: linux* + build-include: freebsd* location: libfoo-1.2.3+2.tar.bz2 sha256sum: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 : @@ -53,6 +56,7 @@ email: libbar-users@example.org build-email: depends: libbaz (1- 2-) | libbaz [3 4-) | libbaz (5 6] | libbaz [7 8] + build-exclude: *-msvc_14*/i?86-*; Linker crash. location: bar/libbar-3.4A.5+6.tbz sha256sum: d4b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 : |