Skip to content

Commit

Permalink
Add INTERFACE_* prefix for interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn authored and vigsterkr committed Jun 30, 2017
1 parent 3f450d4 commit 7e60c06
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 66 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Expand Up @@ -25,42 +25,42 @@ matrix:
- compiler: clang
services: docker
env:
- CMAKE_OPTIONS="-DPython=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CMAKE_OPTIONS="-DINTERFACE_PYTHON=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CC=clang
- CXX=clang++
- compiler: clang
services: docker
env:
- CMAKE_OPTIONS="-DRuby=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CMAKE_OPTIONS="-DINTERFACE_RUBY=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CC=clang
- CXX=clang++
- compiler: clang
services: docker
env:
- CMAKE_OPTIONS="-DJava=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CMAKE_OPTIONS="-DINTERFACE_JAVA=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CC=clang
- CXX=clang++
- compiler: clang
services: docker
env:
- CMAKE_OPTIONS="-DCSharp=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CMAKE_OPTIONS="-DINTERFACE_CSHARP=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CC=clang
- CXX=clang++
- compiler: clang
services: docker
env:
- CMAKE_OPTIONS="-DLua=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CMAKE_OPTIONS="-DINTERFACE_LUA=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CC=clang
- CXX=clang++
- compiler: gcc
services: docker
env:
- CMAKE_OPTIONS="-DOctave=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- OCTAVE=true
- CMAKE_OPTIONS="-DINTERFACE_OCTAVE=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- INTERFACE_OCTAVE=true
- compiler: clang
services: docker
env:
- CMAKE_OPTIONS="-DR=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CMAKE_OPTIONS="-DINTERFACE_R=ON -DTRAVIS_DISABLE_UNIT_TESTS=ON -DTRAVIS_DISABLE_LIBSHOGUN_TESTS=ON"
- CC=clang
- CXX=clang++
# - compiler: clang
Expand All @@ -77,7 +77,7 @@ before_script:
- docker exec -t devenv /bin/sh -c "cd /opt/shogun/build; cmake -DCMAKE_INSTALL_PREFIX=$HOME/shogun-build -DENABLE_TESTING=ON $CMAKE_OPTIONS .."
script:
- |
if [ $CC == "gcc" ] && [ -z $OCTAVE ]; then
if [ $CC == "gcc" ] && [ -z ${INTERFACE_OCTAVE} ]; then
docker exec -t devenv /bin/sh -c "cd /opt/shogun/; if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ./scripts/check_format.sh "$TRAVIS_PULL_REQUEST_BRANCH" "$TRAVIS_BRANCH"; fi"
fi
- docker exec -t devenv /bin/sh -c "cd /opt/shogun/build; make -j2"
Expand Down
51 changes: 26 additions & 25 deletions CMakeLists.txt
Expand Up @@ -87,24 +87,25 @@ SET(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third_party)
SET(LIBSHOGUN_SRC_DIR ${CMAKE_SOURCE_DIR}/src/shogun)
SET(COMMON_MODULAR_SRC_DIR ${CMAKE_SOURCE_DIR}/src/interfaces/modular/)

SET(AVAILABLE_INTERFACES Python;Octave;Java;Perl;Ruby;CSharp;R;Lua;Scala)
SET(PythonDescription "Python")
SET(OctaveDescription "Octave")
SET(JavaDescription "Java")
SET(PerlDescription "Perl")
SET(RubyDescription "Ruby")
SET(CSharpDescription "C#")
SET(RDescription "R")
SET(LuaDescription "Lua")
SET(ScalaDescription "Scala")
SET(AVAILABLE_INTERFACES
INTERFACE_PYTHON;INTERFACE_OCTAVE;INTERFACE_JAVA;INTERFACE_PERL;INTERFACE_RUBY;INTERFACE_CSHARP;INTERFACE_R;INTERFACE_LUA;INTERFACE_SCALA)
SET(INTERFACE_PYTHON_DESCRIPTION "Python")
SET(INTERFACE_OCTAVE_DESCRIPTION "Octave")
SET(INTERFACE_JAVA_DESCRIPTION "Java")
SET(INTERFACE_PERL_DESCRIPTION "Perl")
SET(INTERFACE_RUBY_DESCRIPTION "Ruby")
SET(INTERFACE_CSHARP_DESCRIPTION "C#")
SET(INTERFACE_R_DESCRIPTION "R")
SET(INTERFACE_LUA_DESCRIPTION "Lua")
SET(INTERFACE_SCALA_DESCRIPTION "Scala")
SET(LIBSHOGUN ON CACHE BOOL "Compile shogun library")

