From 987bf4a6522e642a1e4dfe276d4fc1efbb2b52b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 19 Aug 2021 21:23:50 +0300 Subject: Add support for build-time mark (*) in tests, examples, and benchmarks package manifest values --- bpkg/package.hxx | 9 +++++---- bpkg/package.xml | 6 ++++++ bpkg/rep-fetch.cxx | 28 +++++++++++++++++++++++++--- doc/manual.cli | 30 ++++++++++++++++++------------ 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/bpkg/package.hxx b/bpkg/package.hxx index cb1a401..14831e0 100644 --- a/bpkg/package.hxx +++ b/bpkg/package.hxx @@ -27,7 +27,7 @@ // #define DB_SCHEMA_VERSION_BASE 6 -#pragma db model version(DB_SCHEMA_VERSION_BASE, 10, closed) +#pragma db model version(DB_SCHEMA_VERSION_BASE, 11, closed) namespace bpkg { @@ -557,10 +557,10 @@ namespace bpkg // Create the special test dependencies object (built incrementally). // - dependency_alternatives_ex (test_dependency_type t) + dependency_alternatives_ex (test_dependency_type t, bool buildtime) : dependency_alternatives (false /* conditional */, - false /* buildtime */, - "" /* comment */), + buildtime, + "" /* comment */), type (t) {} }; @@ -579,6 +579,7 @@ namespace bpkg // tests // #pragma db value(test_dependency) definition + #pragma db member(test_dependency::buildtime) default(false) using optional_test_dependency_type = optional; diff --git a/bpkg/package.xml b/bpkg/package.xml index e5b28c9..96aeed3 100644 --- a/bpkg/package.xml +++ b/bpkg/package.xml @@ -1,4 +1,10 @@ + + + + + + diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx index de6e3b7..7e0d3da 100644 --- a/bpkg/rep-fetch.cxx +++ b/bpkg/rep-fetch.cxx @@ -1448,10 +1448,32 @@ namespace bpkg dependencies& ds (tp->dependencies); if (ds.empty () || !ds.back ().type) - ds.push_back (dependency_alternatives_ex (td.type)); + ds.push_back (dependency_alternatives_ex (td.type, + td.buildtime)); - ds.back ().push_back ( - dependency {p->id.name, version_constraint (p->version)}); + dependency_alternatives_ex& da (ds.back ()); + + // Note that since we store all the primary packages as + // alternative dependencies (which must be all of the same + // dependency type) for the test package, it must either be a + // runtime or build-time dependency for all of them. + // + // Note that the test package alternative dependencies contain the + // `== ` constraints (see below), so we can use min + // version of such a constraint as the primary package version. + // + if (da.buildtime != td.buildtime) + fail << to_string (td.type) << " package " << td.name << " is a " + << "build-time dependency for one primary package and a " + << "run-time for another" << + info << (da.buildtime ? "build-time for " : "run-time for ") + << package_string (da[0].name, + *da[0].constraint->min_version) << + info << (td.buildtime ? "build-time for " : "run-time for ") + << package_string (p->id.name, p->version); + + da.push_back (dependency {p->id.name, + version_constraint (p->version)}); db.update (tp); } diff --git a/doc/manual.cli b/doc/manual.cli index d8c8254..5332281 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -1236,18 +1236,24 @@ msvc[_NU] ; For example: msvc_14, msvc_15u3 \h2#manifest-package-tests-examples-benchmarks|\c{tests, examples, benchmarks}| \ -[tests]: [] -[examples]: [] -[benchmarks]: [] -\ - -Separate tests, examples, and benchmarks packages. These packages are built -and tested by automated build bots together with the primary package (see the -\c{bbot} documentation for details). This, in particular, implies that these -packages must be available from the primary package's repository or its -complement repositories, recursively. The recommended naming convention for -these packages is the primary package name followed by \c{-tests}, -\c{-examples}, or \c{-benchmarks}, respectively. For example: +[tests]: [*] [] +[examples]: [*] [] +[benchmarks]: [*] [] +\ + +Separate tests, examples, and benchmarks packages. If the value starts with +\c{*}, then the primary package is a \i{build-time} prerequisite for the +specified package. Otherwise it is \i{run-time}. See the +\l{#manifest-package-depends \c{depends}} value for details on \i{build-time} +prerequisites. + +These packages are built and tested by automated build bots together with the +primary package (see the \c{bbot} documentation for details). This, in +particular, implies that these packages must be available from the primary +package's repository or its complement repositories, recursively. The +recommended naming convention for these packages is the primary package name +followed by \c{-tests}, \c{-examples}, or \c{-benchmarks}, respectively. For +example: \ name: hello -- cgit v1.1