diff options
author | Ryan Kuester <rkuester@insymbols.com> | 2021-09-17 15:47:25 -0500 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2021-09-20 12:14:06 -0700 |
commit | 945f1851461a9db91ee0d2a4d623d15020650c2b (patch) | |
tree | dee17a834b2db12a92e7f074e9889dc806dfddcc /mesonbuild/backend/ninjabackend.py | |
parent | d7e71f3912df926e0fbb0dcebddfb4a7e6cc19f3 (diff) | |
download | meson-945f1851461a9db91ee0d2a4d623d15020650c2b.zip meson-945f1851461a9db91ee0d2a4d623d15020650c2b.tar.gz meson-945f1851461a9db91ee0d2a4d623d15020650c2b.tar.bz2 |
ninjabackend/vs: handle builddir on different drive from cwd
When setup creates a Visual Studio environment, a message is logged
which contains a path to the build directory. Typically, this path is
converted to a relative path prior to printing. If the path cannot be
converted to a relative path (e.g., because buildpath is on a different
drive from the cwd), print out the full path instead of failing with an
unhandled exception.
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index d821734..844c612 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -515,7 +515,13 @@ class NinjaBackend(backends.Backend): ninja = environment.detect_ninja_command_and_version(log=True) if need_setup_vsenv: builddir = Path(self.environment.get_build_dir()) - builddir = builddir.relative_to(Path.cwd()) + try: + # For prettier printing, reduce to a relative path. If + # impossible (e.g., because builddir and cwd are on + # different Windows drives), skip and use the full path. + builddir = builddir.relative_to(Path.cwd()) + except ValueError: + pass meson_command = mesonlib.join_args(mesonlib.get_meson_command()) mlog.log() mlog.log('Visual Studio environment is needed to run Ninja. It is recommended to use Meson wrapper:') |