From 523168b187b55085ff47064585838d321eb724a5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 28 Sep 2023 22:15:02 +0300 Subject: Add support for *-build-*email package manifest values and their overrides --- libbpkg/manifest.hxx | 58 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-) (limited to 'libbpkg/manifest.hxx') diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index dce0870..8439cdf 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -980,12 +980,15 @@ namespace bpkg return os << bce.string (); } - // Package build configuration. Includes comment and optional target build - // configuration class expressions/constraints overrides. + // Package build configuration. Includes comment and optional overrides for + // target build configuration class expressions/constraints and build + // notification emails. // class build_package_config { public: + using email_type = bpkg::email; + std::string name; // Whitespace separated list of potentially double/single-quoted package @@ -999,6 +1002,10 @@ namespace bpkg butl::small_vector builds; std::vector constraints; + butl::optional email; + butl::optional warning_email; + butl::optional error_email; + build_package_config () = default; // Built incrementally. @@ -1024,6 +1031,31 @@ namespace bpkg { return !builds.empty () || !constraints.empty () ? constraints : common; } + + // Return the configuration's build notification emails if they override + // the specified common build notification emails and return the latter + // otherwise (see package_manifest::override() for the override semantics + // details). + // + const butl::optional& + effective_email (const butl::optional& common) const noexcept + { + return email || warning_email || error_email ? email : common; + } + + const butl::optional& + effective_warning_email (const butl::optional& common) const + noexcept + { + return email || warning_email || error_email ? warning_email : common; + } + + const butl::optional& + effective_error_email (const butl::optional& common) const + noexcept + { + return email || warning_email || error_email ? error_email : common; + } }; enum class test_dependency_type @@ -1330,14 +1362,15 @@ namespace bpkg // {builds, build-{include,exclude}} // {*-builds, *-build-{include,exclude}} // {*-build-config} + // {*-build-*email} // // Throw manifest_parsing if the configuration specified by the build - // package configuration-specific build constraints group value overrides - // doesn't exists. In contrast, for the build config override add a new - // configuration if it doesn't exist and update the arguments of the - // existing configuration otherwise. In the former case, all the potential - // build constraints overrides for such a newly added configuration must - // follow the respective *-build-config override. + // package configuration-specific build constraints or emails group value + // overrides doesn't exists. In contrast, for the build config override + // add a new configuration if it doesn't exist and update the arguments of + // the existing configuration otherwise. In the former case, all the + // potential build constraints and emails overrides for such a newly added + // configuration must follow the respective *-build-config override. // // Note that the build constraints group values (both common and build // config-specific) are overridden hierarchically so that the @@ -1351,6 +1384,15 @@ namespace bpkg // constraints are overridden, then for the remaining configs the build // constraints are reset to `builds: none`. // + // Similar to the build constraints groups, the common and build + // config-specific build emails group value overrides are mutually + // exclusive. If the common build emails are overridden, then all the + // build config-specific emails are reset to nullopt. Otherwise, if some + // build config-specific emails are overridden, then for the remaining + // configs the email is reset to the empty value and the warning and error + // emails are reset to nullopt (which effectively disables email + // notifications for such configurations). + // // If a non-empty source name is specified, then the specified values are // assumed to also include the line/column information and the possibly // thrown manifest_parsing exception will contain the invalid value's -- cgit v1.1