extpp 0.0.4 → 0.0.9

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: 1c37906ea8ea871e171e387ce61d68bc162cdc7d45aa94c85e9a080c1565b4a1
4
- data.tar.gz: c1f54dea942fa0329b8e275bdb296e880d1b1731ec16eff59ef663509bad2fbc
3
+ metadata.gz: 3ad1ded05bdc3f935efd716bf7efca2248ff163e32ead6ad7fd2207d9c49e883
4
+ data.tar.gz: b8439db5e84748907e4f4e744ee3916e96ab70b1284a6f63a376678a6d3669fb
5
5
  SHA512:
6
- metadata.gz: 0dd33cc753814d03f1d2f1177a4ff74138a1c52808ee4bccfd3f4d8c52f8667e35f310d7d9afd3b64c3f0233d6549e2e0977b80a8d6947f3297f4188b4c5f089
7
- data.tar.gz: 92f0058fb4af4f2da3702a0af37a4afb3095cb7fc3e5891b7500e29458a3fe21f4a7cf4c17c82553a916603643eb871fd921df3cf354336fb903d0ddf184756f
6
+ metadata.gz: d55f0224494159be0b951787bcf5e28990f7cbd2b5a17aabdce821dcc390ca9309c8f4eb7d04db755c1bd3defb6c45807592cfb672a41af45c060de7c497fccd
7
+ data.tar.gz: 3f9fb2d6a8e80e7087e5f45b8713fad57166fcfbd29e43c03c16bea3db62865def8413ea815022f02f7e08d896eebf40f5b9b6add4cb4d4f55ce334d3a8a54f2
data/README.md CHANGED
@@ -90,12 +90,12 @@ Build this extension:
90
90
  Now, you can use this extension:
91
91
 
92
92
  ```console
93
- % ruby -r ./hello -e 'p Hello.new("me").greet'
93
+ % ruby -r extpp/setup -r ./hello -e 'p Hello.new("me").greet'
94
94
  "Hello me"
95
95
  ```
96
96
 
97
97
  ## License
98
98
 
99
- Copyright (C) 2017-2018 Kouhei Sutou
99
+ Copyright (C) 2017-2019 Kouhei Sutou
100
100
 
101
101
  The 2-Clause BSD License. See [LICENSE.txt](LICENSE.txt) for details.
@@ -1,5 +1,67 @@
1
1
  # News
2
2
 