IsAnyTrue("${AVAILABLE_INTERFACES}" ANY_INTERFACE_ENABLED)
IF (${ANY_INTERFACE_ENABLED})
# SWIG3 is the minimum requirement because of C++11 support
SET(SWIG_VERSION_MINIMUM 3.0.0)

IF(CSharp)
IF(INTERFACE_CSHARP)
# We require SWIG 3.0.7 to support functions with a few SGVector or
# SGMatrix arguments. The required SWIG feature is called
# "Support for special variable expansion in typemap attributes."
Expand All @@ -115,7 +116,7 @@ IF (${ANY_INTERFACE_ENABLED})
# typemapping created for earlier versions of SWIG.
# see: http://www.swig.org/Doc3.0/CSharp.html#CSharp_introduction_swig2_compatibility
LIST(APPEND CMAKE_SWIG_FLAGS "-DSWIG2_CSHARP")
ELSEIF(Python)
ELSEIF(INTERFACE_PYTHON)
# SWIG was broken for combining -builtin and -modernargs
# from v3.0.0 and until 3.0.4. This bug was fixed in
# v3.0.5. Make CMake emit an error and fail to configure.
Expand Down Expand Up @@ -430,66 +431,66 @@ IF(REDUCE_SWIG_DEBUG)
ENDIF(REDUCE_SWIG_DEBUG)

# python
IF (Python)
IF (INTERFACE_PYTHON)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/python_modular)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/python_modular)
ENDIF()
ENDIF()

# lua
IF (Lua)
IF (INTERFACE_LUA)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/lua_modular)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/lua_modular)
ENDIF()
ENDIF()

# scala
IF (Scala)
IF (INTERFACE_SCALA)
# Java needed because Scala extends Java Classes and uses the executable generated from Java example for Integration testing
set(Java "ON")
set(INTERFACE_JAVA "ON")
FIND_PACKAGE(Scala REQUIRED)
IF(NOT Java)
IF(NOT INTERFACE_JAVA)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/java_modular)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/java_modular)
ENDIF()
ENDIF()
ENDIF()

# java
IF (Java)
IF (INTERFACE_JAVA)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/java_modular)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/java_modular)
ENDIF()
ENDIF()

# ruby
IF (Ruby)
IF (INTERFACE_RUBY)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/ruby_modular)
ENDIF()

# octave
IF (Octave)
IF (INTERFACE_OCTAVE)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/octave_modular)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/octave_modular)
ENDIF()
ENDIF()

# csharp
IF (CSharp)
IF (INTERFACE_CSHARP)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/csharp_modular)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/csharp_modular)
ENDIF()
ENDIF()

# R
IF (R)
IF (INTERFACE_R)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/r_modular)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/interfaces/r_modular)
ENDIF()
ENDIF()

# perl
IF (Perl)
IF (INTERFACE_PERL)
FIND_PACKAGE(FindPerlLibs REQUIRED)
UNSET(TARGET_SWIGFLAGS)
IF(EXISTS ${CMAKE_SOURCE_DIR}/src/interfaces/perl_modular)
Expand Down Expand Up @@ -564,15 +565,15 @@ include(FeatureSummary)
feature_summary(WHAT ALL)

PrintLine()
PrintStatus("Integration")
PrintStatus("Integrations")

PrintInterfaceStatus("OpenCV Integration" OpenCV)

