From 36115f92a7fdebaf13cb968b1acfe3c9973c0df4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 21 Dec 2021 21:37:02 +0300 Subject: Adapt to package manifest requirement classes change --- libbrep/build-extra.sql | 4 +-- libbrep/build.hxx | 2 +- libbrep/build.xml | 2 ++ libbrep/package.hxx | 2 +- libbrep/package.xml | 9 ++++++ mod/mod-package-version-details.cxx | 45 ++++++++++++++++++++------- mod/page.cxx | 34 +++++++++++++-------- tests/load/1/math/libfoo-1.2.4+1.tar.gz | Bin 1061 -> 1142 bytes tests/load/1/math/packages.manifest | 10 ++++-- tests/load/driver.cxx | 52 +++++++++++++++----------------- 10 files changed, 102 insertions(+), 58 deletions(-) diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql index a8464cf..a2960ba 100644 --- a/libbrep/build-extra.sql +++ b/libbrep/build-extra.sql @@ -70,7 +70,6 @@ CREATE FOREIGN TABLE build_package_requirements ( version_canonical_release TEXT NOT NULL COLLATE "C", version_revision INTEGER NOT NULL, index BIGINT NOT NULL, - conditional BOOLEAN NOT NULL, buildtime BOOLEAN NOT NULL, comment TEXT NOT NULL) SERVER package_server OPTIONS (table_name 'package_requirements'); @@ -84,7 +83,8 @@ CREATE FOREIGN TABLE build_package_requirement_alternatives ( version_revision INTEGER NOT NULL, requirement_index BIGINT NOT NULL, index BIGINT NOT NULL, - enable TEXT NULL) + enable TEXT NULL, + reflect TEXT NULL) SERVER package_server OPTIONS (table_name 'package_requirement_alternatives'); CREATE FOREIGN TABLE build_package_requirement_alternative_requirements ( diff --git a/libbrep/build.hxx b/libbrep/build.hxx index de12a70..968a91f 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -30,7 +30,7 @@ // #define LIBBREP_BUILD_SCHEMA_VERSION_BASE 15 -#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 16, closed) +#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 17, closed) // We have to keep these mappings at the global scope instead of inside // the brep namespace because they need to be also effective in the diff --git a/libbrep/build.xml b/libbrep/build.xml index d90f871..92b83af 100644 --- a/libbrep/build.xml +++ b/libbrep/build.xml @@ -1,4 +1,6 @@ + + diff --git a/libbrep/package.hxx b/libbrep/package.hxx index 7c214f7..46e5292 100644 --- a/libbrep/package.hxx +++ b/libbrep/package.hxx @@ -20,7 +20,7 @@ // #define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 21 -#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 22, closed) +#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 23, closed) namespace brep { diff --git a/libbrep/package.xml b/libbrep/package.xml index 956e5d2..72e9c83 100644 --- a/libbrep/package.xml +++ b/libbrep/package.xml @@ -1,4 +1,13 @@ + + + + + + + + + diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index e271c45..f1a641b 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -362,32 +362,55 @@ handle (request& rq, response& rs) << TABLE(CLASS="proplist", ID="requires") << TBODY; - for (const auto& ras: rm) + for (const requirement_alternatives& ras: rm) { s << TR(CLASS="requires") << TH; - if (ras.conditional) - s << "?"; - if (ras.buildtime) - s << "*"; - - if (ras.conditional || ras.buildtime) - s << " "; + s << '*'; s << ~TH << TD << SPAN(CLASS="value"); - for (const auto& ra: ras) + for (const requirement_alternative& ra: ras) { if (&ra != &ras[0]) s << " | "; - assert (ra.size () == 1); // @@ DEP + // Should we enclose multiple requirement ids into curly braces as in + // the manifest? Somehow feels redundant here, since there can't be + // any ambiguity (requirement group version constraint is already + // punched into the specific requirements without constraints). + // + for (const string& r: ra) + { + if (&r != &ra[0]) + s << ' '; + + s << r; + } - s << ra[0]; + if (ra.enable) + { + if (!ra.simple () || !ra[0].empty ()) + s << ' '; + + s << '?'; + + if (!ra.enable->empty ()) + { + s << " ("; + + if (full) + s << *ra.enable; + else + s << "..."; + + s << ')'; + } + } } s << ~SPAN diff --git a/mod/page.cxx b/mod/page.cxx index fb6ba90..8d315e9 100644 --- a/mod/page.cxx +++ b/mod/page.cxx @@ -520,20 +520,20 @@ namespace brep if (&ras != &requirements_[0]) s << ", "; - if (ras.conditional) - s << "?"; - if (ras.buildtime) - s << "*"; + s << '*'; - if (ras.empty ()) + // If this is a simple requirement without id, then print the comment + // first word. + // + if (ras.simple () && ras[0][0].empty ()) { - // If there is no requirement alternatives specified, then print the - // comment first word. - // const auto& c (ras.comment); if (!c.empty ()) { + if (ras[0].enable) + s << "? "; + auto n (c.find (' ')); s << string (c, 0, n); @@ -543,23 +543,31 @@ namespace brep } else { - bool mult (ras.size () > 1); + bool mult (ras.size () > 1 || + (ras.size () == 1 && ras[0].size () > 1)); if (mult) - s << "("; + s << '('; for (const auto& ra: ras) { if (&ra != &ras[0]) s << " | "; - assert (ra.size () == 1); // @@ DEP + for (const string& r: ra) + { + if (&r != &ra[0]) + s << ' '; + + s << r; + } - s << ra[0]; + if (ra.enable) + s << " ?"; } if (mult) - s << ")"; + s << ')'; } } diff --git a/tests/load/1/math/libfoo-1.2.4+1.tar.gz b/tests/load/1/math/libfoo-1.2.4+1.tar.gz index c678acf..a52548c 100644 Binary files a/tests/load/1/math/libfoo-1.2.4+1.tar.gz and b/tests/load/1/math/libfoo-1.2.4+1.tar.gz differ diff --git a/tests/load/1/math/packages.manifest b/tests/load/1/math/packages.manifest index aa09eec..882aff6 100644 --- a/tests/load/1/math/packages.manifest +++ b/tests/load/1/math/packages.manifest @@ -75,17 +75,21 @@ email: foo-users@example.com; Public mailing list. Read FAQ before posting. package-email: pack@example.com; Current packager. depends: libmisc < 1.1 | libmisc > 2.3.0+0; Crashes with 1.1.0-2.3.0. depends: libexp >= 1.0 -depends: ? libstudxml | libexpat; The newer the better. +depends: libstudxml ? ($cxx.target.class == 'windows') | libexpat ?\ + ($cxx.target.class != 'windows'); The newer the better. requires: linux | windows | macosx; Symbian support is coming. requires: c++11 requires: ? ; libc++ standard library if using Clang on Mac OS X. -requires: ? vc++ >= 12.0; Only if using VC++ on Windows. +requires: ; X11 libs. +requires: ? ($windows); Only 64-bit. +requires: x86_64 ? ; Only if on Windows. +requires: * vc++ >= 12.0 ? (windows); Only if using VC++ on Windows. requires: host tests: * libfoo-tests == 1.2.4 examples: libfoo-examples benchmarks: libfoo-benchmarks > 0.0.1 location: libfoo-1.2.4+1.tar.gz -sha256sum: f99cb46b97d0e1dccbdd10571f1f649ac5bbb22d6c25adadbc579ffbbb89d31c +sha256sum: d23a7ff116ab7264c3d423af97e4830bdaa8c9101cd95b210b19a97bb8512b74 : name: libfoo-benchmarks version: 1.2.4 diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx index bc51c8d..727f054 100644 --- a/tests/load/driver.cxx +++ b/tests/load/driver.cxx @@ -34,21 +34,6 @@ using labels = small_vector; static const path packages ("packages.manifest"); static const path repositories ("repositories.manifest"); -static requirement_alternatives -req_alts (const strings& ras) -{ - requirement_alternatives r; - for (const string& s: ras) - { - requirement_alternative ra; - ra.push_back (s); - - r.push_back (move (ra)); - } - - return r; -} - static bool check_location (shared_ptr& p) { @@ -822,31 +807,44 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->dependencies[2][1][0] == dep ("libexpat", nullopt)); requirements& fpvr5 (fpv5->requirements); - assert (fpvr5.size () == 5); + assert (fpvr5.size () == 8); - assert (fpvr5[0] == req_alts ({"linux", "windows", "macosx"})); - assert (!fpvr5[0].conditional); + assert (fpvr5[0][0][0] == "linux"); + assert (fpvr5[0][1][0] == "windows"); + assert (fpvr5[0][2][0] == "macosx"); assert (fpvr5[0].comment == "Symbian support is coming."); - assert (fpvr5[1] == req_alts ({"c++11"})); - assert (!fpvr5[1].conditional); + assert (fpvr5[1][0][0] == "c++11"); assert (fpvr5[1].comment.empty ()); - assert (fpvr5[2].empty ()); - assert (fpvr5[2].conditional); + assert (fpvr5[2][0][0] == ""); + assert (fpvr5[2][0].enable && *fpvr5[2][0].enable == ""); assert (fpvr5[2].comment == "libc++ standard library if using Clang on Mac OS X."); - assert (fpvr5[3] == req_alts ({"vc++ >= 12.0"})); - assert (fpvr5[3].conditional); - assert (fpvr5[3].comment == "Only if using VC++ on Windows."); + assert (fpvr5[3][0][0] == ""); + assert (!fpvr5[3][0].enable); + assert (fpvr5[3].comment == "X11 libs."); + + assert (fpvr5[4][0][0] == ""); + assert (fpvr5[4][0].enable && *fpvr5[4][0].enable == "$windows"); + assert (fpvr5[4].comment == "Only 64-bit."); + + assert (fpvr5[5][0][0] == "x86_64"); + assert (fpvr5[5][0].enable && *fpvr5[5][0].enable == ""); + assert (fpvr5[5].comment == "Only if on Windows."); + + assert (fpvr5[6][0][0] == "vc++ >= 12.0"); + assert (fpvr5[6][0].enable && *fpvr5[6][0].enable == "windows"); + assert (fpvr5[6].buildtime); + assert (fpvr5[6].comment == "Only if using VC++ on Windows."); - assert (fpvr5[4][0][0] == "host"); + assert (fpvr5[7][0][0] == "host"); assert (check_location (fpv5)); assert (fpv5->sha256sum && *fpv5->sha256sum == - "f99cb46b97d0e1dccbdd10571f1f649ac5bbb22d6c25adadbc579ffbbb89d31c"); + "d23a7ff116ab7264c3d423af97e4830bdaa8c9101cd95b210b19a97bb8512b74"); assert (fpv5->buildable); -- cgit v1.1