From: Daniel Elstner Date: Thu, 29 Oct 2015 21:39:44 +0000 (+0100) Subject: build: Use common SWIG defines for Python and Java X-Git-Tag: libsigrok-0.4.0~145 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=8ebf1469a91b7f7899d84386dee021575752b6d8;hp=e1172cf847e522b07d063c36c3f54b0a5dc8429f build: Use common SWIG defines for Python and Java Make the Python and Java bindings use the same set of preprocessor macros for the SWIG parsing stage, taken from a make variable. Add G_GNUC_{BEGIN,END}_IGNORE_DEPRECATIONS to that set. --- diff --git a/Makefile.am b/Makefile.am index 1079ce8a..10b2d03b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -581,6 +581,9 @@ $(CPPXMLDOC): bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp \ bindings/cxx/enums.timestamp $(AM_V_GEN)cd $(srcdir)/bindings/cxx && BUILDDIR=$(abs_builddir)/bindings/cxx/ doxygen Doxyfile 2>/dev/null +# Macro definitions to be used by the SWIG parser. +swig_defs = -Dnoexcept= -Dprivate=protected -DG_GNUC_BEGIN_IGNORE_DEPRECATIONS= -DG_GNUC_END_IGNORE_DEPRECATIONS= + if BINDINGS_PYTHON PDIR = bindings/python @@ -610,7 +613,7 @@ $(PDIR)/timestamp: $(PDIR)/sigrok/core/classes.i \ $(nodist_bindings_cxx_libsigrokcxx_la_include_HEADERS) \ @ORDER@ bindings/cxx/libsigrokcxx.la $(AM_V_at)$(setup_py) clean --all 2>/dev/null - $(AM_V_GEN)$(setup_py) build_ext --swig "$(SWIG)" build_py + $(AM_V_GEN)$(setup_py) build_ext --swig "$(SWIG)" --swig-opts '$(swig_defs)' build_py $(AM_V_at): >$@ python-install: @@ -658,7 +661,7 @@ $(JCXX): $(srcdir)/$(JSWG) $(JDOC) bindings/swig/classes.i \ $(bindings_cxx_libsigrokcxx_la_include_HEADERS) \ $(nodist_bindings_cxx_libsigrokcxx_la_include_HEADERS) -$(AM_V_at)rm -f $(java_cleanfiles) - $(AM_V_GEN)$(SWIG) -c++ -Dnoexcept= -Dprivate=protected \ + $(AM_V_GEN)$(SWIG) -c++ $(swig_defs) \ -java -package org.sigrok.core.classes \ -Ibindings -I$(JCLS) $(local_includes) -I$(srcdir) $(JNI_CPPFLAGS) \ -outdir $(JCLS) -o $@ $(srcdir)/$(JSWG) diff --git a/bindings/python/setup.py b/bindings/python/setup.py index e38acc75..dd8a3d7b 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -69,6 +69,10 @@ class build_py(_build_py): return _build_py.check_package(self, package, vpath(package_dir)) class build_ext(_build_ext): + def finalize_options(self): + _build_ext.finalize_options(self) + self.swig_opts = ['-c++', '-threads', '-Isigrok/core', '-I..', + '-I' + srcdir_parent] + ['-I%s' % i for i in includes] + self.swig_opts def spawn (self, cmd): cmd[1:-1] = [arg if arg.startswith('-') else unvpath(arg) for arg in cmd[1:-1]] @@ -87,9 +91,6 @@ setup( ext_modules = [ Extension('sigrok.core._classes', sources = [vpath('sigrok/core/classes.i')], - swig_opts = ['-c++', '-threads', '-Dnoexcept=', '-Dprivate=protected', - '-Isigrok/core', '-I..', '-I' + srcdir_parent] + - ['-I%s' % i for i in includes], extra_compile_args = ['-Wno-uninitialized'], include_dirs = includes, library_dirs = libdirs,