mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
esx: separate header and source file generation
Invoke the generator twice and introduce separate meson targets for headers and C sources. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
b15483ff7b
commit
01c620ffc0
@ -1331,24 +1331,27 @@ additional_object_features = {
|
|||||||
|
|
||||||
removed_object_features = {}
|
removed_object_features = {}
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 4:
|
||||||
report_error("usage: %s srcdir builddir" % sys.argv[0])
|
report_error("usage: %s srcdir builddir header" % sys.argv[0])
|
||||||
|
|
||||||
input_filename = os.path.join(sys.argv[1], "esx/esx_vi_generator.input")
|
input_filename = os.path.join(sys.argv[1], "esx/esx_vi_generator.input")
|
||||||
output_dirname = os.path.join(sys.argv[2], "esx")
|
output_dirname = os.path.join(sys.argv[2], "esx")
|
||||||
|
header = sys.argv[3] == "header"
|
||||||
|
|
||||||
|
|
||||||
types_typedef = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typedef"))
|
if header:
|
||||||
types_typeenum = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typeenum"))
|
types_typedef = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typedef"))
|
||||||
types_typetostring = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typetostring"))
|
types_typeenum = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typeenum"))
|
||||||
types_typefromstring = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typefromstring"))
|
types_header = open_file(os.path.join(output_dirname, "esx_vi_types.generated.h"))
|
||||||
types_header = open_file(os.path.join(output_dirname, "esx_vi_types.generated.h"))
|
methods_header = open_file(os.path.join(output_dirname, "esx_vi_methods.generated.h"))
|
||||||
types_source = open_file(os.path.join(output_dirname, "esx_vi_types.generated.c"))
|
helpers_header = open_file(os.path.join(output_dirname, "esx_vi.generated.h"))
|
||||||
methods_header = open_file(os.path.join(output_dirname, "esx_vi_methods.generated.h"))
|
else:
|
||||||
methods_source = open_file(os.path.join(output_dirname, "esx_vi_methods.generated.c"))
|
types_typetostring = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typetostring"))
|
||||||
methods_macro = open_file(os.path.join(output_dirname, "esx_vi_methods.generated.macro"))
|
types_typefromstring = open_file(os.path.join(output_dirname, "esx_vi_types.generated.typefromstring"))
|
||||||
helpers_header = open_file(os.path.join(output_dirname, "esx_vi.generated.h"))
|
types_source = open_file(os.path.join(output_dirname, "esx_vi_types.generated.c"))
|
||||||
helpers_source = open_file(os.path.join(output_dirname, "esx_vi.generated.c"))
|
methods_macro = open_file(os.path.join(output_dirname, "esx_vi_methods.generated.macro"))
|
||||||
|
methods_source = open_file(os.path.join(output_dirname, "esx_vi_methods.generated.c"))
|
||||||
|
helpers_source = open_file(os.path.join(output_dirname, "esx_vi.generated.c"))
|
||||||
|
|
||||||
|
|
||||||
number = 0
|
number = 0
|
||||||
@ -1604,96 +1607,114 @@ for obj in managed_objects_by_name.values():
|
|||||||
|
|
||||||
notice = "/* Generated by esx_vi_generator.py */\n\n\n\n"
|
notice = "/* Generated by esx_vi_generator.py */\n\n\n\n"
|
||||||
|
|
||||||
types_typedef.write(notice)
|
if (header):
|
||||||
types_typeenum.write(notice)
|
types_typedef.write(notice)
|
||||||
types_typetostring.write(notice)
|
types_typeenum.write(notice)
|
||||||
types_typefromstring.write(notice)
|
types_header.write(notice)
|
||||||
types_header.write(notice)
|
methods_header.write(notice)
|
||||||
types_source.write(notice)
|
helpers_header.write(notice)
|
||||||
methods_header.write(notice)
|
else:
|
||||||
methods_source.write(notice)
|
types_typetostring.write(notice)
|
||||||
methods_macro.write(notice)
|
types_typefromstring.write(notice)
|
||||||
helpers_header.write(notice)
|
types_source.write(notice)
|
||||||
helpers_source.write(notice)
|
methods_macro.write(notice)
|
||||||
|
methods_source.write(notice)
|
||||||
|
helpers_source.write(notice)
|
||||||
|
|
||||||
|
|
||||||
# output enums
|
# output enums
|
||||||
types_typedef.write(separator +
|
if header:
|
||||||
" * VI Enums\n" +
|
types_typedef.write(separator +
|
||||||
" */\n\n")
|
" * VI Enums\n" +
|
||||||
|
" */\n\n")
|
||||||
|
|
||||||
names = sorted(enums_by_name.keys())
|
names = sorted(enums_by_name.keys())
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
types_typedef.write(enums_by_name[name].generate_typedef())
|
if header:
|
||||||
types_typeenum.write(enums_by_name[name].generate_typeenum())
|
types_typedef.write(enums_by_name[name].generate_typedef())
|
||||||
types_typetostring.write(enums_by_name[name].generate_typetostring())
|
types_typeenum.write(enums_by_name[name].generate_typeenum())
|
||||||
types_typefromstring.write(enums_by_name[name].generate_typefromstring())
|
types_header.write(enums_by_name[name].generate_header())
|
||||||
types_header.write(enums_by_name[name].generate_header())
|
else:
|
||||||
types_source.write(enums_by_name[name].generate_source())
|
types_typetostring.write(enums_by_name[name].generate_typetostring())
|
||||||
|
types_typefromstring.write(enums_by_name[name].generate_typefromstring())
|
||||||
|
types_source.write(enums_by_name[name].generate_source())
|
||||||
|
|
||||||
|
|
||||||
# output objects
|
# output objects
|
||||||
types_typedef.write("\n\n\n" +
|
if header:
|
||||||
separator +
|
types_typedef.write("\n\n\n" +
|
||||||
" * VI Objects\n" +
|
separator +
|
||||||
" */\n\n")
|
" * VI Objects\n" +
|
||||||
types_typeenum.write("\n")
|
" */\n\n")
|
||||||
types_typetostring.write("\n")
|
types_typeenum.write("\n")
|
||||||
types_typefromstring.write("\n")
|
else:
|
||||||
|
types_typetostring.write("\n")
|
||||||
|
types_typefromstring.write("\n")
|
||||||
|
|
||||||
names = sorted(objects_by_name.keys())
|
names = sorted(objects_by_name.keys())
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
types_typedef.write(objects_by_name[name].generate_typedef())
|
if header:
|
||||||
types_typeenum.write(objects_by_name[name].generate_typeenum())
|
types_typedef.write(objects_by_name[name].generate_typedef())
|
||||||
types_typetostring.write(objects_by_name[name].generate_typetostring())
|
types_typeenum.write(objects_by_name[name].generate_typeenum())
|
||||||
types_typefromstring.write(objects_by_name[name].generate_typefromstring())
|
types_header.write(objects_by_name[name].generate_header())
|
||||||
types_header.write(objects_by_name[name].generate_header())
|
else:
|
||||||
types_source.write(objects_by_name[name].generate_source())
|
types_typetostring.write(objects_by_name[name].generate_typetostring())
|
||||||
|
types_typefromstring.write(objects_by_name[name].generate_typefromstring())
|
||||||
|
types_source.write(objects_by_name[name].generate_source())
|
||||||
|
|
||||||
|
|
||||||
# output managed objects
|
# output managed objects
|
||||||
types_typedef.write("\n\n\n" +
|
if header:
|
||||||
separator +
|
types_typedef.write("\n\n\n" +
|
||||||
" * VI Managed Objects\n" +
|
separator +
|
||||||
" */\n\n")
|
" * VI Managed Objects\n" +
|
||||||
types_typeenum.write("\n")
|
" */\n\n")
|
||||||
types_typetostring.write("\n")
|
types_typeenum.write("\n")
|
||||||
types_typefromstring.write("\n")
|
else:
|
||||||
|
types_typetostring.write("\n")
|
||||||
|
types_typefromstring.write("\n")
|
||||||
|
|
||||||
names = sorted(managed_objects_by_name.keys())
|
names = sorted(managed_objects_by_name.keys())
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
types_typedef.write(managed_objects_by_name[name].generate_typedef())
|
if header:
|
||||||
types_typeenum.write(managed_objects_by_name[name].generate_typeenum())
|
types_typedef.write(managed_objects_by_name[name].generate_typedef())
|
||||||
types_typetostring.write(managed_objects_by_name[name].generate_typetostring())
|
types_typeenum.write(managed_objects_by_name[name].generate_typeenum())
|
||||||
types_typefromstring.write(managed_objects_by_name[name].generate_typefromstring())
|
types_header.write(managed_objects_by_name[name].generate_header())
|
||||||
types_header.write(managed_objects_by_name[name].generate_header())
|
else:
|
||||||
types_source.write(managed_objects_by_name[name].generate_source())
|
types_typetostring.write(managed_objects_by_name[name].generate_typetostring())
|
||||||
|
types_typefromstring.write(managed_objects_by_name[name].generate_typefromstring())
|
||||||
|
types_source.write(managed_objects_by_name[name].generate_source())
|
||||||
|
|
||||||
|
|
||||||
# output methods
|
# output methods
|
||||||
names = sorted(methods_by_name.keys())
|
names = sorted(methods_by_name.keys())
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
methods_header.write(methods_by_name[name].generate_header())
|
if header:
|
||||||
methods_source.write(methods_by_name[name].generate_source())
|
methods_header.write(methods_by_name[name].generate_header())
|
||||||
|
else:
|
||||||
|
methods_source.write(methods_by_name[name].generate_source())
|
||||||
|
|
||||||
names = list(autobind_names)
|
if not header:
|
||||||
names.sort()
|
names = list(autobind_names)
|
||||||
|
names.sort()
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
string = aligned("#define ESX_VI__METHOD__PARAMETER__THIS__%s " % name, "\\\n", 78)
|
string = aligned("#define ESX_VI__METHOD__PARAMETER__THIS__%s " % name, "\\\n", 78)
|
||||||
string += " ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference, \\\n"
|
string += " ESX_VI__METHOD__PARAMETER__THIS_FROM_SERVICE(ManagedObjectReference, \\\n"
|
||||||
string += aligned("", "%s)\n\n\n\n" % name, 49)
|
string += aligned("", "%s)\n\n\n\n" % name, 49)
|
||||||
|
|
||||||
methods_macro.write(string)
|
methods_macro.write(string)
|
||||||
|
|
||||||
|
|
||||||
# output helpers
|
# output helpers
|
||||||
names = sorted(managed_objects_by_name.keys())
|
names = sorted(managed_objects_by_name.keys())
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
helpers_header.write(managed_objects_by_name[name].generate_helper_header())
|
if header:
|
||||||
helpers_source.write(managed_objects_by_name[name].generate_helper_source())
|
helpers_header.write(managed_objects_by_name[name].generate_helper_header())
|
||||||
|
else:
|
||||||
|
helpers_source.write(managed_objects_by_name[name].generate_helper_source())
|
||||||
|
@ -12,21 +12,36 @@ esx_sources = [
|
|||||||
'esx_vi_types.c',
|
'esx_vi_types.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
esx_gen_headers = custom_target(
|
||||||
|
'virtesxgenheaders',
|
||||||
|
input: [
|
||||||
|
'esx_vi_generator.input',
|
||||||
|
],
|
||||||
|
output: [
|
||||||
|
'esx_vi.generated.h',
|
||||||
|
'esx_vi_methods.generated.h',
|
||||||
|
'esx_vi_types.generated.h',
|
||||||
|
'esx_vi_types.generated.typedef',
|
||||||
|
'esx_vi_types.generated.typeenum',
|
||||||
|
],
|
||||||
|
command: [
|
||||||
|
meson_python_prog, python3_prog.path(), esx_vi_generator_prog.path(),
|
||||||
|
meson.source_root() / 'src',
|
||||||
|
meson.build_root() / 'src',
|
||||||
|
'header',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
esx_gen_sources = custom_target(
|
esx_gen_sources = custom_target(
|
||||||
'virtesxgen',
|
'virtesxgensources',
|
||||||
input: [
|
input: [
|
||||||
'esx_vi_generator.input',
|
'esx_vi_generator.input',
|
||||||
],
|
],
|
||||||
output: [
|
output: [
|
||||||
'esx_vi.generated.c',
|
'esx_vi.generated.c',
|
||||||
'esx_vi.generated.h',
|
|
||||||
'esx_vi_methods.generated.c',
|
|
||||||
'esx_vi_methods.generated.h',
|
|
||||||
'esx_vi_methods.generated.macro',
|
'esx_vi_methods.generated.macro',
|
||||||
|
'esx_vi_methods.generated.c',
|
||||||
'esx_vi_types.generated.c',
|
'esx_vi_types.generated.c',
|
||||||
'esx_vi_types.generated.h',
|
|
||||||
'esx_vi_types.generated.typedef',
|
|
||||||
'esx_vi_types.generated.typeenum',
|
|
||||||
'esx_vi_types.generated.typefromstring',
|
'esx_vi_types.generated.typefromstring',
|
||||||
'esx_vi_types.generated.typetostring',
|
'esx_vi_types.generated.typetostring',
|
||||||
],
|
],
|
||||||
@ -34,6 +49,7 @@ esx_gen_sources = custom_target(
|
|||||||
meson_python_prog, python3_prog.path(), esx_vi_generator_prog.path(),
|
meson_python_prog, python3_prog.path(), esx_vi_generator_prog.path(),
|
||||||
meson.source_root() / 'src',
|
meson.source_root() / 'src',
|
||||||
meson.build_root() / 'src',
|
meson.build_root() / 'src',
|
||||||
|
'source',
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -42,6 +58,7 @@ if conf.has('WITH_ESX')
|
|||||||
'virt_driver_esx',
|
'virt_driver_esx',
|
||||||
[
|
[
|
||||||
esx_sources,
|
esx_sources,
|
||||||
|
esx_gen_headers[1],
|
||||||
esx_gen_sources[1],
|
esx_gen_sources[1],
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
|
Loading…
Reference in New Issue
Block a user