rice 4.9.0 → 4.10.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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +66 -1
  3. data/CMakePresets.json +77 -50
  4. data/FindRuby.cmake +22 -46
  5. data/include/rice/rice.hpp +1235 -1043
  6. data/include/rice/stl.hpp +681 -166
  7. data/lib/rice/doc/config.rb +57 -57
  8. data/lib/rice/doc/cpp_reference.rb +158 -158
  9. data/lib/rice/doc/doxygen.rb +289 -289
  10. data/lib/rice/doc/mkdocs.rb +332 -332
  11. data/lib/rice/doc/rice.rb +48 -48
  12. data/lib/rice/doc/ruby.rb +26 -26
  13. data/lib/rice/native.rb +15 -15
  14. data/lib/rice/native_registry.rb +12 -12
  15. data/lib/rice/parameter.rb +5 -5
  16. data/lib/rice/rbs.rb +71 -71
  17. data/lib/rice/version.rb +1 -1
  18. data/lib/rubygems/builder.rb +9 -9
  19. data/lib/rubygems_plugin.rb +8 -8
  20. data/rice/Arg.hpp +1 -7
  21. data/rice/Arg.ipp +0 -12
  22. data/rice/Buffer.hpp +27 -2
  23. data/rice/Buffer.ipp +111 -49
  24. data/rice/Data_Object.ipp +9 -16
  25. data/rice/Data_Type.hpp +7 -28
  26. data/rice/Data_Type.ipp +53 -67
  27. data/rice/Pin.hpp +40 -0
  28. data/rice/Pin.ipp +12 -0
  29. data/rice/Pointer.ipp +2 -2
  30. data/rice/Reference.ipp +2 -2
  31. data/rice/cpp_api/Module.hpp +1 -1
  32. data/rice/cpp_api/Module.ipp +1 -1
  33. data/rice/cpp_api/Object.hpp +6 -8
  34. data/rice/cpp_api/Object.ipp +29 -4
  35. data/rice/detail/Anchor.hpp +58 -0
  36. data/rice/detail/Anchor.ipp +49 -0
  37. data/rice/detail/Native.ipp +10 -9
  38. data/rice/detail/NativeAttributeGet.hpp +8 -4
  39. data/rice/detail/NativeAttributeGet.ipp +5 -5
  40. data/rice/detail/NativeAttributeSet.hpp +5 -3
  41. data/rice/detail/NativeAttributeSet.ipp +41 -33
  42. data/rice/detail/NativeCallback.hpp +6 -3
  43. data/rice/detail/NativeCallback.ipp +5 -19
  44. data/rice/detail/NativeFunction.ipp +6 -6
  45. data/rice/detail/NativeIterator.ipp +10 -5
  46. data/rice/detail/NativeMethod.ipp +34 -31
  47. data/rice/detail/NativeProc.ipp +4 -4
  48. data/rice/detail/NativeRegistry.hpp +3 -2
  49. data/rice/detail/NativeRegistry.ipp +13 -9
  50. data/rice/detail/Parameter.ipp +59 -29
  51. data/rice/detail/Proc.ipp +1 -1
  52. data/rice/detail/Type.hpp +5 -37
  53. data/rice/detail/Type.ipp +14 -317
  54. data/rice/detail/TypeIndexParser.hpp +52 -0
  55. data/rice/detail/TypeIndexParser.ipp +368 -0
  56. data/rice/detail/TypeRegistry.hpp +4 -1
  57. data/rice/detail/TypeRegistry.ipp +35 -25
  58. data/rice/detail/Wrapper.hpp +5 -1
  59. data/rice/detail/Wrapper.ipp +42 -9
  60. data/rice/detail/from_ruby.ipp +20 -8
  61. data/rice/detail/ruby.hpp +1 -17
  62. data/rice/detail/to_ruby.ipp +8 -6
  63. data/rice/forward_declares.ipp +1 -1
  64. data/rice/rice.hpp +12 -9
  65. data/rice/stl/exception.ipp +1 -1
  66. data/rice/stl/filesystem.ipp +1 -1
  67. data/rice/stl/function.hpp +12 -0
  68. data/rice/stl/function.ipp +96 -0
  69. data/rice/stl/ios_base.hpp +13 -0
  70. data/rice/stl/ios_base.ipp +38 -0
  71. data/rice/stl/map.ipp +15 -13
  72. data/rice/stl/multimap.ipp +17 -15
  73. data/rice/stl/optional.ipp +2 -2
  74. data/rice/stl/ostream.hpp +13 -0
  75. data/rice/stl/ostream.ipp +200 -0
  76. data/rice/stl/pair.ipp +16 -10
  77. data/rice/stl/reference_wrapper.ipp +2 -2
  78. data/rice/stl/set.ipp +95 -26
  79. data/rice/stl/shared_ptr.ipp +31 -11
  80. data/rice/stl/type_index.ipp +1 -1
  81. data/rice/stl/unique_ptr.ipp +16 -10
  82. data/rice/stl/unordered_map.ipp +16 -14
  83. data/rice/stl/vector.ipp +69 -33
  84. data/rice/stl.hpp +4 -1
  85. data/rice/traits/function_traits.hpp +15 -2
  86. data/rice/traits/rice_traits.hpp +21 -0
  87. data/test/embed_ruby.cpp +9 -5
  88. data/test/extconf.rb +3 -0
  89. data/test/test_Attribute.cpp +157 -63
  90. data/test/test_Buffer.cpp +103 -0
  91. data/test/test_Callback.cpp +14 -6
  92. data/test/test_Data_Type.cpp +147 -6
  93. data/test/test_Incomplete.cpp +739 -0
  94. data/test/test_Iterator.cpp +193 -38
  95. data/test/test_Overloads.cpp +142 -35
  96. data/test/test_Pin.cpp +79 -0
  97. data/test/test_Proc.cpp +8 -6
  98. data/test/test_Stl_Function.cpp +261 -0
  99. data/test/test_Stl_Map.cpp +48 -3
  100. data/test/test_Stl_Multimap.cpp +48 -3
  101. data/test/test_Stl_OStream.cpp +333 -0
  102. data/test/test_Stl_Set.cpp +34 -0
  103. data/test/test_Stl_SharedPtr.cpp +60 -6
  104. data/test/test_Stl_UniquePtr.cpp +2 -2
  105. data/test/test_Stl_Unordered_Map.cpp +46 -0
  106. data/test/test_Stl_Variant.cpp +12 -16
  107. data/test/test_Stl_Vector.cpp +140 -13
  108. data/test/test_Template.cpp +19 -23
  109. data/test/test_Tracking.cpp +3 -0
  110. data/test/test_Type.cpp +204 -128
  111. data/test/test_global_functions.cpp +17 -1
  112. data/test/unittest.hpp +29 -2
  113. metadata +18 -7
  114. data/rice/Address_Registration_Guard.hpp +0 -76
  115. data/rice/Address_Registration_Guard.ipp +0 -80
  116. data/rice/detail/Forwards.hpp +0 -18
  117. data/rice/detail/Forwards.ipp +0 -60
  118. data/test/test_Address_Registration_Guard.cpp +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60ee7533ef1a2e8fae4a992ef2d1dc2f3dd1cd4ab260217058e9de77ead8f80b
