[Spice-devel] [spice-common v2 2/2] Use installed spice-protocol for code generation

Frediano Ziglio fziglio at redhat.com
Fri Aug 7 08:20:13 PDT 2015


> 
> Now that spice-protocol ships the needed .proto files as well as the
> corresponding python scripts, spice-common can use these in order to
> generate the C code for the SPICE (de)marshallers.
> ---
>  common/Makefile.am | 52 +++++++++++++++++++++++-----------------------------
>  configure.ac       |  4 +++-
>  m4/spice-deps.m4   |  1 +
>  3 files changed, 27 insertions(+), 30 deletions(-)
> 
> diff --git a/common/Makefile.am b/common/Makefile.am
> index b4384e8..2be512c 100644
> --- a/common/Makefile.am
> +++ b/common/Makefile.am
> @@ -14,7 +14,7 @@ SERVER_MARSHALLERS =				\
>  	generated_server_marshallers.h		\
>  	$(NULL)
>  
> -BUILT_SOURCES = $(CLIENT_MARSHALLERS) $(SERVER_MARSHALLERS)
> $(top_srcdir)/spice-protocol/spice/enums.h
> +BUILT_SOURCES = $(CLIENT_MARSHALLERS) $(SERVER_MARSHALLERS)
>  
>  noinst_LTLIBRARIES = libspice-common.la libspice-common-server.la
>  libspice-common-client.la
>  libspice_common_la_SOURCES =		\
> @@ -99,45 +99,39 @@ libspice_common_la_LIBADD =				\
>  	$(SPICE_COMMON_LIBS)				\
>  	$(NULL)
>  
> -MARSHALLERS_DEPS =					\
> -	$(top_srcdir)/python_modules/__init__.py	\
> -	$(top_srcdir)/python_modules/codegen.py		\
> -	$(top_srcdir)/python_modules/demarshal.py	\
> -	$(top_srcdir)/python_modules/marshal.py		\
> -	$(top_srcdir)/python_modules/ptypes.py		\
> -	$(top_srcdir)/python_modules/spice_parser.py	\
> -	$(top_srcdir)/spice_codegen.py			\
> +MARSHALLERS_DEPS =							\
> +	$(CODE_GENERATOR_BASEDIR)/python_modules/__init__.py		\
> +	$(CODE_GENERATOR_BASEDIR)/python_modules/codegen.py		\
> +	$(CODE_GENERATOR_BASEDIR)/python_modules/demarshal.py		\
> +	$(CODE_GENERATOR_BASEDIR)/python_modules/marshal.py		\
> +	$(CODE_GENERATOR_BASEDIR)/python_modules/ptypes.py		\
> +	$(CODE_GENERATOR_BASEDIR)/python_modules/spice_parser.py	\
> +	$(CODE_GENERATOR_BASEDIR)/spice_codegen.py			\
>  	$(NULL)
>  
>  # Note despite being autogenerated these are not part of CLEANFILES, they
>  are
>  # actually a part of EXTRA_DIST, to avoid the need for pyparser by end users
> -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_demarshallers.c: $(CODE_GENERATOR_BASEDIR)/spice.proto
> $(MARSHALLERS_DEPS)
> +	$(AM_V_GEN)$(PYTHON) $(CODE_GENERATOR_BASEDIR)/spice_codegen.py
> --generate-demarshallers --client --include common/messages.h $< $@
> >/dev/null
>  
> -generated_client_demarshallers1.c: $(top_srcdir)/spice1.proto
> $(MARSHALLERS_DEPS)
> -	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py
> --generate-demarshallers --client --include common/messages.h --prefix 1
> --ptrsize 8 $< $@ >/dev/null
> +generated_client_demarshallers1.c: $(CODE_GENERATOR_BASEDIR)/spice1.proto
> $(MARSHALLERS_DEPS)
> +	$(AM_V_GEN)$(PYTHON) $(CODE_GENERATOR_BASEDIR)/spice_codegen.py
> --generate-demarshallers --client --include common/messages.h --prefix 1
> --ptrsize 8 $< $@ >/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 common/messages.h --include client_marshallers.h --client $< $@
> >/dev/null
> +generated_client_marshallers.c: $(CODE_GENERATOR_BASEDIR)/spice.proto
> $(MARSHALLERS_DEPS)
> +	$(AM_V_GEN)$(PYTHON) $(CODE_GENERATOR_BASEDIR)/spice_codegen.py
> --generate-marshallers -P --include common/messages.h --include
> client_marshallers.h --client $< $@ >/dev/null
>  
> -generated_client_marshallers1.c: $(top_srcdir)/spice1.proto
> $(MARSHALLERS_DEPS)
> -	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers
> -P --include common/messages.h --include client_marshallers.h --client
> --prefix 1 --ptrsize 8 $< $@ >/dev/null
> +generated_client_marshallers1.c: $(CODE_GENERATOR_BASEDIR)/spice1.proto
> $(MARSHALLERS_DEPS)
> +	$(AM_V_GEN)$(PYTHON) $(CODE_GENERATOR_BASEDIR)/spice_codegen.py
> --generate-marshallers -P --include common/messages.h --include
> client_marshallers.h --client --prefix 1 --ptrsize 8 $< $@ >/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
> +generated_server_demarshallers.c: $(CODE_GENERATOR_BASEDIR)/spice.proto
> $(MARSHALLERS_DEPS)
> +	$(AM_V_GEN)$(PYTHON) $(CODE_GENERATOR_BASEDIR)/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.c: $(CODE_GENERATOR_BASEDIR)/spice.proto
> $(MARSHALLERS_DEPS)
> +	$(AM_V_GEN)$(PYTHON) $(CODE_GENERATOR_BASEDIR)/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
> -
> -# this is going to upset automake distcheck, since we try to write to
> -# readonly srcdir. To limit the fail chances, rebuild automatically
> -# enums.h only if the spice.proto has changed.
> -$(top_srcdir)/spice-protocol/spice/enums.h: $(top_srcdir)/spice.proto #
> $(MARSHALLERS_DEPS)
> -	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-enums $< $@
> >/dev/null
> +generated_server_marshallers.h: $(CODE_GENERATOR_BASEDIR)/spice.proto
> $(MARSHALLERS_DEPS)
> +	$(AM_V_GEN)$(PYTHON) $(CODE_GENERATOR_BASEDIR)/spice_codegen.py
> --generate-marshallers $(STRUCTS) --server --include common/messages.h -H $<
> $@ >/dev/null
>  
>  EXTRA_DIST =				\
>  	$(CLIENT_MARSHALLERS)		\
> diff --git a/configure.ac b/configure.ac
> index 1dacfa2..bc7ace2 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -28,7 +28,9 @@ AM_PROG_CC_C_O
>  SPICE_CHECK_SYSDEPS
>  
>  # Checks for libraries
> -PKG_CHECK_MODULES([PROTOCOL], [spice-protocol])
> +PKG_CHECK_MODULES([PROTOCOL], [spice-protocol >= 0.12.10])
> +CODE_GENERATOR_BASEDIR=`pkg-config --variable=codegendir spice-protocol`
> +AC_SUBST([CODE_GENERATOR_BASEDIR])
>  
>  SPICE_CHECK_PYTHON_MODULES()
>  

Tested. I had to check with a git diff --word-diff-regex to make the patch more understandable :)

> diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
> index 68dec42..e4b2c8d 100644
> --- a/m4/spice-deps.m4
> +++ b/m4/spice-deps.m4
> @@ -168,6 +168,7 @@ AC_DEFUN([SPICE_CHECK_GLIB2], [
>  # tarballs so they are disabled by default.
>  #---------------------------
>  AC_DEFUN([SPICE_CHECK_PYTHON_MODULES], [
> +    AM_PATH_PYTHON
>      AC_ARG_ENABLE([python-checks],
>          AS_HELP_STRING([--enable-python-checks=@<:@yes/no@:>@],
>                         [Enable checks for Python modules needed to build
>                         from git @<:@default=no@:>@]),
> --
> 2.4.3
> 

Last last hunk looks is not really related.

Frediano


More information about the Spice-devel mailing list