diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-04-08 13:44:33 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-04-08 13:44:33 +0200 |
commit | cea5dd6f96f2c06467264644f800619e9d24564d (patch) | |
tree | 1cbc193b5c2d4e18c6ef91952cdf4fe36f8f6264 /libbuild2/file.cxx | |
parent | 7ef1fb36f19adc7e31939fcfd874b6ad4b6d25c1 (diff) |
Allow configuration variables in unnamed projects
While generally a bad idea, there are valid situations where this may happen,
such as a standalone build of the tests subproject in test-installed.
Diffstat (limited to 'libbuild2/file.cxx')
-rw-r--r-- | libbuild2/file.cxx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx index 3e6282c..cbad9ec 100644 --- a/libbuild2/file.cxx +++ b/libbuild2/file.cxx @@ -1305,7 +1305,7 @@ namespace build2 // if (!p.config_report.empty () && verb >= (p.config_report_new ? 2 : 3)) { - const project_name& proj (named_project (root)); // Must be there. + const project_name& proj (named_project (root)); // Can be empty. // @@ TODO/MAYBE: // @@ -1323,7 +1323,14 @@ namespace build2 // the repetitive config.<project>. So we are only going to print the // part after <project> (see parser::parse_config() for details). // - string stem ('.' + proj.variable () + '.'); + // But if there is no named project, then we print everything after + // config. This feels right since there could be zero identifiable + // information about the project in the header line. For example: + // + // config @/tmp/tests + // libhello.tests.remote true + // + string stem (!proj.empty () ? '.' + proj.variable () + '.' : string ()); names storage; for (const pair<lookup, string>& lf: p.config_report) @@ -1342,8 +1349,10 @@ namespace build2 } else { - size_t p (l.var->name.find (stem)); // Must be there. - n = string (l.var->name, p + stem.size ()); + size_t p (!stem.empty () + ? l.var->name.find (stem) + stem.size () + : 7); // "config." + n = string (l.var->name, p); } dr << "\n "; |