rcx 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67bf53ccbe670ee75a0faa064fed2c9cedb0f91042c52a61f75d2fa2948f36b7
4
- data.tar.gz: cc83c45e03bd7cb72bf8856385c74c061e3995c50f409ff9fbc9beb9a62c12c2
3
+ metadata.gz: 4074c5868fd711ee67726acd364d4aa243c5aeaf9fad6232756e9c1fde7539e3
4
+ data.tar.gz: e38a49e450466554a5845189cf2ae51ba31665f18389bf9a8d1a052fe6858353
5
5
  SHA512:
6
- metadata.gz: '08a0a98e5eade9330c4cd599b25264a3ea792ff5fc7067a122176bbf0a95e766cb6b7d0e6bc583e1bdb8535d49f5ac36624453bfa6455b381564b413e73ee5bb'
7
- data.tar.gz: 19d7231302d29d691af29fd21696e43ed9f31be3b293f48c87fc7cd6b73e58e23307a558693cdb60da49d7d8a2a6c553c35bdbb6def1e0efd4ccf847cc07e2da
6
+ metadata.gz: cb13a7ca26f4caf50b3ad8038044f6abf7f932e612e1047df7c54bc543af07a4400a5f68fc64f37406eedff1234de7e99a58583a073c0cf4cbae916c0b03cdd8
7
+ data.tar.gz: 918833acbc1d6d1bc2b5c9678533ccd6a8bbdd8f5a6b2b87e18e0baf12443eb3887cb2b8b7ca5349f897e37eb9d0a2c06381e4501870db5e00c25317cc76a9f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## UNRELEASED
2
2
 
3
+ ## v0.3.1 (2025-09-02)
4
+ - Now `extconf.rb`'s can only `require 'rcx/mkmf/c++20'` to enable RCX.
5
+
3
6
  ## v0.3.0 (2025-08-22)
4
7
  - Added `rcx::gvl::without_gvl`
5
8
 
