[sword-svn] r3659 - in trunk: . bindings bindings/swig bindings/swig/python cmake
greg.hellings at crosswire.org
greg.hellings at crosswire.org
Thu Jun 13 13:23:40 MST 2019
Author: greg.hellings
Date: 2019-06-13 13:23:38 -0700 (Thu, 13 Jun 2019)
New Revision: 3659
Modified:
trunk/CMakeLists.txt
trunk/bindings/CMakeLists.txt
trunk/bindings/swig/CMakeLists.txt
trunk/bindings/swig/python/CMakeLists.txt
trunk/bindings/swig/python/install.cmake.in
trunk/bindings/swig/swbuf.i
trunk/cmake/build-debug.sh
trunk/cmake/build-release.sh
trunk/cmake/options.cmake
Log:
Change how Swig Bindings are specified
Change the CMake methods of specifying the SWIG bindings so that Python 2 and
Python 3 can both be supported at the same time. Also, clean up the build and
test process for the bindings and resolve a problem with their updates
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/CMakeLists.txt 2019-06-13 20:23:38 UTC (rev 3659)
@@ -293,9 +293,10 @@
# Bindings are good, right?
#
-IF(NOT SWORD_BINDINGS STREQUAL "" AND SWORD_BINDINGS)
+MESSAGE(STATUS "${SWORD_SWIG_BINDINGS}")
+IF(SWORD_SWIG_BINDINGS)
ADD_SUBDIRECTORY("${CMAKE_CURRENT_SOURCE_DIR}/bindings")
-ENDIF(NOT SWORD_BINDINGS STREQUAL "" AND SWORD_BINDINGS)
+ENDIF(SWORD_SWIG_BINDINGS)
##############################################################################################
# Utilities are hawt
Modified: trunk/bindings/CMakeLists.txt
===================================================================
--- trunk/bindings/CMakeLists.txt 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/bindings/CMakeLists.txt 2019-06-13 20:23:38 UTC (rev 3659)
@@ -1,5 +1,3 @@
-IF(SWORD_BINDINGS MATCHES ".*Python.*"
- OR SWORD_BINDINGS MATCHES ".*Perl.*")
+IF(SWORD_SWIG_BINDINGS)
ADD_SUBDIRECTORY("${CMAKE_CURRENT_SOURCE_DIR}/swig")
-ENDIF(SWORD_BINDINGS MATCHES ".*Python.*"
- OR SWORD_BINDINGS MATCHES ".*Perl.*")
+ENDIF(SWORD_SWIG_BINDINGS)
Modified: trunk/bindings/swig/CMakeLists.txt
===================================================================
--- trunk/bindings/swig/CMakeLists.txt 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/bindings/swig/CMakeLists.txt 2019-06-13 20:23:38 UTC (rev 3659)
@@ -15,27 +15,33 @@
MESSAGE(FATAL_ERROR "Swig: no")
ELSE(NOT SWIG_FOUND)
MESSAGE(STATUS "Swig: yes")
-
+
SET(CMAKE_SWIG_FLAGS "-w-451,-402;-shadow;-c++")
-
+
MACRO(SWORD_SWIG_GENERATE LANG)
- ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx
+ ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx"
COMMAND ${SWIG_EXECUTABLE} ${CMAKE_SWIG_FLAGS} -${LANG} -o "${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx"
"-I${CMAKE_SOURCE_DIR}/bindings/swig" ${SWIG_INCLUDES} "${CMAKE_SOURCE_DIR}/bindings/swig/sword.i"
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
ENDMACRO(SWORD_SWIG_GENERATE)
-
+
GET_DIRECTORY_PROPERTY(cmake_include_directories INCLUDE_DIRECTORIES)
SET(SWIG_INCLUDES)
FOREACH(directory ${cmake_include_directories})
SET(SWIG_INCLUDES ${SWIG_INCLUDES} "-I${directory}")
ENDFOREACH(directory ${cmake_include_directories})
-
- IF(SWORD_BINDINGS MATCHES ".*Python.*")
- ADD_SUBDIRECTORY(python)
- ENDIF(SWORD_BINDINGS MATCHES ".*Python.*")
-
- IF(SWORD_BINDINGS MATCHES ".*Perl.*")
+
+ IF(SWORD_PYTHON_2)
+ SET(SWORD_PYTHON_VERSION 2)
+ ADD_SUBDIRECTORY(python python2)
+ ENDIF(SWORD_PYTHON_2)
+
+ IF(SWORD_PYTHON_3)
+ SET(SWORD_PYTHON_VERSION 3)
+ ADD_SUBDIRECTORY(python python3)
+ ENDIF(SWORD_PYTHON_3)
+
+ IF(SWORD_PERL)
ADD_SUBDIRECTORY(perl)
- ENDIF(SWORD_BINDINGS MATCHES ".*Perl.*")
+ ENDIF(SWORD_PERL)
ENDIF(NOT SWIG_FOUND)
Modified: trunk/bindings/swig/python/CMakeLists.txt
===================================================================
--- trunk/bindings/swig/python/CMakeLists.txt 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/bindings/swig/python/CMakeLists.txt 2019-06-13 20:23:38 UTC (rev 3659)
@@ -11,6 +11,11 @@
#
#SWIG_LINK_LIBRARIES(Sword ${PYTHON_LIBRARIES} ${SWORD_LINK_NAME})
+UNSET(PYTHON_EXECUTABLE CACHE)
+UNSET(PYTHON_LIBS CACHE)
+SET(PythonInterp_FIND_VERSION "${SWORD_PYTHON_VERSION}")
+SET(PythonInterp_FIND_VERSION_MAJOR "${SWORD_PYTHON_VERSION}")
+SET(PythonLibs_FIND_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonLibs)
@@ -38,10 +43,10 @@
SWORD_SWIG_GENERATE(python)
-ADD_CUSTOM_TARGET(swordswig ALL
- COMMAND python setup.py build
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx ${SWORD_LINK_NAME}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ADD_CUSTOM_TARGET(swordswig_python${SWORD_PYTHON_VERSION} ALL
+ COMMAND "${PYTHON_EXECUTABLE}" setup.py build
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Sword.cxx" ${SWORD_LINK_NAME}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# Allow user installation to custom directory
IF(NOT SWORD_PYTHON_INSTALL_DIR STREQUAL "")
Modified: trunk/bindings/swig/python/install.cmake.in
===================================================================
--- trunk/bindings/swig/python/install.cmake.in 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/bindings/swig/python/install.cmake.in 2019-06-13 20:23:38 UTC (rev 3659)
@@ -1,4 +1,4 @@
EXECUTE_PROCESS(COMMAND
- python setup.py install @SETUP_ARGS@
+ "@PYTHON_EXECUTABLE@" setup.py install @SETUP_ARGS@
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
Modified: trunk/bindings/swig/swbuf.i
===================================================================
--- trunk/bindings/swig/swbuf.i 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/bindings/swig/swbuf.i 2019-06-13 20:23:38 UTC (rev 3659)
@@ -18,6 +18,7 @@
%ignore sword::SWBuf::operator=;
%ignore sword::SWBuf::operator--;
%ignore sword::SWBuf::charAt(unsigned long);
+%ignore sword::SWBuf::setFormattedVA(const char *format, va_list argptr);
/* Ignore this horrible constructor.
* This would be the default for single character strings passed in. This can
Modified: trunk/cmake/build-debug.sh
===================================================================
--- trunk/cmake/build-debug.sh 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/cmake/build-debug.sh 2019-06-13 20:23:38 UTC (rev 3659)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -e
#
# A sample script showing how to build most of the options available to this system.
# Invoke it from the top directory of SWORD by calling $ cmake/build-debug.sh
@@ -8,7 +8,8 @@
cd build
# Configure with Python and Perl bindings, examples, tests and a debug build into
# a shared library
-cmake \ #-DSWORD_BINDINGS="Python Perl" \
+cmake -DSWORD_PYTHON_3:BOOL=TRUE \
+ -DSWORD_PERL:BOOL=TRUE \
-DSWORD_BUILD_EXAMPLES="Yes" \
-DSWORD_BUILD_TESTS="Yes" \
-DLIBSWORD_LIBRARY_TYPE="Shared" \
Modified: trunk/cmake/build-release.sh
===================================================================
--- trunk/cmake/build-release.sh 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/cmake/build-release.sh 2019-06-13 20:23:38 UTC (rev 3659)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -e
#
# A sample script showing how to build most of the options available to this system.
# Invoke it from the top directory of SWORD by calling $ cmake/build-release.sh
@@ -9,7 +9,8 @@
# Configure with Python and Perl bindings, examples, tests and a debug build into
# a shared library, plus static option as well. They will be installed to the
# /opt/sword directory
-cmake -DSWORD_BINDINGS="Python Perl" \
+cmake -DSWORD_PYTHON_3:BOOL=TRUE \
+ -DSWORD_PERL:BOOL=TRUE \
-DSWORD_BUILD_EXAMPLES="Yes" \
-DSWORD_BUILD_TESTS="Yes" \
-DLIBSWORD_LIBRARY_TYPE="Shared Static" \
Modified: trunk/cmake/options.cmake
===================================================================
--- trunk/cmake/options.cmake 2019-06-13 19:13:27 UTC (rev 3658)
+++ trunk/cmake/options.cmake 2019-06-13 20:23:38 UTC (rev 3659)
@@ -46,6 +46,12 @@
_SET_FANCY(SWORD_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" STRING "Directory where the Python bindings will be installed. Defaults to default Python path.")
+_SET_FANCY(SWORD_PYTHON_2 FALSE STRING "Set to TRUE to build Swig Python bindings for Python 2")
+
+_SET_FANCY(SWORD_PYTHON_3 FALSE STRING "Set to TRUE to build Swig Python bindings for Python 3")
+
+_SET_FANCY(SWORD_PERL FALSE STRING "Set to TRUE to build Swig Perl bindings")
+
# Post-processing of variables
MACRO(PROCESS_VERSION LEVEL VALUE)
SET(SWORD_VERSION_${LEVEL} ${VALUE})
@@ -74,3 +80,16 @@
SET(SWORD_VERSION_NUM "${SWORD_VERSION_MAJOR}${MINOR}${MICRO}${NANO}")
MESSAGE(STATUS "SWORD Version ${SWORD_VERSION_NUM}")
+
+IF(SWORD_PYTHON_2 OR SWORD_PYTHON_3 OR SWORD_PERL)
+ MESSAGE(STATUS "Building SWIG Bindings")
+ SET(SWORD_SWIG_BINDINGS 1)
+ELSE()
+ SET(SWORD_SWIG_BINDINGS 0)
+ENDIF()
+
+IF(SWORD_SWIG_BINDINGS)
+ SET(SWORD_BINDINGS TRUE)
+ELSE()
+ SET(SWORD_BINDINGS FALSE)
+ENDIF()
More information about the sword-cvs
mailing list