aboutsummaryrefslogtreecommitdiff
path: root/bdep/ci.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bdep/ci.cxx')
-rw-r--r--bdep/ci.cxx150
1 files changed, 116 insertions, 34 deletions
diff --git a/bdep/ci.cxx b/bdep/ci.cxx
index f97f0cb..0b26b35 100644
--- a/bdep/ci.cxx
+++ b/bdep/ci.cxx
@@ -228,6 +228,30 @@ namespace bdep
bool build_email_ovr (false);
bool aux_ovr (false);
+ // Return true, if the [*-]builds override is specified.
+ //
+ auto builds_override = [&overrides] (const string& config = empty_string)
+ {
+ if (config.empty ())
+ {
+ return find_if (overrides.begin (), overrides.end (),
+ [] (const manifest_name_value& v)
+ {
+ return v.name == "builds";
+ }) != overrides.end ();
+ }
+ else
+ {
+ string n (config + "-builds");
+
+ return find_if (overrides.begin (), overrides.end (),
+ [&n] (const manifest_name_value& v)
+ {
+ return v.name == n;
+ }) != overrides.end ();
+ }
+ };
+
if (o.overrides_specified ())
{
const char* co (o.target_config_specified () ? "--target-config" :
@@ -240,21 +264,29 @@ namespace bdep
{
const string& n (nv.name);
- // True if the name is one of {*-builds, *-build-{include,exclude}}.
+ // True if the name is *-builds.
+ //
+ bool cbso (
+ n.size () > 7 && n.compare (n.size () - 7, 7, "-builds") == 0);
+
+ // True if the name is one of {*-builds, *-build-{include,exclude}}
+ // and update the pkg_config_ovr flag accordingly if that's the case.
//
- bool pco ((n.size () > 7 &&
- n.compare (n.size () - 7, 7, "-builds") == 0) ||
+ bool cbo (cbso ||
(n.size () > 14 &&
n.compare (n.size () - 14, 14, "-build-include") == 0) ||
(n.size () > 14 &&
n.compare (n.size () - 14, 14, "-build-exclude") == 0));
- if (pco)
+ if (cbo)
pkg_config_ovr = true;
+ // Fail if --{target,build,package}-config or --interactive is
+ // combined with a [*-]build-{include,exclude} override (but not with
+ // [*-]builds).
+ //
if (co != nullptr &&
- (pco ||
- n == "builds" ||
+ ((cbo && !cbso) ||
n == "build-include" ||
n == "build-exclude"))
{
@@ -264,21 +296,34 @@ namespace bdep
info << "override: " << n << ": " << nv.value;
}
- bool eo (
- (n == "build-email" ||
- n == "build-warning-email" ||
- n == "build-error-email" ||
- (n.size () > 12 &&
- n.compare (n.size () - 12, 12, "-build-email") == 0) ||
- (n.size () > 20 &&
- n.compare (n.size () - 20, 20, "-build-warning-email") == 0) ||
- (n.size () > 18 &&
- n.compare (n.size () - 18, 18, "-build-error-email") == 0)));
-
- if (eo)
- build_email_ovr = true;
-
- if (!pco && !eo)
+ // Check if the name is one of {[*-]build-*email} and update the
+ // pkg_config_ovr and build_email_ovr flags accordingly if that's the
+ // case.
+ //
+ if (!cbo)
+ {
+ bool ceo (
+ (n.size () > 12 &&
+ n.compare (n.size () - 12, 12, "-build-email") == 0) ||
+ (n.size () > 20 &&
+ n.compare (n.size () - 20, 20, "-build-warning-email") == 0) ||
+ (n.size () > 18 &&
+ n.compare (n.size () - 18, 18, "-build-error-email") == 0));
+
+ if (ceo)
+ pkg_config_ovr = true;
+
+ build_email_ovr = (ceo ||
+ n == "build-email" ||
+ n == "build-warning-email" ||
+ n == "build-error-email");
+ }
+
+ // Check if the name is one of {[*-]build-auxiliary[-*]} and update
+ // the pkg_config_ovr and aux_ovr flags accordingly if that's the
+ // case.
+ //
+ if (!cbo && !build_email_ovr)
{
if (optional<pair<string, string>> an =
bpkg::build_auxiliary::parse_value_name (n))
@@ -289,6 +334,16 @@ namespace bdep
pkg_config_ovr = true;
}
}
+
+ // Check if the name is one of {*-build-bot}and update the
+ // pkg_config_ovr flag accordingly if that's the case.
+ //
+ if (!cbo && !build_email_ovr && !aux_ovr)
+ {
+ if (n.size () > 10 &&
+ n.compare (n.size () - 10, 10, "-build-bot") == 0)
+ pkg_config_ovr = true;
+ }
}
overrides.insert (overrides.end (),
@@ -315,7 +370,10 @@ namespace bdep
if (o.interactive_specified ())
fail << "--target-config specified together with --interactive|-i";
- override ("builds", "all", origin::target_config);
+ // Add "builds: all", unless the builds value is already overridden.
+ //
+ if (!builds_override ())
+ override ("builds", "all", origin::target_config);
for (const string& c: o.target_config ())
override ("build-include", c, origin::target_config);
@@ -380,8 +438,8 @@ namespace bdep
// Add a package to the list and suppressing duplicates.
//
auto add_package = [&pkgs] (package_name n,
- const dir_path& d,
- package_info&& pi)
+ const dir_path& d,
+ package_info&& pi)
{
auto i (find_if (pkgs.begin (),
pkgs.end (),
@@ -423,15 +481,17 @@ namespace bdep
}
else
{
- configurations cfgs;
+ pair<configurations, bool> cfgs;
{
// Don't keep the database open longer than necessary.
//
database db (open (prj, trace));
transaction t (db.begin ());
- cfgs = find_configurations (o, prj, t).first;
+ cfgs = find_configurations (o, prj, t);
t.commit ();
+
+ verify_project_packages (pp, cfgs);
}
// Add a package to the list, suppressing duplicates and verifying that
@@ -470,7 +530,7 @@ namespace bdep
if (pp.packages.empty ())
{
- for (const shared_ptr<configuration>& c: cfgs)
+ for (const shared_ptr<configuration>& c: cfgs.first)
{
for (const package_state& p: c->packages)
add_package (p.name, c);
@@ -482,7 +542,7 @@ namespace bdep
{
bool init (false);
- for (const shared_ptr<configuration>& c: cfgs)
+ for (const shared_ptr<configuration>& c: cfgs.first)
{
if (find_if (c->packages.begin (),
c->packages.end (),
@@ -499,9 +559,7 @@ namespace bdep
}
}
- if (!init)
- fail << "package " << p.name << " is not initialized in any "
- << "configuration";
+ assert (init); // Wouldn't be here otherwise.
}
}
}
@@ -570,7 +628,11 @@ namespace bdep
bool first (find (package_configs.begin (), package_configs.end (),
pc) == package_configs.end ());
- if (first)
+ // For the specific <pc> add "<pc>-builds: all" when the first
+ // --build-config <pc>/... option is encountered, unless the
+ // "<pc>-builds" value is already overridden.
+ //
+ if (first && !builds_override (pc))
override (pc + "-builds", "all", origin::build_config);
override (pc + "-build-include",
@@ -603,6 +665,14 @@ namespace bdep
fail << "package configuration " << pc << " is specified using "
<< "both --package-config and --build-config";
+ // If for the specific <pc> the "<pc>-builds" value is already
+ // overridden, then skip the --package-config <pc> option, assuming
+ // that the former override has already selected the <pc>
+ // configuration for the CI task.
+ //
+ if (builds_override (pc))
+ continue;
+
using bpkg::build_package_config;
using bpkg::build_class_expr;
using bpkg::build_constraint;
@@ -777,13 +847,20 @@ namespace bdep
fail << "invalid --interactive|-i option value '" << s
<< "': target configuration name is empty";
+ // For the specific <pc> add "<pc>-builds: all", unless the
+ // "<pc>-builds" value is already overridden.
+ //
+ bool bo (builds_override (pc));
+
if (!pc.empty ())
pc += '-';
if (!tg.empty ())
tg = '/' + tg;
- override (pc + "builds", "all", origin::interactive);
+ if (!bo)
+ override (pc + "builds", "all", origin::interactive);
+
override (pc + "build-include", tc + tg, origin::interactive);
override (pc + "build-exclude", "**", origin::interactive);
@@ -816,7 +893,12 @@ namespace bdep
diag_record dr (fail);
dr << "invalid " << to_string (static_cast<origin> (e.line))
<< ": " << e.description <<
- info << "override: " << nv.name << ": " << nv.value;
+ info << "override: " << nv.name << ':';
+
+ if (nv.value.find ('\n') == string::npos)
+ dr << ' ' << nv.value;
+ else
+ dr << "\n\\\n" << nv.value << "\n\\";
if (!n.empty () && override_manifests.size () != 1)
dr << info << "package: " << n;