mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-01 20:05:19 +00:00
src: add new target for regenerating protocol structs files
Introduce a new ninja target ninja -C build regen-{PROTO} eg ninja -C build regen-admin_protocol that will re-create the reference output file based on what the current pdwtags command emits. A small change is made to squash whitespace on enum declarations so that introducing a new longer enum name doesn't trigger re-indent of all existing enum names. Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
dcd1132937
commit
acf2f9e1ef
@ -36,6 +36,9 @@ targetname = sys.argv[2]
|
||||
libpath = sys.argv[3]
|
||||
pdwtags = sys.argv[4]
|
||||
expected = sys.argv[5]
|
||||
regen = False
|
||||
if len(sys.argv) == 7 and sys.argv[6] == "--regenerate":
|
||||
regen = True
|
||||
|
||||
builddir = os.path.dirname(libpath)
|
||||
libname = os.path.basename(libpath)
|
||||
@ -128,7 +131,29 @@ actualstr = "\n".join(actual) + "\n"
|
||||
# know our RPC structs are suitably aligned to not need
|
||||
# packing, so we can just trim the attribute.
|
||||
actualstr = re.sub(r'''} __attribute__\(\(__packed__\)\);''', "};", actualstr)
|
||||
actualstr = re.sub(r'''([A-Z0-9]+)\s+=\s+(\d)''', r'''\1 = \2''', actualstr)
|
||||
|
||||
diff.communicate(input=actualstr.encode("utf-8"))
|
||||
|
||||
sys.exit(diff.returncode)
|
||||
if diff.returncode != 0:
|
||||
if regen:
|
||||
with open(expected, "w") as fh:
|
||||
print(actualstr, file=fh, end='')
|
||||
|
||||
print("")
|
||||
print("WARNING: reference output was re-generated to apply")
|
||||
print("WARNING: the above diff. Validate the changes are")
|
||||
print("WARNING: expected and correct before committing")
|
||||
print("")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print("")
|
||||
print("WARNING: validate the above protocol changes are")
|
||||
print("WARNING: expected and correct. To re-generate the")
|
||||
print("WARNING: reference output invoke")
|
||||
print("")
|
||||
print(" $ ninja regen-%s" % name)
|
||||
|
||||
sys.exit(diff.returncode)
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
@ -1088,6 +1088,20 @@ if tests_enabled[0]
|
||||
depends: [ lib ],
|
||||
suite: 'script'
|
||||
)
|
||||
|
||||
run_target(
|
||||
'regen-@0@'.format(proto['name']),
|
||||
command: [python3_prog,
|
||||
check_remote_protocol_prog.full_path(),
|
||||
proto['name'],
|
||||
lib.name(),
|
||||
lib.full_path(),
|
||||
pdwtags_prog.full_path(),
|
||||
files('@0@-structs'.format(proto['name'])),
|
||||
'--regenerate',
|
||||
],
|
||||
env: runutf8,
|
||||
depends: [ lib ])
|
||||
endforeach
|
||||
endif
|
||||
endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user