mkmf-lite 0.5.2 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2bb0ebe67ed8844ab179b66b5818a0affe93ce2d762bca7a43b920161b7dfdb
4
- data.tar.gz: 7d972aa186c36a84b613409ebc15c9223a21a2520f9565483976ae8d875bff0b
3
+ metadata.gz: e9c5878b974662c777fea5c8d6d31df14c3d098168a3cf393f8849cb0e9b4277
4
+ data.tar.gz: 363a30d11f1c788cb8a234b221e8a937f2f2b47d0fb71fcfdfecab5e21a9847b
5
5
  SHA512:
6
- metadata.gz: 6a5064c3121ff5d770339e482f0d1a6b42113c2f405ce1265886e122e9754eb58c1152028deb0662bf9c46ed25b8c7204c946cbf6c162346c522cc65431ac301
7
- data.tar.gz: 00e32c33cfb6d7125ddb1c66151d1b775693a0705b07bf1e525ba5428574e9b4cca146ea52c02123ff485fb098aac4c919e2b24b69c7913971e4544ba0f4edf5
6
+ metadata.gz: 96fc5d53b094dae8f3fbe95a0e946e51c304855ff5363961a9d7906b9724321b585f7d69bbce903f861673ced068547fc17bdcd3a56a5c921ef51784b3f6c1d3
7
+ data.tar.gz: fd8e851d41e663ab6fe3419ca8892fae78be63d8260eca88a4856067ed8de17030adf42001c1a9bd0944ffa36186b33bec3e99d0a2d43b896a08cfbd40ac4f8a
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,4 +1,8 @@
1
- ## 0.5.2 - 24-Mar-2022
1
+ ## 0.6.0 - 26-Sep-2023
2
+ * Added the memoist gem and memoized the results of all public methods since
3
+ the odds of them changing between calls is basically zero.
4
+
5
+ ## 0.5.2 - 24-Mar-2023
2
6
  * Lots of rubocop updates and minor cleanup, including the addition of
3
7
  rubocop and rubocop-rspec as deve dependencies.