PrintLine()
PrintStatus("Interfaces")

ForEach(Interface ${AVAILABLE_INTERFACES})
PrintInterfaceStatus("${${Interface}Description} interface" ${Interface})
PrintInterfaceStatus("${${Interface}_DESCRIPTION}" ${Interface})
EndForEach(Interface)

PrintLine()
Expand Down
14 changes: 8 additions & 6 deletions cmake/ShogunUtils.cmake
Expand Up @@ -70,11 +70,15 @@ MACRO(PrintInterfaceStatus INTERFACE_NAME INTERFACE_FLAG)
message(STATUS " ${INTERFACE_NAME} is ON")
ELSE()
STRING(LENGTH ${INTERFACE_NAME} IFACE_NAME_LENGTH)
IF (IFACE_NAME_LENGTH LESS 10)
message(STATUS " ${INTERFACE_NAME} is OFF \t\t - enable with -D${INTERFACE_FLAG}=ON")
IF (IFACE_NAME_LENGTH LESS 3)
SET(INDENT "\t\t\t")
ELSEIF (IFACE_NAME_LENGTH LESS 10)
SET(INDENT "\t\t")
ELSE ()
message(STATUS " ${INTERFACE_NAME} is OFF \t - enable with -D${INTERFACE_FLAG}=ON")
SET(INDENT "\t")
ENDIF ()
message(STATUS " ${INTERFACE_NAME} is OFF ${INDENT} enable with -D${INTERFACE_FLAG}=ON")
UNSET(INDENT)
ENDIF()
ENDMACRO()

Expand Down Expand Up @@ -247,9 +251,7 @@ endfunction()


function(GET_INTERFACE_VARS INTERFACE DIRECTORY EXTENSION)
# Interfaces were called Modular that's why we needed regex.
# Now it is an identity regex.
string(REGEX MATCH "([a-zA-Z]+)" _dir ${INTERFACE})
string(REGEX MATCH "INTERFACE_([a-zA-Z]+)" _dir ${INTERFACE})
STRING(TOLOWER "${CMAKE_MATCH_1}" _dir)
SET(${DIRECTORY} ${_dir} PARENT_SCOPE)

Expand Down
10 changes: 5 additions & 5 deletions doc/readme/INSTALL.md
Expand Up @@ -175,10 +175,10 @@ In both cases, it is necessary to set a number of system libraries for using Sho

## Interfaces <a name="manual-interfaces"></a>
The native C++ interface is always included.
The cmake options for building interfaces are `-DPython -DOctave -DR -DJava -DRuby -DLua -DCSharp` etc.
The cmake options for building interfaces are `-DINTERFACE_PYTHON=ON -DINTERFACE_R ..` etc.
For example, replace the cmake step above by
```
cmake -DPython=ON [potentially more options] ..
cmake -DINTERFACE_PYTHON=ON [potentially more options] ..
```

The required packages (here debian/Ubuntu package names) for each interface are
Expand Down Expand Up @@ -249,16 +249,16 @@ For that, you need to do something similar to

For example, for `brew` installed Python under MacOS, use something like:

cmake -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Headers -DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib -DPython=ON ..
cmake -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Headers -DPYTHON_LIBRARY=/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib -DINTERFACE_PYTHON=ON ..

Under Linux, where you want to use Python 3, which is not the system's default:

cmake -DPYTHON_INCLUDE_DIR=/usr/include/python3.3 -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPYTHON_PACKAGES_PATH=/usr/local/lib/python3.3/dist-packages -DPython=ON ..
cmake -DPYTHON_INCLUDE_DIR=/usr/include/python3.3 -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -DPYTHON_PACKAGES_PATH=/usr/local/lib/python3.3/dist-packages -DINTERFACE_PYTHON=ON ..