3
+ ## 0.0.9 - 2020-11-03
4
+
5
+ ### Improvements
6
+
7
+ * Improved `clang++` version detection.
8
+ [GitHub#10][Patch by Alex Neill]
9
+
10
+ * Improved `g++` version detection.
11
+
12
+ ### Thanks
13
+
14
+ * Alex Neill
15
+
16
+ ## 0.0.8 - 2019-09-25
17
+
18
+ ### Improvements
19
+
20
+ * Changed to use `RbConfig::CONFIG["SOEXT"]`.
21
+ [Suggested by Nobuyoshi Nakada]
22
+
23
+ * Added `ExtpPP::Platform#shared_library_extension`.
24
+
25
+ * Added support for macOS Majave.
26
+ [GitHub#8][Patch by Josh Huckabee]
27
+
28
+ ### Thanks
29
+
30
+ * Nobuyoshi Nakada
31
+
32
+ * Josh Huckabee
33
+
34
+ ## 0.0.7 - 2019-03-21
35
+
36
+ ### Improvements
37
+
38
+ * Added support for Windows.
39
+
40
+ ## 0.0.6 - 2019-02-25
41
+
42
+ ### Improvements
43
+
44
+ * Suppressed warnings by `register`.
45
+ [GitHub#6][Patch by Kenta Murata]
46
+
47
+ * Added `noreturn` attribute to suppress warning.
48
+ [GitHub#7][Patch by Kenta Murata]
49
+
50
+ ### Thanks
51
+
52
+ * Kenta Murata
53
+
54
+ ## 0.0.5 - 2019-02-25
55
+
56
+ ### Improvements
57
+
58
+ * Added support for Xcode 10.
59
+ [GitHub#4][Reported by Kenta Murata]
60
+
61
+ ### Thanks
62
+
63
+ * Kenta Murata
64
+
3
65
  ## 0.0.4 - 2019-02-16
4
66
 
5
67
  ### Improvements
@@ -53,7 +53,7 @@ HEADERS = #{headers.collect(&:quote).join(" ")}
53
53
 
54
54
  INCLUDE_DIR = #{include_dir.quote}
55
55
 
56
- CXX = #{RbConfig::CONFIG["CXX"].quote}
56
+ CXX = #{RbConfig.expand("$(CXX)")}
57
57
 
58
58
  RUBY = #{RbConfig.ruby.quote}
59
59
  RUBY_HEADER_DIR = #{RbConfig::CONFIG["rubyhdrdir"].quote}
@@ -75,7 +75,7 @@ INCLUDEFLAGS = \
75
75
  -I$(INCLUDE_DIR) \
76
76
  -I$(RUBY_HEADER_DIR) \
77
77
  -I$(RUBY_ARCH_HEADER_DIR)
78
- CPPFLAGS = #{RbConfig::CONFIG["CPPFLAGS"]}
78
+ CPPFLAGS = #{RbConfig::CONFIG["CPPFLAGS"]} -DRB_EXTPP_COMPILATION
79
79
  CXXFLAGS = $(CCDLFLAGS) #{cxxflags}
80
80
 
81
81
  all: $(LIBRARY)
@@ -1,4 +1,4 @@
1
- #include <ruby/object.hpp>
1
+ #include <ruby.hpp>
2
2
 
3
3
  namespace {
4
4
  VALUE call_block(RB_BLOCK_CALL_FUNC_ARGLIST(rb_data, rb_block)) {
@@ -1,4 +1,4 @@
1
- #include <ruby/protect.hpp>
1
+ #include <ruby.hpp>
2
2
 
3
3
  namespace rb {
4
4
  VALUE protect(RawCallback callback, VALUE callback_data) {
@@ -5,6 +5,16 @@
5
5
  #define RB_BEGIN_DECLS extern "C" {
6
6
  #define RB_END_DECLS }
7
7
 
8
+ #ifdef _WIN32
9
+ # ifdef RB_EXTPP_COMPILATION
10
+ # define RB_EXTPP_EXPORT __declspec(dllexport)
11
+ # else
12
+ # define RB_EXTPP_EXPORT __declspec(dllimport)
13
+ # endif
14
+ #else
15
+ # define RB_EXTPP_EXPORT __attribute__((visibility("default")))
16
+ #endif
17
+
8
18
  #include <ruby/cast.hpp>
9
19
  #include <ruby/class.hpp>
10
20
  #include <ruby/object.hpp>
@@ -36,12 +36,12 @@ namespace rb {
36
36
 
37
37
  template <>
38
38
  inline int64_t cast<int64_t, Object>(const Object& rb_object) {
39
- return NUM2LONG(rb_object);
39
+ return NUM2LL(rb_object);
40
40
  }
41
41
 
42
42
  template <>
43
43
  inline Object cast<Object, int64_t>(const int64_t& n) {
44
- return Object(LONG2NUM(n));
44
+ return Object(LL2NUM(n));
45
45
  }
46
46
 
47
47
 
@@ -58,12 +58,12 @@ namespace rb {
58
58
 
59
59
  template <>
60
60
  inline uint64_t cast<uint64_t, Object>(const Object& rb_object) {
61
- return NUM2ULONG(rb_object);
61
+ return NUM2ULL(rb_object);
62
62
  }
63
63
 
64
64
  template <>
65
65
  inline Object cast<Object, uint64_t>(const uint64_t& n) {
66
- return Object(ULONG2NUM(n));
66
+ return Object(ULL2NUM(n));
67
67
  }
68
68
 
69
69
 
@@ -3,7 +3,7 @@
3
3
  #include <ruby/object.hpp>
4
4
 
5
5
  namespace rb {
6
- class Class: public Object {
6
+ class RB_EXTPP_EXPORT Class: public Object {
7
7
  public:
8
8
  Class(const char *name);
9
9
  Class(const char *name, VALUE parent);
@@ -5,7 +5,7 @@
5
5
  #include <initializer_list>
6
6
 
7
7
  namespace rb {
8
- class Object {
8
+ class RB_EXTPP_EXPORT Object {
9
9
  public:
10
10
  explicit Object(VALUE rb_object=Qnil) :
11
11
  rb_object_(rb_object),
@@ -3,13 +3,13 @@
3
3
  #include <ruby/type.hpp>
4
4
 
5
5
  namespace rb {
6
- class State {
6
+ class RB_EXTPP_EXPORT State {
7
7
  public:
8
8
  explicit State(int state) :
9
9
  state_(state) {
10
10
  }
11
11
 
12
- inline void jump() {
12
+ [[noreturn]] inline void jump() {
13
13
  rb_jump_tag(state_);
14
14
  }
15
15
 
@@ -17,15 +17,15 @@ namespace rb {
17
17
  int state_;
18
18
  };
19
19
 
20
- VALUE protect(RawCallback callback, VALUE callback_data);
20
+ RB_EXTPP_EXPORT VALUE protect(RawCallback callback, VALUE callback_data);
21
21
 
22
- template <typename CALLBACK>
23
- VALUE protect(const CALLBACK& callback) {
22
+ template <typename NoArgumentCallback>
23
+ VALUE protect(const NoArgumentCallback& callback) {
24
24
  struct Data {
25
- Data(const CALLBACK& callback) :
25
+ Data(const NoArgumentCallback& callback) :
26
26
  callback_(callback) {
27
27
  }
28
- const CALLBACK& callback_;
28
+ const NoArgumentCallback& callback_;
29
29
  } data(callback);
30
30
  auto callback_data = reinterpret_cast<VALUE>(&data);
31
31
  return protect([](VALUE callback_data) -> VALUE {
@@ -13,6 +13,7 @@ module ExtPP
13
13
 
14
14
  def check
15
15
  check_debug_build
16
+ check_cxx
16
17
  check_version
17
18
  check_warning_flags
18
19
  end
@@ -45,6 +46,12 @@ module ExtPP
45
46
  end
46
47
  end
47
48
 
49
+ def check_cxx
50
+ checking_for(checking_message("C++ compiler"), "%s") do
51
+ RbConfig.expand("$(CXX)")
52
+ end
53
+ end
54
+
48
55
  def check_version
49
56
  return unless gcc?
50
57
 
@@ -53,28 +60,31 @@ module ExtPP
53
60
  std = nil
54
61
 
55
62
  case `#{RbConfig.expand("$(CXX) --version")}`
56
- when /\Ag\+\+ .+ (\d\.\d)\.\d/
63
+ when /g\+\+.+ (\d+\.\d+)\.\d/
57
64
  version = Float($1)
58
65
  if version < 5.1
59
66
  std = "gnu++11"
60
67
  elsif version < 6.1
61
68
  std = "gnu++14"
69
+ else
70
+ std = "gnu++17"
62
71
  end
63
- when /\A.+ clang version (\d\.\d)\.\d/
72
+ when /\AApple (?:LLVM|clang) version (\d+\.\d+)\.\d/
64
73
  version = Float($1)
65
- if version < 3.5
74
+ # TODO: Is it right?
75
+ if version < 9.0
66
76
  std = "gnu++11"
67
- elsif version < 5
77
+ elsif version < 9.1
68
78
  std = "gnu++14"
69
79
  else
70
80
  std = "gnu++17"
71
81
  end
72
- when /\AApple LLVM version (\d\.\d)\.\d/
82
+ cxx_flags = "-Wno-deprecated-register"
83
+ when /clang version (\d+\.\d+)\.\d/
73
84
  version = Float($1)
74
- # TODO: Is it right?
75
- if version < 9.0
85
+ if version < 3.5
76
86
  std = "gnu++11"
77
- elsif version < 9.1
87
+ elsif version < 5
78
88
  std = "gnu++14"
79
89
  else
80
90
  std = "gnu++17"
@@ -82,7 +92,14 @@ module ExtPP
82
92
  end
83
93
 
84
94
  if std
95
+ if std == "gnu++17"
96
+ # ruby/intern.h doesn't adapt to C++17. Because it uses
97
+ # "register" for "rb_mem_clear(register VALUE *mem,
98
+ # register long size)". C++17 removes "register" keyword.
99
+ std = "gnu++14"
100
+ end
85
101
  @cxx_flags += " -std=#{std}"
102
+ @cxx_flags += " #{cxx_flags}" if cxx_flags
86
103
  [version, " (#{std})"]
87
104
  else
88
105
  [version, ""]
@@ -120,7 +137,12 @@ module ExtPP
120
137
  flags << warning_flag
121
138
  end
122
139
  end
123
- @cxx_flags = Shellwords.join(flags)
140
+ case RUBY_PLATFORM
141
+ when /windows/, /mingw/
142
+ @cxx_flags = flags.join(" ")
143
+ else
144
+ @cxx_flags = Shellwords.join(flags)
145
+ end
124
146
  end
125
147
  end
126
148
  end
@@ -1,14 +1,8 @@
1
1
  module ExtPP
2
2
  class Platform
3
3
  def dynamic_library_extension
4
- case RUBY_PLATFORM
5
- when /windows/, /mingw/
6
- "dll"
7
- when /darwin/
8
- "dylib"
9
- else
10
- RbConfig::CONFIG["DLEXT"]
11
- end
4
+ RbConfig::CONFIG["SOEXT"]
12
5
  end
6
+ alias_method :shared_library_extension, :dynamic_library_extension
13
7
  end
14
8
  end
@@ -0,0 +1,4 @@
1
+ if Object.const_defined?(:RubyInstaller)
2
+ ext_dir = File.expand_path(File.join(__dir__, "..", "..", "ext", "extpp"))
3
+ RubyInstaller::Runtime.add_dll_directory(ext_dir)
4
+ end
@@ -1,3 +1,3 @@
1
1
  module ExtPP
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -1,4 +1,9 @@
1
- task :default => :build
1
+ task :default => :run
2
+
3
+ desc "Run"
4
+ task :run => :build do
5
+ ruby("hello.rb")
6
+ end
2
7
 
3
8
  desc "Build"
4
9
  task :build => "hello.so"
Binary file
Binary file
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
Binary file
Binary file
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
@@ -2,7 +2,11 @@ check_debug_build: checking --enable-debug-build option... --------------------
2
2
 
3
3
  --------------------
4
4
 
5
- check_version: checking g++ version... -------------------- 8.2
5
+ check_cxx: checking C++ compiler... -------------------- g++
6
+
7
+ --------------------
8
+
9
+ check_version: checking g++ version... -------------------- 8.3
6
10
 
7
11
  --------------------
8
12
 
@@ -1,5 +1,7 @@
1
1
  require "test-unit"
2
2
 
3
+ require "extpp/setup"
4
+
3
5
  module Helper
4
6
  module Fixture
5
7
  def fixture_path(*components)
@@ -10,9 +10,17 @@ ext_dir = base_dir + "ext" + "extpp"
10
10
  lib_dir = base_dir + "lib"
11
11
  test_dir = base_dir + "test"
12
12
 
13
- Dir.chdir(ext_dir.to_s) do
14
- if File.exist?("Makefile")
15
- system("make > /dev/null") or exit(false)
13
+ make = nil
14
+ if system("which gmake > #{File::NULL} 2>&1")
15
+ make = "gmake"
16
+ elsif system("which make > #{File::NULL} 2>&1")
17
+ make = "make"
18
+ end
19
+ if make
20
+ Dir.chdir(ext_dir.to_s) do
21
+ if File.exist?("Makefile")
22
+ system("#{make} > #{File::NULL}") or exit(false)
23
+ end
16
24
  end
17
25
  end
18
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extpp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-15 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - lib/extpp.rb
82
82
  - lib/extpp/compiler.rb
83
83
  - lib/extpp/platform.rb
84
+ - lib/extpp/setup.rb
84
85
  - lib/extpp/version.rb
85
86
  - sample/hello/Rakefile
86
87
  - sample/hello/extconf.rb
@@ -134,39 +135,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
135
  - !ruby/object:Gem::Version
135
136
  version: '0'
136
137
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.7.6
138
+ rubygems_version: 3.2.0.rc.2
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Ext++ is a Ruby extension that provides C++ API for writing Ruby extension.
142
142
  test_files:
143
- - test/test-object.rb
144
- - test/test-protect.rb
145
- - test/test-class.rb
146
- - test/fixtures/class/class.so
147
- - test/fixtures/class/mkmf.log
148
- - test/fixtures/class/class.cpp
149
- - test/fixtures/class/class.o
150
- - test/fixtures/class/Makefile
151
- - test/fixtures/class/extconf.rb
152
- - test/fixtures/protect/mkmf.log
153
- - test/fixtures/protect/protect.so
154
- - test/fixtures/protect/protect.cpp
155
- - test/fixtures/protect/Makefile
156
- - test/fixtures/protect/protect.o
157
- - test/fixtures/protect/extconf.rb
158
- - test/fixtures/cast/mkmf.log
159
- - test/fixtures/cast/cast.cpp
160
- - test/fixtures/cast/cast.so
161
143
  - test/fixtures/cast/Makefile
144
+ - test/fixtures/cast/cast.cpp
162
145
  - test/fixtures/cast/cast.o
146
+ - test/fixtures/cast/cast.so
163
147
  - test/fixtures/cast/extconf.rb
164
- - test/fixtures/object/mkmf.log
165
- - test/fixtures/object/object.so
148
+ - test/fixtures/cast/mkmf.log
149
+ - test/fixtures/class/Makefile
150
+ - test/fixtures/class/class.cpp
151
+ - test/fixtures/class/class.o
152
+ - test/fixtures/class/class.so
153
+ - test/fixtures/class/extconf.rb
154
+ - test/fixtures/class/mkmf.log
166
155
  - test/fixtures/object/Makefile
156
+ - test/fixtures/object/extconf.rb
157
+ - test/fixtures/object/mkmf.log
167
158
  - test/fixtures/object/object.cpp
168
159
  - test/fixtures/object/object.o
169
- - test/fixtures/object/extconf.rb
160
+ - test/fixtures/object/object.so
161
+ - test/fixtures/protect/Makefile
162
+ - test/fixtures/protect/extconf.rb
163
+ - test/fixtures/protect/mkmf.log
164
+ - test/fixtures/protect/protect.cpp
165
+ - test/fixtures/protect/protect.o
166
+ - test/fixtures/protect/protect.so
170
167
  - test/helper.rb
171
168
  - test/run-test.rb
172
169
  - test/test-cast.rb
170
+ - test/test-class.rb
171
+ - test/test-object.rb
172
+ - test/test-protect.rb