Commit graph

9 commits

Author SHA1 Message Date
Markus Armbruster 6fe71ebc68
qapi: Generate in source order
The generators' conversion to visitors (merge commit 9e72681d16)
changed the processing order of entities from source order to
alphabetical order. The next commit needs source order, so change it
back.

Backports commit 8a84767cc4f7e00e5dd62435c32be9e7d2cbe4d3 from qemu
2018-03-09 09:01:16 -05:00
Markus Armbruster cad1593b7d
qapi: Record 'include' directives in parse tree
The parse tree is a list of expressions. Except include expressions
currently get replaced by the included file's parse tree.

Instead of throwing away the include expression, keep it with the file
name expanded so you don't have to track the including file's
directory to make sense of it.

A future commit will put this include expression to use.

Backports commit 97f0249474d19c1d60fb9d934c8bc08625a619ca from qemu
2018-03-09 08:58:49 -05:00
Markus Armbruster 07453b11b8
qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
Backports commit 4257053083775c1f670fa828003915e25d13e9d7 from qemu
2018-03-09 08:56:45 -05:00
Markus Armbruster aaa4a812ed
qapi: Lift error reporting from QAPISchema.__init__() to callers
Backports commit 181feaf3555136dd7883e2434c4498ca1939bf1a from qemu
2018-03-09 08:55:45 -05:00
Markus Armbruster b859a59f49
qapi/common: Eliminate QAPISchema.exprs
Backports commit 71a7510baf8a5745eb844ab289f007ff8bbbee41 from qemu
2018-03-09 08:54:20 -05:00
Markus Armbruster 3ab06081d4
qapi: Improve include file name reporting in error messages
Error messages print absolute file names of included files even if the
user gave a relative one on the command line:

$ PYTHONPATH=scripts python -B tests/qapi-schema/test-qapi.py tests/qapi-schema/include-cycle.json
In file included from tests/qapi-schema/include-cycle.json:1:
In file included from /work/armbru/qemu/tests/qapi-schema/include-cycle-b.json:1:
/work/armbru/qemu/tests/qapi-schema/include-cycle-c.json:1: Inclusion loop for include-cycle.json

Improve this to

In file included from tests/qapi-schema/include-cycle.json:1:
In file included from tests/qapi-schema/include-cycle-b.json:1:
tests/qapi-schema/include-cycle-c.json:1: Inclusion loop for include-cycle.json

The error message when an include file can't be opened prints the
include directive's file name, which is relative to the including
file. Change this to print the file name relative to the working
directory. Visible in tests/qapi-schema/include-no-file.err.

Backports commit af97502ce9c648ae5c746b9e562d6e4586f02eee from qemu
2018-03-09 08:53:00 -05:00
Markus Armbruster d74daa8fce
qapi: Touch generated files only when they change
A massive number of objects depends on QAPI-generated headers. In my
"build everything" tree, it's roughly 4800 out of 5100. This is
particularly annoying when only some of the generated files change,
say for a doc fix.

Improve qapi-gen.py to touch its output files only if they actually
change. Rebuild time for a QAPI doc fix drops from many minutes to a
few seconds. Rebuilds get faster for certain code changes, too. For
instance, adding a simple QMP event now recompiles less than 200
instead of 4800 objects. But adding a QAPI type is as bad as ever;
we've clearly got more work to do.

Backports commit 907b846653fb3757bf2ab98d6d66f92df34d875f from qemu
2018-03-09 08:51:14 -05:00
Markus Armbruster 3b1d4defe3
qapi-gen: Convert from getopt to argparse
argparse is nicer to use than getopt, and gives us --help almost for
free.

Backports commit 3b446a1817289d89844ad77c719bdc44bbcd1198 from qemu
2018-03-09 08:49:33 -05:00
Markus Armbruster 8c51980332
qapi-gen: New common driver for code and doc generators
Whenever qapi-schema.json changes, we run six programs eleven times to
update eleven files. Similar for qga/qapi-schema.json. This is
silly. Replace the six programs by a single program that spits out
all eleven files.

The programs become modules in new Python package qapi, along with the
helper library. This requires moving them to scripts/qapi/. While
moving them, consistently drop executable mode bits.

Backports commit fb0bc835e56b894cbc7236294921e5393c786ad8 from qemu
2018-03-09 08:47:12 -05:00