aboutsummaryrefslogtreecommitdiff
path: root/mod/build-config.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-11-30 13:28:04 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-11-30 17:10:06 +0300
commitf3d3143aa67d1d038f5eee1103c2b783d54955c4 (patch)
tree85e2c5eedf24cfef718c724a7711a2260397cc4f /mod/build-config.cxx
parent68aa933548c0fb927d0d03c522e49ba361c0e294 (diff)
Match build configuration names, targets and machine names as paths
Diffstat (limited to 'mod/build-config.cxx')
-rw-r--r--mod/build-config.cxx78
1 files changed, 66 insertions, 12 deletions
diff --git a/mod/build-config.cxx b/mod/build-config.cxx
index 5d3f46b..9368d33 100644
--- a/mod/build-config.cxx
+++ b/mod/build-config.cxx
@@ -6,7 +6,7 @@
#include <map>
#include <sstream>
-#include <algorithm> // find()
+#include <algorithm> // replace()
#include <libbutl/sha256.mxx>
#include <libbutl/utility.mxx> // throw_generic_error(), alpha(), etc.
@@ -245,24 +245,78 @@ namespace brep
// Now check if the configuration is excluded/included via the patterns.
//
- const string& cn (cfg.name);
- string tg (cfg.target.string ());
-
- for (const build_constraint& c: constrs)
+ // To implement matching of absent name components with wildcard-only name
+ // components we are going to convert names into paths (see
+ // from_build_config_name() 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.
+ //
+ try
{
- if (path_match (c.config, cn) &&
- (!c.target || path_match (*c.target, tg)))
+ path cn (from_build_config_name (cfg.name));
+ path tg (from_build_config_name (cfg.target.string ()));
+
+ for (const build_constraint& c: constrs)
{
- if (!c.exclusion)
- return false;
+ if (path_match (from_build_config_name (c.config),
+ cn,
+ dir_path () /* start */,
+ path_match_flags::match_absent) &&
+ (!c.target ||
+ path_match (from_build_config_name (*c.target),
+ tg,
+ dir_path () /* start */,
+ path_match_flags::match_absent)))
+ {
+ if (!c.exclusion)
+ return false;
- if (reason != nullptr)
- *reason = sanitize (c.comment);
+ if (reason != nullptr)
+ *reason = sanitize (c.comment);
- return true;
+ return true;
+ }
}
}
+ catch (const invalid_path&) {}
return false;
}
+
+ path
+ from_build_config_name (const string& s)
+ {
+ string r;
+ for (size_t i (0); i != s.size (); ++i)
+ {
+ char c (s[i]);
+
+ switch (c)
+ {
+ case '-':
+ {
+ r += '/';
+ break;
+ }
+ case '*':
+ {
+ if (s[i + 1] == '*') // Can be '\0'.
+ {
+ r += "*/**/*";
+ ++i;
+ break;
+ }
+ }
+ default:
+ {
+ r += c;
+ break;
+ }
+ }
+ }
+
+ return path (move (r));
+ }
}