aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-09-06 19:22:56 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-09-24 11:37:05 +0300
commit28de3ed8416c20ab54527e5cc8a48c46de3bb9b5 (patch)
tree70d8b5843ab0d990f03cb6277ad340b797d4a17c
parenta9b630f95ba352430f1f25d25b538672fddce93c (diff)
Add support for requires, tests, examples, benchmarks, and host task manifest values
-rw-r--r--libbrep/build-extra.sql50
-rw-r--r--libbrep/build-package.hxx49
-rw-r--r--libbrep/build.hxx15
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/common.hxx28
-rw-r--r--libbrep/package.hxx31
-rw-r--r--mod/mod-build-task.cxx13
-rw-r--r--tests/load/1/math/libfoo-1.2.4+1.tar.gzbin1032 -> 1033 bytes
-rw-r--r--tests/load/1/math/packages.manifest3
-rw-r--r--tests/load/driver.cxx6
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 <odb/core.hxx>
+#include <odb/nested-container.hxx>
#include <libbrep/types.hxx>
#include <libbrep/utility.hxx>
@@ -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<version_constraint> constraint;
+
lazy_shared_ptr<build_package> 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<build_test_dependency, 1> tests;
lazy_shared_ptr<build_repository> 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 <libbutl/target-triplet.mxx>
-#include <libbbot/manifest.hxx>
-
#include <libbrep/types.hxx>
#include <libbrep/utility.hxx>
-// Must be included last (see assert in libbrep/common.hxx).
-//
#include <libbrep/common.hxx>
#include <libbrep/build-package.hxx>
+// 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 <libbbot/manifest.hxx>
+
// 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 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="14"/>
+
<changeset version="13">
<alter-table name="build">
<add-column name="interactive" type="TEXT" null="true"/>
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 <type_traits> // static_assert
#include <odb/query.hxx>
+#include <odb/nested-container.hxx>
#include <libbpkg/package-name.hxx>
@@ -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<requirement_alternatives>;
+
+ #pragma db value(requirement_alternatives) definition
+
+ using requirement_key = odb::nested_key<requirement_alternatives>;
+ using requirement_alternatives_map = std::map<requirement_key, string>;
+
+ #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<dependency_alternatives>;
- // requirements
- //
- using bpkg::requirement_alternatives;
- using requirements = vector<requirement_alternatives>;
-
- #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<email_type> build_warning_email;
optional<email_type> build_error_email;
dependencies_type dependencies;
- requirements_type requirements;
+ requirements_type requirements; // Note: foreign-mapped in build.
small_vector<test_dependency, 1> 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<requirement_alternatives>;
- 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<package, 1> tes;
+ small_vector<bpkg::test_dependency, 1> 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
--- a/tests/load/1/math/libfoo-1.2.4+1.tar.gz
+++ b/tests/load/1/math/libfoo-1.2.4+1.tar.gz
Binary files 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);