diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-04-09 19:41:49 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-04-10 14:16:19 +0300 |
commit | bf42edca4c714138b59f429f44368a71a855902f (patch) | |
tree | 9b692243c8910ad52d5d04e1772c2311808dd96d | |
parent | 10b1d816fbea0f7c88fa1e4c56b5d757212fe751 (diff) |
Override build constraints group values hierarchically
-rw-r--r-- | libbpkg/manifest.cxx | 20 | ||||
-rw-r--r-- | libbpkg/manifest.hxx | 4 | ||||
-rw-r--r-- | 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<manifest_name_value>& 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' <<EOI >>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 |