From bf42edca4c714138b59f429f44368a71a855902f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 9 Apr 2020 19:41:49 +0300 Subject: Override build constraints group values hierarchically --- libbpkg/manifest.cxx | 20 ++++++++++++++++---- libbpkg/manifest.hxx | 4 ++++ tests/overrides/testscript | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index 7de5f7e..c1c541f 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -2413,15 +2413,27 @@ namespace bpkg void package_manifest:: override (const vector& nvs, const string& name) { + // Reset the build constraints value sub-group on the first call. + // + bool rbc (true); + auto reset_build_constraints = [&rbc, this] () + { + if (rbc) + { + build_constraints.clear (); + rbc = false; + } + }; + // Reset the builds value group on the first call. // bool rb (true); - auto reset_builds = [&rb, this] () + auto reset_builds = [&rb, &reset_build_constraints, this] () { if (rb) { builds.clear (); - build_constraints.clear (); + reset_build_constraints (); rb = false; } }; @@ -2451,14 +2463,14 @@ namespace bpkg } else if (n == "build-include") { - reset_builds (); + reset_build_constraints (); build_constraints.push_back ( parse_build_constraint (nv, false /* exclusion */, name)); } else if (n == "build-exclude") { - reset_builds (); + reset_build_constraints (); build_constraints.push_back ( parse_build_constraint (nv, true /* exclusion */, name)); diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 80b410d..05b6dfc 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -788,6 +788,10 @@ namespace bpkg // the following value groups can be overridden: {build-*email} and // {builds, build-{include,exclude}}. // + // Note that the build constraints group values are overridden + // hierarchically so that the build-{include,exclude} overrides don't + // affect the builds values. + // // If a non-empty source name is specified, then the specified values are // assumed to also include the line/column information and the possibly // thrown manifest_parsing exception will contain the invalid value diff --git a/tests/overrides/testscript b/tests/overrides/testscript index 6100485..babe57d 100644 --- a/tests/overrides/testscript +++ b/tests/overrides/testscript @@ -53,12 +53,35 @@ summary: Modern C++ parser license: LGPLv2 builds: default + build-exclude: freebsd* EOI : 1 name: libfoo version: 2.0.0 summary: Modern C++ parser license: LGPLv2 + builds: default + build-include: linux* + build-exclude: *; Only supports Linux. + EOO + + : builds-build-include-exclude + : + $* 'build-include: linux*' 'build-exclude: *; Only supports Linux.' 'builds: all' <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + builds: default + build-exclude: windows; Only supports POSIX. + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + builds: all build-include: linux* build-exclude: *; Only supports Linux. EOO -- cgit v1.1