rice 4.5.0 → 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 (166) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  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/Rakefile +5 -4
  8. data/include/rice/rice.hpp +5436 -3201
  9. data/include/rice/stl.hpp +2355 -1269
  10. data/lib/make_rice_headers.rb +79 -0
  11. data/lib/mkmf-rice.rb +4 -0
  12. data/lib/rice/version.rb +3 -0
  13. data/lib/rice.rb +1 -0
  14. data/lib/rubygems/builder.rb +11 -0
  15. data/lib/rubygems/cmake_builder.rb +113 -0
  16. data/lib/rubygems_plugin.rb +9 -0
  17. data/rice/Arg.hpp +7 -1
  18. data/rice/Arg.ipp +11 -2
  19. data/rice/Buffer.hpp +123 -0
  20. data/rice/Buffer.ipp +599 -0
  21. data/rice/Constructor.ipp +3 -3
  22. data/rice/Data_Object.hpp +2 -3
  23. data/rice/Data_Object.ipp +188 -188
  24. data/rice/Data_Type.hpp +4 -5
  25. data/rice/Data_Type.ipp +42 -26
  26. data/rice/Enum.hpp +0 -1
  27. data/rice/Enum.ipp +26 -23
  28. data/rice/Init.hpp +8 -0
  29. data/rice/Init.ipp +8 -0
  30. data/rice/MemoryView.ipp +1 -41
  31. data/rice/Return.hpp +1 -1
  32. data/rice/Return.ipp +6 -0
  33. data/rice/cpp_api/Array.hpp +209 -0
  34. data/rice/cpp_api/Array.ipp +304 -0
  35. data/rice/cpp_api/Builtin_Object.hpp +31 -0
  36. data/rice/cpp_api/Builtin_Object.ipp +37 -0
  37. data/rice/cpp_api/Class.hpp +70 -0
  38. data/rice/cpp_api/Class.ipp +97 -0
  39. data/rice/cpp_api/Encoding.hpp +32 -0
  40. data/rice/cpp_api/Encoding.ipp +59 -0
  41. data/rice/cpp_api/Hash.hpp +194 -0
  42. data/rice/cpp_api/Hash.ipp +257 -0
  43. data/rice/cpp_api/Identifier.hpp +46 -0
  44. data/rice/cpp_api/Identifier.ipp +31 -0
  45. data/rice/cpp_api/Module.hpp +72 -0
  46. data/rice/cpp_api/Module.ipp +101 -0
  47. data/rice/cpp_api/Object.hpp +272 -0
  48. data/rice/cpp_api/Object.ipp +235 -0
  49. data/rice/cpp_api/String.hpp +74 -0
  50. data/rice/cpp_api/String.ipp +120 -0
  51. data/rice/cpp_api/Struct.hpp +113 -0
  52. data/rice/cpp_api/Struct.ipp +92 -0
  53. data/rice/cpp_api/Symbol.hpp +46 -0
  54. data/rice/cpp_api/Symbol.ipp +93 -0
  55. data/rice/cpp_api/shared_methods.hpp +134 -0
  56. data/rice/detail/MethodInfo.hpp +1 -9
  57. data/rice/detail/MethodInfo.ipp +5 -72
  58. data/rice/detail/Native.hpp +3 -2
  59. data/rice/detail/Native.ipp +32 -4
  60. data/rice/detail/NativeAttributeGet.hpp +3 -2
  61. data/rice/detail/NativeAttributeGet.ipp +8 -2
  62. data/rice/detail/NativeAttributeSet.hpp +3 -2
  63. data/rice/detail/NativeAttributeSet.ipp +8 -2
  64. data/rice/detail/NativeCallbackFFI.ipp +1 -1
  65. data/rice/detail/NativeFunction.hpp +17 -6
  66. data/rice/detail/NativeFunction.ipp +168 -64
  67. data/rice/detail/NativeIterator.hpp +3 -2
  68. data/rice/detail/NativeIterator.ipp +8 -2
  69. data/rice/detail/RubyType.hpp +2 -5
  70. data/rice/detail/RubyType.ipp +50 -5
  71. data/rice/detail/Type.hpp +3 -1
  72. data/rice/detail/Type.ipp +61 -31
  73. data/rice/detail/Wrapper.hpp +68 -33
  74. data/rice/detail/Wrapper.ipp +103 -113
  75. data/rice/detail/from_ruby.hpp +5 -4
  76. data/rice/detail/from_ruby.ipp +737 -365
  77. data/rice/detail/to_ruby.ipp +1092 -186
  78. data/rice/global_function.ipp +1 -1
  79. data/rice/libc/file.hpp +11 -0
  80. data/rice/libc/file.ipp +32 -0
  81. data/rice/rice.hpp +23 -16
  82. data/rice/stl/complex.hpp +6 -0
  83. data/rice/stl/complex.ipp +93 -0
  84. data/rice/stl/exception.hpp +11 -0
  85. data/rice/stl/exception.ipp +29 -0
  86. data/rice/stl/exception_ptr.hpp +6 -0
  87. data/rice/stl/exception_ptr.ipp +27 -0
  88. data/rice/stl/map.hpp +12 -0
  89. data/rice/stl/map.ipp +469 -0
  90. data/rice/stl/monostate.hpp +6 -0
  91. data/rice/stl/monostate.ipp +80 -0
  92. data/rice/stl/multimap.hpp +14 -0
  93. data/rice/stl/multimap.ipp +448 -0
  94. data/rice/stl/optional.hpp +6 -0
  95. data/rice/stl/optional.ipp +118 -0
  96. data/rice/stl/pair.hpp +13 -0
  97. data/rice/stl/pair.ipp +155 -0
  98. data/rice/stl/reference_wrapper.hpp +6 -0
  99. data/rice/stl/reference_wrapper.ipp +41 -0
  100. data/rice/stl/set.hpp +12 -0
  101. data/rice/stl/set.ipp +495 -0
  102. data/rice/stl/shared_ptr.hpp +28 -0
  103. data/rice/stl/shared_ptr.ipp +224 -0
  104. data/rice/stl/string.hpp +6 -0
  105. data/rice/stl/string.ipp +158 -0
  106. data/rice/stl/string_view.hpp +6 -0
  107. data/rice/stl/string_view.ipp +65 -0
  108. data/rice/stl/tuple.hpp +6 -0
  109. data/rice/stl/tuple.ipp +128 -0
  110. data/rice/stl/type_index.hpp +6 -0
  111. data/rice/stl/type_index.ipp +30 -0
  112. data/rice/stl/type_info.hpp +6 -0
  113. data/rice/stl/type_info.ipp +29 -0
  114. data/rice/stl/unique_ptr.hpp +22 -0
  115. data/rice/stl/unique_ptr.ipp +139 -0
  116. data/rice/stl/unordered_map.hpp +12 -0
  117. data/rice/stl/unordered_map.ipp +469 -0
  118. data/rice/stl/variant.hpp +6 -0
  119. data/rice/stl/variant.ipp +242 -0
  120. data/rice/stl/vector.hpp +12 -0
  121. data/rice/stl/vector.ipp +590 -0
  122. data/rice/stl.hpp +7 -3
  123. data/rice/traits/attribute_traits.hpp +26 -0
  124. data/rice/traits/function_traits.hpp +95 -0
  125. data/rice/traits/method_traits.hpp +47 -0
  126. data/rice/traits/rice_traits.hpp +160 -0
  127. data/rice.gemspec +85 -0
  128. data/test/embed_ruby.cpp +3 -0
  129. data/test/ruby/test_multiple_extensions_same_class.rb +14 -14
  130. data/test/test_Array.cpp +6 -3
  131. data/test/test_Attribute.cpp +34 -1
  132. data/test/test_Buffer.cpp +285 -0
  133. data/test/test_Callback.cpp +2 -3
  134. data/test/test_Data_Object.cpp +88 -34
  135. data/test/test_Data_Type.cpp +106 -65
  136. data/test/test_Director.cpp +7 -3
  137. data/test/test_Enum.cpp +5 -2
  138. data/test/test_File.cpp +1 -1
  139. data/test/test_From_Ruby.cpp +181 -114
  140. data/test/test_Iterator.cpp +1 -1
  141. data/test/{test_JumpException.cpp → test_Jump_Exception.cpp} +1 -0
  142. data/test/test_Keep_Alive.cpp +7 -18
  143. data/test/test_Keep_Alive_No_Wrapper.cpp +0 -1
  144. data/test/test_Module.cpp +13 -6
  145. data/test/test_Native_Registry.cpp +0 -1
  146. data/test/test_Overloads.cpp +180 -5
  147. data/test/test_Ownership.cpp +100 -57
  148. data/test/test_Proc.cpp +0 -1
  149. data/test/test_Self.cpp +4 -4
  150. data/test/test_Stl_Map.cpp +37 -39
  151. data/test/test_Stl_Multimap.cpp +693 -0
  152. data/test/test_Stl_Pair.cpp +8 -8
  153. data/test/test_Stl_Reference_Wrapper.cpp +4 -2
  154. data/test/test_Stl_Set.cpp +790 -0
  155. data/test/{test_Stl_SmartPointer.cpp → test_Stl_SharedPtr.cpp} +97 -127
  156. data/test/test_Stl_Tuple.cpp +116 -0
  157. data/test/test_Stl_Type.cpp +1 -1
  158. data/test/test_Stl_UniquePtr.cpp +202 -0
  159. data/test/test_Stl_Unordered_Map.cpp +28 -34
  160. data/test/test_Stl_Variant.cpp +217 -89
  161. data/test/test_Stl_Vector.cpp +209 -83
  162. data/test/test_To_Ruby.cpp +373 -1
  163. data/test/test_Type.cpp +85 -14
  164. data/test/test_global_functions.cpp +17 -4
  165. metadata +94 -10
  166. data/rice/detail/TupleIterator.hpp +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92005bd0a63d8dbc92dead037df25df0e79ed3fe58dcd4f6f60179b5790160f4
