Thanks, that might be worth fixing in Meson.

Paolo

Il gio 27 ago 2020, 17:57 Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk>
ha scritto:

> On 26/08/2020 20:02, Paolo Bonzini wrote:
>
> > On Windows it is not possible to invoke a Python script as $NINJA.
> > If ninja is present use it directly, while if it is not we can
> > keep using ninjatool.
> >
> > Reported-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk>
> > Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> > ---
> >  configure | 16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/configure b/configure
> > index 9db9bb89b9..6ecaff429b 100755
> > --- a/configure
> > +++ b/configure
> > @@ -568,6 +568,7 @@ rng_none="no"
> >  secret_keyring=""
> >  libdaxctl=""
> >  meson=""
> > +ninja=""
> >  skip_meson=no
> >  gettext=""
> >
> > @@ -1052,6 +1053,8 @@ for opt do
> >    ;;
> >    --meson=*) meson="$optarg"
> >    ;;
> > +  --ninja=*) ninja="$optarg"
> > +  ;;
> >    --smbd=*) smbd="$optarg"
> >    ;;
> >    --extra-cflags=*)
> > @@ -1820,6 +1823,7 @@ Advanced options (experts only):
> >    --python=PYTHON          use specified python [$python]
> >    --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
> >    --meson=MESON            use specified meson [$meson]
> > +  --ninja=NINJA            use specified ninja [$ninja]
> >    --smbd=SMBD              use specified smbd [$smbd]
> >    --with-git=GIT           use specified git [$git]
> >    --static                 enable static build [$static]
> > @@ -2058,6 +2062,16 @@ case "$meson" in
> >      *) meson=$(command -v meson) ;;
> >  esac
> >
> > +# Probe for ninja (used for compdb)
> > +
> > +if test -z "$ninja"; then
> > +    for c in ninja ninja-build samu; do
> > +        if has $c; then
> > +            ninja=$(command -v "$c")
> > +            break
> > +        fi
> > +    done
> > +fi
> >
> >  # Check that the C compiler works. Doing this here before testing
> >  # the host CPU ensures that we had a valid CC to autodetect the
> > @@ -8197,7 +8211,7 @@ fi
> >  mv $cross config-meson.cross
> >
> >  rm -rf meson-private meson-info meson-logs
> > -NINJA=$PWD/ninjatool $meson setup \
> > +NINJA=${ninja:-$PWD/ninjatool} $meson setup \
> >          --prefix "${pre_prefix}$prefix" \
> >          --libdir "${pre_prefix}$libdir" \
> >          --libexecdir "${pre_prefix}$libexecdir" \
>
> I've just tested this, but it gives me a python stacktrace if I run it
> without
> passing a --ninja argument to configure. With a bit of extra debugging
> added to see
> what is being generated:
>
> ###XXX ['C:/msys64/mingw64/bin/ninja', '--version']
> Traceback (most recent call last):
>   File "C:/msys64/home/Mark/qemu/meson/mesonbuild/mesonmain.py", line 131,
> in run
>     return options.run_func(options)
>   File "C:/msys64/home/Mark/qemu/meson/mesonbuild/msetup.py", line 245, in
> run
>     app.generate()
>   File "C:/msys64/home/Mark/qemu/meson/mesonbuild/msetup.py", line 159, in
> generate
>     self._generate(env)
>   File "C:/msys64/home/Mark/qemu/meson/mesonbuild/msetup.py", line 215, in
> _generate
>     intr.backend.generate()
>   File
> "C:/msys64/home/Mark/qemu/meson/mesonbuild/backend/ninjabackend.py", line
> 483,
> in generate
>     ninja = environment.detect_ninja_command_and_version(log=True)
>   File "C:/msys64/home/Mark/qemu/meson/mesonbuild/environment.py", line
> 177, in
> detect_ninja_command_and_version
>     name = os.path.basename(n)
>   File "C:/msys64/mingw64/lib/python3.8/ntpath.py", line 231, in basename
>     return split(p)[1]
>   File "C:/msys64/mingw64/lib/python3.8/ntpath.py", line 200, in split
>     p = os.fspath(p)
> TypeError: expected str, bytes or os.PathLike object, not NoneType
>
> ERROR: meson setup failed
>
> It seems that it doesn't like parsing the discovered ninja path. I can
> make configure
> work by passing --ninja=ninja to configure which falls back to PATH and
> appears to do
> the right thing:
>
> ###XXX ['ninja', '--version']
> Found ninja.EXE-1.10.1 at C:\msys64\mingw64\bin/ninja.EXE
>
> I tried a few other things too:
>
>  --ninja=C:/msys64/mingw64/bin/ninja - fails
>  --ninja=C:/msys64/mingw64/bin/ninja.exe - works
>  --ninja=ninja.exe - works
>  --ninja=/c/msys64/mingw64/bin/ninja - fails similar as above
>  --ninja=/c/msys64/mingw64/bin/ninja.exe - works
>  --ninja=C:\\msys64\\mingw64\\bin\\ninja - fails similar as above
>  --ninja=C:\\msys64\\mingw64\\bin\\ninja.exe - works
>
> From these tests it looks as if the .exe prefix is required when using a
> full path to
> the ninja executable.
>
>
> ATB,
>
> Mark.
>
>

Reply via email to