Skip to content

Commit

Permalink
Ruby: enable Ruby bindings for BINDINGS="ALL"
Browse files Browse the repository at this point in the history
- fix travis build:
  - using rvm ruby 2.3.1
  - use CMAKE_FIND_FRAMEWORK="LAST" to use the rvm library per default
  - set LD_LIBRARY_PATH for tests (required to kdb loader)
  • Loading branch information
BernhardDenner committed Nov 5, 2016
1 parent 1b5c6b9 commit ea75497
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -17,6 +17,10 @@ matrix:

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
rvm list;
rvm install 2.3.1;
rvm use 2.3.1;
gem install test-unit --no-document;
export PATH=/usr/local/bin:/usr/local/sbin:$PATH;
brew update;
brew tap caskroom/cask;
Expand Down
1 change: 1 addition & 0 deletions cmake/ElektraCache.cmake
Expand Up @@ -53,6 +53,7 @@ if (BINDINGS MATCHES "ALL" OR FINDEX GREATER -1)
swig_lua
swig_python2
swig_python
swig_ruby
)
set (BINDINGS_FORCE FORCE)
endif ()
Expand Down
18 changes: 13 additions & 5 deletions src/bindings/swig/ruby/CMakeLists.txt
@@ -1,6 +1,10 @@
include (${SWIG_USE_FILE})
include(LibAddMacros)

# try user environment first, then search for system libs
# required on OSX under rvm
set (CMAKE_FIND_FRAMEWORK "LAST")

find_package(Ruby)

if (NOT RUBY_FOUND)
Expand Down Expand Up @@ -29,6 +33,8 @@ else()

# just for debugging
message (STATUS "Ruby executable: ${RUBY_EXECUTABLE}")
message (STATUS "Ruby library: ${RUBY_LIBRARY}")
message (STATUS "Ruby version: ${RUBY_VERSION}")
message (STATUS "Ruby vendor arch dir: ${RUBY_VENDOR_ARCH_DIR}")
message (STATUS "Ruby site arch dir: ${RUBY_SITE_ARCH_DIR}")
message (STATUS "Ruby include path: ${RUBY_INCLUDE_PATH}")
Expand All @@ -40,10 +46,11 @@ else()
set (CMAKE_SWIG_FLAGS "-O;-autorename;-DSWIG_NO_EXPORT_ITERATOR_METHODS;-v")

swig_add_module (swig-ruby ruby kdb.i)
swig_link_libraries (swig-ruby elektra-core elektra-kdb)
set_target_properties (swig-ruby PROPERTIES
swig_link_libraries (swig-ruby ${RUBY_LIBRARY} elektra-core elektra-kdb)
set_target_properties (swig-ruby PROPERTIES
OUTPUT_NAME kdb
PREFIX "")
PREFIX ""
)

set_source_files_properties (
${swig_generated_file_fullname} PROPERTIES
Expand Down Expand Up @@ -73,6 +80,7 @@ else()
)

include_directories (${CMAKE_CURRENT_SOURCE_DIR})

add_subdirectory (tests)
if (BUILD_TESTING)
add_subdirectory (tests)
endif (BUILD_TESTING)
endif()
14 changes: 13 additions & 1 deletion src/bindings/swig/ruby/tests/CMakeLists.txt
Expand Up @@ -10,7 +10,19 @@ foreach (file ${TESTS})
set_property (
TEST ${name}
PROPERTY ENVIRONMENT
"RUBYLIB=${CMAKE_CURRENT_BINARY_DIR}/.."
"RUBYLIB=${CMAKE_CURRENT_BINARY_DIR}/.."
"LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
)

set_property (
TEST ${name}
PROPERTY LABELS bindings memleak
)

endforeach (file ${TESTS})

# special label for kdb
set_property (
TEST "testruby_kdb"
APPEND PROPERTY LABELS kdbtests
)

0 comments on commit ea75497

Please sign in to comment.