mkmf-lite 0.5.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +12 -1
- data/README.md +8 -6
- data/Rakefile +5 -0
- data/lib/mkmf/lite.rb +36 -12
- data/mkmf-lite.gemspec +3 -1
- data/spec/mkmf_lite_spec.rb +5 -4
- data.tar.gz.sig +0 -0
- metadata +20 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72c07ed9aa3d8aef12735ec24829df062a4e0461251cbc756f1b45e4e7db0c84
|
4
|
+
data.tar.gz: '04393aeb022d6686e32406dc15f0370ca128ca65508ef11d07c477c1049a3728'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69323d948af2a1c02bdb3b2189b083f66a19438c6ecfa142414b25f46465aa2c5e1860c3993d6dbac69eb337de939ef80defce1caa65267c25db6a9a5f1b9148
|
7
|
+
data.tar.gz: cd7610faf9fcc1638980e4938b87fa73a9beb6376e291c51ba4fdc79e616a01e4db2493211d55ccf07d1f58c94b077e15c573a403bc363f42c657b4005f347b9
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGES.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.7.0 - 13-Sep-2024
|
2
|
+
* Append typical library switches to the compiler command. There was a private
|
3
|
+
method already in the code but I wasn't using it.
|
4
|
+
* Append DEFS if present in your RbConfig options. This was mainly to ensure
|
5
|
+
that FILE_OFFSET_BITS is passed, if present, but there could be other
|
6
|
+
macros in theory.
|
7
|
+
|
8
|
+
## 0.6.0 - 26-Sep-2023
|
9
|
+
* Added the memoist gem and memoized the results of all public methods since
|
10
|
+
the odds of them changing between calls is basically zero.
|
11
|
+
|
12
|
+
## 0.5.2 - 24-Mar-2023
|
2
13
|
* Lots of rubocop updates and minor cleanup, including the addition of
|
3
14
|
rubocop and rubocop-rspec as deve dependencies.
|
4
15
|
* 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
|
-
|
45
|
-
|
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
|
-
|
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-
|
57
|
+
(C) 2010-2023 Daniel J. Berger
|
56
58
|
All Rights Reserved
|
57
59
|
|
58
60
|
## Warranty
|
data/Rakefile
CHANGED
data/lib/mkmf/lite.rb
CHANGED
@@ -5,17 +5,25 @@ 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.
|
19
|
+
MKMF_LITE_VERSION = '0.7.0'
|
16
20
|
|
17
21
|
private
|
18
22
|
|
23
|
+
def cpp_defs
|
24
|
+
RbConfig::CONFIG['DEFS']
|
25
|
+
end
|
26
|
+
|
19
27
|
# rubocop:disable Layout/LineLength
|
20
28
|
def cpp_command
|
21
29
|
command = RbConfig::CONFIG['CC'] || RbConfig::CONFIG['CPP'] || File.which('cc') || File.which('gcc') || File.which('cl')
|
@@ -24,6 +32,8 @@ module Mkmf
|
|
24
32
|
end
|
25
33
|
# rubocop:enable Layout/LineLength
|
26
34
|
|
35
|
+
memoize :cpp_command
|
36
|
+
|
27
37
|
def cpp_source_file
|
28
38
|
'conftest.c'
|
29
39
|
end
|
@@ -36,16 +46,20 @@ module Mkmf
|
|
36
46
|
end
|
37
47
|
end
|
38
48
|
|
39
|
-
|
40
|
-
|
49
|
+
memoize :cpp_out_file
|
50
|
+
|
41
51
|
def cpp_libraries
|
42
|
-
if RbConfig::CONFIG['
|
43
|
-
|
52
|
+
return if File::ALT_SEPARATOR && RbConfig::CONFIG['CPP'] =~ /^cl/
|
53
|
+
|
54
|
+
if cpp_command =~ /clang/i
|
55
|
+
'-Lrt -Ldl -Lcrypt -Lm'
|
44
56
|
else
|
45
57
|
'-lrt -ldl -lcrypt -lm'
|
46
58
|
end
|
47
59
|
end
|
48
60
|
|
61
|
+
memoize :cpp_libraries
|
62
|
+
|
49
63
|
public
|
50
64
|
|
51
65
|
# Check for the presence of the given +header+ file. You may optionally
|
@@ -68,6 +82,8 @@ module Mkmf
|
|
68
82
|
try_to_compile(code, options)
|
69
83
|
end
|
70
84
|
|
85
|
+
memoize :have_header
|
86
|
+
|
71
87
|
# Check for the presence of the given +function+ in the common header
|
72
88
|
# files, or within any +headers+ that you provide.
|
73
89
|
#
|
@@ -87,6 +103,8 @@ module Mkmf
|
|
87
103
|
try_to_compile(ptr_code) || try_to_compile(std_code)
|
88
104
|
end
|
89
105
|
|
106
|
+
memoize :have_func
|
107
|
+
|
90
108
|
# Checks whether or not the struct of type +struct_type+ contains the
|
91
109
|
# +struct_member+. If it does not, or the struct type cannot be found,
|
92
110
|
# then false is returned.
|
@@ -102,6 +120,8 @@ module Mkmf
|
|
102
120
|
try_to_compile(code)
|
103
121
|
end
|
104
122
|
|
123
|
+
memoize :have_struct_member
|
124
|
+
|
105
125
|
# Returns the value of the given +constant+ (which could also be a macro)
|
106
126
|
# using +headers+, or common headers if no headers are specified.
|
107
127
|
#
|
@@ -116,6 +136,8 @@ module Mkmf
|
|
116
136
|
try_to_execute(code)
|
117
137
|
end
|
118
138
|
|
139
|
+
memoize :check_valueof
|
140
|
+
|
119
141
|
# Returns the sizeof +type+ using +headers+, or common headers if no
|
120
142
|
# headers are specified.
|
121
143
|
#
|
@@ -137,6 +159,8 @@ module Mkmf
|
|
137
159
|
try_to_execute(code)
|
138
160
|
end
|
139
161
|
|
162
|
+
memoize :check_sizeof
|
163
|
+
|
140
164
|
private
|
141
165
|
|
142
166
|
# Take an array of header file names (or convert it to an array if it's a
|
@@ -185,7 +209,7 @@ module Mkmf
|
|
185
209
|
Dir.chdir(Dir.tmpdir) do
|
186
210
|
File.write(cpp_source_file, code)
|
187
211
|
|
188
|
-
command = "#{cpp_command} "
|
212
|
+
command = "#{cpp_command} #{cpp_libraries} #{cpp_defs} "
|
189
213
|
command += "#{cpp_out_file} "
|
190
214
|
command += cpp_source_file
|
191
215
|
|
@@ -208,8 +232,8 @@ module Mkmf
|
|
208
232
|
end
|
209
233
|
end
|
210
234
|
ensure
|
211
|
-
|
212
|
-
|
235
|
+
FileUtils.rm_f(cpp_source_file)
|
236
|
+
FileUtils.rm_f(cpp_out_file)
|
213
237
|
$stderr.reopen(stderr_orig)
|
214
238
|
$stdout.reopen(stdout_orig)
|
215
239
|
end
|
@@ -234,9 +258,9 @@ module Mkmf
|
|
234
258
|
File.write(cpp_source_file, code)
|
235
259
|
|
236
260
|
if command_options
|
237
|
-
command = "#{cpp_command} #{command_options} "
|
261
|
+
command = "#{cpp_command} #{command_options} #{cpp_libraries} #{cpp_defs} "
|
238
262
|
else
|
239
|
-
command = "#{cpp_command} "
|
263
|
+
command = "#{cpp_command} #{cpp_libraries} #{cpp_defs} "
|
240
264
|
end
|
241
265
|
|
242
266
|
command += "#{cpp_out_file} "
|
@@ -247,8 +271,8 @@ module Mkmf
|
|
247
271
|
boolean = system(command)
|
248
272
|
end
|
249
273
|
ensure
|
250
|
-
|
251
|
-
|
274
|
+
FileUtils.rm_f(cpp_source_file)
|
275
|
+
FileUtils.rm_f(cpp_out_file)
|
252
276
|
$stdout.reopen(stdout_orig)
|
253
277
|
$stderr.reopen(stderr_orig)
|
254
278
|
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.
|
6
|
+
spec.version = '0.7.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')
|
data/spec/mkmf_lite_spec.rb
CHANGED
@@ -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.
|
23
|
+
expect(described_class::MKMF_LITE_VERSION).to eq('0.7.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',
|
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
|
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
|
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,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mkmf-lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2024-09-14 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
|
@@ -146,7 +160,7 @@ metadata:
|
|
146
160
|
source_code_uri: https://github.com/djberg96/mkmf-lite
|
147
161
|
wiki_uri: https://github.com/djberg96/mkmf-lite/wiki
|
148
162
|
rubygems_mfa_required: 'true'
|
149
|
-
post_install_message:
|
163
|
+
post_install_message:
|
150
164
|
rdoc_options: []
|
151
165
|
require_paths:
|
152
166
|
- lib
|
@@ -161,8 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
175
|
- !ruby/object:Gem::Version
|
162
176
|
version: '0'
|
163
177
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
165
|
-
signing_key:
|
178
|
+
rubygems_version: 3.5.11
|
179
|
+
signing_key:
|
166
180
|
specification_version: 4
|
167
181
|
summary: A lighter version of mkmf designed for use as a library
|
168
182
|
test_files:
|
metadata.gz.sig
CHANGED
Binary file
|