diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-18 22:17:49 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-27 17:28:44 +0300 |
commit | 35359f038f571dc46de3d14af72a2bc911fb0a24 (patch) | |
tree | de3e89d678e78b9efc4d395274fd7ccc68f4a213 /mod | |
parent | 8ad672cc7211952716ffe1fbf76c179b4f1149e3 (diff) |
Implement brep-monitor
Diffstat (limited to 'mod')
43 files changed, 428 insertions, 383 deletions
diff --git a/mod/.gitignore b/mod/.gitignore index c6e608b..6b64ad0 100644 --- a/mod/.gitignore +++ b/mod/.gitignore @@ -1 +1 @@ -options.?xx +*-options.?xx diff --git a/mod/build-config-module.cxx b/mod/build-config-module.cxx index b1818b7..831cb78 100644 --- a/mod/build-config-module.cxx +++ b/mod/build-config-module.cxx @@ -9,10 +9,9 @@ #include <sstream> #include <libbutl/sha256.mxx> -#include <libbutl/utility.mxx> // throw_generic_error(), alpha(), etc. +#include <libbutl/utility.mxx> // throw_generic_error() #include <libbutl/openssl.mxx> #include <libbutl/filesystem.mxx> // dir_iterator, dir_entry -#include <libbutl/path-pattern.mxx> namespace brep { @@ -157,184 +156,6 @@ namespace brep build_conf_map_ = make_shared<conf_map_type> (move (conf_map)); } - // The default underlying class set expression (see below). - // - static const build_class_expr default_ucs_expr ( - {"default"}, '+', "Default."); - - bool build_config_module:: - exclude (const small_vector<build_class_expr, 1>& exprs, - const vector<build_constraint>& constrs, - const build_config& cfg, - string* reason) const - { - // Save the first sentence of the reason, lower-case the first letter if - // the beginning looks like a word (all subsequent characters until a - // whitespace are lower-case letters). - // - auto sanitize = [] (const string& reason) - { - string r (reason.substr (0, reason.find ('.'))); - - char c (r[0]); // Can be '\0'. - if (alpha (c) && c == ucase (c)) - { - bool word (true); - - for (size_t i (1); - i != r.size () && (c = r[i]) != ' ' && c != '\t' && c != '\n'; - ++i) - { - // Is not a word if contains a non-letter or an upper-case letter. - // - if (!alpha (c) || c == ucase (c)) - { - word = false; - break; - } - } - - if (word) - r[0] = lcase (r[0]); - } - - return r; - }; - - // First, match the configuration against the package underlying build - // class set and expressions. - // - bool m (false); - - // Match the configuration against an expression, updating the match - // result. - // - // We will use a comment of the first encountered excluding expression - // (changing the result from true to false) or non-including one (leaving - // the false result) as an exclusion reason. - // - auto match = [&cfg, &m, reason, &sanitize, this] - (const build_class_expr& e) - { - bool pm (m); - e.match (cfg.classes, build_conf_->class_inheritance_map, m); - - if (reason != nullptr) - { - // Reset the reason which, if saved, makes no sense anymore. - // - if (m) - { - reason->clear (); - } - else if (reason->empty () && - // - // Exclusion. - // - (pm || - // - // Non-inclusion. Make sure that the build class expression - // is empty or starts with an addition (+...). - // - e.expr.empty () || - e.expr.front ().operation == '+')) - { - *reason = sanitize (e.comment); - } - } - }; - - // Determine the underlying class set. Note that in the future we can - // potentially extend the underlying set with special classes. - // - const build_class_expr* ucs ( - !exprs.empty () && !exprs.front ().underlying_classes.empty () - ? &exprs.front () - : nullptr); - - // Note that the combined package build configuration class expression can - // be represented as the underlying class set used as a starting set for - // the original expressions and a restricting set, simultaneously. For - // example, for the expression: - // - // default legacy : -msvc - // - // the resulting expression will be: - // - // +( +default +legacy ) -msvc &( +default +legacy ) - // - // Let's, however, optimize it a bit based on the following facts: - // - // - If the underlying class set expression (+default +legacy in the above - // example) evaluates to false, then the resulting expression also - // evaluates to false due to the trailing '&' operation. Thus, we don't - // need to evaluate further if that's the case. - // - // - On the other hand, if the underlying class set expression evaluates - // to true, then we don't need to apply the trailing '&' operation as it - // cannot affect the result. - // - const build_class_expr& ucs_expr ( - ucs != nullptr - ? build_class_expr (ucs->underlying_classes, '+', ucs->comment) - : default_ucs_expr); - - match (ucs_expr); - - if (m) - { - for (const build_class_expr& e: exprs) - match (e); - } - - // Exclude the configuration if it doesn't match the compound expression. - // - if (!m) - return true; - - // Now check if the configuration is excluded/included via the patterns. - // - // To implement matching of absent name components with wildcard-only - // pattern components we are going to convert names to paths (see - // dash_components_to_path() for details). - // - // And if any of the build-{include,exclude} values (which is legal) or - // the build configuration name/target (illegal) are invalid paths, then - // we assume no match. - // - if (!constrs.empty ()) - try - { - path cn (dash_components_to_path (cfg.name)); - path tg (dash_components_to_path (cfg.target.string ())); - - for (const build_constraint& c: constrs) - { - if (path_match (cn, - dash_components_to_path (c.config), - dir_path () /* start */, - path_match_flags::match_absent) && - (!c.target || - path_match (tg, - dash_components_to_path (*c.target), - dir_path () /* start */, - path_match_flags::match_absent))) - { - if (!c.exclusion) - return false; - - if (reason != nullptr) - *reason = sanitize (c.comment); - - return true; - } - } - } - catch (const invalid_path&) {} - - return false; - } - bool build_config_module:: belongs (const bbot::build_config& cfg, const char* cls) const { @@ -360,59 +181,4 @@ namespace brep return false; } - - path build_config_module:: - dash_components_to_path (const string& pattern) - { - string r; - size_t nstar (0); - for (const path_pattern_term& pt: path_pattern_iterator (pattern)) - { - switch (pt.type) - { - case path_pattern_term_type::star: - { - // Replace ** with */**/* and skip all the remaining stars that may - // follow in this sequence. - // - if (nstar == 0) - r += "*"; - else if (nstar == 1) - r += "/**/*"; // The first star is already copied. - - break; - } - case path_pattern_term_type::literal: - { - // Replace '-' with '/' and fall through otherwise. - // - if (get_literal (pt) == '-') - { - r += '/'; - break; - } - } - // Fall through. - default: - { - r.append (pt.begin, pt.end); // Copy the pattern term as is. - } - } - - nstar = pt.star () ? nstar + 1 : 0; - } - - // Append the trailing slash to match the resulting paths as directories. - // This is required for the trailing /* we could append to match absent - // directory path components (see path_match_flags::match_absent for - // details). - // - // Note that valid dash components may not contain a trailing dash. - // Anyway, any extra trailing slashes will be ignored by the path - // constructor. - // - r += '/'; - - return path (move (r)); - } } diff --git a/mod/build-config-module.hxx b/mod/build-config-module.hxx index 4b23056..04fd5b1 100644 --- a/mod/build-config-module.hxx +++ b/mod/build-config-module.hxx @@ -5,7 +5,6 @@ #define MOD_BUILD_CONFIG_MODULE_HXX #include <map> -#include <algorithm> // find() #include <libbutl/utility.mxx> // compare_c_string @@ -16,8 +15,8 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/module.hxx> -#include <mod/options.hxx> +#include <mod/build-config.hxx> +#include <mod/module-options.hxx> // Base class for modules that utilize the build controller configuration. // @@ -39,17 +38,18 @@ namespace brep void init (const options::build&); - // Return true if the specified build configuration is excluded by a - // package based on its underlying build class set, build class - // expressions, and build constraints, potentially extending the - // underlying set with the special classes. Set the exclusion reason if - // requested. - // bool - exclude (const small_vector<bpkg::build_class_expr, 1>&, - const vector<bpkg::build_constraint>&, - const bbot::build_config&, - string* reason = nullptr) const; + exclude (const small_vector<bpkg::build_class_expr, 1>& exprs, + const vector<bpkg::build_constraint>& constrs, + const bbot::build_config& cfg, + string* reason = nullptr) const + { + return brep::exclude (exprs, + constrs, + cfg, + build_conf_->class_inheritance_map, + reason); + } // Check if the configuration belongs to the specified class. // @@ -62,20 +62,6 @@ namespace brep return belongs (cfg, cls.c_str ()); } - // Convert dash-separated components (target, build configuration name, - // machine name) or a pattern thereof into a path, replacing dashes with - // slashes (directory separators), `**` with `*/**/*`, and appending the - // trailing slash for a subsequent match using the path_match() - // functionality (the idea here is for `linux**` to match `linux-gcc` - // which is quite natural to expect). Throw invalid_path if the resulting - // path is invalid. - // - // Note that the match_absent path match flag must be used for the above - // `**` transformation to work. - // - static path - dash_components_to_path (const string&); - // Configuration/toolchain combination that, in particular, can be used as // a set value. // diff --git a/mod/build-config.cxx b/mod/build-config.cxx new file mode 100644 index 0000000..2d64aec --- /dev/null +++ b/mod/build-config.cxx @@ -0,0 +1,249 @@ +// file : mod/build-config-module.cxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#include <mod/build-config.hxx> + +#include <libbutl/utility.mxx> // alpha(), etc. +#include <libbutl/path-pattern.mxx> + +namespace brep +{ + using namespace std; + using namespace butl; + using namespace bpkg; + using namespace bbot; + + // The default underlying class set expression (see below). + // + static const build_class_expr default_ucs_expr ( + {"default"}, '+', "Default."); + + bool + exclude (const small_vector<build_class_expr, 1>& exprs, + const vector<build_constraint>& constrs, + const build_config& cfg, + const map<string, string>& class_inheritance_map, + string* reason) + { + // Save the first sentence of the reason, lower-case the first letter if + // the beginning looks like a word (all subsequent characters until a + // whitespace are lower-case letters). + // + auto sanitize = [] (const string& reason) + { + string r (reason.substr (0, reason.find ('.'))); + + char c (r[0]); // Can be '\0'. + if (alpha (c) && c == ucase (c)) + { + bool word (true); + + for (size_t i (1); + i != r.size () && (c = r[i]) != ' ' && c != '\t' && c != '\n'; + ++i) + { + // Is not a word if contains a non-letter or an upper-case letter. + // + if (!alpha (c) || c == ucase (c)) + { + word = false; + break; + } + } + + if (word) + r[0] = lcase (r[0]); + } + + return r; + }; + + // First, match the configuration against the package underlying build + // class set and expressions. + // + bool m (false); + + // Match the configuration against an expression, updating the match + // result. + // + // We will use a comment of the first encountered excluding expression + // (changing the result from true to false) or non-including one (leaving + // the false result) as an exclusion reason. + // + auto match = [&cfg, &m, reason, &sanitize, &class_inheritance_map] + (const build_class_expr& e) + { + bool pm (m); + e.match (cfg.classes, class_inheritance_map, m); + + if (reason != nullptr) + { + // Reset the reason which, if saved, makes no sense anymore. + // + if (m) + { + reason->clear (); + } + else if (reason->empty () && + // + // Exclusion. + // + (pm || + // + // Non-inclusion. Make sure that the build class expression + // is empty or starts with an addition (+...). + // + e.expr.empty () || + e.expr.front ().operation == '+')) + { + *reason = sanitize (e.comment); + } + } + }; + + // Determine the underlying class set. Note that in the future we can + // potentially extend the underlying set with special classes. + // + const build_class_expr* ucs ( + !exprs.empty () && !exprs.front ().underlying_classes.empty () + ? &exprs.front () + : nullptr); + + // Note that the combined package build configuration class expression can + // be represented as the underlying class set used as a starting set for + // the original expressions and a restricting set, simultaneously. For + // example, for the expression: + // + // default legacy : -msvc + // + // the resulting expression will be: + // + // +( +default +legacy ) -msvc &( +default +legacy ) + // + // Let's, however, optimize it a bit based on the following facts: + // + // - If the underlying class set expression (+default +legacy in the above + // example) evaluates to false, then the resulting expression also + // evaluates to false due to the trailing '&' operation. Thus, we don't + // need to evaluate further if that's the case. + // + // - On the other hand, if the underlying class set expression evaluates + // to true, then we don't need to apply the trailing '&' operation as it + // cannot affect the result. + // + const build_class_expr& ucs_expr ( + ucs != nullptr + ? build_class_expr (ucs->underlying_classes, '+', ucs->comment) + : default_ucs_expr); + + match (ucs_expr); + + if (m) + { + for (const build_class_expr& e: exprs) + match (e); + } + + // Exclude the configuration if it doesn't match the compound expression. + // + if (!m) + return true; + + // Now check if the configuration is excluded/included via the patterns. + // + // To implement matching of absent name components with wildcard-only + // pattern components we are going to convert names to paths (see + // dash_components_to_path() for details). + // + // And if any of the build-{include,exclude} values (which is legal) or + // the build configuration name/target (illegal) are invalid paths, then + // we assume no match. + // + if (!constrs.empty ()) + try + { + path cn (dash_components_to_path (cfg.name)); + path tg (dash_components_to_path (cfg.target.string ())); + + for (const build_constraint& c: constrs) + { + if (path_match (cn, + dash_components_to_path (c.config), + dir_path () /* start */, + path_match_flags::match_absent) && + (!c.target || + path_match (tg, + dash_components_to_path (*c.target), + dir_path () /* start */, + path_match_flags::match_absent))) + { + if (!c.exclusion) + return false; + + if (reason != nullptr) + *reason = sanitize (c.comment); + + return true; + } + } + } + catch (const invalid_path&) {} + + return false; + } + + path + dash_components_to_path (const string& pattern) + { + string r; + size_t nstar (0); + for (const path_pattern_term& pt: path_pattern_iterator (pattern)) + { + switch (pt.type) + { + case path_pattern_term_type::star: + { + // Replace ** with */**/* and skip all the remaining stars that may + // follow in this sequence. + // + if (nstar == 0) + r += "*"; + else if (nstar == 1) + r += "/**/*"; // The first star is already copied. + + break; + } + case path_pattern_term_type::literal: + { + // Replace '-' with '/' and fall through otherwise. + // + if (get_literal (pt) == '-') + { + r += '/'; + break; + } + } + // Fall through. + default: + { + r.append (pt.begin, pt.end); // Copy the pattern term as is. + } + } + + nstar = pt.star () ? nstar + 1 : 0; + } + + // Append the trailing slash to match the resulting paths as directories. + // This is required for the trailing /* we could append to match absent + // directory path components (see path_match_flags::match_absent for + // details). + // + // Note that valid dash components may not contain a trailing dash. + // Anyway, any extra trailing slashes will be ignored by the path + // constructor. + // + r += '/'; + + return path (move (r)); + } +} diff --git a/mod/build-config.hxx b/mod/build-config.hxx new file mode 100644 index 0000000..d5e44ce --- /dev/null +++ b/mod/build-config.hxx @@ -0,0 +1,45 @@ +// file : mod/build-config.hxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#ifndef MOD_BUILD_CONFIG_HXX +#define MOD_BUILD_CONFIG_HXX + +#include <map> + +#include <libbpkg/manifest.hxx> + +#include <libbbot/build-config.hxx> + +#include <libbrep/types.hxx> +#include <libbrep/utility.hxx> + +namespace brep +{ + // Return true if the specified build configuration is excluded by a package + // based on its underlying build class set, build class expressions, and + // build constraints, potentially extending the underlying set with the + // special classes. Set the exclusion reason if requested. + // + bool + exclude (const small_vector<bpkg::build_class_expr, 1>&, + const vector<bpkg::build_constraint>&, + const bbot::build_config&, + const std::map<string, string>& class_inheritance_map, + string* reason = nullptr); + + // Convert dash-separated components (target, build configuration name, + // machine name) or a pattern thereof into a path, replacing dashes with + // slashes (directory separators), `**` with `*/**/*`, and appending the + // trailing slash for a subsequent match using the path_match() + // functionality (the idea here is for `linux**` to match `linux-gcc` which + // is quite natural to expect). Throw invalid_path if the resulting path is + // invalid. + // + // Note that the match_absent path match flag must be used for the above + // `**` transformation to work. + // + path + dash_components_to_path (const string&); +} + +#endif // MOD_BUILD_CONFIG diff --git a/mod/build.cxx b/mod/build.cxx index cdbaa60..5b9d8aa 100644 --- a/mod/build.cxx +++ b/mod/build.cxx @@ -3,7 +3,7 @@ #include <mod/build.hxx> -#include <web/mime-url-encoding.hxx> +#include <web/server/mime-url-encoding.hxx> #include <mod/utility.hxx> diff --git a/mod/buildfile b/mod/buildfile index 9300faf..ca46bc4 100644 --- a/mod/buildfile +++ b/mod/buildfile @@ -19,25 +19,38 @@ import libs += libbpkg%lib{bpkg} import libs += libbbot%lib{bbot} include ../libbrep/ -include ../web/ -mod{brep}: {hxx ixx txx cxx}{* -options} \ - {hxx ixx cxx}{ options} \ - ../libbrep/lib{brep} ../web/libus{web} $libs +include ../web/xhtml/ +include ../web/server/ + +./: mod{brep} {libue libus}{mod} + +libu_src = options-types types-parsers build-config + +mod{brep}: {hxx ixx txx cxx}{* -module-options -{$libu_src}} \ + libus{mod} ../libbrep/lib{brep} ../web/server/libus{web-server} \ + $libs + +{libue libus}{mod}: {hxx ixx cxx}{module-options} \ + {hxx ixx txx cxx}{+{$libu_src} } \ + $libs + +libus{mod}: ../web/xhtml/libus{xhtml} +libue{mod}: ../web/xhtml/libue{xhtml} # Generated options parser. # if $cli.configured { - cli.cxx{options}: cli{options} + cli.cxx{module-options}: cli{module} # Set option prefix to the empty value to handle all unknown request # parameters uniformly with a single catch block. # - cli.options += --std c++11 -I $src_root --include-with-brackets \ ---include-prefix mod --guard-prefix MOD --generate-specifier \ ---cxx-prologue "#include <mod/types-parsers.hxx>" \ ---cli-namespace brep::cli --generate-file-scanner --suppress-usage \ + cli.options += --std c++11 -I $src_root --include-with-brackets \ +--include-prefix mod --guard-prefix MOD --generate-specifier \ +--cxx-prologue "#include <mod/types-parsers.hxx>" \ +--cli-namespace brep::cli --generate-file-scanner --option-length 38 \ --generate-modifier --generate-description --option-prefix "" # Include the generated cli files into the distribution and don't remove diff --git a/mod/database-module.cxx b/mod/database-module.cxx index 5516730..f598bfd 100644 --- a/mod/database-module.cxx +++ b/mod/database-module.cxx @@ -5,8 +5,8 @@ #include <odb/exceptions.hxx> -#include <mod/options.hxx> #include <mod/database.hxx> +#include <mod/module-options.hxx> namespace brep { diff --git a/mod/database-module.hxx b/mod/database-module.hxx index a41752d..f72ba83 100644 --- a/mod/database-module.hxx +++ b/mod/database-module.hxx @@ -10,7 +10,7 @@ #include <libbrep/utility.hxx> #include <mod/module.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> namespace brep { diff --git a/mod/mod-build-configs.cxx b/mod/mod-build-configs.cxx index 8efc6c9..6731b28 100644 --- a/mod/mod-build-configs.cxx +++ b/mod/mod-build-configs.cxx @@ -7,11 +7,12 @@ #include <libstudxml/serializer.hxx> -#include <web/xhtml.hxx> -#include <web/module.hxx> +#include <web/server/module.hxx> + +#include <web/xhtml/serialization.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace bbot; diff --git a/mod/mod-build-configs.hxx b/mod/mod-build-configs.hxx index 333680a..562ac6d 100644 --- a/mod/mod-build-configs.hxx +++ b/mod/mod-build-configs.hxx @@ -8,7 +8,7 @@ #include <libbrep/utility.hxx> #include <mod/module.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/build-config-module.hxx> namespace brep diff --git a/mod/mod-build-force.cxx b/mod/mod-build-force.cxx index 4dc71c8..bd172e3 100644 --- a/mod/mod-build-force.cxx +++ b/mod/mod-build-force.cxx @@ -8,12 +8,12 @@ #include <odb/database.hxx> #include <odb/transaction.hxx> -#include <web/module.hxx> +#include <web/server/module.hxx> #include <libbrep/build.hxx> #include <libbrep/build-odb.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace bbot; diff --git a/mod/mod-build-force.hxx b/mod/mod-build-force.hxx index 7b6b3b6..22df383 100644 --- a/mod/mod-build-force.hxx +++ b/mod/mod-build-force.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> #include <mod/build-config-module.hxx> diff --git a/mod/mod-build-log.cxx b/mod/mod-build-log.cxx index 16cc965..3032e52 100644 --- a/mod/mod-build-log.cxx +++ b/mod/mod-build-log.cxx @@ -10,12 +10,12 @@ #include <libbutl/timestamp.mxx> // to_stream() -#include <web/module.hxx> +#include <web/server/module.hxx> #include <libbrep/build.hxx> #include <libbrep/build-odb.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace bbot; diff --git a/mod/mod-build-log.hxx b/mod/mod-build-log.hxx index 9f9d1d9..a2f4e48 100644 --- a/mod/mod-build-log.hxx +++ b/mod/mod-build-log.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> #include <mod/build-config-module.hxx> diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx index b3467d2..734ea5c 100644 --- a/mod/mod-build-result.cxx +++ b/mod/mod-build-result.cxx @@ -15,15 +15,15 @@ #include <libbbot/manifest.hxx> -#include <web/module.hxx> +#include <web/server/module.hxx> #include <libbrep/build.hxx> #include <libbrep/build-odb.hxx> #include <libbrep/package.hxx> #include <libbrep/package-odb.hxx> -#include <mod/build.hxx> // *_url() -#include <mod/options.hxx> +#include <mod/build.hxx> // *_url() +#include <mod/module-options.hxx> using namespace std; using namespace butl; @@ -409,6 +409,7 @@ handle (request& rq, response&) b->results = move (rqm.result.results); b->timestamp = system_clock::now (); + b->completion_timestamp = b->timestamp; build_db_->update (b); diff --git a/mod/mod-build-result.hxx b/mod/mod-build-result.hxx index b3911e1..71a60f9 100644 --- a/mod/mod-build-result.hxx +++ b/mod/mod-build-result.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> #include <mod/build-config-module.hxx> diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index c232815..17bc15e 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -22,14 +22,14 @@ #include <libbbot/manifest.hxx> #include <libbbot/build-config.hxx> -#include <web/module.hxx> +#include <web/server/module.hxx> #include <libbrep/build.hxx> #include <libbrep/build-odb.hxx> #include <libbrep/build-package.hxx> #include <libbrep/build-package-odb.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace butl; @@ -384,28 +384,18 @@ handle (request& rq, response& rs) using prep_bld_query = prepared_query<build>; package_id id; - const auto& qv (bld_query::id.package.version); bld_query bq ( - bld_query::id.package.tenant == bld_query::_ref (id.tenant) && - - bld_query::id.package.name == bld_query::_ref (id.name) && - - qv.epoch == bld_query::_ref (id.version.epoch) && - qv.canonical_upstream == - bld_query::_ref (id.version.canonical_upstream) && - qv.canonical_release == - bld_query::_ref (id.version.canonical_release) && - qv.revision == bld_query::_ref (id.version.revision) && + equal<build> (bld_query::id.package, id) && bld_query::id.configuration.in_range (cfg_names.begin (), - cfg_names.end ()) && + cfg_names.end ()) && - bld_query::id.toolchain_name == tqm.toolchain_name && + bld_query::id.toolchain_name == tqm.toolchain_name && compare_version_eq (bld_query::id.toolchain_version, canonical_version (toolchain_version), - true /* revision */) && + true /* revision */) && (bld_query::state == "built" || ((bld_query::force == "forcing" && diff --git a/mod/mod-build-task.hxx b/mod/mod-build-task.hxx index 5f4c14a..7875db1 100644 --- a/mod/mod-build-task.hxx +++ b/mod/mod-build-task.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> #include <mod/build-config-module.hxx> diff --git a/mod/mod-builds.cxx b/mod/mod-builds.cxx index 77ebc05..ab9e93e 100644 --- a/mod/mod-builds.cxx +++ b/mod/mod-builds.cxx @@ -16,9 +16,10 @@ #include <libbbot/manifest.hxx> // to_result_status(), to_string(result_status) -#include <web/xhtml.hxx> -#include <web/module.hxx> -#include <web/mime-url-encoding.hxx> +#include <web/server/module.hxx> +#include <web/server/mime-url-encoding.hxx> + +#include <web/xhtml/serialization.hxx> #include <libbrep/build.hxx> #include <libbrep/build-odb.hxx> @@ -26,7 +27,7 @@ #include <libbrep/build-package-odb.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace butl; @@ -231,7 +232,10 @@ build_query (const brep::cstrings* configs, else { query sq (qb::status == rs); - result_status st (to_result_status(rs)); // May throw invalid_argument. + + // May throw invalid_argument. + // + result_status st (to_result_status (rs)); if (st != result_status::success) { @@ -312,22 +316,6 @@ package_query (const brep::params::builds& params, return q; } -template <typename T, typename ID> -static inline query<T> -package_id_eq (const ID& x, const brep::package_id& y) -{ - using query = query<T>; - const auto& qv (x.version); - - return - x.tenant == query::_ref (y.tenant) && - x.name == query::_ref (y.name) && - qv.epoch == query::_ref (y.version.epoch) && - qv.canonical_upstream == query::_ref (y.version.canonical_upstream) && - qv.canonical_release == query::_ref (y.version.canonical_release) && - qv.revision == query::_ref (y.version.revision); -} - static const vector<pair<string, string>> build_results ({ {"unbuilt", "<unbuilt>"}, {"*", "*"}, @@ -821,9 +809,8 @@ handle (request& rq, response& rs) const auto& bid (bld_query::build::id); - bld_query bq ( - package_id_eq<package_build_count> (bid.package, id) && - bid.configuration == bld_query::_ref (config) && + bld_query bq (equal<package_build_count> (bid.package, id) && + bid.configuration == bld_query::_ref (config) && // Note that the query already constrains configurations via the // configuration name and the tenant via the build package id. @@ -936,7 +923,7 @@ handle (request& rq, response& rs) package_id id; bld_query bq ( - package_id_eq<package_build> (bld_query::build::id.package, id) && + equal<package_build> (bld_query::build::id.package, id) && // Note that the query already constrains the tenant via the build // package id. diff --git a/mod/mod-builds.hxx b/mod/mod-builds.hxx index 714b374..0aa7916 100644 --- a/mod/mod-builds.hxx +++ b/mod/mod-builds.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> #include <mod/build-config-module.hxx> diff --git a/mod/mod-ci.cxx b/mod/mod-ci.cxx index 77377eb..d2da93f 100644 --- a/mod/mod-ci.cxx +++ b/mod/mod-ci.cxx @@ -17,11 +17,12 @@ #include <libbpkg/manifest.hxx> #include <libbpkg/package-name.hxx> -#include <web/xhtml.hxx> -#include <web/module.hxx> +#include <web/server/module.hxx> + +#include <web/xhtml/serialization.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/external-handler.hxx> using namespace std; @@ -116,8 +117,8 @@ handle (request& rq, response& rs) // latter case we will always respond with the same neutral message for // security reason, logging the error details. Note that descriptions of // exceptions caught by the web server are returned to the client (see - // web/module.hxx for details), and we want to avoid this when there is a - // danger of exposing sensitive data. + // web/server/module.hxx for details), and we want to avoid this when there + // is a danger of exposing sensitive data. // // Also we will pass through exceptions thrown by the underlying API, unless // we need to handle them or add details for the description, in which case diff --git a/mod/mod-ci.hxx b/mod/mod-ci.hxx index 1228714..431f53b 100644 --- a/mod/mod-ci.hxx +++ b/mod/mod-ci.hxx @@ -4,13 +4,13 @@ #ifndef MOD_MOD_CI_HXX #define MOD_MOD_CI_HXX -#include <web/xhtml-fragment.hxx> +#include <web/xhtml/fragment.hxx> #include <libbrep/types.hxx> #include <libbrep/utility.hxx> #include <mod/module.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> namespace brep { diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx index c7973d3..e0bd1ef 100644 --- a/mod/mod-package-details.cxx +++ b/mod/mod-package-details.cxx @@ -9,15 +9,16 @@ #include <odb/database.hxx> #include <odb/transaction.hxx> -#include <web/xhtml.hxx> -#include <web/module.hxx> -#include <web/mime-url-encoding.hxx> +#include <web/server/module.hxx> +#include <web/server/mime-url-encoding.hxx> + +#include <web/xhtml/serialization.hxx> #include <libbrep/package.hxx> #include <libbrep/package-odb.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace odb::core; using namespace brep::cli; diff --git a/mod/mod-package-details.hxx b/mod/mod-package-details.hxx index 16f8c3e..e1b0a9c 100644 --- a/mod/mod-package-details.hxx +++ b/mod/mod-package-details.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> namespace brep diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index cde65b0..bfc08b0 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -9,9 +9,10 @@ #include <odb/database.hxx> #include <odb/transaction.hxx> -#include <web/xhtml.hxx> -#include <web/module.hxx> -#include <web/mime-url-encoding.hxx> +#include <web/server/module.hxx> +#include <web/server/mime-url-encoding.hxx> + +#include <web/xhtml/serialization.hxx> #include <libbrep/build.hxx> #include <libbrep/build-odb.hxx> @@ -19,7 +20,7 @@ #include <libbrep/package-odb.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace butl; diff --git a/mod/mod-package-version-details.hxx b/mod/mod-package-version-details.hxx index 8d0d373..a88d6c2 100644 --- a/mod/mod-package-version-details.hxx +++ b/mod/mod-package-version-details.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> #include <mod/build-config-module.hxx> diff --git a/mod/mod-packages.cxx b/mod/mod-packages.cxx index 81cf83c..65c7c5b 100644 --- a/mod/mod-packages.cxx +++ b/mod/mod-packages.cxx @@ -10,15 +10,16 @@ #include <odb/transaction.hxx> #include <odb/schema-catalog.hxx> -#include <web/xhtml.hxx> -#include <web/module.hxx> -#include <web/mime-url-encoding.hxx> +#include <web/server/module.hxx> +#include <web/server/mime-url-encoding.hxx> + +#include <web/xhtml/serialization.hxx> #include <libbrep/package.hxx> #include <libbrep/package-odb.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace odb::core; using namespace brep::cli; diff --git a/mod/mod-packages.hxx b/mod/mod-packages.hxx index d1c4677..611d63c 100644 --- a/mod/mod-packages.hxx +++ b/mod/mod-packages.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> namespace brep diff --git a/mod/mod-repository-details.cxx b/mod/mod-repository-details.cxx index 988c445..813b738 100644 --- a/mod/mod-repository-details.cxx +++ b/mod/mod-repository-details.cxx @@ -12,15 +12,16 @@ #include <libbutl/timestamp.mxx> // to_string() -#include <web/xhtml.hxx> -#include <web/module.hxx> -#include <web/mime-url-encoding.hxx> +#include <web/server/module.hxx> +#include <web/server/mime-url-encoding.hxx> + +#include <web/xhtml/serialization.hxx> #include <libbrep/package.hxx> #include <libbrep/package-odb.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace odb::core; diff --git a/mod/mod-repository-details.hxx b/mod/mod-repository-details.hxx index bd4b3ba..e83831d 100644 --- a/mod/mod-repository-details.hxx +++ b/mod/mod-repository-details.hxx @@ -7,7 +7,7 @@ #include <libbrep/types.hxx> #include <libbrep/utility.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/database-module.hxx> namespace brep diff --git a/mod/mod-repository-root.cxx b/mod/mod-repository-root.cxx index b6c54b8..02d6c93 100644 --- a/mod/mod-repository-root.cxx +++ b/mod/mod-repository-root.cxx @@ -10,10 +10,10 @@ #include <sstream> #include <algorithm> // find() -#include <web/module.hxx> +#include <web/server/module.hxx> #include <mod/module.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/mod-ci.hxx> #include <mod/mod-submit.hxx> diff --git a/mod/mod-repository-root.hxx b/mod/mod-repository-root.hxx index ac4b254..9e28797 100644 --- a/mod/mod-repository-root.hxx +++ b/mod/mod-repository-root.hxx @@ -8,7 +8,7 @@ #include <libbrep/utility.hxx> #include <mod/module.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> namespace brep { diff --git a/mod/mod-submit.cxx b/mod/mod-submit.cxx index 0dea2b7..9c93a36 100644 --- a/mod/mod-submit.cxx +++ b/mod/mod-submit.cxx @@ -14,11 +14,12 @@ #include <libbutl/manifest-types.mxx> #include <libbutl/manifest-serializer.mxx> -#include <web/xhtml.hxx> -#include <web/module.hxx> +#include <web/server/module.hxx> + +#include <web/xhtml/serialization.hxx> #include <mod/page.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> #include <mod/external-handler.hxx> using namespace std; diff --git a/mod/mod-submit.hxx b/mod/mod-submit.hxx index 96a60f9..fc5f8d4 100644 --- a/mod/mod-submit.hxx +++ b/mod/mod-submit.hxx @@ -4,13 +4,13 @@ #ifndef MOD_MOD_SUBMIT_HXX #define MOD_MOD_SUBMIT_HXX -#include <web/xhtml-fragment.hxx> +#include <web/xhtml/fragment.hxx> #include <libbrep/types.hxx> #include <libbrep/utility.hxx> #include <mod/module.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> namespace brep { diff --git a/mod/options.cli b/mod/module.cli index f02d7a6..fa1d2cc 100644 --- a/mod/options.cli +++ b/mod/module.cli @@ -3,7 +3,7 @@ include <libbpkg/manifest.hxx>; // repository_location -include <web/xhtml-fragment.hxx>; +include <web/xhtml/fragment.hxx>; include <libbrep/types.hxx>; @@ -37,7 +37,7 @@ namespace brep dir_path root = "/" { - "<path>" + "<path>", "Repository root. That is, this is the part of the URL between the host name and the start of the repository. For example, root value '\cb{/pkg}' means the repository URL is \cb{http://example.org/pkg/}. @@ -214,7 +214,7 @@ namespace brep { "<user>", "Build database execution user name. If not empty then the login - user will be switched (with \c{SET ROLE}) to this user prior to + user will be switched (with \c{SET ROLE}) to this user prior to executing any statements. If not specified, then \cb{brep} is used." } @@ -565,7 +565,7 @@ namespace brep string root-tenant-view = "packages" { - "<service>" + "<service>", "The default view to display for the tenant repository root. The <service> argument is one of the supported services (\c{packages}, \c{builds}, \c{submit}, \c{ci}, etc). The default service is diff --git a/mod/module.cxx b/mod/module.cxx index 8f306fd..06799d7 100644 --- a/mod/module.cxx +++ b/mod/module.cxx @@ -10,10 +10,10 @@ #include <cstring> // strchr() #include <functional> // bind() -#include <web/module.hxx> -#include <web/apache/log.hxx> +#include <web/server/module.hxx> +#include <web/server/apache/log.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace placeholders; // For std::bind's _1, etc. diff --git a/mod/module.hxx b/mod/module.hxx index 2c62166..b3ed67b 100644 --- a/mod/module.hxx +++ b/mod/module.hxx @@ -4,14 +4,14 @@ #ifndef MOD_MODULE_HXX #define MOD_MODULE_HXX -#include <web/module.hxx> +#include <web/server/module.hxx> #include <libbrep/types.hxx> #include <libbrep/utility.hxx> #include <mod/utility.hxx> -#include <mod/options.hxx> #include <mod/diagnostics.hxx> +#include <mod/module-options.hxx> namespace brep { diff --git a/mod/page.cxx b/mod/page.cxx index 64e31c0..c7dc403 100644 --- a/mod/page.cxx +++ b/mod/page.cxx @@ -16,9 +16,10 @@ #include <libbutl/url.mxx> -#include <web/xhtml.hxx> -#include <web/xhtml-fragment.hxx> -#include <web/mime-url-encoding.hxx> +#include <web/xhtml/fragment.hxx> +#include <web/xhtml/serialization.hxx> + +#include <web/server/mime-url-encoding.hxx> #include <libbrep/package.hxx> #include <libbrep/package-odb.hxx> diff --git a/mod/page.hxx b/mod/page.hxx index 8c92d10..49d8608 100644 --- a/mod/page.hxx +++ b/mod/page.hxx @@ -8,7 +8,7 @@ #include <libbbot/manifest.hxx> -#include <web/xhtml-fragment.hxx> +#include <web/xhtml/fragment.hxx> #include <libbrep/types.hxx> #include <libbrep/utility.hxx> diff --git a/mod/services.cxx b/mod/services.cxx index 7739011..b17e32e 100644 --- a/mod/services.cxx +++ b/mod/services.cxx @@ -3,7 +3,7 @@ #include <ap_config.h> // AP_MODULE_DECLARE_DATA -#include <web/apache/service.hxx> +#include <web/server/apache/service.hxx> #include <libbrep/types.hxx> #include <libbrep/utility.hxx> diff --git a/mod/types-parsers.cxx b/mod/types-parsers.cxx index 70d77dd..ceaab29 100644 --- a/mod/types-parsers.cxx +++ b/mod/types-parsers.cxx @@ -3,7 +3,7 @@ #include <mod/types-parsers.hxx> -#include <mod/options.hxx> +#include <mod/module-options.hxx> using namespace std; using namespace bpkg; diff --git a/mod/types-parsers.hxx b/mod/types-parsers.hxx index a81ef90..091c868 100644 --- a/mod/types-parsers.hxx +++ b/mod/types-parsers.hxx @@ -9,7 +9,7 @@ #include <libbpkg/manifest.hxx> // repository_location -#include <web/xhtml-fragment.hxx> +#include <web/xhtml/fragment.hxx> #include <libbrep/types.hxx> #include <libbrep/utility.hxx> |