diff mbox

[trivial] qapi: Build-depend on all json files

Message ID 145459675563.11777.5257429454748921678.stgit@localhost (mailing list archive)
State New, archived
Headers show

Commit Message

Lluís Vilanova Feb. 4, 2016, 2:39 p.m. UTC
Dynamically detects the files used to generate QAPI code, thus ensuring
it's never out of sync with the sources.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 Makefile |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Peter Maydell Feb. 4, 2016, 2:55 p.m. UTC | #1
On 4 February 2016 at 14:39, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
> Dynamically detects the files used to generate QAPI code, thus ensuring
> it's never out of sync with the sources.
>
> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
>  Makefile |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d0de2d4..627f772 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -269,10 +269,8 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>                 $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
>                 "  GEN   $@")
>
> -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
> -               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
> -               $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \
> -               $(SRC_PATH)/qapi/crypto.json
> +qapi-modules = $(SRC_PATH)/qapi-schema.json
> +qapi-modules += $(shell find $(SRC_PATH)/qapi -name "*.json")

All the .json files are in the same directory, so I don't think we should
need to use find here. Does

qapi-modules += $(wildcard $(SRC_PATH)/qapi/*.json))

work ?

thanks
-- PMM
Lluís Vilanova Feb. 4, 2016, 2:58 p.m. UTC | #2
Lluís Vilanova writes:

> Dynamically detects the files used to generate QAPI code, thus ensuring
> it's never out of sync with the sources.

> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
>  Makefile |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Sorry, I forgot to cc you (I guess you're the right people).

Thanks,
  Lluis
Eric Blake Feb. 4, 2016, 3:32 p.m. UTC | #3
On 02/04/2016 07:55 AM, Peter Maydell wrote:
> On 4 February 2016 at 14:39, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
>> Dynamically detects the files used to generate QAPI code, thus ensuring
>> it's never out of sync with the sources.
>>
>> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
>> ---
>>  Makefile |    6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index d0de2d4..627f772 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -269,10 +269,8 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>>                 $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
>>                 "  GEN   $@")
>>
>> -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
>> -               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
>> -               $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \
>> -               $(SRC_PATH)/qapi/crypto.json
>> +qapi-modules = $(SRC_PATH)/qapi-schema.json
>> +qapi-modules += $(shell find $(SRC_PATH)/qapi -name "*.json")
> 
> All the .json files are in the same directory, so I don't think we should
> need to use find here. Does
> 
> qapi-modules += $(wildcard $(SRC_PATH)/qapi/*.json))
> 
> work ?

Does this wildcard affect what goes into a tarball? I'm worried that we
may run the risk of a stale .json file on one developer's machine
causing an unreproducible build on other machines where the file is not
found; explicit lists tend to be safer than wildcards.

I won't reject the patch if others like it, but I won't approve it myself.
Peter Maydell Feb. 4, 2016, 3:36 p.m. UTC | #4
On 4 February 2016 at 15:32, Eric Blake <eblake@redhat.com> wrote:
> On 02/04/2016 07:55 AM, Peter Maydell wrote:
>> On 4 February 2016 at 14:39, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
>>> Dynamically detects the files used to generate QAPI code, thus ensuring
>>> it's never out of sync with the sources.
>>>
>>> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
>>> ---
>>>  Makefile |    6 ++----
>>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/Makefile b/Makefile
>>> index d0de2d4..627f772 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -269,10 +269,8 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>>>                 $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
>>>                 "  GEN   $@")
>>>
>>> -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
>>> -               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
>>> -               $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \
>>> -               $(SRC_PATH)/qapi/crypto.json
>>> +qapi-modules = $(SRC_PATH)/qapi-schema.json
>>> +qapi-modules += $(shell find $(SRC_PATH)/qapi -name "*.json")
>>
>> All the .json files are in the same directory, so I don't think we should
>> need to use find here. Does
>>
>> qapi-modules += $(wildcard $(SRC_PATH)/qapi/*.json))
>>
>> work ?
>
> Does this wildcard affect what goes into a tarball? I'm worried that we
> may run the risk of a stale .json file on one developer's machine
> causing an unreproducible build on other machines where the file is not
> found; explicit lists tend to be safer than wildcards.
>
> I won't reject the patch if others like it, but I won't approve it myself.

You need to ask Mike Roth about our tarball generation process, not me.

I do agree that this patch needs to make the case for why .json source
files are special and should be wildcarded, when for instance all our
C source files are explicitly listed in makefiles.

thanks
-- PMM
Lluís Vilanova Feb. 4, 2016, 3:58 p.m. UTC | #5
Peter Maydell writes:

> On 4 February 2016 at 14:39, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
>> Dynamically detects the files used to generate QAPI code, thus ensuring
>> it's never out of sync with the sources.
>> 
>> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
>> ---
>> Makefile |    6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>> 
>> diff --git a/Makefile b/Makefile
>> index d0de2d4..627f772 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -269,10 +269,8 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>> $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
>> "  GEN   $@")
>> 
>> -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
>> -               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
>> -               $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \
>> -               $(SRC_PATH)/qapi/crypto.json
>> +qapi-modules = $(SRC_PATH)/qapi-schema.json
>> +qapi-modules += $(shell find $(SRC_PATH)/qapi -name "*.json")

> All the .json files are in the same directory, so I don't think we should
> need to use find here. Does

> qapi-modules += $(wildcard $(SRC_PATH)/qapi/*.json))

> work ?

It certainly would work, I'll send a v2 with wildcard.

PS: this patch was triggered by finding out that qapi/trace.json is not on the
    qapi-modules list

Cheers,
  Lluis
Lluís Vilanova Feb. 4, 2016, 4:31 p.m. UTC | #6
Peter Maydell writes:

> On 4 February 2016 at 15:32, Eric Blake <eblake@redhat.com> wrote:
>> On 02/04/2016 07:55 AM, Peter Maydell wrote:
>>> On 4 February 2016 at 14:39, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
>>>> Dynamically detects the files used to generate QAPI code, thus ensuring
>>>> it's never out of sync with the sources.
>>>> 
>>>> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
>>>> ---
>>>> Makefile |    6 ++----
>>>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>>> 
>>>> diff --git a/Makefile b/Makefile
>>>> index d0de2d4..627f772 100644
>>>> --- a/Makefile
>>>> +++ b/Makefile
>>>> @@ -269,10 +269,8 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>>>> $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
>>>> "  GEN   $@")
>>>> 
>>>> -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
>>>> -               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
>>>> -               $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \
>>>> -               $(SRC_PATH)/qapi/crypto.json
>>>> +qapi-modules = $(SRC_PATH)/qapi-schema.json
>>>> +qapi-modules += $(shell find $(SRC_PATH)/qapi -name "*.json")
>>> 
>>> All the .json files are in the same directory, so I don't think we should
>>> need to use find here. Does
>>> 
>>> qapi-modules += $(wildcard $(SRC_PATH)/qapi/*.json))
>>> 
>>> work ?
>> 
>> Does this wildcard affect what goes into a tarball? I'm worried that we
>> may run the risk of a stale .json file on one developer's machine
>> causing an unreproducible build on other machines where the file is not
>> found; explicit lists tend to be safer than wildcards.
>> 
>> I won't reject the patch if others like it, but I won't approve it myself.

> You need to ask Mike Roth about our tarball generation process, not me.

> I do agree that this patch needs to make the case for why .json source
> files are special and should be wildcarded, when for instance all our
> C source files are explicitly listed in makefiles.

Ok, so I found that qapi/trace.json is missing in qapi-modules. I'm prototyping
some changes to it, but suddenly found that QAPI was failing to compile due to
outdated code.

So I followed the same approach used in tracetool, where find/wildcard will pull
in all relevant files as a dependency, without fear of missing any.

An explicit list makes a good case for reproducible builds wrt the distribution
tarball, but find/wildcard eliminate these type of compilation errors I've found
when a json file is not listed.

Cheers,
  Lluis
diff mbox

Patch

diff --git a/Makefile b/Makefile
index d0de2d4..627f772 100644
--- a/Makefile
+++ b/Makefile
@@ -269,10 +269,8 @@  $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
 		"  GEN   $@")
 
-qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
-               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
-               $(SRC_PATH)/qapi/event.json $(SRC_PATH)/qapi/introspect.json \
-               $(SRC_PATH)/qapi/crypto.json
+qapi-modules = $(SRC_PATH)/qapi-schema.json
+qapi-modules += $(shell find $(SRC_PATH)/qapi -name "*.json")
 
 qapi-types.c qapi-types.h :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)