aboutsummaryrefslogtreecommitdiff
path: root/libbrep/build-package.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbrep/build-package.hxx')
-rw-r--r--libbrep/build-package.hxx182
1 files changed, 160 insertions, 22 deletions
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 6ca8702..9a9c277 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/section.hxx>
#include <odb/nested-container.hxx>
#include <libbrep/types.hxx>
@@ -22,9 +23,11 @@ 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 a subset of the tenant object.
//
+ // Note: table created manually thus assign table name explicitly.
+ //
#pragma db object table("build_tenant") pointer(shared_ptr)
class build_tenant
{
@@ -34,6 +37,9 @@ namespace brep
bool private_;
optional<string> interactive;
bool archived;
+ optional<tenant_service> service;
+ optional<timestamp> queued_timestamp;
+ optional<build_toolchain> toolchain;
// Database mapping.
//
@@ -46,6 +52,8 @@ namespace brep
// Foreign object that is mapped to a subset of the repository object.
//
+ // Note: table created manually thus assign table name explicitly.
+ //
#pragma db object table("build_repository") pointer(shared_ptr) readonly
class build_repository
{
@@ -71,6 +79,54 @@ namespace brep
build_repository (): canonical_name (id.canonical_name) {}
};
+ // Foreign object that is mapped to a subset of the public key object.
+ //
+ // Note: table created manually thus assign table name explicitly.
+ //
+ #pragma db object table("build_public_key") pointer(shared_ptr) readonly
+ class build_public_key: public string
+ {
+ public:
+ public_key_id id;
+
+ // Database mapping.
+ //
+ #pragma db member(id) id column("")
+
+ #pragma db member(data) virtual(string) access(this)
+
+ private:
+ friend class odb::access;
+ build_public_key () = default;
+ };
+
+ // build_package_config
+ //
+ using build_package_config =
+ build_package_config_template<lazy_shared_ptr<build_public_key>>;
+
+ using build_package_configs =
+ build_package_configs_template<lazy_shared_ptr<build_public_key>>;
+
+ #pragma db value(build_package_config) definition
+
+ #pragma db member(build_package_config::builds) transient
+ #pragma db member(build_package_config::constraints) transient
+ #pragma db member(build_package_config::auxiliaries) transient
+ #pragma db member(build_package_config::bot_keys) transient
+
+ // build_package_bot_keys
+ //
+ using build_package_bot_keys = vector<lazy_shared_ptr<build_public_key>>;
+ using build_package_bot_key_key = odb::nested_key<build_package_bot_keys>;
+
+ using build_package_bot_keys_map =
+ std::map<build_package_bot_key_key, lazy_shared_ptr<build_public_key>>;
+
+ #pragma db value(build_package_bot_key_key)
+ #pragma db member(build_package_bot_key_key::outer) column("config_index")
+ #pragma db member(build_package_bot_key_key::inner) column("index")
+
// Forward declarations.
//
class build_package;
@@ -97,11 +153,14 @@ namespace brep
{
test_dependency_type type;
bool buildtime;
+ optional<string> enable;
optional<string> reflect;
};
// Foreign object that is mapped to a subset of the package object.
//
+ // Note: table created manually thus assign table name explicitly.
+ //
#pragma db object table("build_package") pointer(shared_ptr) readonly session
class build_package
{
@@ -111,21 +170,42 @@ namespace brep
package_id id;
upstream_version version;
+ package_name project;
+
+ optional<email> build_email;
+ optional<email> build_warning_email;
+ optional<email> build_error_email;
+
// 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;
+ odb::section requirements_tests_section;
+
lazy_shared_ptr<build_repository> internal_repository;
bool buildable;
+ optional<bool> custom_bot;
- // Mapped to the package object builds, build_constraints, and
- // build_configs members using the PostgreSQL foreign table mechanism.
+ // Mapped to the package object builds, build_constraints,
+ // build_auxiliaries, bot_keys, and build_configs members using the
+ // PostgreSQL foreign table mechanism.
//
- build_class_exprs builds;
- build_constraints constraints;
- build_package_configs configs;
+ build_class_exprs builds;
+ build_constraints constraints;
+ build_auxiliaries auxiliaries;
+ build_package_bot_keys bot_keys;
+ build_package_configs configs;
+
+ // Group the builds/constraints, auxiliaries, and bot_keys members of this
+ // object together with their respective nested configs entries into the
+ // separate sections for an explicit load. Note that the configs top-level
+ // members are loaded implicitly.
+ //
+ odb::section constraints_section;
+ odb::section auxiliaries_section;
+ odb::section bot_keys_section;
bool
internal () const noexcept {return internal_repository != nullptr;}
@@ -143,7 +223,8 @@ namespace brep
// Container of the requirement_alternatives values.
//
- #pragma db member(requirements) id_column("") value_column("")
+ #pragma db member(requirements) id_column("") value_column("") \
+ section(requirements_tests_section)
// Container of the requirement_alternative values.
//
@@ -152,7 +233,8 @@ namespace brep
after(requirements) \
get(odb::nested_get (this.requirements)) \
set(odb::nested_set (this.requirements, std::move (?))) \
- id_column("") key_column("") value_column("")
+ id_column("") key_column("") value_column("") \
+ section(requirements_tests_section)
// Container of the requirement (string) values.
//
@@ -161,19 +243,35 @@ namespace brep
after(requirement_alternatives) \
get(odb::nested2_get (this.requirements)) \
set(odb::nested2_set (this.requirements, std::move (?))) \
- id_column("") key_column("") value_column("id")
+ id_column("") key_column("") value_column("id") \
+ section(requirements_tests_section)
+
+ // tests
+ //
+ #pragma db member(tests) id_column("") value_column("test_") \
+ section(requirements_tests_section)
- // tests, builds, and constraints
+ #pragma db member(requirements_tests_section) load(lazy) update(always)
+
+ // builds, constraints, auxiliaries, and bot_keys
//
- #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("")
+ #pragma db member(builds) id_column("") value_column("") \
+ section(constraints_section)
+
+ #pragma db member(constraints) id_column("") value_column("") \
+ section(constraints_section)
+
+ #pragma db member(auxiliaries) id_column("") value_column("") \
+ section(auxiliaries_section)
+
+ #pragma db member(bot_keys) id_column("") value_column("key_") \
+ section(bot_keys_section)
// configs
//
- // Note that build_package_config::{builds,constraints} are
- // persisted/loaded via the separate nested containers (see commons.hxx
- // for details).
+ // Note that build_package_config::{builds,constraints,auxiliaries,bot_keys}
+ // are persisted/loaded via the separate nested containers (see
+ // commons.hxx for details).
//
#pragma db member(configs) id_column("") value_column("config_")
@@ -185,7 +283,8 @@ namespace brep
set(brep::build_package_config_builds bs; \
odb::nested_set (bs, std::move (?)); \
move (bs).to_configs (this.configs)) \
- id_column("") key_column("") value_column("")
+ id_column("") key_column("") value_column("") \
+ section(constraints_section)
#pragma db member(config_constraints) \
virtual(build_constraints_map) \
@@ -195,13 +294,53 @@ namespace brep
set(brep::build_package_config_constraints cs; \
odb::nested_set (cs, std::move (?)); \
move (cs).to_configs (this.configs)) \
- id_column("") key_column("") value_column("")
+ id_column("") key_column("") value_column("") \
+ section(constraints_section)
+
+ #pragma db member(config_auxiliaries) \
+ virtual(build_auxiliaries_map) \
+ after(config_constraints) \
+ get(odb::nested_get ( \
+ brep::build_package_config_auxiliaries (this.configs))) \
+ set(brep::build_package_config_auxiliaries as; \
+ odb::nested_set (as, std::move (?)); \
+ move (as).to_configs (this.configs)) \
+ id_column("") key_column("") value_column("") \
+ section(auxiliaries_section)
+
+ #pragma db member(config_bot_keys) \
+ virtual(build_package_bot_keys_map) \
+ after(config_auxiliaries) \
+ get(odb::nested_get ( \
+ brep::build_package_config_bot_keys< \
+ lazy_shared_ptr<brep::build_public_key>> (this.configs))) \
+ set(brep::build_package_config_bot_keys< \
+ lazy_shared_ptr<brep::build_public_key>> bks; \
+ odb::nested_set (bks, std::move (?)); \
+ move (bks).to_configs (this.configs)) \
+ id_column("") key_column("") value_column("key_") \
+ section(bot_keys_section)
+
+ #pragma db member(constraints_section) load(lazy) update(always)
+ #pragma db member(auxiliaries_section) load(lazy) update(always)
+ #pragma db member(bot_keys_section) load(lazy) update(always)
private:
friend class odb::access;
build_package () = default;
};
+ #pragma db view object(build_package)
+ struct build_package_version
+ {
+ package_id id;
+ upstream_version version;
+
+ // Database mapping.
+ //
+ #pragma db member(version) set(this.version.init (this.id.version, (?)))
+ };
+
// Packages that can potentially be built.
//
// Note that ADL can't find the equal operator, so we use the function call
@@ -216,14 +355,13 @@ namespace brep
object(build_tenant: build_package::id.tenant == build_tenant::id)
struct buildable_package
{
- package_id id;
- upstream_version version;
+ shared_ptr<build_package> package;
bool archived; // True if the tenant the package belongs to is archived.
- // Database mapping.
+ // Present if the tenant the package belongs to is interactive.
//
- #pragma db member(version) set(this.version.init (this.id.version, (?)))
+ optional<string> interactive;
};
#pragma db view \