From 22059500a799d788c09171e31b668ab8259ec057 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 17 Nov 2018 23:41:25 +0300 Subject: Add support for builds manifest value --- libbrep/build-extra.sql | 21 ++++++++++++++++++++- libbrep/build-package.hxx | 46 +++++++++------------------------------------- libbrep/build.hxx | 2 +- libbrep/build.xml | 2 ++ libbrep/common.hxx | 21 +++++++++++++++++++++ libbrep/package.cxx | 2 ++ libbrep/package.hxx | 16 ++++++++-------- libbrep/package.xml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 110 insertions(+), 47 deletions(-) (limited to 'libbrep') diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql index 6c0d6ef..1ada713 100644 --- a/libbrep/build-extra.sql +++ b/libbrep/build-extra.sql @@ -8,6 +8,8 @@ DROP FOREIGN TABLE IF EXISTS build_package_constraints; +DROP FOREIGN TABLE IF EXISTS build_package_builds; + DROP FOREIGN TABLE IF EXISTS build_package; DROP FOREIGN TABLE IF EXISTS build_repository; @@ -49,6 +51,22 @@ CREATE FOREIGN TABLE build_package ( internal_repository_canonical_name TEXT NULL) SERVER package_server OPTIONS (table_name 'package'); +-- The foreign table for the build_package object builds member (that is of a +-- container type). +-- +-- +CREATE FOREIGN TABLE build_package_builds ( + 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, + expression TEXT NOT NULL, + comment TEXT NOT NULL) +SERVER package_server OPTIONS (table_name 'package_builds'); + -- The foreign table for the build_package object constraints member (that is -- of a container type). -- @@ -63,5 +81,6 @@ CREATE FOREIGN TABLE build_package_constraints ( index BIGINT NOT NULL, exclusion BOOLEAN NOT NULL, config TEXT NOT NULL, - target TEXT NULL) + target TEXT NULL, + comment TEXT NOT NULL) SERVER package_server OPTIONS (table_name 'package_build_constraints'); diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx index 0d6b5bf..4294106 100644 --- a/libbrep/build-package.hxx +++ b/libbrep/build-package.hxx @@ -69,17 +69,6 @@ namespace brep build_repository (): canonical_name (id.canonical_name) {} }; - // "Foreign" value type that is mapped to a subset of the build_constraint - // value type (see libbpkg/manifest.hxx for details). - // - #pragma db value - struct build_constraint_subset - { - bool exclusion; - string config; - optional target; - }; - // Foreign object that is mapped to a subset of the package object. // #pragma db object table("build_package") pointer(shared_ptr) readonly @@ -90,15 +79,21 @@ namespace brep upstream_version version; lazy_shared_ptr internal_repository; - // Mapped to a subset of the package object build_constraints member - // using the PostgreSQL foreign table mechanism. + // Mapped to the package object builds member using the PostgreSQL foreign + // table mechanism. + // + build_class_exprs builds; + + // Mapped to the package object build_constraints member using the + // PostgreSQL foreign table mechanism. // - vector constraints; + build_constraints constraints; // Database mapping. // #pragma db member(id) id column("") #pragma db member(version) set(this.version.init (this.id.version, (?))) + #pragma db member(builds) id_column("") value_column("") #pragma db member(constraints) id_column("") value_column("") private: @@ -149,29 +144,6 @@ namespace brep // #pragma db member(result) column("count(" + build_package::id.name + ")") }; - - // Packages that have the build constraints. Note that only buildable - // (internal and non-stub) packages can have such constraints, so there is - // no need for additional checks. - // - #pragma db view \ - table("build_package_constraints" = "c") \ - object(build_package inner: \ - "c.exclusion AND " \ - "c.tenant = " + build_package::id.tenant + "AND" + \ - "c.name = " + build_package::id.name + "AND" + \ - "c.version_epoch = " + build_package::id.version.epoch + "AND" + \ - "c.version_canonical_upstream = " + \ - build_package::id.version.canonical_upstream + "AND" + \ - "c.version_canonical_release = " + \ - build_package::id.version.canonical_release + "AND" + \ - "c.version_revision = " + build_package::id.version.revision) \ - object(build_tenant: build_package::id.tenant == build_tenant::id) \ - query(distinct) - struct build_constrained_package - { - shared_ptr package; - }; } #endif // LIBBREP_BUILD_PACKAGE_HXX diff --git a/libbrep/build.hxx b/libbrep/build.hxx index 279c1d7..03807fa 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -26,7 +26,7 @@ // #define LIBBREP_BUILD_SCHEMA_VERSION_BASE 4 -#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 5, open) +#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 6, open) // 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 13b47a6..434eac2 100644 --- a/libbrep/build.xml +++ b/libbrep/build.xml @@ -1,4 +1,6 @@ + + diff --git a/libbrep/common.hxx b/libbrep/common.hxx index b9adee8..b2e2052 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -267,6 +267,27 @@ namespace brep : tenant (move (t)), canonical_name (move (n)) {} }; + // build_class_expr + // + using bpkg::build_class_expr; + using build_class_exprs = vector; + + #pragma db value(build_class_expr) definition + + #pragma db member(build_class_expr::expr) transient + #pragma db member(build_class_expr::underlying_classes) transient + + #pragma db member(build_class_expr::expression) virtual(string) before \ + get(this.string ()) \ + set(this = brep::build_class_expr ((?), "" /* comment */)) + + // build_constraints + // + using bpkg::build_constraint; + using build_constraints = vector; + + #pragma db value(build_constraint) definition + // Version comparison operators. // // They allow comparing objects that have epoch, canonical_upstream, diff --git a/libbrep/package.cxx b/libbrep/package.cxx index 0a711ba..5b7c716 100644 --- a/libbrep/package.cxx +++ b/libbrep/package.cxx @@ -70,6 +70,7 @@ namespace brep optional bee, dependencies_type dp, requirements_type rq, + build_class_exprs bs, build_constraints_type bc, optional lc, optional fr, @@ -97,6 +98,7 @@ namespace brep build_error_email (move (bee)), dependencies (move (dp)), requirements (move (rq)), + builds (move (bs)), build_constraints (version.compare (wildcard_version, true) != 0 ? move (bc) : build_constraints_type ()), diff --git a/libbrep/package.hxx b/libbrep/package.hxx index 97ea864..73dfd14 100644 --- a/libbrep/package.hxx +++ b/libbrep/package.hxx @@ -21,7 +21,7 @@ // #define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 7 -#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 10, open) +#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 11, open) namespace brep { @@ -164,13 +164,6 @@ namespace brep #pragma db value(requirement_alternatives) definition - // build_constraints - // - using bpkg::build_constraint; - using build_constraints = vector; - - #pragma db value(build_constraint) definition - // certificate // #pragma db value @@ -376,6 +369,7 @@ namespace brep optional build_error_email, dependencies_type, requirements_type, + build_class_exprs, build_constraints_type, optional location, optional fragment, @@ -425,6 +419,7 @@ namespace brep dependencies_type dependencies; requirements_type requirements; + build_class_exprs builds; // Note: foreign-mapped in build. build_constraints_type build_constraints; // Note: foreign-mapped in build. odb::section build_section; @@ -511,6 +506,11 @@ namespace brep set(odb::nested_set (this.requirements, std::move (?))) \ id_column("") key_column("") value_column("id") + // builds + // + #pragma db member(builds) id_column("") value_column("") \ + section(build_section) + // build_constraints // #pragma db member(build_constraints) id_column("") value_column("") \ diff --git a/libbrep/package.xml b/libbrep/package.xml index dff6a47..e90a3a1 100644 --- a/libbrep/package.xml +++ b/libbrep/package.xml @@ -1,4 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1