4
8
  * Deprecation warning fixes (actually bug fixes for Ruby 3.2).
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby](https://github.com/djberg96/mkmf-lite/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/mkmf-lite/actions/workflows/ruby.yml)
2
+
1
3
  ## Summary
2
4
  A light version of mkmf designed for use within programs.
3
5
 
@@ -41,18 +43,18 @@ used in conjunction with FFI. Also, the source code is quite readable.
41
43
  It does not package C extensions, nor generate a log file or a Makefile. It
42
44
  does, however, require that you have a C compiler somewhere on your system.
43
45
 
44
- ## Known Issues
45
- You may see this warning from JRuby 1.4.x and earlier:
46
-
47
- warning: Useless use of a variable in void context.
46
+ As of version 0.6.0 it memoizes the results of any checks that you make
47
+ since they wouldn't ever change without requiring a reboot/restart of your
48
+ server, container, etc, anyway.
48
49
 
49
- You can ignore these (or, upgrade your Jruby).
50
+ ## Known Issues
51
+ Very old versions of JRuby will emit a warning. You should upgrade.
50
52
 
51
53
  ## License
52
54
  Apache-2.0
53
55
 
54
56
  ## Copyright
55
- (C) 2010-2020 Daniel J. Berger
57
+ (C) 2010-2023 Daniel J. Berger
56
58
  All Rights Reserved
57
59
 
58
60
  ## Warranty
data/lib/mkmf/lite.rb CHANGED
@@ -5,14 +5,18 @@ require 'rbconfig'
5
5
  require 'tmpdir'
6
6
  require 'open3'
7
7
  require 'ptools'
8
+ require 'fileutils'
9
+ require 'memoist'
8
10
 
9
11
  # The Mkmf module serves as a namespace only.
10
12
  module Mkmf
11
13
  # The Lite module scopes the Mkmf module to differentiate it from the
12
14
  # Mkmf module in the standard library.
13
15
  module Lite
16
+ extend Memoist
17
+
14
18
  # The version of the mkmf-lite library
15
- MKMF_LITE_VERSION = '0.5.2'
19
+ MKMF_LITE_VERSION = '0.6.0'
16
20
 
17
21
  private
18
22
 
@@ -24,6 +28,8 @@ module Mkmf
24
28
  end
25
29
  # rubocop:enable Layout/LineLength
26
30
 
31
+ memoize :cpp_command
32
+
27
33
  def cpp_source_file
28
34
  'conftest.c'
29
35
  end
@@ -36,6 +42,8 @@ module Mkmf
36
42
  end
37
43
  end
38
44
 
45
+ memoize :cpp_out_file
46
+
39
47
  # TODO: We should adjust this based on OS. For now we're using
40
48
  # arguments I think you'll typically see set on Linux and BSD.
41
49
  def cpp_libraries
@@ -46,6 +54,8 @@ module Mkmf
46
54
  end
47
55
  end
48
56
 
57
+ memoize :cpp_libraries
58
+
49
59
  public
50
60
 
51
61
  # Check for the presence of the given +header+ file. You may optionally
@@ -68,6 +78,8 @@ module Mkmf
68
78
  try_to_compile(code, options)
69
79
  end
70
80
 
81
+ memoize :have_header
82
+
71
83
  # Check for the presence of the given +function+ in the common header
72
84
  # files, or within any +headers+ that you provide.
73
85
  #
@@ -87,6 +99,8 @@ module Mkmf
87
99
  try_to_compile(ptr_code) || try_to_compile(std_code)
88
100
  end
89
101
 
102
+ memoize :have_func
103
+
90
104
  # Checks whether or not the struct of type +struct_type+ contains the
91
105
  # +struct_member+. If it does not, or the struct type cannot be found,
92
106
  # then false is returned.
@@ -102,6 +116,8 @@ module Mkmf
102
116
  try_to_compile(code)
103
117
  end
104
118
 
119
+ memoize :have_struct_member
120
+
105
121
  # Returns the value of the given +constant+ (which could also be a macro)
106
122
  # using +headers+, or common headers if no headers are specified.
107
123
  #
@@ -116,6 +132,8 @@ module Mkmf
116
132
  try_to_execute(code)
117
133
  end
118
134
 
135
+ memoize :check_valueof
136
+
119
137
  # Returns the sizeof +type+ using +headers+, or common headers if no
120
138
  # headers are specified.
121
139
  #
@@ -137,6 +155,8 @@ module Mkmf
137
155
  try_to_execute(code)
138
156
  end
139
157
 
158
+ memoize :check_sizeof
159
+
140
160
  private
141
161
 
142
162
  # Take an array of header file names (or convert it to an array if it's a
@@ -208,8 +228,8 @@ module Mkmf
208
228
  end
209
229
  end
210
230
  ensure
211
- File.delete(cpp_source_file) if File.exist?(cpp_source_file)
212
- File.delete(cpp_out_file) if File.exist?(cpp_out_file)
231
+ FileUtils.rm_f(cpp_source_file)
232
+ FileUtils.rm_f(cpp_out_file)
213
233
  $stderr.reopen(stderr_orig)
214
234
  $stdout.reopen(stdout_orig)
215
235
  end
@@ -247,8 +267,8 @@ module Mkmf
247
267
  boolean = system(command)
248
268
  end
249
269
  ensure
250
- File.delete(cpp_source_file) if File.exist?(cpp_source_file)
251
- File.delete(cpp_out_file) if File.exist?(cpp_out_file)
270
+ FileUtils.rm_f(cpp_source_file)
271
+ FileUtils.rm_f(cpp_out_file)
252
272
  $stdout.reopen(stdout_orig)
253
273
  $stderr.reopen(stderr_orig)
254
274
  end
data/mkmf-lite.gemspec CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'mkmf-lite'
5
5
  spec.summary = 'A lighter version of mkmf designed for use as a library'
6
- spec.version = '0.5.2'
6
+ spec.version = '0.6.0'
7
7
  spec.author = 'Daniel J. Berger'
8
8
  spec.license = 'Apache-2.0'
9
9
  spec.email = 'djberg96@gmail.com'
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
15
15
  spec.add_dependency('ptools', '~> 1.4')
16
+ spec.add_dependency('memoist', '~> 0.16.2')
17
+
16
18
  spec.add_development_dependency('rake')
17
19
  spec.add_development_dependency('rspec', '~> 3.9')
18
20
  spec.add_development_dependency('rubocop')
@@ -8,6 +8,7 @@
8
8
  require 'rubygems'
9
9
  require 'rspec'
10
10
  require 'mkmf/lite'
11
+ require 'fileutils'
11
12
 
12
13
  RSpec.describe Mkmf::Lite do
13
14
  subject { Class.new{ |obj| obj.extend Mkmf::Lite } }
@@ -19,7 +20,7 @@ RSpec.describe Mkmf::Lite do
19
20
 
20
21
  describe 'constants' do
21
22
  example 'version information' do
22
- expect(described_class::MKMF_LITE_VERSION).to eq('0.5.2')
23
+ expect(described_class::MKMF_LITE_VERSION).to eq('0.6.0')
23
24
  expect(described_class::MKMF_LITE_VERSION).to be_frozen
24
25
  end
25
26
  end
@@ -81,7 +82,7 @@ RSpec.describe Mkmf::Lite do
81
82
  end
82
83
 
83
84
  example 'have_struct_member accepts a maximum of three arguments' do
84
- expect{ subject.have_struct_member('struct passwd', 'pw_name', 'pwd.h', true) }.to raise_error(ArgumentError)
85
+ expect{ subject.have_struct_member('struct passwd', 'pw_name', 'pwd.h', 1) }.to raise_error(ArgumentError)
85
86
  end
86
87
  end
87
88
 
@@ -106,7 +107,7 @@ RSpec.describe Mkmf::Lite do
106
107
 
107
108
  example 'check_valueof returns an integer value' do
108
109
  value = subject.check_valueof(constant)
109
- expect(value).to be_kind_of(Integer)
110
+ expect(value).to be_a(Integer)
110
111
  expect(value).to eq(-1)
111
112
  end
112
113
  end
@@ -132,7 +133,7 @@ RSpec.describe Mkmf::Lite do
132
133
 
133
134
  example 'check_sizeof returns an integer value' do
134
135
  size = subject.check_sizeof(st_type, st_header)
135
- expect(size).to be_kind_of(Integer)
136
+ expect(size).to be_a(Integer)
136
137
  expect(size).to be > 0
137
138
  end
138
139
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkmf-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2023-03-24 00:00:00.000000000 Z
38
+ date: 2023-09-26 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ptools
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.4'
54
+ - !ruby/object:Gem::Dependency
55
+ name: memoist
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.16.2
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.16.2
54
68
  - !ruby/object:Gem::Dependency
55
69
  name: rake
56
70
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
175
  - !ruby/object:Gem::Version
162
176
  version: '0'
163
177
  requirements: []
164
- rubygems_version: 3.4.6
178
+ rubygems_version: 3.3.26
165
179
  signing_key:
166
180
  specification_version: 4
167
181
  summary: A lighter version of mkmf designed for use as a library
metadata.gz.sig CHANGED
Binary file