4
- data.tar.gz: 29bf823a8e24fc33775481f9ec0cbbf727e8a81ab6879201e852378c17bbb896
3
+ metadata.gz: 0415303e9003a2751cb4fcf3488f068359a805ed3a3df83010aa6ca032c504c9
4
+ data.tar.gz: 895d2ce47c9daa951362c7854e3bf228a3d88c3efd04a0d79f0a8acc898c6cec
5
5
  SHA512:
6
- metadata.gz: 37095af3336e4d2b15833df29eea5eef7d845fc02677f21e442c4ab9493c3bea9498afe559cdc3d2702bfa5300405f903a426c878e6a473ca7021dbe0c9e19e9
7
- data.tar.gz: d38cea1597a125fce293b522973e237fee46042248345e65871a839ce20620b0b1ffb931002ef0c51557cea1783e242052f3b395be1c765296d8b960df5f559b
6
+ metadata.gz: 3ee378cf6732ec73edd4ea33c47f58c87a996b380b019edeb3b2f279e4576924de79529ddfc086898e6d3d0f713859d8363ace294f3a621848e1d401a477b10d
7
+ data.tar.gz: 3d9834d152b559902cd378d4d00de32efbffc06ab8e5104bd895ae4f96848de2e0b42536b212cb83e154d1eb503cb9eefc2a4dad0b27a510b9fa1da5d40a9b9a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## 4.6.0 (2025-06-09)
2
+ Rice 4.6 is a major release that adds significant new functionality based on wrapping the OpenCV library, including:
3
+
4
+ * Add a new Buffer class to provide Ruby API support for pointers sent to or returned by C++
5
+ * Support C style out parameters
6
+ * Support C style arrays
7
+ * Rewrite keyword arguments
8
+ * Rewrite default value handling allowing the removal of a lot of boilerplate
9
+ * Add support for std::multimap
10
+ * Add support for std::set
11
+ * Add support for std::tuple
12
+ * Add support for smart pointers (shared_ptr, unique_ptr) to fundamental types (void, int, etc)
13
+ * Improve std::variant support
14
+ * Update is_convertible documentation
15
+ * Fix missing version.rb file in gemspec
16
+ * Add C++ preprocessor defines for Rice version
17
+ * Include Rice::VERSION in published gem
18
+ * Moved auto-generated C++ STL classes (std::vector, std::map, etc.) from the module Rice::Std module to Std module
19
+ * Make Rice const aware to improve overload method support
20
+ * Improve error messages when Rice cannot determine what overloaded method to call
21
+ * Improve handling of unbound Data_Type instances to avoid crashes when initializing global static variables of type Data_Type<T>
22
+ * Make Enums more useful by adding coerce method to enable stringing together bitwise operators - for example Season::Winter | Season::Spring | Season::Summer.
23
+
1
24
  ## 4.5 (2025-02-09)
