[Spice-devel] [spice-protocol 3/4] build-sys: Add --enable-code-generator
Christophe Fergeau
cfergeau at redhat.com
Mon Jul 6 09:33:12 PDT 2015
This flag is only used for git builds, and can usually safely be
disabled.
When it's enabled, configure.ac will check that python-six and pyparsing
are available, and will use these together with the codegen python
scripts in order to automatically regenerate enums.h when the .proto
files change.
---
autogen.sh | 2 +-
configure.ac | 16 ++++++++++++++++
spice/Makefile.am | 24 ++++++++++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/autogen.sh b/autogen.sh
index de6881d..9e5365e 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -11,7 +11,7 @@ test -z "$srcdir" && srcdir=.
autoreconf --verbose --force --install
)
-CONFIGURE_ARGS="--enable-maintainer-mode"
+CONFIGURE_ARGS="--enable-maintainer-mode --enable-code-generator"
if [ -z "$NOCONFIGURE" ]; then
echo "Running configure with $CONFIGURE_ARGS $@"
diff --git a/configure.ac b/configure.ac
index 4cc6a27..341f515 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,6 +14,22 @@ AM_MAINTAINER_MODE
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+dnl Enable generation of enums.h, mainly useful when building from git,
+dnl should not be needed for tarball users
+AC_ARG_ENABLE([code-generator],
+ AS_HELP_STRING([--enable-code-generator=@<:@yes/no/auto@:>@],
+ [Enable checks needed to use the Python code generator @<:@default=auto@:>@]),
+ [],
+ [enable_code_generator="auto"])
+if test "x$enable_code_generator" != "xno"; then
+ AS_IF([test "x$enable_code_generator" = "xyes"], modules_required=[1], modules_required=[])
+ AX_PYTHON_MODULE([six], $modules_required)
+ AX_PYTHON_MODULE([pyparsing], $modules_required)
+ AS_IF([test "x${HAVE_PYMOD_SIX}" = "xno"], enable_code_generator="no")
+ AS_IF([test "x${HAVE_PYMOD_PYPARSING}" = "xno"], enable_code_generator="no")
+fi
+AM_CONDITIONAL([ENABLE_CODEGEN], [test "x$enable_code_generator" != "xno"])
+
AC_OUTPUT([
Makefile
spice-protocol.pc
diff --git a/spice/Makefile.am b/spice/Makefile.am
index a54ae89..9be09ec 100644
--- a/spice/Makefile.am
+++ b/spice/Makefile.am
@@ -21,4 +21,28 @@ spice_protocol_include_HEADERS = \
vdi_dev.h \
$(NULL)
+# Using the python code generator requires some python modules
+# which might not be installed on the user computer. Given that
+# enums.h is stored in git, and should be up-to-date anyway,
+# we can make this part optional
+if ENABLE_CODEGEN
+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 \
+ $(NULL)
+
+BUILT_SOURCES = enums.h
+
+# 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.
+enums.h: $(top_srcdir)/spice.proto # $(MARSHALLERS_DEPS)
+ $(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-enums $< $@ >/dev/null
+endif
+
-include $(top_srcdir)/git.mk
--
2.4.3
More information about the Spice-devel
mailing list