summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2015-07-06 18:18:55 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2015-08-07 11:54:47 +0200
commit2b9d15c1d3c8d17e0b9867a47887f2f676994015 (patch)
tree5c6d184dda6f20a6eade4a46102ec1f447b971c5
parenteb2e8ba0e8055a90f1425cacdb2c55660a087a6a (diff)
build-sys: Add --enable-code-generator
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.
-rwxr-xr-xautogen.sh2
-rw-r--r--configure.ac16
-rw-r--r--spice/Makefile.am24
3 files changed, 41 insertions, 1 deletions
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 af0e48c..2485489 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