aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-05-31 09:09:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-05-31 09:09:40 +0200
commitab424dffc590483c3a6a43f5e8ecb012aa9d6a78 (patch)
tree97adeb0d3defb7890f7dc46e872e4fd883debbf0 /libbuild2/config
parent54797bb6feb5f94a7f65b69c5b3b16da5410a2bc (diff)
Improve diagnostics when dropping config.import.* values
Diffstat (limited to 'libbuild2/config')
-rw-r--r--libbuild2/config/operation.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx
index aca6ce8..b06c29d 100644
--- a/libbuild2/config/operation.cxx
+++ b/libbuild2/config/operation.cxx
@@ -258,6 +258,24 @@ namespace build2
continue;
}
+ // A common reason behind an unused config.import.* value is an
+ // unused dependency. That is, there is depends in manifest but no
+ // import in buildfile (or import could be conditional in which case
+ // depends should also be conditional). So let's suggest this
+ // possibility. Note that the project name may have been sanitized
+ // to a variable name. Oh, well, better than nothing.
+ //
+ auto info_import = [] (diag_record& dr, const string& var)
+ {
+ if (var.compare (0, 14, "config.import.") == 0)
+ {
+ size_t p (var.find ('.', 14));
+
+ dr << info << "potentially unused dependency on "
+ << string (var, 14, p == string::npos ? p : p - 14);
+ }
+ };
+
const value& v (p.first->second);
pair<bool, bool> r (save_config_variable (*var,
@@ -285,6 +303,7 @@ namespace build2
diag_record dr;
dr << warn (on) << "saving no longer used variable " << *var;
+ info_import (dr, var->name);
if (verb >= 2)
info_value (dr, v);
}
@@ -295,6 +314,7 @@ namespace build2
{
diag_record dr;
dr << warn (on) << "dropping no longer used variable " << *var;
+ info_import (dr, var->name);
info_value (dr, v);
}
}