From 28de3ed8416c20ab54527e5cc8a48c46de3bb9b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 6 Sep 2021 19:22:56 +0300 Subject: Add support for requires, tests, examples, benchmarks, and host task manifest values --- libbrep/build-extra.sql | 50 +++++++++++++++++++++++++++++++- libbrep/build-package.hxx | 49 ++++++++++++++++++++++++------- libbrep/build.hxx | 15 ++++++---- libbrep/build.xml | 2 ++ libbrep/common.hxx | 28 ++++++++++++++++++ libbrep/package.hxx | 31 +++----------------- mod/mod-build-task.cxx | 13 +++++++-- tests/load/1/math/libfoo-1.2.4+1.tar.gz | Bin 1032 -> 1033 bytes tests/load/1/math/packages.manifest | 3 +- tests/load/driver.cxx | 6 ++-- 10 files changed, 148 insertions(+), 49 deletions(-) diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql index a0cea97..bd3df2b 100644 --- a/libbrep/build-extra.sql +++ b/libbrep/build-extra.sql @@ -12,6 +12,10 @@ DROP FOREIGN TABLE IF EXISTS build_package_builds; DROP FOREIGN TABLE IF EXISTS build_package_tests; +DROP FOREIGN TABLE IF EXISTS build_package_requirement_alternatives; + +DROP FOREIGN TABLE IF EXISTS build_package_requirements; + DROP FOREIGN TABLE IF EXISTS build_package; DROP FOREIGN TABLE IF EXISTS build_repository; @@ -53,6 +57,34 @@ CREATE FOREIGN TABLE build_package ( buildable BOOLEAN NOT NULL) SERVER package_server OPTIONS (table_name 'package'); +-- The foreign tables for the build_package object requirements member (that +-- is of a 2-dimensional container type). +-- +CREATE FOREIGN TABLE build_package_requirements ( + tenant TEXT NOT NULL, + name CITEXT NOT NULL, + version_epoch INTEGER NOT NULL, + version_canonical_upstream TEXT NOT NULL, + 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'); + +CREATE FOREIGN TABLE build_package_requirement_alternatives ( + tenant TEXT NOT NULL, + name CITEXT NOT NULL, + version_epoch INTEGER NOT NULL, + version_canonical_upstream TEXT NOT NULL, + version_canonical_release TEXT NOT NULL COLLATE "C", + version_revision INTEGER NOT NULL, + requirement_index BIGINT NOT NULL, + index BIGINT NOT NULL, + id TEXT NOT NULL) +SERVER package_server OPTIONS (table_name 'package_requirement_alternatives'); + -- The foreign table for the build_package object tests member (that is of a -- container type). -- @@ -65,12 +97,28 @@ CREATE FOREIGN TABLE build_package_tests ( version_revision INTEGER NOT NULL, index BIGINT NOT NULL, test_name CITEXT NOT NULL, + test_min_version_epoch INTEGER NULL, + test_min_version_canonical_upstream TEXT NULL, + test_min_version_canonical_release TEXT NULL, + test_min_version_revision INTEGER NULL, + test_min_version_upstream TEXT NULL, + test_min_version_release TEXT NULL, + test_max_version_epoch INTEGER NULL, + test_max_version_canonical_upstream TEXT NULL, + test_max_version_canonical_release TEXT NULL, + test_max_version_revision INTEGER NULL, + test_max_version_upstream TEXT NULL, + test_max_version_release TEXT NULL, + test_min_open BOOLEAN NULL, + test_max_open BOOLEAN NULL, test_package_tenant TEXT NULL, test_package_name CITEXT NULL, test_package_version_epoch INTEGER NULL, test_package_version_canonical_upstream TEXT NULL, test_package_version_canonical_release TEXT NULL COLLATE "C", - test_package_version_revision INTEGER NULL) + test_package_version_revision INTEGER NULL, + test_type TEXT NOT NULL, + test_buildtime BOOLEAN NOT NULL) SERVER package_server OPTIONS (table_name 'package_tests'); -- The foreign table for the build_package object builds member (that is of a diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx index 0cfd609..77520d1 100644 --- a/libbrep/build-package.hxx +++ b/libbrep/build-package.hxx @@ -5,6 +5,7 @@ #define LIBBREP_BUILD_PACKAGE_HXX #include +#include #include #include @@ -74,13 +75,28 @@ namespace brep // class build_package; - // Build package external test dependency. + // Build package dependency. // #pragma db value - struct build_test_dependency + struct build_dependency { package_name name; + optional constraint; + lazy_shared_ptr package; + + // Database mapping. + // + #pragma db member(constraint) column("") + }; + + // Build package external test dependency. + // + #pragma db value + struct build_test_dependency: build_dependency + { + test_dependency_type type; + bool buildtime; }; // Foreign object that is mapped to a subset of the package object. @@ -89,25 +105,24 @@ namespace brep class build_package { public: + using requirements_type = brep::requirements; + package_id id; upstream_version version; - // Mapped to the package object tests member using the PostgreSQL foreign - // table mechanism. + // Mapped to the package object requirements and tests members using the + // PostgreSQL foreign table mechanism. // + requirements_type requirements; small_vector tests; lazy_shared_ptr internal_repository; bool buildable; - // Mapped to the package object builds member using the PostgreSQL foreign - // table mechanism. + // Mapped to the package object builds and build_constraints members using + // the PostgreSQL foreign table mechanism. // build_class_exprs builds; - - // Mapped to the package object build_constraints member using the - // PostgreSQL foreign table mechanism. - // build_constraints constraints; bool @@ -117,6 +132,20 @@ namespace brep // #pragma db member(id) id column("") #pragma db member(version) set(this.version.init (this.id.version, (?))) + + // requirements + // + #pragma db member(requirement_key::outer) column("requirement_index") + #pragma db member(requirement_key::inner) column("index") + + #pragma db member(requirements) id_column("") value_column("") + #pragma db member(requirement_alternatives) \ + virtual(requirement_alternatives_map) \ + after(requirements) \ + get(odb::nested_get (this.requirements)) \ + set(odb::nested_set (this.requirements, std::move (?))) \ + id_column("") key_column("") value_column("id") + #pragma db member(tests) id_column("") value_column("test_") #pragma db member(builds) id_column("") value_column("") #pragma db member(constraints) id_column("") value_column("") diff --git a/libbrep/build.hxx b/libbrep/build.hxx index 49105d1..8263b9e 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -11,21 +11,26 @@ #include -#include - #include #include -// Must be included last (see assert in libbrep/common.hxx). -// #include #include +// Must be included after libbrep/common.hxx, so that the _version structure +// get defined before libbpkg/manifest.hxx inclusion. +// +// Note that if we start using assert() in get/set expressions in this header, +// we will have to redefine it for ODB compiler after all include directives +// (see libbrep/common.hxx for details). +// +#include + // Used by the data migration entries. // #define LIBBREP_BUILD_SCHEMA_VERSION_BASE 12 -#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 13, closed) +#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 14, 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 31bb4de..0ca362a 100644 --- a/libbrep/build.xml +++ b/libbrep/build.xml @@ -1,4 +1,6 @@ + + diff --git a/libbrep/common.hxx b/libbrep/common.hxx index 73353c7..0899dc9 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -9,6 +9,7 @@ #include // static_assert #include +#include #include @@ -355,6 +356,33 @@ namespace brep ? brep::to_unbuildable_reason (*(?)) \ : brep::optional_unbuildable_reason ()) \ + // version_constraint + // + using bpkg::version_constraint; + + #pragma db value(version_constraint) definition + + // test_dependency_type + // + using bpkg::test_dependency_type; + using bpkg::to_test_dependency_type; + + #pragma db map type(test_dependency_type) as(string) \ + to(to_string (?)) \ + from(brep::to_test_dependency_type (?)) + + // requirements + // + using bpkg::requirement_alternatives; + using requirements = vector; + + #pragma db value(requirement_alternatives) definition + + using requirement_key = odb::nested_key; + using requirement_alternatives_map = std::map; + + #pragma db value(requirement_key) + // Version comparison operators. // // They allow comparing objects that have epoch, canonical_upstream, diff --git a/libbrep/package.hxx b/libbrep/package.hxx index 85eaec0..67536ce 100644 --- a/libbrep/package.hxx +++ b/libbrep/package.hxx @@ -85,10 +85,6 @@ namespace brep // dependencies // - using bpkg::version_constraint; - - #pragma db value(version_constraint) definition - // Notes: // // 1. Will the package be always resolvable? What if it is in @@ -174,22 +170,8 @@ namespace brep using dependencies = vector; - // requirements - // - using bpkg::requirement_alternatives; - using requirements = vector; - - #pragma db value(requirement_alternatives) definition - // tests // - using bpkg::test_dependency_type; - using bpkg::to_test_dependency_type; - - #pragma db map type(test_dependency_type) as(string) \ - to(to_string (?)) \ - from(brep::to_test_dependency_type (?)) - #pragma db value struct test_dependency: dependency { @@ -500,7 +482,7 @@ namespace brep optional build_warning_email; optional build_error_email; dependencies_type dependencies; - requirements_type requirements; + requirements_type requirements; // Note: foreign-mapped in build. small_vector tests; // Note: foreign-mapped in build. build_class_exprs builds; // Note: foreign-mapped in build. @@ -587,17 +569,12 @@ namespace brep // requirements // - using _requirement_key = odb::nested_key; - using _requirement_alternatives_type = - std::map<_requirement_key, string>; - - #pragma db value(_requirement_key) - #pragma db member(_requirement_key::outer) column("requirement_index") - #pragma db member(_requirement_key::inner) column("index") + #pragma db member(requirement_key::outer) column("requirement_index") + #pragma db member(requirement_key::inner) column("index") #pragma db member(requirements) id_column("") value_column("") #pragma db member(requirement_alternatives) \ - virtual(_requirement_alternatives_type) \ + virtual(requirement_alternatives_map) \ after(requirements) \ get(odb::nested_get (this.requirements)) \ set(odb::nested_set (this.requirements, std::move (?))) \ diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index de75c07..5a7a428 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -234,7 +234,7 @@ handle (request& rq, response& rs) // Exclude external test packages which exclude the task build // configuration. // - small_vector tes; + small_vector tests; for (const build_test_dependency& td: p->tests) { @@ -259,19 +259,26 @@ handle (request& rq, response& rs) *cm.config, nullptr /* reason */, true /* default_all_ucs */)) - tes.push_back (package {move (p->id.name), move (p->version)}); + continue; } + + tests.emplace_back (move (td.name), + td.type, + td.buildtime, + move (td.constraint)); } task_manifest task (move (b->package_name), move (b->package_version), move (r->location), move (fps), - move (tes), + move (p->requirements), + move (tests), cm.machine->name, cm.config->target, cm.config->environment, cm.config->args, + belongs (*cm.config, "host"), cm.config->warning_regexes, move (t->interactive)); 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 bafc657..80a6271 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 335b9d0..7ed9a7d 100644 --- a/tests/load/1/math/packages.manifest +++ b/tests/load/1/math/packages.manifest @@ -79,11 +79,12 @@ 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: 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: 042a9c1df1bf6fc61a47d864dceff3cb68640aa68490174c10f5baf813116fa5 +sha256sum: 6692a487e0908598e36bdeb9c25ed1e4a35bb99587dbc475807d314fa0719ac6 : name: libfoo-benchmarks version: 1.2.4 diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx index 7ebbc93..02ce68a 100644 --- a/tests/load/driver.cxx +++ b/tests/load/driver.cxx @@ -806,7 +806,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->dependencies[2][1] == dep ("libexpat", nullopt)); requirements& fpvr5 (fpv5->requirements); - assert (fpvr5.size () == 4); + assert (fpvr5.size () == 5); assert (fpvr5[0] == req_alts ({"linux", "windows", "macosx"})); assert (!fpvr5[0].conditional); @@ -825,10 +825,12 @@ test_pkg_repos (const cstrings& loader_args, assert (fpvr5[3].conditional); assert (fpvr5[3].comment == "Only if using VC++ on Windows."); + assert (fpvr5[4][0] == "host"); + assert (check_location (fpv5)); assert (fpv5->sha256sum && *fpv5->sha256sum == - "042a9c1df1bf6fc61a47d864dceff3cb68640aa68490174c10f5baf813116fa5"); + "6692a487e0908598e36bdeb9c25ed1e4a35bb99587dbc475807d314fa0719ac6"); assert (fpv5->buildable); -- cgit v1.1