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 ++++------------------------- 6 files changed, 132 insertions(+), 43 deletions(-) (limited to 'libbrep') 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 (?))) \ -- cgit v1.1