From f2dfe3ab13148fd1d3bd5adcfaa1b0ee1af89a1a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 May 2019 09:04:51 +0200 Subject: Diagnose package/project name mismatch in version module --- build2/file.cxx | 1 + build2/scope.hxx | 1 + build2/version/init.cxx | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/build2/file.cxx b/build2/file.cxx index b12d39c..139cf99 100644 --- a/build2/file.cxx +++ b/build2/file.cxx @@ -452,6 +452,7 @@ namespace build2 a ? alt_buildignore_file : std_buildignore_file, a ? alt_root_dir : std_root_dir, a ? alt_bootstrap_dir : std_bootstrap_dir, + a ? alt_bootstrap_file : std_bootstrap_file, a ? alt_root_file : std_root_file, a ? alt_export_file : std_export_file, a ? alt_src_root_file : std_src_root_file, diff --git a/build2/scope.hxx b/build2/scope.hxx index 84e7ffb..83396b4 100644 --- a/build2/scope.hxx +++ b/build2/scope.hxx @@ -283,6 +283,7 @@ namespace build2 const dir_path& root_dir; // build[2]/root/ const dir_path& bootstrap_dir; // build[2]/bootstrap/ + const path& bootstrap_file; // build[2]/bootstrap.build[2] const path& root_file; // build[2]/root.build[2] const path& export_file; // build[2]/export.build[2] const path& src_root_file; // build[2]/bootstrap/src-root.build[2] diff --git a/build2/version/init.cxx b/build2/version/init.cxx index 1a5f249..c4a0444 100644 --- a/build2/version/init.cxx +++ b/build2/version/init.cxx @@ -41,6 +41,9 @@ namespace build2 // Extract the version from the manifest file. As well as summary and // url while at it. // + // Also, as a sanity check, verify the package name matches the build + // system project name. + // string sum; string url; @@ -63,6 +66,21 @@ namespace build2 for (nv = p.next (); !nv.empty (); nv = p.next ()) { + if (nv.name == "name") + { + auto& pn (cast (rs.vars[var_project])); + + if (nv.value != pn.string ()) + { + path bf (rs.src_path () / rs.root_extra->bootstrap_file); + location ml (&f, nv.value_line, nv.value_column); + location bl (&bf); + + fail (ml) << "package name " << nv.value << " does not match " + << "build system project name " << pn << + info (bl) << "build system project name specified here"; + } + } if (nv.name == "summary") sum = move (nv.value); else if (nv.name == "url") -- cgit v1.1