diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index 83ab67d..967cdca 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -21,8 +21,8 @@ # Check if there is C++ code at all ######################################################################## if(NOT satnogs_sources) - MESSAGE(STATUS "No C++ sources... skipping swig/") - return() + MESSAGE(STATUS "No C++ sources... skipping swig/") + return() endif(NOT satnogs_sources) ######################################################################## @@ -43,32 +43,51 @@ foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) endforeach(incdir) -set(GR_SWIG_LIBRARIES gnuradio-satnogs) -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/satnogs_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) +if(${INCLUDE_DEBUG_BLOCKS}) + set(INCLUDE_DEBUG_BLOCKS_BOOL_VAL 1) +else() + set(INCLUDE_DEBUG_BLOCKS_BOOL_VAL 0) +endif() -GR_SWIG_MAKE(satnogs_swig satnogs_swig.i) - -######################################################################## -# Install the build swig module -######################################################################## -GR_SWIG_INSTALL(TARGETS satnogs_swig DESTINATION ${GR_PYTHON_DIR}/satnogs) - -######################################################################## -# Install swig .i files for development -######################################################################## -list(APPEND swig_files - satnogs_swig.i - ${CMAKE_CURRENT_BINARY_DIR}/satnogs_swig_doc.i -) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/satnogs_swig.py.in + ${CMAKE_CURRENT_BINARY_DIR}/satnogs_swig.py +@ONLY) if(${INCLUDE_DEBUG_BLOCKS}) - list(APPEND swig_files "satnogs_debug_swig.i") + set(SATONGS_SWIG_FILES + satnogs_swig0 + satnogs_debug_swig + ) +else() + set(SATONGS_SWIG_FILES + satnogs_swig0 + ) endif() +foreach(swigfile ${SATONGS_SWIG_FILES}) + set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${swigfile}_doc.i) + set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) + + set(GR_SWIG_LIBRARIES gnuradio-satnogs) + GR_SWIG_MAKE(${swigfile} ${swigfile}.i) + + GR_SWIG_INSTALL(TARGETS ${swigfile} DESTINATION ${GR_PYTHON_DIR}/satnogs) + + list(APPEND SWIGFILES ${swigfile}.i) + list(APPEND SWIGDOCFILES ${CMAKE_CURRENT_BINARY_DIR}/${swigfile}_doc.i) +endforeach(swigfile) + install( FILES - ${swig_files} - ${CMAKE_CURRENT_BINARY_DIR}/satnogs_swig_doc.i + ${SWIGFILES} + ${SWIGDOCFILES} DESTINATION ${GR_INCLUDE_DIR}/satnogs/swig ) + +# Install the Python file that pulls in the swig built files. +GR_PYTHON_INSTALL( + FILES ${CMAKE_CURRENT_BINARY_DIR}/satnogs_swig.py + DESTINATION ${GR_PYTHON_DIR}/satnogs + COMPONENT "satnogs_python" +) diff --git a/swig/satnogs_debug_swig.i b/swig/satnogs_debug_swig.i index 32d71a3..fdeb447 100644 --- a/swig/satnogs_debug_swig.i +++ b/swig/satnogs_debug_swig.i @@ -1,10 +1,12 @@ /* -*- c++ -*- */ +#define SATNOGS_API + %include %include "gnuradio.i" // the common stuff //load generated python docstrings -%include "satnogs_swig_doc.i" +%include "satnogs_debug_swig_doc.i" %{ #include "satnogs/morse_debug_source.h" diff --git a/swig/satnogs_swig.py.in b/swig/satnogs_swig.py.in new file mode 100644 index 0000000..afd0a98 --- /dev/null +++ b/swig/satnogs_swig.py.in @@ -0,0 +1,24 @@ +#! /usr/bin/python +# +# gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module +# +# Copyright (C) 2018 +# Libre Space Foundation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# + +from satnogs_swig0 import * +if @INCLUDE_DEBUG_BLOCKS_BOOL_VAL@: + from satnogs_debug_swig import * \ No newline at end of file diff --git a/swig/satnogs_swig.i b/swig/satnogs_swig0.i similarity index 98% rename from swig/satnogs_swig.i rename to swig/satnogs_swig0.i index 0ff9594..e7a24cd 100644 --- a/swig/satnogs_swig.i +++ b/swig/satnogs_swig0.i @@ -6,7 +6,7 @@ %include "gnuradio.i" // the common stuff //load generated python docstrings -%include "satnogs_swig_doc.i" +%include "satnogs_swig0_doc.i" %{ #include "satnogs/morse_tree.h"