From 98f8d3031eb4b55fcedb753fdd4473b081023db9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 5 Jul 2017 21:44:50 +0300 Subject: Add support for build include/exclude manifest values --- libbpkg/manifest.cxx | 32 ++++++++++++++++++++++++++++++++ libbpkg/manifest.hxx | 28 ++++++++++++++++++++++++++++ tests/manifest/testscript | 4 ++++ 3 files changed, 64 insertions(+) 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 tg (p != string::npos + ? optional (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 target; + + std::string comment; + + build_constraint () = default; + build_constraint (bool e, + std::string n, + butl::optional 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 build_email; std::vector dependencies; std::vector requirements; + std::vector 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 : -- cgit v1.1