Python script generates code and header together however allowed to save only one of them. Allows to save both of them together to reduce number of time we call Python script. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- common/Makefile.am | 16 ++++++---------- common/client_marshallers.h | 2 +- common/meson.build | 19 +++++++++++++++---- spice_codegen.py | 12 ++++++++++-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/common/Makefile.am b/common/Makefile.am index 3318009..3da5bad 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -112,21 +112,17 @@ MARSHALLERS_DEPS = \ generated_client_demarshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include common/messages.h $< $@ >/dev/null -generated_client_marshallers.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) - $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --client --include common/messages.h -H $< $@ >/dev/null - -generated_client_marshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) - $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include client_marshallers.h --client $< $@ >/dev/null +generated_client_marshallers.c generated_client_marshallers.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include client_marshallers.h --client \ + --generated-header generated_client_marshallers.h $< $@ >/dev/null generated_server_demarshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --server --include common/messages.h $< $@ >/dev/null STRUCTS = -M String -M Rect -M Point -M DisplayBase -M Fill -M Opaque -M Copy -M Blend -M Blackness -M Whiteness -M Invers -M Rop3 -M Stroke -M Text -M Transparent -M AlphaBlend -M Composite -generated_server_marshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) - $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include common/messages.h $< $@ >/dev/null - -generated_server_marshallers.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) - $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include common/messages.h -H $< $@ >/dev/null +generated_server_marshallers.c generated_server_marshallers.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS) + $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include common/messages.h \ + --generated-header generated_server_marshallers.h $< $@ >/dev/null EXTRA_DIST = \ $(CLIENT_MARSHALLERS) \ diff --git a/common/client_marshallers.h b/common/client_marshallers.h index f082934..b67b98e 100644 --- a/common/client_marshallers.h +++ b/common/client_marshallers.h @@ -21,9 +21,9 @@ #include <spice/protocol.h> +#include "messages.h" #include "common/generated_client_marshallers.h" #include "marshaller.h" -#include "messages.h" SPICE_BEGIN_DECLS diff --git a/common/meson.build b/common/meson.build index 156297b..9575568 100644 --- a/common/meson.build +++ b/common/meson.build @@ -65,8 +65,14 @@ spice_common_dep = declare_dependency(link_with : spice_common_lib, if spice_common_generate_client_code targets = [ ['client_demarshallers', spice_proto, 'generated_client_demarshallers.c', ['--generate-demarshallers', '--client', '--include', 'common/messages.h', '@INPUT@', '@OUTPUT@']], - ['client_marshalers', spice_proto, 'generated_client_marshallers.c', ['--generate-marshallers', '-P', '--client', '--include', 'client_marshallers.h', '@INPUT@', '@OUTPUT@']], - ['client_marshallers_h', spice_proto, 'generated_client_marshallers.h', ['--generate-marshallers', '-P', '--client', '--include', 'common/messages.h', '-H', '@INPUT@', '@OUTPUT@']], + ['client_marshallers', spice_proto, + ['generated_client_marshallers.c', 'generated_client_marshallers.h'], + ['--generate-marshallers', + '-P', '--client', '--include', 'client_marshallers.h', + '--generated-header', '@OUTPUT1@', + '@INPUT@', '@OUTPUT0@' + ] + ] ] spice_common_client_sources = [ @@ -116,8 +122,13 @@ if spice_common_generate_server_code targets = [ ['server_demarshallers', spice_proto, 'generated_server_demarshallers.c', ['--generate-demarshallers', '--server', '--include', 'common/messages.h', '@INPUT@', '@OUTPUT@']], - ['server_marshallers', spice_proto, 'generated_server_marshallers.c', ['--generate-marshallers', '--server'] + structs_args + ['--include', 'common/messages.h', '@INPUT@', '@OUTPUT@']], - ['server_marshallers_h', spice_proto, 'generated_server_marshallers.h', ['--generate-marshallers', '--server'] + structs_args + ['--include', 'common/messages.h', '-H', '@INPUT@', '@OUTPUT@']], + ['server_marshallers', spice_proto, + ['generated_server_marshallers.c', 'generated_server_marshallers.h'], + ['--generate-marshallers', + '--generated-header', '@OUTPUT1@', + '--server'] + structs_args + ['--include', 'common/messages.h', '@INPUT@', '@OUTPUT0@' + ] + ], ] spice_common_server_sources = [] diff --git a/spice_codegen.py b/spice_codegen.py index 7e22092..4664740 100755 --- a/spice_codegen.py +++ b/spice_codegen.py @@ -175,6 +175,8 @@ parser.add_option("--ptrsize", dest="ptrsize", help="set default pointer size", default="4") parser.add_option("--license", dest="license", help="license to use for generated file(s) (LGPL/BSD)", default="LGPL") +parser.add_option("--generated-header", dest="generated_header", metavar="FILE", + help="Name of the file to generate the header") (options, args) = parser.parse_args() @@ -196,7 +198,10 @@ if proto == None: codegen.set_prefix(proto.name) writer = codegen.CodeWriter() writer.header = codegen.CodeWriter() -writer.header.set_option("dest_file", dest_file) +if options.generated_header: + writer.header.set_option("dest_file", options.generated_header) +else: + writer.header.set_option("dest_file", dest_file) writer.set_option("source", os.path.basename(proto_file)) if options.license == "LGPL": @@ -260,7 +265,7 @@ writer.writeln("/* this is a file autogenerated by spice_codegen.py */") writer.write(license) writer.header.writeln("/* this is a file autogenerated by spice_codegen.py */") writer.header.write(license) -if not options.header and not options.generate_enums: +if not options.generate_enums: writer.writeln("#ifdef HAVE_CONFIG_H") writer.writeln("#include <config.h>") writer.writeln("#endif") @@ -315,4 +320,7 @@ if options.header: else: content = writer.getvalue() write_content(dest_file, content, options.keep_identical_file) +if options.generated_header: + content = writer.header.getvalue() + write_content(options.generated_header, content, options.keep_identical_file) sys.exit(0) -- 2.20.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel