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 --- mod/mod-package-version-details.cxx | 71 +++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'mod/mod-package-version-details.cxx') diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index fd8d9a1..4da13ab 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -10,6 +10,8 @@ #include #include +#include // alpha(), ucase(), lcase() + #include #include #include @@ -23,6 +25,7 @@ #include using namespace std; +using namespace butl; using namespace odb::core; using namespace brep::cli; @@ -280,6 +283,14 @@ handle (request& rq, response& rs) << ~TABLE; } + // Don't display the page builds section for stub packages. + // + bool builds (build_db_ != nullptr && + ver.compare (wildcard_version, true) != 0); + + if (builds) + package_db_->load (*pkg, pkg->build_section); + t.commit (); const auto& rm (pkg->requirements); @@ -325,9 +336,7 @@ handle (request& rq, response& rs) << ~TABLE; } - // Don't display the section for stub packages. - // - if (build_db_ != nullptr && ver.compare (wildcard_version, true) != 0) + if (builds) { s << H3 << "Builds" << ~H3 << DIV(ID="builds"); @@ -335,6 +344,8 @@ handle (request& rq, response& rs) timestamp now (timestamp::clock::now ()); transaction t (build_db_->begin ()); + // Print built package configurations. + // using query = query; for (auto& b: build_db_->query ( @@ -368,6 +379,60 @@ handle (request& rq, response& rs) << ~TABLE; } + // Print configurations that are excluded by the package. + // + auto excluded = [&pkg] (const bbot::build_config& c, string& reason) + { + for (const auto& bc: pkg->build_constraints) + { + if (!bc.exclusion && match (bc.config, bc.target, c)) + return false; + } + + for (const auto& bc: pkg->build_constraints) + { + if (bc.exclusion && match (bc.config, bc.target, c)) + { + // Save the first sentence of the exclusion comment, lower-case the + // first letter if the beginning looks like a word (the second + // character is the lower-case letter or space). + // + reason = bc.comment.substr (0, bc.comment.find ('.')); + + char c; + size_t n (reason.size ()); + if (n > 0 && alpha (c = reason[0]) && c == ucase (c) && + (n == 1 || + (alpha (c = reason[1]) && c == lcase (c)) || + c == ' ')) + reason[0] = lcase (reason[0]); + + return true; + } + } + + return false; + }; + + for (const auto& c: *build_conf_) + { + string reason; + if (excluded (c, reason)) + { + s << TABLE(CLASS="proplist build") + << TBODY + << TR_VALUE ("config", + c.name + " / " + + (c.target ? c.target->string () : "")) + << TR_VALUE ("result", + !reason.empty () + ? "excluded (" + reason + ')' + : "excluded") + << ~TBODY + << ~TABLE; + } + } + t.commit (); s << ~DIV; -- cgit v1.1