2
25
  Rice 4.5 is a major release that adds significant new functionality, including:
3
26
 
data/CMakeLists.txt ADDED
@@ -0,0 +1,31 @@
1
+ cmake_minimum_required (VERSION 3.26)
2
+
3
+ project(Rice)
4
+
5
+ set(CMAKE_CXX_STANDARD 17)
6
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
+
8
+ # For older versions of CMake can use include("./FindRuby.cmake")
9
+ find_package("Ruby")
10
+
11
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
12
+ set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
13
+ add_compile_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
14
+ add_compile_options(/bigobj /utf-8)
15
+ # The default of /EHsc crashes Ruby when calling longjmp with optimizations on (/O2)
16
+ string(REGEX REPLACE "/EHsc" "/EHs" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
17
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
18
+ add_compile_definitions(-D_CRT_SECURE_NO_WARNINGS)
19
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
20
+ add_compile_options(-ftemplate-backtrace-limit=0)
21
+ # https://github.com/doxygen/doxygen/issues/9269#issuecomment-1094975328
22
+ #add_compile_options(unittest PRIVATE -Wa,-mbig-obj)
23
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
24
+ endif ()
25
+
26
+ # Include sub-projects.
27
+ add_subdirectory ("test")
28
+ add_subdirectory ("sample/callbacks")
29
+ add_subdirectory ("sample/enum")
30
+ add_subdirectory ("sample/inheritance")
31
+ add_subdirectory ("sample/map")
data/CMakePresets.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "version": 3,
3
+ "configurePresets": [
4
+ {
5
+ "name": "windows-base",
6
+ "hidden": true,
7
+ "generator": "Ninja",
8
+ "binaryDir": "${sourceDir}/out/build/${presetName}",
9
+ "installDir": "${sourceDir}/out/install/${presetName}",
10
+ "cacheVariables": {
11
+ "CMAKE_C_COMPILER": "cl.exe",
12
+ "CMAKE_CXX_COMPILER": "cl.exe"
13
+ },
14
+ "condition": {
15
+ "type": "equals",
16
+ "lhs": "${hostSystemName}",
17
+ "rhs": "Windows"
18
+ }
19
+ },
20
+ {
21
+ "name": "x64-debug",
22
+ "displayName": "MSVC++ Debug",
23
+ "inherits": "windows-base",
24
+ "architecture": {
25
+ "value": "x64",
26
+ "strategy": "external"
27
+ },
28
+ "cacheVariables": {
29
+ "CMAKE_BUILD_TYPE": "Debug"
30
+ }
31
+ },
32
+ {
33
+ "name": "x64-release",
34
+ "displayName": "x64 Release",
35
+ "inherits": "x64-debug",
36
+ "cacheVariables": {
37
+ "CMAKE_BUILD_TYPE": "Release"
38
+ }
39
+ },
40
+ {
41
+ "name": "linux-default",
42
+ "displayName": "Linux Debug",
43
+ "description": "Sets Ninja generator, compilers, build and install directory, debug build type",
44
+ "generator": "Ninja",
45
+ "binaryDir": "${sourceDir}/out/build/${presetName}",
46
+ "cacheVariables": {
47
+ "CMAKE_BUILD_TYPE": "Debug",
48
+ "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
49
+ },
50
+ "vendor": {
51
+ "microsoft.com/VisualStudioSettings/CMake/1.0": {
52
+ "hostOS": [ "Linux" ]
53
+ },
54
+ "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
55
+ "sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
56
+ }
57
+ }
58
+ },
59
+ {
60
+ "name": "x64_debug_clang",
61
+ "displayName": "Clang Debug",
62
+ "description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)",
63
+ "inherits": "windows-base",
64
+ "architecture": {
65
+ "value": "x64",
66
+ "strategy": "external"
67
+ },
68
+ "cacheVariables": {
69
+ "CMAKE_BUILD_TYPE": "Debug",
70
+ "CMAKE_C_COMPILER": "clang.exe",
71
+ "CMAKE_CXX_COMPILER": "clang.exe"
72
+ }
73
+ }
74
+ ]
75
+ }
data/COPYING CHANGED
@@ -1,5 +1,6 @@
1
- Copyright (C) 2020 Jason Roelofs <jasongroelofs@gmail.com>
2
- Paul Brannan <curlypaul924@gmail.com>,
1
+ Copyright (C) 2025 Jason Roelofs <jasongroelofs@gmail.com>
2
+ Paul Brannan <curlypaul924@gmail.com>,
3
+ Charlie Savage
3
4
 
4
5
  Redistribution and use in source and binary forms, with or without
5
6
  modification, are permitted provided that the following conditions
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/Rakefile CHANGED
@@ -90,7 +90,7 @@ FileUtils.mkdir_p(include_dir) #unless File.exists?('include')
90
90
  desc "Update rice header files"
91
91
  task :headers do
92
92
  FileUtils.rm_rf(File.join(include_dir, "rice", "*"))
93
- path = File.join(__dir__, 'make_rice_headers.rb')
93
+ path = File.join(__dir__, 'lib', 'make_rice_headers.rb')
94
94
  # Execute make_rice_headers.rb
95
95
  run_command(Gem.ruby, path)
96
96
  end
@@ -98,9 +98,10 @@ end
98
98
  # --------- Documentation --------------
99
99
  desc "Build the documentation"
100
100
  task :doc do
101
- cd "doc" do
102
- sh "make clean html"
103
- 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
104
105
  end
105
106
 
106
107
  task :default => :test