From 8ea9bf7420a74e750f5ffbceb1b8667b097b3e96 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 6 Dec 2022 22:19:18 +0300 Subject: Add support for *-build-config override for bdep-ci command --- bdep/ci.cxx | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'bdep/ci.cxx') diff --git a/bdep/ci.cxx b/bdep/ci.cxx index 5f93872..e6acf98 100644 --- a/bdep/ci.cxx +++ b/bdep/ci.cxx @@ -221,7 +221,8 @@ namespace bdep // --build-email, and --builds which are all handled by // cli::parser. But first verify that they don't clash // with the other build constraints-related options. Also detect if any of - // these overrides are build package configuration-specific. + // them are build package configuration-specific build constraint + // overrides. // bool pkg_config_ovr (o.build_config_specified () || o.package_config_specified () || @@ -616,22 +617,41 @@ namespace bdep const small_vector& cs (m.build_configs); + // Fail if the specified build configuration is not found, unless + // there is a corresponding *-build-config override which means that + // this configuration will be created. Note that no configuration- + // specific build constraint overrides have been specified for it, + // since we would fail earlier in that case (they would clash with + // *-package-config). Thus, we will just override this being created + // build configuration with the common build constraints. + // + const build_package_config* c (nullptr); + auto i (find_if (cs.begin (), cs.end (), [&pc] (const build_package_config& c) {return c.name == pc;})); if (i == cs.end ()) - fail << "invalid --package-config option value: package " << m.name - << " has no build configuration '" << pc << '\''; + { + string v (pc + "-build-config"); + + if(find_if (overrides.begin (), overrides.end (), + [&v] (const manifest_name_value& nv) + {return nv.name == v;}) == overrides.end ()) + { + fail << "invalid --package-config option value: package " + << m.name << " has no build configuration '" << pc << '\''; + } + } + else + c = &*i; // Override the package configuration with it's current build // constraints, if present, and with the common build constraints // otherwise. // - const build_package_config& bc (*i); - - if (!bc.builds.empty () || !bc.constraints.empty ()) - override_builds (bc.builds, bc.constraints); + if (c != nullptr && (!c->builds.empty () || !c->constraints.empty ())) + override_builds (c->builds, c->constraints); else if (!m.builds.empty () || !m.build_constraints.empty ()) override_builds (m.builds, m.build_constraints); else -- cgit v1.1