msetup: fix misleading error message about directories

`validate_core_dirs` method is used to find out which directory contains the
sources and which one will be used as build directory.

Its error message misleads the user when the user follows the order of
positional arguments of `meson setup` (the first one should be the build
directory and the second one the source directory). In case of invalid
configuration, e.g. when neither directory contained a `meson.build` file, the
error message was:

> $ meson setup ./build ./src
> ERROR: Neither source directory './build' nor build directory './src' contain
> a build file meson.build.

In this case, a user might waste time trying to figure out why their build
directory is being reported as the source directory.

Since the purpose of this method is to determine what each directory
corresponds, the best possible error message should make no assumptions about
the directories.
This commit is contained in:
Adrien Dorsaz authored and Paolo Bonzini committed 2026-08-21 23:41:02 +02:00
1 parent 7d02790a23
commit fb0c38e959
1 file changed
+1 -1
+1 -1
View File
@@ -119,7 +119,7 @@ class MesonApp:
return os.path.exists(fname)
def validate_core_dirs(self, dir1: T.Optional[str], dir2: T.Optional[str]) -> T.Tuple[str, str]:
invalid_msg_prefix = f'Neither source directory {dir1!r} nor build directory {dir2!r}'
invalid_msg_prefix = f'Neither directory {dir1!r} nor directory {dir2!r}'
if dir1 is None:
if dir2 is None:
if not self.has_build_file('.') and self.has_build_file('..'):