aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/ci.cli10
-rw-r--r--bdep/ci.cxx67
-rw-r--r--tests/ci.testscript40
3 files changed, 100 insertions, 17 deletions
diff --git a/bdep/ci.cli b/bdep/ci.cli
index 65ae252..99b7834 100644
--- a/bdep/ci.cli
+++ b/bdep/ci.cli
@@ -237,10 +237,13 @@ namespace bdep
"<pc>/<tc>[/<tg>]",
"Shortcut for the following options sequence:
- \c{\b{--override\ }<pc>\b{-builds:all}}\n
+ [\c{\b{--override\ }<pc>\b{-builds:all}}]\n
\c{\b{--override\ }<pc>\b{-build-include:}<tc>[\b{/}<tg>]}\n
\c{\b{--override\ }<pc>\b{-build-exclude:**}}
+ The first override is omitted from the above sequence if the
+ \c{<pc>\b{-builds}} override is specified on the command line.
+
Repeat this option to specify multiple build configurations."
}
@@ -249,10 +252,13 @@ namespace bdep
"<tc>[/<tg>]",
"Shortcut for the following options sequence:
- \c{\b{--override\ builds:all}}\n
+ [\c{\b{--override\ builds:all}}]\n
\c{\b{--override\ build-include:}<tc>[\b{/}<tg>]}\n
\c{\b{--override\ build-exclude:**}}
+ The first override is omitted from the above sequence if the
+ \cb{builds} override is specified on the command line.
+
Repeat this option to specify multiple build target configurations."
}
diff --git a/bdep/ci.cxx b/bdep/ci.cxx
index dbe07bf..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,11 +264,15 @@ namespace bdep
{
const string& n (nv.name);
+ // 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 cbo ((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 &&
@@ -253,9 +281,12 @@ namespace bdep
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 &&
- (cbo ||
- n == "builds" ||
+ ((cbo && !cbso) ||
n == "build-include" ||
n == "build-exclude"))
{
@@ -339,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);
@@ -594,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",
@@ -627,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;
@@ -801,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);
diff --git a/tests/ci.testscript b/tests/ci.testscript
index 4f1a883..7f3e538 100644
--- a/tests/ci.testscript
+++ b/tests/ci.testscript
@@ -608,9 +608,21 @@ windows = ($cxx.target.class == 'windows')
{
$clone_prj;
- $* --target-config 'linux_debian_8-gcc_4.9' --builds '&gcc' 2>>EOE != 0
- error: invalid --builds option value: 'builds' override specified together with --target-config
- info: override: builds: &gcc
+ $* --target-config 'linux_debian_8-gcc_4.9' \
+ --override 'build-include: linux_debian_12-gcc_13' 2>>EOE != 0
+ error: invalid --override option value: 'build-include' override specified together with --target-config
+ info: override: build-include: linux_debian_12-gcc_13
+ EOE
+ }
+
+ : builds-overrides
+ :
+ {
+ $clone_prj;
+
+ $* --target-config 'linux_debian_8-gcc_4.9' --builds '&gcc' 2>>~%EOE%
+ %CI request is queued.*%
+ %reference: .+%
EOE
}
@@ -733,8 +745,8 @@ windows = ($cxx.target.class == 'windows')
$clone_prj;
$* --build-config 'default/linux_debian_8-gcc_4.9' --builds '&gcc' 2>>EOE != 0
- error: invalid --builds option value: 'builds' override specified together with --build-config
- info: override: builds: &gcc
+ error: invalid --build-config option value: 'default-builds' override specified together with 'builds' override
+ info: override: default-builds: all
EOE
}
@@ -856,9 +868,21 @@ windows = ($cxx.target.class == 'windows')
{
$clone_prj;
- $* --interactive 'linux_debian_8-gcc_4.9' --builds '&gcc' 2>>EOE != 0
- error: invalid --builds option value: 'builds' override specified together with --interactive|-i
- info: override: builds: &gcc
+ $* --interactive 'linux_debian_8-gcc_4.9' \
+ --override 'build-include: linux_debian_12-gcc_13' 2>>EOE != 0
+ error: invalid --override option value: 'build-include' override specified together with --interactive|-i
+ info: override: build-include: linux_debian_12-gcc_13
+ EOE
+ }
+
+ : overrides-builds
+ :
+ {
+ $clone_prj;
+
+ $* --interactive 'linux_debian_8-gcc_4.9' --builds '&gcc' 2>>~%EOE%
+ %CI request is queued.*%
+ %reference: .+%
EOE
}
}