4
- data.tar.gz: 83393a7a4238d817da51eccc5392d318bb2dab00e57d9ce688867a748a50f7a5
3
+ metadata.gz: bfec1a3dda6cae1e2a2e4ead3b3d6d856487a6d214ec89a2aa7c32cab9debf24
4
+ data.tar.gz: 2bb3f7480a0ffcaee70ccc15ea7410c764a67b0b6d229300264570b1e58f8b59
5
5
  SHA512:
6
- metadata.gz: 26c796a5fcac6d816f9cddda0944be07a16cc93a0264221a351f4612061ed3b0e61dd4ab99eae0470ebc62e483f762820116024f6814f9f0023adccc466d66cf
7
- data.tar.gz: aacb86cb9d086100650839ac2cf2cf49d60dcf4604f3539be24e0922c3f3ca3a8f06dfb0511e1e1b3281e9f475cf621218ac165b4c155e5d6e4e2083b3444823
6
+ metadata.gz: a6e7edb4a1332104c7e2a0bf616919ceef92fb4d87bbca650898c1a8e705df20f54a02a78372a1a9b66b499c6d1e4a47ed75e8a2e20ebbe57cbfa0c6cd9a953d
7
+ data.tar.gz: 9ea2f5c76ccbb2d4a8e62ead7a796ad700ef77d07cf0c2fbc59b8c7626068225900009a861a654b95dd8476c80ba1e041c46b43f2969318479a28b12f7dc8678
data/CHANGELOG.md CHANGED
@@ -1,4 +1,69 @@
1
- # Changelog
1
+ # Changelog
2
+
3
+ ## 4.10.0 (2026-02-07)
4
+
5
+ Enhancements:
6
+ * Ruby 4.0 support
7
+ * Support incomplete types (PIMPL/opaque handle patterns). Rice now uses `typeid(T*)` for forward-declared types that are never fully defined.
8
+ * Support `noexcept` functions, static members, and static member functions
9
+ * Support for `Buffer<void*>` and `Pointer<void*>`
10
+ * Add `std::function`. Ruby procs, lambdas, and blocks can be wrapped in `std::function` objects and passed to C++ methods. C++ functions returning `std::function` are automatically wrapped.
11
+ * Add `std::ostream`, `std::ostringstream`, and `std::ofstream`. Ruby can write to C++ streams and pass them to C++ functions. Standard streams are exposed as `Std::COUT` and `Std::CERR`.
12
+ * Support verifying arrays of non-fundamental types (e.g., `MyClass[2]`)
13
+ * Delegate method calls for smart pointers to their wrapped objects via method_missing?
14
+
15
+ Internal:
16
+ * Refactor type handling by merging `TypeMapper` into `TypeDetail` and simplifying class hierarchy
17
+ * Greatly simplify define_attr
18
+
19
+ Incompatible Changes:
20
+ * `Address_Registration_Guard` has been replaced by `Pin`. If you are using `Address_Registration_Guard`
21
+ to protect Ruby VALUEs from garbage collection, update your code to use `Pin` instead:
22
+
23
+ Before:
24
+ ```cpp
25
+ VALUE value_;
26
+ Address_Registration_Guard guard_;
27
+ MyClass() : value_(rb_str_new2("test")), guard_(&value_) {}
28
+ ```
29
+
30
+ After:
31
+ ```cpp
32
+ Pin pin_;
33
+ MyClass() : pin_(rb_str_new2("test")) {}
34
+ VALUE getValue() { return pin_.get(); }
35
+ ```
36
+
37
+ `Pin` is self-contained and provides `get()` and `set()` methods to access the pinned VALUE.
38
+
39
+ * Rice converts Ruby blocks to procs. Thus if you have a method that expects a block, you must add
40
+ a VALUE parameter and tell Rice it is a value. For example:
41
+
42
+ ```cpp
43
+ define_method("my_method", [](VALUE self, VALUE proc)
44
+ {
45
+ }, Arg("proc").setValue())
46
+ ```
47
+
48
+ Think of this as similar to how you would capture a block in Ruby using the &block syntax.
49
+
50
+ * The `Data_Type<T>::define()` method has been removed. See the [Class Templates](bindings/class_templates.md) documentation for the recommended approach.
51
+
52
+ ## 4.9.1 (2026-01-04)
53
+ This release focuses on improving memory management for STL containers and attribute setters.
54
+
55
+ Enhancements:
56
+ * Support `takeOwnership` and `keepAlive` when setting attributes via `Arg("value").takeOwnership()` and `Arg("value").keepAlive()`
57
+ * Add `Arg` parameter names to all STL container methods for keyword argument support
58
+ * Add `keepAlive` support for STL container operations (vector push/insert, set insert, map/multimap store)
59
+ * Add `keepAlive` for map/unordered_map/multimap keys to prevent GC of pointer-type keys
60
+
61
+ Bug Fixes:
62
+ * Fix error when multiple overloaded methods take different types of vectors
63
+ * Fix type unknown errors when using `std::shared_ptr` with g++
64
+ * Fix CMake `_Ruby_DLEXT` variable type (string, not path)
65
+ * Fix crash caused by static variable in keepAlive implementation
66
+ * Fix incorrect attribute overloading behavior
2
67
 
