]> sigrok.org Git - libsigrok.git/commitdiff
build: Use common SWIG defines for Python and Java
authorDaniel Elstner <redacted>
Thu, 29 Oct 2015 21:39:44 +0000 (22:39 +0100)
committerDaniel Elstner <redacted>
Fri, 30 Oct 2015 11:51:16 +0000 (12:51 +0100)
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.

Makefile.am
bindings/python/setup.py

index 1079ce8a8d9ca5a418d71c33dc4217b8241e67df..10b2d03b94d39452118b8f17c0d4420cd1f6c2b8 100644 (file)
@@ -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)
index e38acc7511c4290fc1b6f79c49eb26efc75e01b1..dd8a3d7b9f48c4a12e661bc261bc3e66d5218f8d 100644 (file)
@@ -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,