Add DOWNLOAD_RUBY option to Ruby plugin cmake, defaulting to ON

If DOWNLOAD_RUBY is set to OFF, the build will not attempt to download
a prebuilt libruby.so and not fire a warning that one is not present.
This may be desired if one wants to link dfhack against a newer system
libruby.so, now that dfhack supports ruby 2.x and also supports linking
against system libruby (at least, on Linux), as per the following commit:

df9b5bca73

This also allows the dfhack build to proceed without network access
(once all submodules have been fetched), which at least some Linux
distributions, like Fedora, require.

By default DOWNLOAD_RUBY is set to ON, so this should not change
the behavior of default builds.

I tested that when DOWNLOAD_RUBY is set to OFF, dfhack still launches
and that the Ruby plugin still functions, e.g. by running
```rb_eval puts('Hello world.')``` in the dfhack console.
develop
Ben Rosser 2017-01-20 17:16:19 -05:00
parent e2fc7d3e00
commit f0d4a1f563
1 changed files with 56 additions and 48 deletions

@ -1,52 +1,59 @@
IF (APPLE) # Allow build system to turn off downloading of libruby.so.
SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/osx${DFHACK_BUILD_ARCH}/libruby.dylib) OPTION(DOWNLOAD_RUBY "Download prebuilt libruby.so for ruby plugin." ON)
SET(RUBYLIB_INSTALL_NAME "libruby.dylib")
IF(${DFHACK_BUILD_ARCH} STREQUAL 64) IF (DOWNLOAD_RUBY)
# MESSAGE("No ruby lib for 64-bit OS X yet")
ELSE() IF (APPLE)
DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/osx32-libruby187.dylib.gz" SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/osx${DFHACK_BUILD_ARCH}/libruby.dylib)
"gz" SET(RUBYLIB_INSTALL_NAME "libruby.dylib")
${RUBYLIB}.gz IF(${DFHACK_BUILD_ARCH} STREQUAL 64)
"e9bc4263557e652121b055a46abb4f97" # MESSAGE("No ruby lib for 64-bit OS X yet")
${RUBYLIB} ELSE()
"3ee5356759f764a440be5b5b44649826") DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/osx32-libruby187.dylib.gz"
ENDIF() "gz"
ELSEIF(UNIX) ${RUBYLIB}.gz
SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/linux${DFHACK_BUILD_ARCH}/libruby.so) "e9bc4263557e652121b055a46abb4f97"
SET(RUBYLIB_INSTALL_NAME "libruby.so") ${RUBYLIB}
IF(${DFHACK_BUILD_ARCH} STREQUAL 64) "3ee5356759f764a440be5b5b44649826")
DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/linux64-libruby187.so.gz" ENDIF()
"gz" ELSEIF(UNIX)
${RUBYLIB}.gz SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/linux${DFHACK_BUILD_ARCH}/libruby.so)
"8eb757bb9ada08608914d8ca8906c427" SET(RUBYLIB_INSTALL_NAME "libruby.so")
${RUBYLIB} IF(${DFHACK_BUILD_ARCH} STREQUAL 64)
"e8c36a06f031cfbf02def28169bb5f1f") DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/linux64-libruby187.so.gz"
ELSE() "gz"
DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/linux32-libruby187.so.gz" ${RUBYLIB}.gz
"gz" "8eb757bb9ada08608914d8ca8906c427"
${RUBYLIB}.gz ${RUBYLIB}
"2d06f5069ff07ea934ecd40db55a4ac5" "e8c36a06f031cfbf02def28169bb5f1f")
${RUBYLIB} ELSE()
"b00d8d7086cb39f6fde793f9d89cb2d7") DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/linux32-libruby187.so.gz"
ENDIF() "gz"
ELSE() ${RUBYLIB}.gz
SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/win${DFHACK_BUILD_ARCH}/libruby.dll) "2d06f5069ff07ea934ecd40db55a4ac5"
SET(RUBYLIB_INSTALL_NAME "libruby.dll") ${RUBYLIB}
IF(${DFHACK_BUILD_ARCH} STREQUAL 64) "b00d8d7086cb39f6fde793f9d89cb2d7")
DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/win64-libruby200.dll.gz" ENDIF()
"gz"
${RUBYLIB}.gz
"81db54a8b8b3090c94c6ae2147d30b8f"
${RUBYLIB}
"8a8564418aebddef3dfee1e96690e713")
ELSE() ELSE()
DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/win32-libruby187.dll.gz" SET(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/win${DFHACK_BUILD_ARCH}/libruby.dll)
"gz" SET(RUBYLIB_INSTALL_NAME "libruby.dll")
${RUBYLIB}.gz IF(${DFHACK_BUILD_ARCH} STREQUAL 64)
"ffc0f1b5b33748e2a36128e90c97f6b2" DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/win64-libruby200.dll.gz"
${RUBYLIB} "gz"
"482c1c418f4ee1a5f04203eee1cda0ef") ${RUBYLIB}.gz
"81db54a8b8b3090c94c6ae2147d30b8f"
${RUBYLIB}
"8a8564418aebddef3dfee1e96690e713")
ELSE()
DOWNLOAD_FILE_UNZIP("https://github.com/DFHack/dfhack-bin/releases/download/0.43.05/win32-libruby187.dll.gz"
"gz"
${RUBYLIB}.gz
"ffc0f1b5b33748e2a36128e90c97f6b2"
${RUBYLIB}
"482c1c418f4ee1a5f04203eee1cda0ef")
ENDIF()
ENDIF() ENDIF()
ENDIF() ENDIF()
IF (APPLE OR UNIX) IF (APPLE OR UNIX)
@ -73,7 +80,8 @@ ADD_DEPENDENCIES(ruby ruby-autogen-rb)
IF(EXISTS ${RUBYLIB}) IF(EXISTS ${RUBYLIB})
INSTALL(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION} RENAME ${RUBYLIB_INSTALL_NAME}) INSTALL(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION} RENAME ${RUBYLIB_INSTALL_NAME})
ELSE() ELSE()
IF(NOT(APPLE AND ${DFHACK_BUILD_ARCH} STREQUAL 64)) # Only fire this warning if DOWNLOAD_RUBY was set.
IF(NOT(APPLE AND ${DFHACK_BUILD_ARCH} STREQUAL 64) AND DOWNLOAD_RUBY)
MESSAGE(WARNING "Ruby library not found at ${RUBYLIB} - will not be installed") MESSAGE(WARNING "Ruby library not found at ${RUBYLIB} - will not be installed")
ENDIF() ENDIF()
ENDIF() ENDIF()