3
68
  ## 4.9.0 (2026-01-01)
4
69
  This release revamps smart pointer support for `std::shared_ptr` and `std::unique_ptr`.
data/CMakePresets.json CHANGED
@@ -6,7 +6,11 @@
6
6
  "hidden": true,
7
7
  "generator": "Ninja",
8
8
  "binaryDir": "${sourceDir}/build/${presetName}",
9
- "installDir": "${sourceDir}/install/${presetName}"
9
+ "installDir": "${sourceDir}/install/${presetName}",
10
+ "cacheVariables": {
11
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
12
+ "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden"
13
+ }
10
14
  },
11
15
  {
12
16
  "name": "linux-debug",
@@ -14,7 +18,7 @@
14
18
  "displayName": "Linux Debug",
15
19
  "cacheVariables": {
16
20
  "CMAKE_BUILD_TYPE": "Debug",
17
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Og"
21
+ "CMAKE_CXX_FLAGS_DEBUG": "-ggdb3 -O0 -fno-omit-frame-pointer -fno-inline -fno-optimize-sibling-calls"
18
22
  },
19
23
  "condition": {
20
24
  "type": "equals",
@@ -28,7 +32,9 @@
28
32
  "displayName": "Linux Release",
29
33
  "cacheVariables": {
30
34
  "CMAKE_BUILD_TYPE": "Release",
31
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -O3 -DNDEBUG"
35
+ "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
36
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
37
+ "CMAKE_SHARED_LINKER_FLAGS_RELEASE": "-Wl,--exclude-libs,ALL -Wl,--strip-all"
32
38
  },
33
39
  "condition": {
34
40
  "type": "equals",
@@ -42,7 +48,8 @@
42
48
  "displayName": "macOS Debug",
43
49
  "cacheVariables": {
44
50
  "CMAKE_BUILD_TYPE": "Debug",
45
- "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -Og"
51
+ "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden",
52
+ "CMAKE_CXX_FLAGS_DEBUG": "-g3 -Og -fno-omit-frame-pointer -fno-inline -gsplit-dwarf"
46
53
  },
47
54
  "condition": {
48
55
  "type": "equals",
@@ -56,7 +63,10 @@
56
63
  "displayName": "macOS Release",
57
64
  "cacheVariables": {
58
65
  "CMAKE_BUILD_TYPE": "Release",
59
- "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -O3 -DNDEBUG"
66
+ "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden",
67
+ "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
68
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
69
+ "CMAKE_SHARED_LINKER_FLAGS_RELEASE": "-Wl,-dead_strip -Wl,-x"
60
70
  },
61
71
  "condition": {
62
72
  "type": "equals",
@@ -65,99 +75,116 @@
65
75
  }
66
76
  },
67
77
  {
68
- "name": "windows",
69
- "hidden": true,
78
+ "name": "mingw-debug",
79
+ "inherits": "base",
80
+ "displayName": "Mingw x64 Debug",
81
+ "cacheVariables": {
82
+ "CMAKE_BUILD_TYPE": "Debug",
83
+ "CMAKE_CXX_COMPILER": "g++.exe",
84
+ "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -fvisibility=hidden -fvisibility-inlines-hidden",
85
+ "CMAKE_CXX_FLAGS_DEBUG": "-g3 -Og -fno-omit-frame-pointer -fno-inline -gsplit-dwarf"
86
+ },
87
+ "condition": {
88
+ "type": "equals",
89
+ "lhs": "${hostSystemName}",
90
+ "rhs": "Windows"
91
+ }
92
+ },
93
+ {
94
+ "name": "mingw-release",
70
95
  "inherits": "base",
96
+ "displayName": "Mingw x64 Release",
97
+ "cacheVariables": {
98
+ "CMAKE_BUILD_TYPE": "Release",
99
+ "CMAKE_CXX_COMPILER": "g++.exe",
100
+ "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -fvisibility=hidden -fvisibility-inlines-hidden",
101
+ "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
102
+ "CMAKE_SHARED_LINKER_FLAGS_RELEASE": "-Wl,--exclude-all-symbols"
103
+ },
71
104
  "condition": {
72
105
  "type": "equals",
73
106
  "lhs": "${hostSystemName}",
74
107
  "rhs": "Windows"
108
+ }
109
+ },
110
+ {
111
+ "name": "windows-base",
112
+ "hidden": true,
113
+ "generator": "Ninja",
114
+ "binaryDir": "${sourceDir}/build/${presetName}",
115
+ "installDir": "${sourceDir}/install/${presetName}",
116
+ "toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
117
+ "cacheVariables": {
118
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
119
+ "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE"
75
120
  },
76
- "toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
121
+ "condition": {
122
+ "type": "equals",
123
+ "lhs": "${hostSystemName}",
124
+ "rhs": "Windows"
125
+ }
77
126
  },
78
127
  {
79
128
  "name": "msvc-debug",
80
- "inherits": "windows",
129
+ "inherits": "windows-base",
81
130
  "displayName": "MSVC x64 Debug",
82
131
  "cacheVariables": {
83
132
  "CMAKE_BUILD_TYPE": "Debug",
84
133
  "CMAKE_CXX_COMPILER": "cl.exe",
85
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE",
86
- "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "EditAndContinue"
134
+ "CMAKE_CXX_FLAGS_DEBUG": "/Od",
135
+ "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "ProgramDatabase"
87
136
  }
88
137
  },
89
138
  {
90
139
  "name": "msvc-release",
91
- "inherits": "windows",
140
+ "inherits": "windows-base",
92
141
  "displayName": "MSVC x64 Release",
93
142
  "cacheVariables": {
94
143
  "CMAKE_BUILD_TYPE": "Release",
95
144
  "CMAKE_CXX_COMPILER": "cl.exe",
96
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /O2 /DNDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE",
145
+ "CMAKE_CXX_FLAGS_RELEASE": "/O2 /DNDEBUG",
146
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
97
147
  "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "ProgramDatabase"
98
148
  }
99
149
  },
150
+
100
151
  {
101
152
  "name": "clang-windows-debug",
102
- "inherits": "windows",
153
+ "inherits": "windows-base",
103
154
  "displayName": "Clang Windows Debug",
104
155
  "cacheVariables": {
105
156
  "CMAKE_BUILD_TYPE": "Debug",
106
157
  "CMAKE_CXX_COMPILER": "clang-cl.exe",
107
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field"
158
+ "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field",
159
+ "CMAKE_CXX_FLAGS_DEBUG": "/Od /Zi"
108
160
  }
109
161
  },
110
162
  {
111
163
  "name": "clang-windows-release",
112
- "inherits": "windows",
164
+ "inherits": "windows-base",
113
165
  "displayName": "Clang Windows Release",
114
166
  "cacheVariables": {
115
167
  "CMAKE_BUILD_TYPE": "Release",
116
168
  "CMAKE_CXX_COMPILER": "clang-cl.exe",
117
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /O2 /DNDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field"
118
- }
119
- },
120
- {
121
- "name": "mingw-debug",
122
- "inherits": "base",
123
- "displayName": "Mingw x64 Debug",
124
- "cacheVariables": {
125
- "CMAKE_BUILD_TYPE": "Debug",
126
- "CMAKE_CXX_COMPILER": "g++.exe",
127
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -Og"
128
- },
129
- "condition": {
130
- "type": "equals",
131
- "lhs": "${hostSystemName}",
132
- "rhs": "Windows"
133
- }
134
- },
135
- {
136
- "name": "mingw-release",
137
- "inherits": "base",
138
- "displayName": "Mingw x64 Release",
139
- "cacheVariables": {
140
- "CMAKE_BUILD_TYPE": "Release",
141
- "CMAKE_CXX_COMPILER": "g++.exe",
142
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -O3 -DNDEBUG"
143
- },
144
- "condition": {
145
- "type": "equals",
146
- "lhs": "${hostSystemName}",
147
- "rhs": "Windows"
169
+ "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field",
170
+ "CMAKE_CXX_FLAGS_RELEASE": "/O2 /DNDEBUG",
171
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON"
148
172
  }
149
173
  }
150
174
  ],
175
+
151
176
  "buildPresets": [
152
177
  {
153
178
  "name": "linux-debug",
154
179
  "displayName": "Build Linux Debug",
155
- "configurePreset": "linux-debug"
180
+ "configurePreset": "linux-debug",
181
+ "jobs": 6
156
182
  },
157
183
  {
158
184
  "name": "linux-release",
159
185
  "displayName": "Build Linux Release",
160
- "configurePreset": "linux-release"
186
+ "configurePreset": "linux-release",
187
+ "jobs": 6
161
188
  },
162
189
  {
163
190
  "name": "macos-debug",
@@ -200,4 +227,4 @@
200
227
  "configurePreset": "mingw-release"
201
228
  }
202
229
  ]
203
- }
230
+ }
data/FindRuby.cmake CHANGED
@@ -12,12 +12,14 @@ Finds Ruby installation and the locations of its include files and libraries:
12
12
  find_package(Ruby [<version>] [COMPONENTS <components>...] [...])