data/README.md CHANGED
@@ -6,9 +6,7 @@ Write Ruby extensions in C++20. Inspired by [rice](https://github.com/ruby-rice/
6
6
  ## Creating a new extension
7
7
  In your `extconf.rb` file, add the following:
8
8
  ```ruby
9
- require 'mkmf
10
- $CXXFLAGS += ' -std=c++20' # or newer
11
- require 'rcx/mkmf'
9
+ require 'rcx/mkmf/c++20'
12
10
 
13
11
  create_header
14
12
  create_makefile('your_ext')
@@ -264,7 +264,7 @@ namespace rcx {
264
264
  return arg;
265
265
  }
266
266
 
267
- inline ArgSplat::ResultType ArgSplat::parse(Ruby &, Value self, std::span<Value> &args) {
267
+ inline ArgSplat::ResultType ArgSplat::parse(Ruby &, Value, std::span<Value> &args) {
268
268
  auto result = Array::new_from(args);
269
269
  args = {};
270
270
  return result;
@@ -0,0 +1,3 @@
1
+ require_relative '../mkmf'
2
+ include RCX::MakeMakefile
3
+ setup_rcx(cxx_standard: 'c++20')
data/lib/rcx/mkmf.rb CHANGED
@@ -1,56 +1,76 @@
1
1
  # SPDX-License-Identifier: BSL-1.0
2
2
  # SPDX-FileCopyrightText: Copyright 2024-2025 Kasumi Hanazuki <kasumi@rollingapple.net>
3
3
  require 'mkmf'
4
- include MakeMakefile['C++']
4
+ require_relative '../rcx'
5
5
 
6
- root = File.join(__dir__, '../..')
6
+ module RCX
7
+ CXX_STANDARD_FLAGS = {
8
+ 'c++20' => %w[--std=c++20 --std=c++2a].freeze,
9
+ 'c++23' => %w[--std=c++23 --std=c++2b].freeze,
10
+ 'c++26' => %w[--std=c++26 --std=c++2c].freeze,
11
+ }.freeze
7
12
 
8
- $INCFLAGS << " -I#{File.join(root, 'include').shellescape}"
13
+ root = File.join(__dir__, '../..')
14
+ INCDIR = File.join(root, 'include').shellescape
15
+ HEADERS = Dir[File.join(root, 'include/**/*.hpp')]
9
16
 
10
- $rcx_headers = Dir[File.join(root, 'include/**/*.hpp')]
17
+ module MakeMakefile
18
+ include ::MakeMakefile['C++']
11
19
 
12
- include (Module.new do
13
- def configuration(...)
14
- super.tap do |mk|
15
- mk << <<MAKEFILE
16
- rcx_headers = #{$rcx_headers.join(?\s)}
17
- ruby_headers := $(ruby_headers) $(rcx_headers)
18
- MAKEFILE
19
- end
20
- end
21
- end)
20
+ def setup_rcx(cxx_standard: 'c++20')
21
+ CXX_STANDARD_FLAGS.fetch(cxx_standard).find do |flag|
22
+ if checking_for("whether #{flag} is accepted as CXXFLAGS") { try_cflags(flag) }
23
+ $CXXFLAGS << " " << flag
24
+ true
25
+ else
26
+ false
27
+ end
28
+ end or raise "C++ compiler does not support #{cxx_standard}"
22
29
 
23
- ## libffi
30
+ $INCFLAGS << " -I#{INCDIR}"
24
31
 
25
- dir_config('libffi').any? || pkg_config('libffi')
26
- ffi_h = 'ffi.h'
27
- unless have_func('ffi_prep_cif', ffi_h)
28
- raise "libffi was not found"
29
- end
30
- unless have_func('ffi_closure_alloc', ffi_h) && have_func('ffi_prep_closure_loc', ffi_h)
31
- raise "libffi does not support closures"
32
- end
32
+ ## libffi
33
+ dir_config('libffi').any? || pkg_config('libffi')
34
+ ffi_h = 'ffi.h'
35
+ unless have_func('ffi_prep_cif', ffi_h)
36
+ raise "libffi was not found"
37
+ end
38
+ unless have_func('ffi_closure_alloc', ffi_h) && have_func('ffi_prep_closure_loc', ffi_h)
39
+ raise "libffi does not support closures"
40
+ end
33
41
 
34
- if have_header('cxxabi.h')
35
- have_func('abi::__cxa_demangle', 'cxxabi.h')
36
- have_func('abi::__cxa_current_exception_type', 'cxxabi.h')
37
- end
42
+ if have_header('cxxabi.h')
43
+ have_func('abi::__cxa_demangle', 'cxxabi.h')
44
+ have_func('abi::__cxa_current_exception_type', 'cxxabi.h')
45
+ end
38
46
 
39
- if checking_for("std::is_layout_compatible<>") {
40
- try_compile(<<'CXX')
47
+ if checking_for("std::is_layout_compatible<>") {
48
+ try_compile(<<'CXX')
41
49
  #include <type_traits>
42
50
  struct A { int a; };
43
51
  struct B { int b; };
44
52
  static_assert(std::is_layout_compatible<A, B>::value);
45
53
  CXX
46
- }
47
- $defs.push("-DHAVE_STD_IS_LAYOUT_COMPATIBLE=1")
48
- end
54
+ }
55
+ $defs.push("-DHAVE_STD_IS_LAYOUT_COMPATIBLE=1")
56
+ end
49
57
 
50
- if checking_for("nullability extension") {
51
- try_compile("void *_Nullable p, *_Nonnull q;")
52
- }
53
- $defs.push("-DHAVE_FEATURE_NULLABILITY=1")
54
- end
58
+ if checking_for("nullability extension") {
59
+ try_compile("void *_Nullable p, *_Nonnull q;")
60
+ }
61
+ $defs.push("-DHAVE_FEATURE_NULLABILITY=1")
62
+ end
55
63
 
56
- have_func('ruby_thread_has_gvl_p', 'ruby/thread.h')
64
+ have_func('ruby_thread_has_gvl_p', 'ruby/thread.h')
65
+ end
66
+
67
+ def configuration(...)
68
+ super.tap do |mk|
69
+ mk << <<MAKEFILE
70
+ rcx_headers = #{RCX::HEADERS.join(?\s)}
71
+ ruby_headers := $(ruby_headers) $(rcx_headers)
72
+ MAKEFILE
73
+ end
74
+ end
75
+ end
76
+ end
data/lib/rcx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RCX
2
- VERSION = -'0.3.0'
2
+ VERSION = -'0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasumi Hanazuki
@@ -44,6 +44,7 @@ files:
44
44
  - include/rcx/rcx.hpp
45
45
  - lib/rcx.rb
46
46
  - lib/rcx/mkmf.rb
47
+ - lib/rcx/mkmf/c++20.rb
47
48
  - lib/rcx/version.rb
48
49
  - package.json
49
50
  - yarn.lock