On a Linux cluster without root access, using [Anaconda](https://www.continuum.io/downloads) (note you will need to activate your environment everytime you want to run Shogun):

source path/to/anaconda/bin/activate
cmake -DCMAKE_INSTALL_PREFIX=path/to/shogun/install/dir -DPYTHON_INCLUDE_DIR=path/to/anaconda/include/python2.7/ -DPYTHON_LIBRARY=path/to/anaconda/lib/libpython2.7.so -DPYTHON_EXECUTABLE=path/to/anaconda/bin/python -DPython=ON ..
cmake -DCMAKE_INSTALL_PREFIX=path/to/shogun/install/dir -DPYTHON_INCLUDE_DIR=path/to/anaconda/include/python2.7/ -DPYTHON_LIBRARY=path/to/anaconda/lib/libpython2.7.so -DPYTHON_EXECUTABLE=path/to/anaconda/bin/python -DINTERFACE_PYTHON=ON ..

## Windows build <a name="manual-windows"></a>

Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Expand Up @@ -2,7 +2,7 @@ IF (NOT TRAVIS_DISABLE_LIBSHOGUN_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/un
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/undocumented/libshogun)
ENDIF()

IF (Python AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/undocumented/python_modular)
IF (INTERFACE_PYTHON AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/undocumented/python_modular)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/undocumented/python_modular)
ENDIF()

Expand Down
10 changes: 5 additions & 5 deletions examples/meta/CMakeLists.txt
Expand Up @@ -27,7 +27,7 @@ LIST(APPEND GENERATOR_DEPENDENCIES ${TARGET_LANGUAGES})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/parser_files)

# list of interfaces for which we dont generate meta examples
SET(DISABLED_INTERFACES Perl)
SET(DISABLED_INTERFACES INTERFACE_PERL)

FOREACH(META_EXAMPLE ${META_EXAMPLES})
# assume a structure <target_language>/<category>/listing.sg
Expand All @@ -40,15 +40,15 @@ FOREACH(META_EXAMPLE ${META_EXAMPLES})
# FIXME
# Hack to avoid generation of scala meta examples dependencies that will
# not be generated by generate.py script (since there is no scala.json)
LIST(REMOVE_ITEM AVAILABLE_INTERFACES "Scala")
LIST(REMOVE_ITEM AVAILABLE_INTERFACES INTERFACE_SCALA)
FOREACH(interface ${AVAILABLE_INTERFACES})
list(FIND DISABLED_INTERFACES ${interface} disabled)
if (${disabled} STREQUAL "-1")
GET_INTERFACE_VARS(${interface} DIRECTORY EXTENSION)
LIST(APPEND EXAMPLE_LISTINGS ${CMAKE_CURRENT_BINARY_DIR}/${DIRECTORY}/${BASENAME}.${EXTENSION})
endif()
ENDFOREACH()
LIST(APPEND AVAILABLE_INTERFACES "Scala")
LIST(APPEND AVAILABLE_INTERFACES INTERFACE_SCALA)

# Set generate.py flags
SET(GENERATOR_FLAGS
Expand Down Expand Up @@ -104,11 +104,11 @@ ENDIF()
# FIXME: these are the interfaces which has various problems
# hence need to disable their testing
# temporarily disabled as R and static calls has to be fixed
LIST(APPEND DISABLED_INTERFACES R)
LIST(APPEND DISABLED_INTERFACES INTERFACE_R)
# temporarily removed since lua modular currently
# does not support overloaded c++ methods
# see https://github.com/shogun-toolbox/shogun/issues/3018
LIST(APPEND DISABLED_INTERFACES Lua)
LIST(APPEND DISABLED_INTERFACES INTERFACE_LUA)


FOREACH(interface ${AVAILABLE_INTERFACES})
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -141,7 +141,7 @@ def shogun_cmake(arguments=None):
print("Running CMake")

if arguments is None:
arguments='-DPython=ON -DENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=install'
arguments='-DINTERFACE_PYTHON=ON -DENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=install'

if distutils.spawn.find_executable('cmake') is not None:
print('CMake arguments: %s ' % arguments)
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/java_modular/CMakeLists.txt
Expand Up @@ -10,7 +10,7 @@ IF(JBLAS)
SET(HAVE_JBLAS 1)
ELSE()
MESSAGE(FATAL_ERROR "JBlas could not be found!\n"
"It is required for java modular interface!!!")
"It is required for java interface!")
ENDIF()