13
13
 
14
14
  Ruby is a general-purpose programming language. This module supports Ruby
15
- 1.8 through 3.4. Virtual environments, such as RVM or RBENV, are also
15
+ 2.0 through 4.0. Virtual environments, such as RVM or RBENV, are also
16
16
  supported.
17
17
 
18
18
  Components
19
19
  ^^^^^^^^^^
20
20
 
21
+ .. versionadded:: 4.3
22
+
21
23
  This module supports the following components:
22
24
 
23
25
  ``Interpreter``
@@ -32,6 +34,8 @@ are searched for.
32
34
  Imported Targets
33
35
  ^^^^^^^^^^^^^^^^
34
36
 
37
+ .. versionadded:: 4.3
38
+
35
39
  This module defines the following :prop_tgt:`IMPORTED` targets:
36
40
 
37
41
  ``Ruby::Interpreter``
@@ -171,14 +175,16 @@ endif()
171
175
  set(_Ruby_POSSIBLE_EXECUTABLE_NAMES ruby)
172
176
 
173
177
  # If the user has not specified a Ruby version, create a list of Ruby versions
174
- # to check going from 1.8 to 4.0
178
+ # to search (newest to oldest). Based on https://www.ruby-lang.org/en/downloads/releases/
175
179
  if (NOT Ruby_FIND_VERSION_EXACT)
