From 4b9be1cb87c4759ca08aa89acd9e9fd7ba5b18be Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 6 Jul 2017 20:28:22 +0300 Subject: Add support for build include/exclude manifest values --- libbrep/build-package.hxx | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'libbrep/build-package.hxx') diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx index 8bc703a..324303d 100644 --- a/libbrep/build-package.hxx +++ b/libbrep/build-package.hxx @@ -23,7 +23,7 @@ namespace brep // The mapping is established in build-extra.sql. We also explicitly mark // non-primary key foreign-mapped members in the source object. // - // Foreign object that is mapped to the subset of repository object. + // Foreign object that is mapped to a subset of repository object. // #pragma db object table("build_repository") pointer(shared_ptr) readonly class build_repository @@ -46,7 +46,18 @@ namespace brep build_repository () = default; }; - // Foreign object that is mapped to the subset of package object. + // "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 package object. // #pragma db object table("build_package") pointer(shared_ptr) readonly class build_package @@ -56,10 +67,16 @@ 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. + // + vector constraints; + // Database mapping. // #pragma db member(id) id column("") #pragma db member(version) set(this.version.init (this.id.version, (?))) + #pragma db member(constraints) id_column("") value_column("") private: friend class odb::access; @@ -102,6 +119,27 @@ 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 = package inner: \ + "c.exclusion AND " \ + "c.name = " + package::id.name + "AND" + \ + "c.version_epoch = " + package::id.version.epoch + "AND" + \ + "c.version_canonical_upstream = " + \ + package::id.version.canonical_upstream + "AND" + \ + "c.version_canonical_release = " + \ + package::id.version.canonical_release + "AND" + \ + "c.version_revision = " + package::id.version.revision) \ + query(distinct) + struct build_constrained_package + { + shared_ptr package; + }; } #endif // LIBBREP_BUILD_PACKAGE_HXX -- cgit v1.1