qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/7] configure: integrate Meson in the build sys


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 3/7] configure: integrate Meson in the build system
Date: Thu, 27 Jun 2019 10:52:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

On 26/06/19 19:34, Markus Armbruster wrote:
> Paolo Bonzini <address@hidden> writes:
> 
>> The Meson build system is integrated in the existing configure/make steps
>> by invoking Meson from the configure script and converting Meson's 
>> build.ninja
>> rules to an included Makefile.
>>
>> Signed-off-by: Paolo Bonzini <address@hidden>
>> ---
>>  Makefile             |   9 +
>>  configure            |  30 ++
>>  meson.build          |   9 +
>>  scripts/ninjatool.py | 964 
>> +++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> Uff.

What, the 9+30+9 or the 964? :)

>> +export NINJA=./ninjatool
>> +Makefile.ninja: build.ninja ninjatool
>> +    ./ninjatool -t ninja2make --omit dist uninstall < $< > $@
>> +-include Makefile.ninja
>> +
>> +ninjatool: $(SRC_PATH)/scripts/ninjatool.py
>> +    sed -e '1c\' -e '#! $(PYTHON)' $< > $@
>> +    chmod +x $@
> 
> Why do we need this here, but not for other Python scripts?
> 
> We have 39 Python scripts with #!/usr/bin/env python, one with
> #!/usr/bin/env python2, and 12 with #!/usr/bin/python.  The Makefiles
> generally use $(PYTHON) SCRIPT ARGS...

Because this script is invoked by meson too.  While my patch to support
a NINJA environment variable was accepted (and we point it to
ninjatool), meson invokes it as "$(NINJA)" --foo with no splitting, so
we need the above change.

But I can do better than this.  I can generate the file directly from
meson.build:

   configure_file(input: files('scripts/ninjatool.py'),
                  output: 'ninjatool',
                  configuration: config_host)

and avoid code duplication between configure and Makefile.

>> +rm -rf meson-private meson-info meson-logs
> 
> Ignorant question: why do we need configure remove this stuff?

By default, reinvoking meson complains that you probably want to
reconfigure (a la config.status) because there is already a build tree
here.  Our configure script always reconfigures the tree from scratch.
 So I just cause meson to fail that check.

>> +NINJA=$PWD/ninjatool $python $meson setup \
> 
> This prints
> 
>     /usr/bin/python3: can't open file 'meson': [Errno 2] No such file or 
> directory
> 
> for me, then goes on happily.
> 
> For what it's worth:
> 
>     $ type meson
>     meson is /usr/bin/meson
> 
> Are you sure you want to override /usr/bin/meson's #! line?

No I'm not.  It should be just $meson, as you do below, though it could
also be $python "$(type -p meson)" if I wanted to override---but
certainly not $python $meson.  It worked for me because I was pointing
$meson to an absolute path under my home directory.

There is actually one reason to override it, which is why I did it in
the patch.  Meson has an automagic way to invoke all Python programs
with the same interpreter that was used to run meson itself (you make
the script non-executable and add "#! /usr/bin/env python3" as the first
line).  If we want to use that feature, we should invoke meson with $python.

> If I drop $python, I get
> 
>     meson.build:1:0: ERROR: Meson version is 0.50.1 but project requires 
> >=0.50.999.
> 
> which is expected.
> 
> It's too hot right for me now to figure out how to obtain a suitable
> version.

FWIW 0.51.0 has now been released so you could grab it from Koji.

>> diff --git a/scripts/ninjatool.py b/scripts/ninjatool.py
>> new file mode 100644
>> index 0000000..6d90919
>> --- /dev/null
>> +++ b/scripts/ninjatool.py
> [Lots of code...]
> 
> Did you write ninjatool.py specifically for QEMU, or did you steal it
> (or parts) somewhere?

I wrote it specifically for QEMU.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]