diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-01-09 09:21:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-01-09 09:21:12 +0200 |
commit | 16f5b5d540950f882ee20b13114917f420f41cbb (patch) | |
tree | b8fea9a18c73bdc34af83d189eae3b34c82642a9 /libbuild2/file.cxx | |
parent | 9dfd8f7c6902c7b38f34ca6f87d712d6dcefe3a2 (diff) |
Allow imported buildfiles to using config.* variables from own project
Diffstat (limited to 'libbuild2/file.cxx')
-rw-r--r-- | libbuild2/file.cxx | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx index 1e6cb4c..e62e607 100644 --- a/libbuild2/file.cxx +++ b/libbuild2/file.cxx @@ -1636,12 +1636,17 @@ namespace build2 init_modules (module_boot_init::after); } - // Print the project configuration report, similar to how we do it in + // Print the project configuration report(s), similar to how we do it in // build system modules. // - if (!p.config_report.empty () && verb >= (p.config_report_new ? 2 : 3)) + const project_name* proj (nullptr); // Resolve lazily. + for (const parser::config_report& cr: p.config_reports) { - const project_name& proj (named_project (root)); // Can be empty. + if (verb < (cr.new_value ? 2 : 3)) + continue; + + if (proj == nullptr) + proj = &named_project (root); // Can be empty. // @@ TODO/MAYBE: // @@ -1659,12 +1664,19 @@ namespace build2 // config @/tmp/tests // libhello.tests.remote true // - string stem (!proj.empty () ? '.' + proj.variable () + '.' : string ()); + // If the module name is not empty then it means the config variables + // are from the imported project and so we use that for <project>. + // + string stem (!cr.module.empty () + ? '.' + cr.module.variable () + '.' + : (!proj->empty () + ? '.' + proj->variable () + '.' + : string ())); // Calculate max name length. // size_t pad (10); - for (const pair<lookup, string>& lf: p.config_report) + for (const pair<lookup, string>& lf: cr.values) { lookup l (lf.first); @@ -1686,13 +1698,14 @@ namespace build2 } // Use the special `config` module name (which doesn't have its own - // report) for project configuration. + // report) for project's own configuration. // diag_record dr (text); - dr << "config " << proj << '@' << root; + dr << (cr.module.empty () ? "config" : cr.module.string ().c_str ()) + << ' ' << *proj << '@' << root; names storage; - for (const pair<lookup, string>& lf: p.config_report) + for (const pair<lookup, string>& lf: cr.values) { lookup l (lf.first); const string& f (lf.second); |