aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-07-07 14:08:34 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-07-07 15:19:59 +0300
commit37af85f5b084c234a350235690eb944984567e78 (patch)
tree8a63a39711e9831e456ebdc1f783c10053805865 /mod
parentb125c5f1ca398d4c912ecfba3bf451bfa63b6293 (diff)
Add odb sections to build_package class
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-build-result.cxx2
-rw-r--r--mod/mod-build-task.cxx107
-rw-r--r--mod/mod-builds.cxx12
3 files changed, 75 insertions, 46 deletions
diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx
index 7806cda..533921b 100644
--- a/mod/mod-build-result.cxx
+++ b/mod/mod-build-result.cxx
@@ -365,6 +365,8 @@ handle (request& rq, response&)
if (const build_package_config* pc = find (b->package_config_name,
p->configs))
{
+ build_db_->load (*p, p->constraints_section);
+
if (!exclude (*pc, p->builds, p->constraints, *tc))
bld = move (b);
}
diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx
index 19907ea..27597cf 100644
--- a/mod/mod-build-task.cxx
+++ b/mod/mod-build-task.cxx
@@ -338,6 +338,8 @@ handle (request& rq, response& rs)
//
small_vector<bpkg::test_dependency, 1> tests;
+ build_db_->load (*p, p->requirements_tests_section);
+
for (const build_test_dependency& td: p->tests)
{
// Don't exclude unresolved external tests.
@@ -366,6 +368,8 @@ handle (request& rq, response& rs)
// the `builds: all` and `builds: -windows` manifest values for
// the primary and external test packages, respectively).
//
+ build_db_->load (*p, p->constraints_section);
+
if (exclude (*pc,
p->builds,
p->constraints,
@@ -1081,14 +1085,17 @@ handle (request& rq, response& rs)
// reason (multiple toolchains, buildtab change, etc). Note that the
// build result will still be accepted for an archived build.
//
- shared_ptr<build_tenant> t (
- build_db_->load<build_tenant> (id.tenant));
-
- if (t->interactive)
+ if (bp.interactive)
{
// Note that the tenant can be archived via some other package on
// some previous iteration. Skip the package if that's the case.
//
+ // Also note that we need to (re-)load the tenant object rather
+ // than to refer to bp.archived.
+ //
+ shared_ptr<build_tenant> t (
+ build_db_->load<build_tenant> (id.tenant));
+
if (t->archived)
continue;
@@ -1112,12 +1119,14 @@ handle (request& rq, response& rs)
// per task request. Given that we archive such tenants
// immediately, as a common case there will be none.
//
- pkg_query pq (pkg_query::build_tenant::id == t->id);
+ pkg_query pq (pkg_query::build_tenant::id == id.tenant);
for (auto& tp: build_db_->query<buildable_package> (pq))
{
shared_ptr<build_package> p (
build_db_->load<build_package> (tp.id));
+ build_db_->load (*p, p->constraints_section);
+
for (build_package_config& pc: p->configs)
{
for (const auto& tc: *target_conf_)
@@ -1219,8 +1228,8 @@ handle (request& rq, response& rs)
for (auto i (pkg_builds.begin ()); i != pkg_builds.end (); ++i)
{
auto j (
- configs.find (build_target_config_id {i->id.target,
- i->id.target_config_name}));
+ configs.find (build_target_config_id {
+ i->id.target, i->id.target_config_name}));
// Outdated configurations are already excluded with the
// database query.
@@ -1245,6 +1254,8 @@ handle (request& rq, response& rs)
auto i (configs.begin ());
auto e (configs.end ());
+ build_db_->load (*p, p->constraints_section);
+
for (;
i != e &&
exclude (pc, p->builds, p->constraints, *i->second.config);
@@ -1459,58 +1470,62 @@ handle (request& rq, response& rs)
p->configs)
: nullptr);
- if (pc != nullptr &&
- p->buildable &&
+ if (pc != nullptr &&
+ p->buildable &&
(imode == interactive_mode::both ||
(t->interactive.has_value () ==
- (imode == interactive_mode::true_))) &&
- !exclude (*pc, p->builds, p->constraints, *cm.config))
+ (imode == interactive_mode::true_))))
{
- assert (b->status);
+ build_db_->load (*p, p->constraints_section);
- b->state = build_state::building;
+ if (!exclude (*pc, p->builds, p->constraints, *cm.config))
+ {
+ assert (b->status);
- // Save the interactive build login information into the build
- // object, if the package to be built interactively.
- //
- // Can't move from, as may need it on the next iteration.
- //
- b->interactive = t->interactive
- ? tqm.interactive_login
- : nullopt;
+ b->state = build_state::building;
- // Can't move from, as may need them on the next iteration.
- //
- b->agent_fingerprint = agent_fp;
- b->agent_challenge = cl;
+ // Save the interactive build login information into the
+ // build object, if the package to be built interactively.
+ //
+ // Can't move from, as may need it on the next iteration.
+ //
+ b->interactive = t->interactive
+ ? tqm.interactive_login
+ : nullopt;
- const machine_header_manifest& mh (*cm.machine);
- b->machine = mh.name;
- b->machine_summary = mh.summary;
+ // Can't move from, as may need them on the next iteration.
+ //
+ b->agent_fingerprint = agent_fp;
+ b->agent_challenge = cl;
- // Issue the hard rebuild if the timeout expired, rebuild is
- // forced, or the configuration or machine has changed.
- //
- // Note that we never reset the build status (see above for
- // the reasoning).
- //
- string ccs (controller_checksum (*cm.config));
- string mcs (machine_checksum (*cm.machine));
+ const machine_header_manifest& mh (*cm.machine);
+ b->machine = mh.name;
+ b->machine_summary = mh.summary;
- if (b->hard_timestamp <= hard_rebuild_expiration ||
- b->force == force_state::forced ||
- b->controller_checksum != ccs ||
- b->machine_checksum != mcs)
- convert_to_hard (b);
+ // Issue the hard rebuild if the timeout expired, rebuild is
+ // forced, or the configuration or machine has changed.
+ //
+ // Note that we never reset the build status (see above for
+ // the reasoning).
+ //
+ string ccs (controller_checksum (*cm.config));
+ string mcs (machine_checksum (*cm.machine));
- b->controller_checksum = move (ccs);
- b->machine_checksum = move (mcs);
+ if (b->hard_timestamp <= hard_rebuild_expiration ||
+ b->force == force_state::forced ||
+ b->controller_checksum != ccs ||
+ b->machine_checksum != mcs)
+ convert_to_hard (b);
+
+ b->controller_checksum = move (ccs);
+ b->machine_checksum = move (mcs);
- b->timestamp = system_clock::now ();
+ b->timestamp = system_clock::now ();
- build_db_->update (b);
+ build_db_->update (b);
- tsm = task (move (b), move (p), move (*pc), move (t), cm);
+ tsm = task (move (b), move (p), move (*pc), move (t), cm);
+ }
}
}
diff --git a/mod/mod-builds.cxx b/mod/mod-builds.cxx
index bad13c1..0c9e57a 100644
--- a/mod/mod-builds.cxx
+++ b/mod/mod-builds.cxx
@@ -624,6 +624,8 @@ handle (request& rq, response& rs)
continue;
}
+ build_db_->load (*p, p->constraints_section);
+
if (!exclude (*pc, p->builds, p->constraints, *i->second))
{
if (skip != 0)
@@ -891,6 +893,8 @@ handle (request& rq, response& rs)
shared_ptr<build_package> p (build_db_->load<build_package> (id));
+ // Note: load the constrains section lazily.
+ //
for (const build_package_config& c: p->configs)
{
// Filter by package config name.
@@ -899,6 +903,9 @@ handle (request& rq, response& rs)
{
for (const auto& tc: target_configs)
{
+ if (!p->constraints_section.loaded ())
+ build_db_->load (*p, p->constraints_section);
+
if (exclude (c, p->builds, p->constraints, *tc))
{
target = tc->target;
@@ -1031,6 +1038,8 @@ handle (request& rq, response& rs)
//
set<config_toolchain> unbuilt_configs;
+ // Load the constrains section lazily.
+ //
for (const build_package_config& pc: bp->configs)
{
// Filter by package config name.
@@ -1045,6 +1054,9 @@ handle (request& rq, response& rs)
assert (i != target_conf_map_->end ());
+ if (!bp->constraints_section.loaded ())
+ build_db_->load (*bp, bp->constraints_section);
+
if (!exclude (pc, bp->builds, bp->constraints, *i->second))
unbuilt_configs.insert (
config_toolchain {ct.target,