aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/build-config-module.hxx25
-rw-r--r--mod/mod-builds.cxx39
-rw-r--r--mod/mod-package-version-details.cxx82
3 files changed, 104 insertions, 42 deletions
diff --git a/mod/build-config-module.hxx b/mod/build-config-module.hxx
index 0b5b4d0..3ad1a83 100644
--- a/mod/build-config-module.hxx
+++ b/mod/build-config-module.hxx
@@ -77,6 +77,31 @@ namespace brep
static path
dash_components_to_path (const string&);
+ // Configuration/toolchain combination that, in particular, can be used as
+ // a set value.
+ //
+ // Note: contains shallow references to the configuration, toolchain name,
+ // and version.
+ //
+ struct config_toolchain
+ {
+ const string& configuration;
+ const string& toolchain_name;
+ const bpkg::version& toolchain_version;
+
+ bool
+ operator< (const config_toolchain& ct) const
+ {
+ if (int r = toolchain_name.compare (ct.toolchain_name))
+ return r < 0;
+
+ if (toolchain_version != ct.toolchain_version)
+ return toolchain_version > ct.toolchain_version;
+
+ return configuration.compare (ct.configuration) < 0;
+ }
+ };
+
protected:
// Build configurations.
//
diff --git a/mod/mod-builds.cxx b/mod/mod-builds.cxx
index ffb192b..30a18a6 100644
--- a/mod/mod-builds.cxx
+++ b/mod/mod-builds.cxx
@@ -358,7 +358,8 @@ handle (request& rq, response& rs)
for (auto& t: build_db_->query<toolchain> (
(tn ? query::build::id.package.tenant == *tn : query (true)) +
"ORDER BY" + query::build::id.toolchain_name +
- order_by_version_desc (query::build::id.toolchain_version, false)))
+ order_by_version_desc (query::build::id.toolchain_version,
+ false /* first */)))
r.emplace_back (move (t.name), move (t.version));
return r;
@@ -612,8 +613,8 @@ handle (request& rq, response& rs)
string ts (butl::to_string (b.timestamp,
"%Y-%m-%d %H:%M:%S %Z",
- true,
- true) +
+ true /* special */,
+ true /* local */) +
" (" + butl::to_string (now - b.timestamp, false) + " ago)");
s << TABLE(CLASS="proplist build")
@@ -657,27 +658,6 @@ handle (request& rq, response& rs)
//
toolchains toolchains;
- struct config_toolchain
- {
- const string& configuration;
- const string& toolchain_name;
- const version& toolchain_version;
-
- bool
- operator< (const config_toolchain& ct) const
- {
- int r (configuration.compare (ct.configuration));
- if (r != 0)
- return r < 0;
-
- r = toolchain_name.compare (ct.toolchain_name);
- if (r != 0)
- return r < 0;
-
- return toolchain_version > ct.toolchain_version;
- }
- };
-
// Note that config_toolchains contains shallow references to the
// toolchain names and versions.
//
@@ -841,9 +821,9 @@ handle (request& rq, response& rs)
// 1: package name
// 2: package version (descending)
// 3: package tenant
- // 4: configuration name
- // 5: toolchain name
- // 6: toolchain version (descending)
+ // 4: toolchain name
+ // 5: toolchain version (descending)
+ // 6: configuration name
//
// Prepare the build package prepared query.
//
@@ -872,8 +852,9 @@ handle (request& rq, response& rs)
pq += "ORDER BY" +
pkg_query::build_package::id.name +
- order_by_version_desc (pkg_query::build_package::id.version, false) +
- "," + pkg_query::build_package::id.tenant +
+ order_by_version_desc (pkg_query::build_package::id.version,
+ false /* first */) + "," +
+ pkg_query::build_package::id.tenant +
"OFFSET" + pkg_query::_ref (offset) + "LIMIT 50";
connection_ptr conn (build_db_->connection ());
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index 8680f00..1c7fac4 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -419,17 +419,49 @@ handle (request& rq, response& rs)
timestamp now (system_clock::now ());
transaction t (build_db_->begin ());
- // Print built package configurations, except those that are hidden or
- // excluded by the package.
+ // Print built and unbuilt package configurations, except those that are
+ // hidden or excluded by the package.
+ //
+ // Query toolchains seen for the package tenant.
+ //
+ vector<pair<string, version>> toolchains;
+ {
+ using query = query<toolchain>;
+
+ for (auto& t: build_db_->query<toolchain> (
+ (!tenant.empty ()
+ ? query::build::id.package.tenant == tenant
+ : query (true)) +
+ "ORDER BY" + query::build::id.toolchain_name +
+ order_by_version_desc (query::build::id.toolchain_version,
+ false /* first */)))
+ toolchains.emplace_back (move (t.name), move (t.version));
+ }
+
+ // Collect configuration names and unbuilt configurations, skipping those
+ // that are hidden or excluded by the package.
//
cstrings conf_names;
+ set<config_toolchain> unbuilt_configs;
for (const auto& c: *build_conf_map_)
{
- if (belongs (*c.second, "all"))
+ const build_config& cfg (*c.second);
+
+ if (belongs (cfg, "all") && !exclude (cfg))
+ {
conf_names.push_back (c.first);
+
+ // Note: we will erase built configurations from the unbuilt
+ // configurations set later (see below).
+ //
+ for (const auto& t: toolchains)
+ unbuilt_configs.insert ({cfg.name, t.first, t.second});
+ }
}
+ // Print the package built configurations in the time-descending order.
+ //
using query = query<build>;
for (auto& b: build_db_->query<build> (
@@ -440,18 +472,10 @@ handle (request& rq, response& rs)
"ORDER BY" + query::timestamp + "DESC"))
{
- auto i (build_conf_map_->find (b.configuration.c_str ()));
- assert (i != build_conf_map_->end ());
-
- const build_config& cfg (*i->second);
-
- if (exclude (cfg))
- continue;
-
string ts (butl::to_string (b.timestamp,
"%Y-%m-%d %H:%M:%S %Z",
- true,
- true) +
+ true /* special */,
+ true /* local */) +
" (" + butl::to_string (now - b.timestamp, false) + " ago)");
if (b.state == build_state::built)
@@ -468,6 +492,38 @@ handle (request& rq, response& rs)
<< TR_BUILD_RESULT (b, host, root)
<< ~TBODY
<< ~TABLE;
+
+ // While at it, erase the built configuration from the unbuilt
+ // configurations set.
+ //
+ unbuilt_configs.erase ({b.id.configuration,
+ b.toolchain_name,
+ b.toolchain_version});
+ }
+
+ // Print the package unbuilt configurations with the following sort
+ // priority:
+ //
+ // 1: toolchain name
+ // 2: toolchain version (descending)
+ // 3: configuration name
+ //
+ for (const auto& ct: unbuilt_configs)
+ {
+ auto i (build_conf_map_->find (ct.configuration.c_str ()));
+ assert (i != build_conf_map_->end ());
+
+ s << TABLE(CLASS="proplist build")
+ << TBODY
+ << TR_VALUE ("toolchain",
+ ct.toolchain_name + '-' +
+ ct.toolchain_version.string ())
+ << TR_VALUE ("config",
+ ct.configuration + " / " +
+ i->second->target.string ())
+ << TR_VALUE ("result", "unbuilt")
+ << ~TBODY
+ << ~TABLE;
}
// Print the package build exclusions that belong to the 'default' class.