176
- foreach (_ruby_version RANGE 40 18 -1)
180
+ set(_Ruby_SUPPORTED_VERSIONS 40 34 33 32)
181
+ set(_Ruby_UNSUPPORTED_VERSIONS 31 30 27 26 25 24 23 22 21 20)
182
+ foreach (_ruby_version IN LISTS _Ruby_SUPPORTED_VERSIONS _Ruby_UNSUPPORTED_VERSIONS)
177
183
  string(SUBSTRING "${_ruby_version}" 0 1 _ruby_major_version)
178
184
  string(SUBSTRING "${_ruby_version}" 1 1 _ruby_minor_version)
179
185
  # Append both rubyX.Y and rubyXY (eg: ruby3.4 ruby34)
180
- list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES
181
- ruby${_ruby_major_version}.${_ruby_minor_version}
186
+ list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES
187
+ ruby${_ruby_major_version}.${_ruby_minor_version}
182
188
  ruby${_ruby_major_version}${_ruby_minor_version})
183
189
  endforeach ()
184
190
  endif ()
@@ -231,14 +237,6 @@ function(_RUBY_CONFIG_VAR RBVAR OUTVAR)
231
237
  OUTPUT_VARIABLE _Ruby_OUTPUT
232
238
  ERROR_QUIET)
