tools: fix install-* meson targets.

We should not rely on the current working directory, as it looks like
meson sets it to be the source directory (even when actually in the
build dir) when running custom target (so it fails).

Instead meson explicitly sets MESON_SOURCE_ROOT and MESON_BUILD_ROOT
environment variables for us. We should use these. This should work in
every cases (whether calling from the source or build dir).

Also removing the special-casing for a _build/ directory. This updated
version is generic and won't assume that you used some generic naming or
direct subdir under the source (even if many people might use this path
and name; I, for one, certainly don't!).

See: https://mesonbuild.com/Run-targets.html
This commit is contained in:
Jehan 2019-09-11 18:38:05 +02:00
parent 035802c5a6
commit 3bfbf9972a

View file

@ -34,15 +34,12 @@ class MesonStatus(metaclass = Singleton):
def get_build_dir(self):
self.buildroot = None
cwd = Path(os.getcwd())
# Set up by meson.
cwd = Path(os.environ['MESON_BUILD_ROOT'])
if (cwd / 'meson-info').exists():
self.buildroot = cwd
with cwd / '_build' as _build:
if (_build / 'meson-info').exists():
self.buildroot = _build
if self.buildroot is None:
print('Error: build directory was not detected. Are you in it ?')