SET(TARGET_SWIGFLAGS "-package\;org.shogun")
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/lua_modular/CMakeLists.txt
Expand Up @@ -2,7 +2,7 @@ FIND_PACKAGE(PkgConfig)
pkg_search_module(LUA REQUIRED lua lua5.1)
IF (NOT LUA_FOUND)
MESSAGE(FATAL_ERROR "Lua could not be found!\n"
"Lua is required for compiling lua modular interface!")
"Lua is required for compiling lua interface!")
ENDIF ()
SET(LUA_EXECUTABLE lua)
UNSET(TARGET_SWIGFLAGS)
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/python_modular/CMakeLists.txt
Expand Up @@ -5,7 +5,7 @@ FIND_PACKAGE(NumPy REQUIRED)

SET(HAVE_PYTHON 1)

#custom swig flags for python modular interface
#custom swig flags for python interface
IF(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3)
SET(TARGET_SWIGFLAGS "-builtin\;-modern\;-modernargs\;-threads\;-py3")
SET(PYTHON3 1)
Expand All @@ -19,7 +19,7 @@ ENDIF()
IF ((NOT "${PYTHON_VERSION_STRING}" VERSION_LESS "3.5") AND
("${SWIG_VERSION}" VERSION_LESS "3.0.8"))
MESSAGE(FATAL_ERROR
"Building Python_modular interface for Python >= 3.5 requires SWIG >= 3.0.8.")
"Building Python interface for Python >= 3.5 requires SWIG >= 3.0.8.")
ENDIF ((NOT "${PYTHON_VERSION_STRING}" VERSION_LESS "3.5") AND
("${SWIG_VERSION}" VERSION_LESS "3.0.8"))

Expand Down
20 changes: 10 additions & 10 deletions tests/meta/CMakeLists.txt
Expand Up @@ -57,16 +57,16 @@ FOREACH(REFERENCE_FILE ${META_INTEGRATION_REFERENCES})
IF (NOT ${TRAVIS_DISABLE_META_CPP} AND NOT ${DISABLE_META_INTEGRATION_TESTS})
AddMetaIntegrationTest(cpp 1)
ENDIF()
IF (NOT ${DISABLE_META_INTEGRATION_TESTS})
AddMetaIntegrationTest(python Python)
AddMetaIntegrationTest(java Java)
#AddMetaIntegrationTest(r R) # currently we have the r meta examples disabled, so no generated results that can be tested
AddMetaIntegrationTest(octave Octave)
AddMetaIntegrationTest(csharp CSharp)
AddMetaIntegrationTest(ruby Ruby)
AddMetaIntegrationTest(scala Scala)
#AddMetaIntegrationTest(lua Lua) # currently doesn't have meta examples
ENDIF()
IF (NOT ${DISABLE_META_INTEGRATION_TESTS})
AddMetaIntegrationTest(python INTERFACE_PYTHON)
AddMetaIntegrationTest(java INTERFACE_JAVA)
#AddMetaIntegrationTest(r INTERFACE_R) # currently we have the r meta examples disabled, so no generated results that can be tested
AddMetaIntegrationTest(octave INTERFACE_OCTAVE)
AddMetaIntegrationTest(csharp INTERFACE_CSHARP)
AddMetaIntegrationTest(ruby INTERFACE_RUBY)
AddMetaIntegrationTest(scala INTERFACE_SCALA)
#AddMetaIntegrationTest(lua INTERFACE_LUA) # currently doesn't have meta examples
ENDIF()
ELSE()
MESSAGE(WARNING "Skipping C++ meta integration tests; requires a c++11 compatible compiler.")
ENDIF()
Expand Down

0 comments on commit 7e60c06

Please sign in to comment.