233
239
 
234
- # Config was deprecated in Ruby 1.9 and then removed in Ruby 2 - so this is for ancient code
235
- if (_Ruby_SUCCESS OR _Ruby_OUTPUT STREQUAL "")
236
- execute_process(COMMAND "${Ruby_EXECUTABLE}" -r rbconfig -e "print Config::CONFIG['${RBVAR}']"
237
- RESULT_VARIABLE _Ruby_SUCCESS
238
- OUTPUT_VARIABLE _Ruby_OUTPUT
239
- ERROR_QUIET)
240
- endif ()
241
-
242
240
  set(${OUTVAR} "${_Ruby_OUTPUT}" PARENT_SCOPE)
243
241
  endfunction()
244
242
 
@@ -315,7 +313,7 @@ function(_RUBY_CHECK_BREW)
315
313
  return()
316
314
  endif ()
317
315
 
318
- MESSAGE(DEBUG "Found brew at: ${_BREW_EXECUTABLE}")
316
+ message(DEBUG "Found brew at: ${_BREW_EXECUTABLE}")
319
317
 
320
318
  # Query Homebrew for the prefix of the 'ruby' formula.
321
319
  # If Ruby is not installed via Homebrew, this will fail.
@@ -326,7 +324,7 @@ function(_RUBY_CHECK_BREW)
326
324
  ERROR_QUIET
