rice 4.3.3 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -26
  3. data/CMakeLists.txt +31 -0
  4. data/CMakePresets.json +75 -0
  5. data/COPYING +3 -2
  6. data/FindRuby.cmake +437 -0
  7. data/README.md +7 -2
  8. data/Rakefile +12 -5
  9. data/include/rice/rice.hpp +9522 -4426
  10. data/include/rice/stl.hpp +2831 -1198
  11. data/lib/make_rice_headers.rb +79 -0
  12. data/lib/mkmf-rice.rb +40 -94
  13. data/lib/rice/version.rb +3 -0
  14. data/lib/rice.rb +1 -0
  15. data/lib/rubygems/builder.rb +11 -0
  16. data/lib/rubygems/cmake_builder.rb +113 -0
  17. data/lib/rubygems_plugin.rb +9 -0
  18. data/rice/Address_Registration_Guard.hpp +72 -3
  19. data/rice/Arg.hpp +26 -6
  20. data/rice/Arg.ipp +35 -2
  21. data/rice/Buffer.hpp +123 -0
  22. data/rice/Buffer.ipp +599 -0
  23. data/rice/Callback.hpp +21 -0
  24. data/rice/Callback.ipp +13 -0
  25. data/rice/Constructor.hpp +4 -27
  26. data/rice/Constructor.ipp +79 -0
  27. data/rice/Data_Object.hpp +73 -3
  28. data/rice/Data_Object.ipp +388 -96
  29. data/rice/Data_Type.hpp +214 -3
  30. data/rice/Data_Type.ipp +144 -67
  31. data/rice/Director.hpp +0 -2
  32. data/rice/Enum.hpp +4 -7
  33. data/rice/Enum.ipp +102 -55
  34. data/rice/Exception.hpp +62 -2
  35. data/rice/Exception.ipp +7 -12
  36. data/rice/Init.hpp +8 -0
  37. data/rice/Init.ipp +8 -0
  38. data/rice/JumpException.hpp +44 -0
  39. data/rice/JumpException.ipp +48 -0
  40. data/rice/MemoryView.hpp +11 -0
  41. data/rice/MemoryView.ipp +3 -0
  42. data/rice/Return.hpp +7 -27
  43. data/rice/Return.ipp +13 -13
  44. data/rice/cpp_api/Array.hpp +209 -0
  45. data/rice/cpp_api/Array.ipp +304 -0
  46. data/rice/cpp_api/Builtin_Object.hpp +31 -0
  47. data/rice/cpp_api/Builtin_Object.ipp +37 -0
  48. data/rice/cpp_api/Class.hpp +70 -0
  49. data/rice/cpp_api/Class.ipp +97 -0
  50. data/rice/cpp_api/Encoding.hpp +32 -0
  51. data/rice/cpp_api/Encoding.ipp +59 -0
  52. data/rice/cpp_api/Hash.hpp +194 -0
  53. data/rice/cpp_api/Hash.ipp +257 -0
  54. data/rice/{Identifier.hpp → cpp_api/Identifier.hpp} +2 -6
  55. data/rice/{Identifier.ipp → cpp_api/Identifier.ipp} +4 -2
  56. data/rice/cpp_api/Module.hpp +72 -0
  57. data/rice/cpp_api/Module.ipp +101 -0
  58. data/rice/cpp_api/Object.hpp +272 -0
  59. data/rice/cpp_api/Object.ipp +235 -0
  60. data/rice/cpp_api/String.hpp +74 -0
  61. data/rice/cpp_api/String.ipp +120 -0
  62. data/rice/cpp_api/Struct.hpp +113 -0
  63. data/rice/cpp_api/Struct.ipp +92 -0
  64. data/rice/cpp_api/Symbol.hpp +46 -0
  65. data/rice/cpp_api/Symbol.ipp +93 -0
  66. data/rice/cpp_api/shared_methods.hpp +134 -0
  67. data/rice/detail/DefaultHandler.hpp +12 -0
  68. data/rice/detail/DefaultHandler.ipp +8 -0
  69. data/rice/detail/HandlerRegistry.hpp +5 -35
  70. data/rice/detail/HandlerRegistry.ipp +7 -11
  71. data/rice/detail/InstanceRegistry.hpp +1 -4
  72. data/rice/detail/MethodInfo.hpp +12 -10
  73. data/rice/detail/MethodInfo.ipp +26 -21
  74. data/rice/detail/Native.hpp +33 -0
  75. data/rice/detail/Native.ipp +157 -0
  76. data/rice/detail/NativeAttributeGet.hpp +52 -0
  77. data/rice/detail/NativeAttributeGet.ipp +57 -0
  78. data/rice/detail/NativeAttributeSet.hpp +44 -0
  79. data/rice/detail/NativeAttributeSet.ipp +88 -0
  80. data/rice/detail/NativeCallbackFFI.hpp +55 -0
  81. data/rice/detail/NativeCallbackFFI.ipp +151 -0
  82. data/rice/detail/NativeCallbackSimple.hpp +30 -0
  83. data/rice/detail/NativeCallbackSimple.ipp +29 -0
  84. data/rice/detail/NativeFunction.hpp +33 -23
  85. data/rice/detail/NativeFunction.ipp +309 -70
  86. data/rice/detail/NativeIterator.hpp +9 -11
  87. data/rice/detail/NativeIterator.ipp +33 -31
  88. data/rice/detail/NativeRegistry.hpp +24 -15
  89. data/rice/detail/NativeRegistry.ipp +23 -48
  90. data/rice/detail/Proc.hpp +4 -0
  91. data/rice/detail/Proc.ipp +85 -0
  92. data/rice/detail/Registries.hpp +0 -7
  93. data/rice/detail/Registries.ipp +0 -18
  94. data/rice/detail/RubyFunction.hpp +0 -3
  95. data/rice/detail/RubyFunction.ipp +4 -8
  96. data/rice/detail/RubyType.hpp +16 -0
  97. data/rice/detail/RubyType.ipp +232 -0
  98. data/rice/detail/Type.hpp +7 -6
  99. data/rice/detail/Type.ipp +192 -45
  100. data/rice/detail/TypeRegistry.hpp +15 -7
  101. data/rice/detail/TypeRegistry.ipp +105 -12
  102. data/rice/detail/Wrapper.hpp +68 -32
  103. data/rice/detail/Wrapper.ipp +121 -109
  104. data/rice/detail/cpp_protect.hpp +5 -6
  105. data/rice/detail/default_allocation_func.ipp +0 -2
  106. data/rice/detail/from_ruby.hpp +38 -3
  107. data/rice/detail/from_ruby.ipp +1321 -492
  108. data/rice/detail/ruby.hpp +18 -0
  109. data/rice/detail/to_ruby.hpp +41 -3
  110. data/rice/detail/to_ruby.ipp +1424 -194
  111. data/rice/global_function.hpp +0 -4
  112. data/rice/global_function.ipp +0 -1
  113. data/rice/libc/file.hpp +11 -0
  114. data/rice/libc/file.ipp +32 -0
  115. data/rice/rice.hpp +116 -26
  116. data/rice/ruby_mark.hpp +4 -3
  117. data/rice/stl/complex.hpp +6 -0
  118. data/rice/stl/complex.ipp +93 -0
  119. data/rice/stl/exception.hpp +11 -0
  120. data/rice/stl/exception.ipp +29 -0
  121. data/rice/stl/exception_ptr.hpp +6 -0
  122. data/rice/stl/exception_ptr.ipp +27 -0
  123. data/rice/stl/map.hpp +12 -0
  124. data/rice/stl/map.ipp +469 -0
  125. data/rice/stl/monostate.hpp +6 -0
  126. data/rice/stl/monostate.ipp +80 -0
  127. data/rice/stl/multimap.hpp +14 -0
  128. data/rice/stl/multimap.ipp +448 -0
  129. data/rice/stl/optional.hpp +6 -0
  130. data/rice/stl/optional.ipp +118 -0
  131. data/rice/stl/pair.hpp +13 -0
  132. data/rice/stl/pair.ipp +155 -0
  133. data/rice/stl/reference_wrapper.hpp +6 -0
  134. data/rice/stl/reference_wrapper.ipp +41 -0
  135. data/rice/stl/set.hpp +12 -0
  136. data/rice/stl/set.ipp +495 -0
  137. data/rice/stl/shared_ptr.hpp +28 -0
  138. data/rice/stl/shared_ptr.ipp +224 -0
  139. data/rice/stl/string.hpp +6 -0
  140. data/rice/stl/string.ipp +158 -0
  141. data/rice/stl/string_view.hpp +6 -0
  142. data/rice/stl/string_view.ipp +65 -0
  143. data/rice/stl/tuple.hpp +6 -0
  144. data/rice/stl/tuple.ipp +128 -0
  145. data/rice/stl/type_index.hpp +6 -0
  146. data/rice/stl/type_index.ipp +30 -0
  147. data/rice/stl/type_info.hpp +6 -0
  148. data/rice/stl/type_info.ipp +29 -0
  149. data/rice/stl/unique_ptr.hpp +22 -0
  150. data/rice/stl/unique_ptr.ipp +139 -0
  151. data/rice/stl/unordered_map.hpp +12 -0
  152. data/rice/stl/unordered_map.ipp +469 -0
  153. data/rice/stl/variant.hpp +6 -0
  154. data/rice/stl/variant.ipp +242 -0
  155. data/rice/stl/vector.hpp +12 -0
  156. data/rice/stl/vector.ipp +590 -0
  157. data/rice/stl.hpp +11 -3
  158. data/rice/traits/attribute_traits.hpp +26 -0
  159. data/rice/traits/function_traits.hpp +95 -0
  160. data/rice/traits/method_traits.hpp +47 -0
  161. data/rice/traits/rice_traits.hpp +160 -0
  162. data/rice.gemspec +85 -0
  163. data/test/embed_ruby.cpp +7 -1
  164. data/test/extconf.rb +2 -0
  165. data/test/test_Address_Registration_Guard.cpp +5 -0
  166. data/test/test_Array.cpp +18 -4
  167. data/test/test_Attribute.cpp +136 -21
  168. data/test/test_Buffer.cpp +285 -0
  169. data/test/test_Builtin_Object.cpp +5 -0
  170. data/test/test_Callback.cpp +230 -0
  171. data/test/test_Class.cpp +5 -31
  172. data/test/test_Constructor.cpp +69 -6
  173. data/test/test_Data_Object.cpp +97 -38
  174. data/test/test_Data_Type.cpp +470 -65
  175. data/test/test_Director.cpp +17 -8
  176. data/test/test_Enum.cpp +155 -40
  177. data/test/test_Exception.cpp +235 -0
  178. data/test/test_File.cpp +70 -0
  179. data/test/test_From_Ruby.cpp +609 -0
  180. data/test/test_Hash.cpp +5 -0
  181. data/test/test_Identifier.cpp +5 -0
  182. data/test/test_Inheritance.cpp +6 -1
  183. data/test/test_Iterator.cpp +6 -1
  184. data/test/test_Jump_Exception.cpp +23 -0
  185. data/test/test_Keep_Alive.cpp +13 -19
  186. data/test/test_Keep_Alive_No_Wrapper.cpp +5 -1
  187. data/test/test_Memory_Management.cpp +5 -0
  188. data/test/test_Module.cpp +128 -67
  189. data/test/test_Native_Registry.cpp +2 -34
  190. data/test/test_Object.cpp +5 -0
  191. data/test/test_Overloads.cpp +806 -0
  192. data/test/test_Ownership.cpp +160 -54
  193. data/test/test_Proc.cpp +44 -0
  194. data/test/test_Self.cpp +9 -4
  195. data/test/test_Stl_Exception.cpp +109 -0
  196. data/test/test_Stl_Map.cpp +54 -42
  197. data/test/test_Stl_Multimap.cpp +693 -0
  198. data/test/test_Stl_Optional.cpp +5 -0
  199. data/test/test_Stl_Pair.cpp +14 -9
  200. data/test/test_Stl_Reference_Wrapper.cpp +9 -2
  201. data/test/test_Stl_Set.cpp +790 -0
  202. data/test/test_Stl_SharedPtr.cpp +458 -0
  203. data/test/test_Stl_String.cpp +5 -0
  204. data/test/test_Stl_String_View.cpp +5 -0
  205. data/test/test_Stl_Tuple.cpp +116 -0
  206. data/test/test_Stl_Type.cpp +147 -0
  207. data/test/test_Stl_UniquePtr.cpp +202 -0
  208. data/test/test_Stl_Unordered_Map.cpp +43 -38
  209. data/test/test_Stl_Variant.cpp +217 -84
  210. data/test/test_Stl_Vector.cpp +306 -58
  211. data/test/test_String.cpp +5 -0
  212. data/test/test_Struct.cpp +5 -0
  213. data/test/test_Symbol.cpp +5 -0
  214. data/test/test_Template.cpp +192 -0
  215. data/test/test_To_Ruby.cpp +524 -0
  216. data/test/test_Tracking.cpp +1 -0
  217. data/test/test_Type.cpp +171 -0
  218. data/test/test_global_functions.cpp +67 -7
  219. data/test/unittest.cpp +8 -0
  220. metadata +127 -26
  221. data/lib/version.rb +0 -3
  222. data/rice/Address_Registration_Guard_defn.hpp +0 -79
  223. data/rice/Data_Object_defn.hpp +0 -84
  224. data/rice/Data_Type_defn.hpp +0 -190
  225. data/rice/Exception_defn.hpp +0 -68
  226. data/rice/HandlerRegistration.hpp +0 -15
  227. data/rice/detail/ExceptionHandler.hpp +0 -8
  228. data/rice/detail/ExceptionHandler.ipp +0 -28
  229. data/rice/detail/ExceptionHandler_defn.hpp +0 -77
  230. data/rice/detail/Jump_Tag.hpp +0 -21
  231. data/rice/detail/NativeAttribute.hpp +0 -64
  232. data/rice/detail/NativeAttribute.ipp +0 -112
  233. data/rice/detail/from_ruby_defn.hpp +0 -38
  234. data/rice/detail/to_ruby_defn.hpp +0 -48
  235. data/test/test_Jump_Tag.cpp +0 -17
  236. data/test/test_Stl_SmartPointer.cpp +0 -283
  237. data/test/test_To_From_Ruby.cpp +0 -399
