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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
# Allow build system to turn off downloading of libruby.so.
|
2019-07-16 20:19:11 -06:00
|
|
|
option(DOWNLOAD_RUBY "Download prebuilt libruby.so for ruby plugin." ON)
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(DOWNLOAD_RUBY)
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(APPLE)
|
|
|
|
set(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/osx${DFHACK_BUILD_ARCH}/libruby.dylib)
|
|
|
|
set(RUBYLIB_INSTALL_NAME "libruby.dylib")
|
|
|
|
if(${DFHACK_BUILD_ARCH} STREQUAL 64)
|
|
|
|
# message("No ruby lib for 64-bit OS X yet")
|
|
|
|
else()
|
|
|
|
download_file_unzip("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/osx32-libruby187.dylib.gz"
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
"gz"
|
|
|
|
${RUBYLIB}.gz
|
|
|
|
"e9bc4263557e652121b055a46abb4f97"
|
|
|
|
${RUBYLIB}
|
|
|
|
"3ee5356759f764a440be5b5b44649826")
|
2019-07-16 20:19:11 -06:00
|
|
|
endif()
|
|
|
|
elseif(UNIX)
|
|
|
|
set(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/linux${DFHACK_BUILD_ARCH}/libruby.so)
|
|
|
|
set(RUBYLIB_INSTALL_NAME "libruby.so")
|
|
|
|
if(${DFHACK_BUILD_ARCH} STREQUAL 64)
|
|
|
|
download_file_unzip("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/linux64-libruby187.so.gz"
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
"gz"
|
|
|
|
${RUBYLIB}.gz
|
|
|
|
"8eb757bb9ada08608914d8ca8906c427"
|
|
|
|
${RUBYLIB}
|
|
|
|
"e8c36a06f031cfbf02def28169bb5f1f")
|
2019-07-16 20:19:11 -06:00
|
|
|
else()
|
|
|
|
download_file_unzip("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/linux32-libruby187.so.gz"
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
"gz"
|
|
|
|
${RUBYLIB}.gz
|
|
|
|
"2d06f5069ff07ea934ecd40db55a4ac5"
|
|
|
|
${RUBYLIB}
|
|
|
|
"b00d8d7086cb39f6fde793f9d89cb2d7")
|
2019-07-16 20:19:11 -06:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(RUBYLIB ${CMAKE_CURRENT_SOURCE_DIR}/win${DFHACK_BUILD_ARCH}/libruby.dll)
|
|
|
|
set(RUBYLIB_INSTALL_NAME "libruby.dll")
|
|
|
|
if(${DFHACK_BUILD_ARCH} STREQUAL 64)
|
|
|
|
download_file_unzip("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win64-libruby200.dll.gz"
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
"gz"
|
|
|
|
${RUBYLIB}.gz
|
|
|
|
"81db54a8b8b3090c94c6ae2147d30b8f"
|
|
|
|
${RUBYLIB}
|
|
|
|
"8a8564418aebddef3dfee1e96690e713")
|
2019-07-16 20:19:11 -06:00
|
|
|
else()
|
|
|
|
download_file_unzip("https://github.com/DFHack/dfhack-bin/releases/download/0.44.09/win32-libruby187.dll.gz"
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
"gz"
|
|
|
|
${RUBYLIB}.gz
|
|
|
|
"ffc0f1b5b33748e2a36128e90c97f6b2"
|
|
|
|
${RUBYLIB}
|
|
|
|
"482c1c418f4ee1a5f04203eee1cda0ef")
|
2019-07-16 20:19:11 -06:00
|
|
|
endif()
|
|
|
|
endif()
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
endif()
|
2012-06-09 18:06:22 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(APPLE OR UNIX)
|
|
|
|
set(RUBYAUTOGEN ruby-autogen-gcc.rb)
|
|
|
|
else(APPLE OR UNIX)
|
|
|
|
set(RUBYAUTOGEN ruby-autogen-win.rb)
|
|
|
|
endif(APPLE OR UNIX)
|
2014-11-14 04:47:42 -07:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
add_custom_command(
|
2014-11-14 04:47:42 -07:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN}
|
2016-08-05 15:09:25 -06:00
|
|
|
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/codegen.pl ${dfhack_SOURCE_DIR}/library/include/df/codegen.out.xml ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN} ${CMAKE_SYSTEM_NAME} ${DFHACK_BUILD_ARCH}
|
2012-09-29 04:12:56 -06:00
|
|
|
# cmake quirk: depending on codegen.out.xml or generate_headers only is not enough, needs both
|
|
|
|
# test by manually patching any library/xml/moo.xml, run make ruby-autogen-rb -j2, and check build/plugins/ruby/ruby-autogen.rb for patched xml data
|
|
|
|
DEPENDS generate_headers ${dfhack_SOURCE_DIR}/library/include/df/codegen.out.xml ${CMAKE_CURRENT_SOURCE_DIR}/codegen.pl
|
2014-11-14 04:47:42 -07:00
|
|
|
COMMENT ${RUBYAUTOGEN}
|
2012-06-02 15:44:52 -06:00
|
|
|
)
|
2019-07-16 20:19:11 -06:00
|
|
|
add_custom_target(ruby-autogen-rb DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN})
|
2012-06-09 18:06:22 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
include_directories("${dfhack_SOURCE_DIR}/depends/tthread")
|
2012-06-09 18:06:22 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
dfhack_plugin(ruby ruby.cpp LINK_LIBRARIES dfhack-tinythread)
|
|
|
|
add_dependencies(ruby ruby-autogen-rb)
|
2012-06-09 18:06:22 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
if(EXISTS ${RUBYLIB})
|
|
|
|
install(FILES ${RUBYLIB} DESTINATION ${DFHACK_LIBRARY_DESTINATION} RENAME ${RUBYLIB_INSTALL_NAME})
|
|
|
|
else()
|
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:
https://github.com/DFHack/dfhack/commit/df9b5bca7311489748ab100dfc51080841c3f196
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.
2017-01-20 15:16:19 -07:00
|
|
|
# Only fire this warning if DOWNLOAD_RUBY was set.
|
2019-07-16 20:19:11 -06:00
|
|
|
if(NOT(APPLE AND ${DFHACK_BUILD_ARCH} STREQUAL 64) AND DOWNLOAD_RUBY)
|
|
|
|
message(WARNING "Ruby library not found at ${RUBYLIB} - will not be installed")
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-06-24 08:09:31 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
install(DIRECTORY .
|
|
|
|
DESTINATION hack/ruby
|
|
|
|
FILES_MATCHING PATTERN "*.rb")
|
2012-09-30 09:08:03 -06:00
|
|
|
|
2019-07-16 20:19:11 -06:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RUBYAUTOGEN} DESTINATION hack/ruby)
|