327
325
  OUTPUT_STRIP_TRAILING_WHITESPACE
328
326
  )
329
- MESSAGE(DEBUG "Ruby BREW is: ${_Ruby_BREW_DIR}")
327
+ message(DEBUG "Ruby BREW is: ${_Ruby_BREW_DIR}")
330
328
 
331
329
  if (NOT _Ruby_BREW_RESULT EQUAL 0 OR _Ruby_BREW_DIR STREQUAL "")
332
330
  # No 'ruby' formula installed in Homebrew
@@ -427,8 +425,8 @@ if (Ruby_EXECUTABLE AND NOT Ruby_EXECUTABLE STREQUAL "${_Ruby_EXECUTABLE_LAST_QU
427
425
  set(Ruby_ARCHHDR_DIR ${Ruby_ARCHHDR_DIR} CACHE INTERNAL "The Ruby arch header dir (2.0+)" FORCE)
428
426
  set(_Ruby_POSSIBLE_LIB_DIR ${_Ruby_POSSIBLE_LIB_DIR} CACHE INTERNAL "The Ruby lib dir" FORCE)
429
427
  set(Ruby_RUBY_LIB_DIR ${Ruby_RUBY_LIB_DIR} CACHE INTERNAL "The Ruby ruby-lib dir" FORCE)
430
- set(_Ruby_SO_NAME ${_Ruby_SO_NAME} CACHE PATH "The Ruby shared library name" FORCE)
431
- set(_Ruby_DLEXT ${_Ruby_DLEXT} CACHE PATH "Ruby extensions extension" FORCE)
428
+ set(_Ruby_SO_NAME ${_Ruby_SO_NAME} CACHE STRING "The Ruby shared library name" FORCE)
429
+ set(_Ruby_DLEXT ${_Ruby_DLEXT} CACHE STRING "Ruby extensions extension" FORCE)
432
430
  set(Ruby_SITEARCH_DIR ${Ruby_SITEARCH_DIR} CACHE INTERNAL "The Ruby site arch dir" FORCE)
433
431
  set(Ruby_SITELIB_DIR ${Ruby_SITELIB_DIR} CACHE INTERNAL "The Ruby site lib dir" FORCE)
434
432
  set(Ruby_HAS_VENDOR_RUBY ${Ruby_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
@@ -455,30 +453,6 @@ if (Ruby_EXECUTABLE AND NOT Ruby_EXECUTABLE STREQUAL "${_Ruby_EXECUTABLE_LAST_QU
455
453
  )
456
454
  endif ()
457
455
 
458
- # In case Ruby_EXECUTABLE could not be executed (e.g. cross compiling)
459
- # try to detect which version we found. This is not too good.
460
- if (Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR)
461
- # by default assume 1.8.0
462
- set(Ruby_VERSION_MAJOR 1)
463
- set(Ruby_VERSION_MINOR 8)
464
- set(Ruby_VERSION_PATCH 0)
465
- # check whether we found 1.9.x
466
- if (${Ruby_EXECUTABLE} MATCHES "ruby1\\.?9")
467
- set(Ruby_VERSION_MAJOR 1)
468
- set(Ruby_VERSION_MINOR 9)
469
- endif ()
470
- # check whether we found 2.[0-7].x
471
- if (${Ruby_EXECUTABLE} MATCHES "ruby2")
472
- set(Ruby_VERSION_MAJOR 2)
473
- string(REGEX REPLACE ${Ruby_EXECUTABLE} "ruby2\\.?([0-7])" "\\1" Ruby_VERSION_MINOR)
474
- endif ()
475
- # check whether we found 3.[0-1].x
476
- if (${Ruby_EXECUTABLE} MATCHES "ruby3")
477
- set(Ruby_VERSION_MAJOR 3)
478
- string(REGEX REPLACE ${Ruby_EXECUTABLE} "ruby3\\.?([0-4])" "\\1" Ruby_VERSION_MINOR)
479
- endif ()
480
- endif ()
481
-
482
456
  if (Ruby_VERSION_MAJOR)
483
457
  set(Ruby_VERSION "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}.${Ruby_VERSION_PATCH}")
484
458
  set(_Ruby_VERSION_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}")
@@ -487,9 +461,6 @@ if (Ruby_VERSION_MAJOR)
487
461
  set(_Ruby_VERSION_SHORT_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}")
488
462
  endif ()
489
463
 
490
- # FIXME: Currently we require both the interpreter and development components to be found
491
- # in order to use either. See issue #20474.
492
-
493
464
  # Save CMAKE_FIND_FRAMEWORK
494
465
  set(_Ruby_CMAKE_FIND_FRAMEWORK_ORIGINAL ${CMAKE_FIND_FRAMEWORK})
495
466
 
@@ -516,7 +487,7 @@ set(CMAKE_FIND_FRAMEWORK ${_Ruby_CMAKE_FIND_FRAMEWORK_ORIGINAL})
516
487
  message(DEBUG "--------FindRuby.cmake debug------------")
517
488
  message(DEBUG "_Ruby_POSSIBLE_EXECUTABLE_NAMES: ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}")
518
489
  message(DEBUG "_Ruby_POSSIBLE_LIB_DIR: ${_Ruby_POSSIBLE_LIB_DIR}")
519
- message(DEBUG "Ruby_LIBRUBY_SO: ${_Ruby_SO_NAME}")
490
+ message(DEBUG "_Ruby_SO_NAME: ${_Ruby_SO_NAME}")
520
491
  message(DEBUG "_Ruby_DLEXT: ${_Ruby_DLEXT}")
521
492
  message(DEBUG "Ruby_FIND_VIRTUALENV=${Ruby_FIND_VIRTUALENV}")
522
493
  message(DEBUG "Ruby_ENV: ${Ruby_ENV}")
@@ -558,7 +529,12 @@ foreach (component IN LISTS Ruby_FIND_COMPONENTS)
558
529
  endforeach ()
559
530
 
560
531
  # Set component found flags
561
- set(Ruby_Interpreter_FOUND ${Ruby_EXECUTABLE})
532
+ if (Ruby_EXECUTABLE)
533
+ set(Ruby_Interpreter_FOUND TRUE)
534
+ else ()
535
+ set(Ruby_Interpreter_FOUND FALSE)
536
+ endif ()
537
+
562
538
  if (Ruby_INCLUDE_DIR AND Ruby_CONFIG_INCLUDE_DIR AND (Ruby_LIBRARY OR NOT WIN32))
563
539
  set(Ruby_Development_FOUND TRUE)
564
540
  else ()