data/FindRuby.cmake ADDED
@@ -0,0 +1,437 @@
1
+ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2
+ # file LICENSE.rst or https://cmake.org/licensing for details.
3
+
4
+ #[=======================================================================[.rst:
5
+ FindRuby
6
+ --------
7
+
8
+ This module determines if Ruby is installed and finds the locations of its
9
+ include files and libraries. Ruby 1.8 through 3.4 are supported.
10
+
11
+ The minimum required version of Ruby can be specified using the
12
+ standard syntax, e.g.
13
+
14
+ .. code-block:: cmake
15
+
16
+ find_package(Ruby 3.2.6 EXACT REQUIRED)
17
+ # OR
18
+ find_package(Ruby 3.2)
19
+
20
+ Virtual environments, such as RVM or RBENV, are supported.
21
+
22
+ Result Variables
23
+ ^^^^^^^^^^^^^^^^
24
+
25
+ This module will set the following variables in your project:
26
+
27
+ ``Ruby_FOUND``
28
+ set to true if ruby was found successfully
29
+ ``Ruby_EXECUTABLE``
30
+ full path to the ruby binary
31
+ ``Ruby_INCLUDE_DIRS``
32
+ include dirs to be used when using the ruby library
33
+ ``Ruby_LIBRARIES``
34
+ .. versionadded:: 3.18
35
+ libraries needed to use ruby from C.
36
+ ``Ruby_VERSION``
37
+ the version of ruby which was found, e.g. "3.2.6"
38
+ ``Ruby_VERSION_MAJOR``
39
+ Ruby major version.
40
+ ``Ruby_VERSION_MINOR``
41
+ Ruby minor version.
42
+ ``Ruby_VERSION_PATCH``
43
+ Ruby patch version.
44
+
45
+ .. versionchanged:: 3.18
46
+ Previous versions of CMake used the ``RUBY_`` prefix for all variables.
47
+
48
+ .. deprecated:: 4.0
49
+ The following variables are deprecated. See policy :policy:`CMP0185`.
50
+
51
+ ``RUBY_EXECUTABLE``
52
+ same as ``Ruby_EXECUTABLE``.
53
+ ``RUBY_INCLUDE_DIRS``
54
+ same as ``Ruby_INCLUDE_DIRS``.
55
+ ``RUBY_INCLUDE_PATH``
56
+ same as ``Ruby_INCLUDE_DIRS``.
57
+ ``RUBY_LIBRARY``
58
+ same as ``Ruby_LIBRARY``.
59
+ ``RUBY_VERSION``
60
+ same as ``Ruby_VERSION``.
61
+ ``RUBY_FOUND``
62
+ same as ``Ruby_FOUND``.
63
+
64
+ Hints
65
+ ^^^^^
66
+
67
+ ``Ruby_FIND_VIRTUALENV``
68
+ .. versionadded:: 3.18
69
+
70
+ This variable defines the handling of virtual environments.
71
+ It can be left empty or be set to one of the following values:
72
+
73
+ * ``FIRST``: Virtual Ruby environments are searched for first,
74
+ then the system Ruby installation.
75
+ This is the default.
76
+ * ``ONLY``: Only virtual environments are searched
77
+ * ``STANDARD``: Only the system Ruby installation is searched.
78
+
79
+ Virtual environments may be provided by:
80
+
81
+ ``rvm``
82
+ Requires that the ``MY_RUBY_HOME`` environment environment is defined.
83
+
84
+ ``rbenv``
85
+ Requires that ``rbenv`` is installed in ``~/.rbenv/bin``
86
+ or that the ``RBENV_ROOT`` environment variable is defined.
87
+ #]=======================================================================]
88
+
89
+ # Uncomment the following line to get debug output for this file
90
+ # set(CMAKE_MESSAGE_LOG_LEVEL DEBUG)
91
+
92
+ # Determine the list of possible names of the ruby executable depending
93
+ # on which version of ruby is required
94
+ set(_Ruby_POSSIBLE_EXECUTABLE_NAMES ruby)
95
+
96
+ # If the user has not specified a Ruby version, create a list of Ruby versions
97
+ # to check going from 1.8 to 3.4
98
+ if (NOT Ruby_FIND_VERSION_EXACT)
99
+ foreach (_ruby_version RANGE 34 18 -1)
100
+ string(SUBSTRING "${_ruby_version}" 0 1 _ruby_major_version)
101
+ string(SUBSTRING "${_ruby_version}" 1 1 _ruby_minor_version)
102
+ # Append both rubyX.Y and rubyXY (eg: ruby3.4 ruby34)
103
+ list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby${_ruby_major_version}.${_ruby_minor_version} ruby${_ruby_major_version}${_ruby_minor_version})
104
+ endforeach ()
105
+ endif ()
106
+
107
+ # Virtual environment handling
108
+ if (DEFINED Ruby_FIND_VIRTUALENV AND NOT Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$")
109
+ message(AUTHOR_WARNING "FindRuby: ${Ruby_FIND_VIRTUALENV}: invalid value for 'Ruby_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.")
110
+ set(Ruby_FIND_VIRTUALENV "FIRST")
111
+ elseif (NOT DEFINED Ruby_FIND_VIRTUALENV)
112
+ # Default is to search for virtual environments first
113
+ set(Ruby_FIND_VIRTUALENV "FIRST")
114
+ endif ()
115
+
116
+ # Validate the found Ruby interpreter to make sure that it is
117
+ # callable and that its version matches the requested version
118
+ function(_RUBY_VALIDATE_INTERPRETER result_var path)
119
+ # Get the interpreter version
120
+ execute_process(COMMAND "${path}" -e "puts RUBY_VERSION"
121
+ RESULT_VARIABLE result
122
+ OUTPUT_VARIABLE version
123
+ ERROR_QUIET
124
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
125
+
126
+ if (NOT result EQUAL 0)
127
+ set(_Ruby_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${path}\"")
128
+ set(${result_var} FALSE PARENT_SCOPE)
129
+ return()
130
+ endif ()
131
+
132
+ if (Ruby_FIND_VERSION)
133
+ if (Ruby_FIND_VERSION_EXACT AND NOT version VERSION_EQUAL Ruby_FIND_VERSION)
134
+ message(DEBUG "Incorrect Ruby found. Requested: ${Ruby_FIND_VERSION}. Found: ${version}. Path: \"${path}\"")
135
+ set(${result_var} FALSE PARENT_SCOPE)
136
+ return()
137
+ elseif (version VERSION_LESS Ruby_FIND_VERSION)
138
+ message(DEBUG "Ruby version is too old. Minimum: ${Ruby_FIND_VERSION}. Found: ${version}. Path: \"${path}\"")
139
+ set(${result_var} FALSE PARENT_SCOPE)
140
+ return()
141
+ endif ()
142
+ endif ()
143
+
144
+ # Found valid Ruby interpreter!
145
+ set(${result_var} TRUE PARENT_SCOPE)
146
+ endfunction()
147
+
148
+ # Query Ruby RBConfig module for the specified variable (_RUBY_CONFIG_VAR)
149
+ function(_RUBY_CONFIG_VAR RBVAR OUTVAR)
150
+ execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']"
151
+ RESULT_VARIABLE _Ruby_SUCCESS
152
+ OUTPUT_VARIABLE _Ruby_OUTPUT
153
+ ERROR_QUIET)
154
+
155
+ # Config was deprecated in Ruby 1.9 and then removed in Ruby 2 - so this is for ancient code
156
+ if (_Ruby_SUCCESS OR _Ruby_OUTPUT STREQUAL "")
157
+ execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']"
158
+ RESULT_VARIABLE _Ruby_SUCCESS
159
+ OUTPUT_VARIABLE _Ruby_OUTPUT
160
+ ERROR_QUIET)
161
+ endif ()
162
+
163
+ set(${OUTVAR} "${_Ruby_OUTPUT}" PARENT_SCOPE)
164
+ endfunction()
165
+
166
+ # Check for RVM virtual environments
167
+ function(_RUBY_CHECK_RVM)
168
+ if (NOT DEFINED ENV{MY_RUBY_HOME})
169
+ return()
170
+ endif ()
171
+
172
+ find_program(Ruby_EXECUTABLE
173
+ NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}
174
+ NAMES_PER_DIR
175
+ PATHS ENV MY_RUBY_HOME
176
+ PATH_SUFFIXES bin Scripts
177
+ VALIDATOR _RUBY_VALIDATE_INTERPRETER
178
+ NO_CMAKE_PATH
179
+ NO_CMAKE_ENVIRONMENT_PATH
180
+ NO_SYSTEM_ENVIRONMENT_PATH
181
+ NO_CMAKE_SYSTEM_PATH)
182
+
183
+ if (Ruby_EXECUTABLE)
184
+ set(Ruby_ENV "RVM" CACHE INTERNAL "Ruby environment")
185
+ endif ()
186
+ endfunction()
187
+
188
+ # Check for RBENV virtual environments
189
+ function(_RUBY_CHECK_RBENV)
190
+ find_program(Ruby_RBENV_EXECUTABLE
191
+ NAMES rbenv
192
+ NAMES_PER_DIR
193
+ PATHS "$ENV{HOME}/.rbenv/bin/rbenv" ENV RBENV_ROOT
194
+ PATH_SUFFIXES bin Scripts
195
+ NO_CACHE
196
+ NO_CMAKE_PATH
197
+ NO_CMAKE_ENVIRONMENT_PATH
198
+ NO_CMAKE_SYSTEM_PATH)
199
+
200
+ execute_process(COMMAND "${Ruby_RBENV_EXECUTABLE}" "which" "ruby"
201
+ RESULT_VARIABLE result
202
+ OUTPUT_VARIABLE ruby_exe
203
+ ERROR_QUIET
204
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
205
+ if (NOT result EQUAL 0)
206
+ return()
207
+ endif ()
208
+ cmake_path(GET ruby_exe PARENT_PATH ruby_dir)
209
+
210
+ find_program(Ruby_EXECUTABLE
211
+ NAMES ruby
212
+ NAMES_PER_DIR
213
+ PATHS ${ruby_dir}
214
+ VALIDATOR _RUBY_VALIDATE_INTERPRETER
215
+ NO_DEFAULT_PATH)
216
+
217
+ if (Ruby_EXECUTABLE)
218
+ set(Ruby_ENV "RBENV" CACHE INTERNAL "Ruby environment")
219
+ endif ()
220
+ endfunction()
221
+
222
+ # Check system installed Ruby
223
+ function(_RUBY_CHECK_SYSTEM)
224
+ find_program(Ruby_EXECUTABLE
225
+ NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}
226
+ NAMES_PER_DIR
227
+ VALIDATOR _RUBY_VALIDATE_INTERPRETER)
228
+
229
+ if (Ruby_EXECUTABLE)
230
+ set(Ruby_ENV "Standard" CACHE INTERNAL "Ruby environment")
231
+ endif ()
232
+ endfunction()
233
+
234
+ # Find Ruby
235
+ if (NOT Ruby_EXECUTABLE AND Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
236
+ # First check for RVM virtual environments
237
+ _RUBY_CHECK_RVM()
238
+ # Second check for RBENV virtual environments
239
+ if (NOT Ruby_EXECUTABLE)
240
+ _RUBY_CHECK_RBENV()
241
+ endif ()
242
+ endif ()
243
+
244
+ # Fallback to system installed Ruby
245
+ if (NOT Ruby_EXECUTABLE AND NOT Ruby_FIND_VIRTUALENV STREQUAL "ONLY")
246
+ _RUBY_CHECK_SYSTEM()
247
+ endif ()
248
+
249
+ # We found a new Ruby or a Ruby that is different than the last one we found.
250
+ # So reload a number of variables by querying the Ruby interpreter.
251
+ if (Ruby_EXECUTABLE AND NOT Ruby_EXECUTABLE STREQUAL "${_Ruby_EXECUTABLE_LAST_QUERIED}")
252
+ # query the ruby version
253
+ _RUBY_CONFIG_VAR("MAJOR" Ruby_VERSION_MAJOR)
254
+ _RUBY_CONFIG_VAR("MINOR" Ruby_VERSION_MINOR)
255
+ _RUBY_CONFIG_VAR("TEENY" Ruby_VERSION_PATCH)
256
+
257
+ # query the different directories
258
+ _RUBY_CONFIG_VAR("archdir" Ruby_ARCH_DIR)
259
+ _RUBY_CONFIG_VAR("arch" Ruby_ARCH)
260
+ _RUBY_CONFIG_VAR("rubyhdrdir" Ruby_HDR_DIR)
261
+ _RUBY_CONFIG_VAR("rubyarchhdrdir" Ruby_ARCHHDR_DIR)
262
+ _RUBY_CONFIG_VAR("libdir" _Ruby_POSSIBLE_LIB_DIR)
263
+ _RUBY_CONFIG_VAR("rubylibdir" Ruby_RUBY_LIB_DIR)
264
+
265
+ # site_ruby
266
+ _RUBY_CONFIG_VAR("sitearchdir" Ruby_SITEARCH_DIR)
267
+ _RUBY_CONFIG_VAR("sitelibdir" Ruby_SITELIB_DIR)
268
+
269
+ # vendor_ruby available ?
270
+ execute_process(COMMAND ${Ruby_EXECUTABLE} -r vendor-specific -e "print 'true'"
271
+ OUTPUT_VARIABLE Ruby_HAS_VENDOR_RUBY ERROR_QUIET)
272
+
273
+ if (Ruby_HAS_VENDOR_RUBY)
274
+ _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR)
275
+ _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR)
276
+ endif ()
277
+
278
+ # save the results in the cache so we don't have to run ruby the next time again
279
+ set(_Ruby_EXECUTABLE_LAST_QUERIED "${Ruby_EXECUTABLE}" CACHE INTERNAL "The ruby executable last queried for version and path info")
280
+ set(Ruby_VERSION_MAJOR ${Ruby_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE)
281
+ set(Ruby_VERSION_MINOR ${Ruby_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE)
282
+ set(Ruby_VERSION_PATCH ${Ruby_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE)
283
+ set(Ruby_ARCH_DIR ${Ruby_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE)
284
+ set(Ruby_HDR_DIR ${Ruby_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE)
285
+ set(Ruby_ARCHHDR_DIR ${Ruby_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE)
286
+ set(_Ruby_POSSIBLE_LIB_DIR ${_Ruby_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE)
287
+ set(Ruby_RUBY_LIB_DIR ${Ruby_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE)
288
+ set(Ruby_SITEARCH_DIR ${Ruby_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE)
289
+ set(Ruby_SITELIB_DIR ${Ruby_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE)
290
+ set(Ruby_HAS_VENDOR_RUBY ${Ruby_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
291
+ set(Ruby_VENDORARCH_DIR ${Ruby_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE)
292
+ set(Ruby_VENDORLIB_DIR ${Ruby_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE)
293
+
294
+ mark_as_advanced(
295
+ Ruby_ARCH_DIR
296
+ Ruby_ARCH
297
+ Ruby_HDR_DIR
298
+ Ruby_ARCHHDR_DIR
299
+ _Ruby_POSSIBLE_LIB_DIR
300
+ Ruby_RUBY_LIB_DIR
301
+ Ruby_SITEARCH_DIR
302
+ Ruby_SITELIB_DIR
303
+ Ruby_HAS_VENDOR_RUBY
304
+ Ruby_VENDORARCH_DIR
305
+ Ruby_VENDORLIB_DIR
306
+ Ruby_VERSION_MAJOR
307
+ Ruby_VERSION_MINOR
308
+ Ruby_VERSION_PATCH
309
+ )
310
+ endif ()
311
+
312
+ # In case Ruby_EXECUTABLE could not be executed (e.g. cross compiling)
313
+ # try to detect which version we found. This is not too good.
314
+ if (Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR)
315
+ # by default assume 1.8.0
316
+ set(Ruby_VERSION_MAJOR 1)
317
+ set(Ruby_VERSION_MINOR 8)
318
+ set(Ruby_VERSION_PATCH 0)
319
+ # check whether we found 1.9.x
320
+ if (${Ruby_EXECUTABLE} MATCHES "ruby1\\.?9")
321
+ set(Ruby_VERSION_MAJOR 1)
322
+ set(Ruby_VERSION_MINOR 9)
323
+ endif ()
324
+ # check whether we found 2.[0-7].x
325
+ if (${Ruby_EXECUTABLE} MATCHES "ruby2")
326
+ set(Ruby_VERSION_MAJOR 2)
327
+ string(REGEX_REPLACE ${Ruby_EXECUTABLE} "ruby2\\.?([0-7])" "\\1" Ruby_VERSION_MINOR)
328
+ endif ()
329
+ # check whether we found 3.[0-1].x
330
+ if (${Ruby_EXECUTABLE} MATCHES "ruby3")
331
+ set(Ruby_VERSION_MAJOR 3)
332
+ string(REGEX_REPLACE ${Ruby_EXECUTABLE} "ruby3\\.?([0-1])" "\\1" Ruby_VERSION_MINOR)
333
+ endif ()
334
+ endif ()
335
+
336
+ if (Ruby_VERSION_MAJOR)
337
+ set(Ruby_VERSION "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}.${Ruby_VERSION_PATCH}")
338
+ set(_Ruby_VERSION_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}")
339
+ set(_Ruby_VERSION_NODOT_ZERO_PATCH "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}0")
340
+ set(_Ruby_VERSION_SHORT "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}")
341
+ set(_Ruby_VERSION_SHORT_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}")
342
+ endif ()
343
+
344
+ # FIXME: Currently we require both the interpreter and development components to be found
345
+ # in order to use either. See issue #20474.
346
+ find_path(Ruby_INCLUDE_DIR
347
+ NAMES ruby.h
348
+ HINTS
349
+ ${Ruby_HDR_DIR}
350
+ ${Ruby_ARCH_DIR}
351
+ /usr/lib/ruby/${_Ruby_VERSION_SHORT}/i586-linux-gnu/
352
+ )
353
+
354
+ set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIR})
355
+
356
+ # if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir
357
+ if (Ruby_FIND_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_HDR_DIR)
358
+ find_path(Ruby_CONFIG_INCLUDE_DIR
359
+ NAMES ruby/config.h config.h
360
+ HINTS
361
+ ${Ruby_HDR_DIR}/${Ruby_ARCH}
362
+ ${Ruby_ARCH_DIR}
363
+ ${Ruby_ARCHHDR_DIR}
364
+ )
365
+
366
+ set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIRS} ${Ruby_CONFIG_INCLUDE_DIR})
367
+ endif ()
368
+
369
+ # Determine the list of possible names for the ruby library
370
+ set(_Ruby_POSSIBLE_LIB_NAMES
371
+ ruby
372
+ ruby-static
373
+ ruby-${Ruby_VERSION}
374
+ ruby${_Ruby_VERSION_NODOT}
375
+ ruby${_Ruby_VERSION_NODOT_ZERO_PATCH}
376
+ ruby-${_Ruby_VERSION_SHORT}
377
+ ruby${_Ruby_VERSION_SHORT}
378
+ ruby${_Ruby_VERSION_SHORT_NODOT}
379
+ )
380
+
381
+ if (WIN32)
382
+ set(_Ruby_POSSIBLE_RUNTIMES "ucrt;msvcrt;vcruntime140;vcruntime140_1;vcruntime${MSVC_TOOLSET_VERSION}")
383
+ set(_Ruby_POSSIBLE_VERSION_SUFFIXES "${_Ruby_VERSION_NODOT};${_Ruby_VERSION_NODOT_ZERO_PATCH}")
384
+
385
+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
386
+ set(_Ruby_POSSIBLE_ARCH_PREFIXES "libx64-;x64-")
387
+ else ()
388
+ set(_Ruby_POSSIBLE_ARCH_PREFIXES "lib")
389
+ endif ()
390
+
391
+ foreach (_Ruby_RUNTIME ${_Ruby_POSSIBLE_RUNTIMES})
392
+ foreach (_Ruby_VERSION_SUFFIX ${_Ruby_POSSIBLE_VERSION_SUFFIXES})
393
+ foreach (_Ruby_ARCH_PREFIX ${_Ruby_POSSIBLE_ARCH_PREFIXES})
394
+ list(APPEND _Ruby_POSSIBLE_LIB_NAMES
395
+ "${_Ruby_ARCH_PREFIX}${_Ruby_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}"
396
+ "${_Ruby_ARCH_PREFIX}${_Ruby_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}-static")
397
+ endforeach ()
398
+ endforeach ()
399
+ endforeach ()
400
+ endif ()
401
+
402
+ find_library(Ruby_LIBRARY NAMES ${_Ruby_POSSIBLE_LIB_NAMES} HINTS ${_Ruby_POSSIBLE_LIB_DIR})
403
+
404
+ set(_Ruby_REQUIRED_VARS Ruby_EXECUTABLE Ruby_INCLUDE_DIR Ruby_LIBRARY)
405
+ if (_Ruby_VERSION_SHORT_NODOT GREATER 18)
406
+ list(APPEND _Ruby_REQUIRED_VARS Ruby_CONFIG_INCLUDE_DIR)
407
+ endif ()
408
+
409
+ message(DEBUG "--------FindRuby.cmake debug------------")
410
+ message(DEBUG "_Ruby_POSSIBLE_EXECUTABLE_NAMES: ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}")
411
+ message(DEBUG "_Ruby_POSSIBLE_LIB_DIR: ${_Ruby_POSSIBLE_LIB_DIR}")
412
+ message(DEBUG "_Ruby_POSSIBLE_LIB_NAMES: ${_Ruby_POSSIBLE_LIB_NAMES}")
413
+ message(DEBUG "Ruby_FIND_VIRTUALENV=${Ruby_FIND_VIRTUALENV}")
414
+ message(DEBUG "Ruby_ENV: ${Ruby_ENV}")
415
+ message(DEBUG "Found Ruby_VERSION: \"${Ruby_VERSION}\"")
416
+ message(DEBUG "Ruby_EXECUTABLE: ${Ruby_EXECUTABLE}")
417
+ message(DEBUG "Ruby_LIBRARY: ${Ruby_LIBRARY}")
418
+ message(DEBUG "Ruby_INCLUDE_DIR: ${Ruby_INCLUDE_DIR}")
419
+ message(DEBUG "Ruby_CONFIG_INCLUDE_DIR: ${Ruby_CONFIG_INCLUDE_DIR}")
420
+ message(DEBUG "Ruby_HDR_DIR: ${Ruby_HDR_DIR}")
421
+ message(DEBUG "Ruby_ARCH_DIR: ${Ruby_ARCH_DIR}")
422
+ message(DEBUG "--------------------")
423
+
424
+ include(FindPackageHandleStandardArgs)
425
+ find_package_handle_standard_args(Ruby REQUIRED_VARS ${_Ruby_REQUIRED_VARS}
426
+ VERSION_VAR Ruby_VERSION)
427
+
428
+ if (Ruby_FOUND)
429
+ set(Ruby_LIBRARIES ${Ruby_LIBRARY})
430
+ endif ()
431
+
432
+ mark_as_advanced(
433
+ Ruby_EXECUTABLE
434
+ Ruby_LIBRARY
435
+ Ruby_INCLUDE_DIR
436
+ Ruby_CONFIG_INCLUDE_DIR
437
+ )
data/README.md CHANGED
@@ -58,11 +58,16 @@ files has not yet been checked in.
58
58
  ## Documentation
59
59
 
60
60
  Our documentation makes use of the [sphinx-doc](https://www.sphinx-doc.org) project.
61
- To generate the documentation you need the following Python packages installed:
61
+ To generate the documentation you need to run the following:
62
62
 
63
63
  ```bash
64
- pip install sphinx-docs
64
+ brew install sphinx-doc
65
+
66
+ python -m venv docs
67
+ source docs/bin/activate
65
68
  pip install furo
69
+
70
+ rake doc
66
71
  ```
67
72
 
68
73
  Then, in the `doc` directory you should be able to run `make html` and get generated
data/Rakefile CHANGED
@@ -43,7 +43,13 @@ task :clean do
43
43
  binaries.each do |asset|
44
44
  dir = File.dirname(asset)
45
45
  cd dir do
46
- run_command(MAKE, "clean")
46
+ begin
47
+ run_command(MAKE, "clean")
48
+ rescue
49
+ # If clean crashes, that's probably means there's no Makefile
50
+ # which is fine. That means this is a fresh checkout or the directory
51
+ # already otherwise got cleaned.
52
+ end
47
53
  end
48
54
  end
49
55
  end
@@ -84,7 +90,7 @@ FileUtils.mkdir_p(include_dir) #unless File.exists?('include')
84
90
  desc "Update rice header files"
85
91
  task :headers do
86
92
  FileUtils.rm_rf(File.join(include_dir, "rice", "*"))
87
- path = File.join(__dir__, 'make_rice_headers.rb')
93
+ path = File.join(__dir__, 'lib', 'make_rice_headers.rb')
88
94
  # Execute make_rice_headers.rb
89
95
  run_command(Gem.ruby, path)
90
96
  end
@@ -92,9 +98,10 @@ end
92
98
  # --------- Documentation --------------
93
99
  desc "Build the documentation"
94
100
  task :doc do
95
- cd "doc" do
96
- sh "make clean html"
97
- end
101
+ build_dir = File.expand_path(File.join("doc", "_build"))
102
+ FileUtils.rm_r(build_dir, secure: true)
103
+ cmd = ["sphinx-build", "--builder", "html", "doc", build_dir]
104
+ sh *cmd
98
105
  end
99
106
 
100
107
  task :default => :test