mkmf-lite 0.8.0 → 0.8.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +8 -0
- data/README.md +78 -5
- data/ROADMAP.md +129 -85
- data/lib/mkmf/lite.rb +1 -1
- data/lib/mkmf/templates/check_offsetof.erb +1 -3
- data/lib/mkmf/templates/check_sizeof.erb +2 -3
- data/lib/mkmf/templates/check_valueof.erb +8 -1
- data/lib/mkmf/templates/have_struct_member.erb +1 -1
- data/mkmf-lite.gemspec +1 -1
- data/spec/mkmf_lite_spec.rb +80 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- 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: b780dd7e2e0e1b2be89941ce19c6cd891de5318b53cb199e6b3cbfead5c174be
|
|
4
|
+
data.tar.gz: 7b8afafe384f433f17b309416b24a467c488696b6b2e98560c4f2e545bfd9c77
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a80776330561d06936541572c984baec486bbacce69fa15bf07c3e8578981791a2769e17d94e793781f5203339b037860a5ba7d86bed1d67b65216885cde910
|
|
7
|
+
data.tar.gz: 98dc7c4df08d005d8628b4509f1b58059a2995bc321798138315d794d98ffadad2ef48b383afe5374ac66b162e8c5c9108376ceb6e2d33701e89cf596b8731ae
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.8.1 - 30-Jun-2026
|
|
2
|
+
* Improved generated C formatting for size, offset, and constant probes.
|
|
3
|
+
* Simplified struct member probes to use a compile-only member check.
|
|
4
|
+
* Added regression coverage for generated C, linker arguments, library names,
|
|
5
|
+
and parallel probe invocations.
|
|
6
|
+
* Expanded documentation for portability, diagnostics, FFI use, and
|
|
7
|
+
memoization.
|
|
8
|
+
|
|
1
9
|
## 0.8.0 - 29-Jun-2026
|
|
2
10
|
* Removed implicit Linux-style library flags from compiler probes.
|
|
3
11
|
* Compile probes now use argv-style command execution and per-probe temporary
|
data/README.md
CHANGED
|
@@ -10,7 +10,9 @@ A light version of mkmf designed for use within programs.
|
|
|
10
10
|
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/mkmf-lite/main/certs/djberg96_pub.pem)`
|
|
11
11
|
|
|
12
12
|
## Prerequisites
|
|
13
|
-
A C compiler somewhere on your system.
|
|
13
|
+
A C compiler somewhere on your system. `mkmf-lite` uses the compiler Ruby was
|
|
14
|
+
configured with when possible, falling back to common compiler names on your
|
|
15
|
+
`PATH`.
|
|
14
16
|
|
|
15
17
|
## Synopsis
|
|
16
18
|
```ruby
|
|
@@ -43,9 +45,80 @@ used in conjunction with FFI. Also, the source code is quite readable.
|
|
|
43
45
|
It does not package C extensions, nor generate a log file or a Makefile. It
|
|
44
46
|
does, however, require that you have a C compiler somewhere on your system.
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
## Portability model
|
|
49
|
+
Each probe generates a tiny C program in a per-probe temporary directory and
|
|
50
|
+
asks Ruby's configured compiler to compile it. Boolean probes return whether
|
|
51
|
+
that compile or link step succeeded. Value probes compile and run a small
|
|
52
|
+
program that prints the requested integer value.
|
|
53
|
+
|
|
54
|
+
The generated source is intentionally small and portable. `mkmf-lite` avoids
|
|
55
|
+
assuming Linux-specific libraries or global temporary filenames, and it passes
|
|
56
|
+
compiler arguments as argv-style command parts so paths with spaces can work.
|
|
57
|
+
|
|
58
|
+
Unlike stdlib `mkmf`, this library does not create a `Makefile`, does not build
|
|
59
|
+
an extension, does not write an `mkmf.log`, and keeps its API inside
|
|
60
|
+
`Mkmf::Lite` instead of relying on top-level methods.
|
|
61
|
+
|
|
62
|
+
## Diagnostics
|
|
63
|
+
Boolean probes such as `have_header`, `have_func`, `have_library`, and
|
|
64
|
+
`have_struct_member` are quiet by default and return `true` or `false`.
|
|
65
|
+
|
|
66
|
+
Value probes such as `check_valueof`, `check_sizeof`, and `check_offsetof`
|
|
67
|
+
raise `StandardError` if their generated C cannot be compiled. The exception
|
|
68
|
+
message includes the compiler command, compiler stderr, and generated source so
|
|
69
|
+
you can see what failed without hunting for a separate log file.
|
|
70
|
+
|
|
71
|
+
## FFI examples
|
|
72
|
+
Use `mkmf-lite` to decide which declarations are safe to expose through FFI:
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
require 'ffi'
|
|
76
|
+
require 'mkmf/lite'
|
|
77
|
+
|
|
78
|
+
module LibC
|
|
79
|
+
extend FFI::Library
|
|
80
|
+
extend Mkmf::Lite
|
|
81
|
+
|
|
82
|
+
ffi_lib FFI::Library::LIBC
|
|
83
|
+
|
|
84
|
+
attach_function :getpid, [], :int if have_func('getpid', 'unistd.h')
|
|
85
|
+
end
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
You can also use it to size native structs:
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
class StatLayout
|
|
92
|
+
extend Mkmf::Lite
|
|
93
|
+
|
|
94
|
+
STAT_SIZE = check_sizeof('struct stat', 'sys/stat.h')
|
|
95
|
+
UID_OFFSET = check_offsetof('struct stat', 'st_uid', 'sys/stat.h')
|
|
96
|
+
HAS_BIRTHTIME = have_struct_member('struct stat', 'st_birthtime', 'sys/stat.h')
|
|
97
|
+
end
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
For libraries installed outside the compiler's default include path, pass
|
|
101
|
+
include directories to probes that accept them:
|
|
102
|
+
|
|
103
|
+
```ruby
|
|
104
|
+
class LocalHeader
|
|
105
|
+
extend Mkmf::Lite
|
|
106
|
+
|
|
107
|
+
HAVE_FOO = have_header('foo.h', '/usr/local/include')
|
|
108
|
+
FOO_VERSION = check_valueof('FOO_VERSION', 'foo.h', '/usr/local/include')
|
|
109
|
+
end
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Memoization
|
|
113
|
+
As of version 0.6.0, public probe results are memoized for the lifetime of the
|
|
114
|
+
object that extends `Mkmf::Lite`. The method arguments are part of the cache
|
|
115
|
+
key, so `have_header('foo.h')` and `have_header('foo.h', '/usr/local/include')`
|
|
116
|
+
are distinct checks.
|
|
117
|
+
|
|
118
|
+
This fits the normal use case where compiler configuration, headers, and system
|
|
119
|
+
libraries do not change while the Ruby process is running. If you need to probe
|
|
120
|
+
again after changing the environment, create a new object or restart the
|
|
121
|
+
process.
|
|
49
122
|
|
|
50
123
|
## Known Issues
|
|
51
124
|
JRuby may emit warnings on some platforms.
|
|
@@ -54,7 +127,7 @@ JRuby may emit warnings on some platforms.
|
|
|
54
127
|
Apache-2.0
|
|
55
128
|
|
|
56
129
|
## Copyright
|
|
57
|
-
(C) 2010-
|
|
130
|
+
(C) 2010-2026 Daniel J. Berger
|
|
58
131
|
All Rights Reserved
|
|
59
132
|
|
|
60
133
|
## Warranty
|
data/ROADMAP.md
CHANGED
|
@@ -1,104 +1,148 @@
|
|
|
1
1
|
# Roadmap
|
|
2
2
|
|
|
3
|
-
This branch focuses on
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
* Prefer Ruby's `RbConfig` values where they are appropriate, and only add
|
|
17
|
-
explicit libraries when a probe requires them.
|
|
18
|
-
* Use a per-probe temporary directory instead of shared `conftest.c` and
|
|
3
|
+
This branch focuses on improving `mkmf-lite` without turning it into stdlib
|
|
4
|
+
`mkmf`. The guiding rule is to add clearer extension points and better
|
|
5
|
+
diagnostics while preserving the small public API that existing callers use.
|
|
6
|
+
|
|
7
|
+
## Released
|
|
8
|
+
|
|
9
|
+
### 0.8.0 - Portability Foundation
|
|
10
|
+
|
|
11
|
+
Released 29-Jun-2026.
|
|
12
|
+
|
|
13
|
+
* Removed implicit Linux-style library flags from compiler probes.
|
|
14
|
+
* Replaced shell-built compiler command strings with argv-style execution.
|
|
15
|
+
* Used per-probe temporary directories instead of shared `conftest.c` and
|
|
19
16
|
`conftest.exe` files in `Dir.tmpdir`.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
FreeBSD runner.
|
|
25
|
-
|
|
26
|
-
## 0.9.0 - API Improvements
|
|
27
|
-
|
|
28
|
-
Add clearer extension points while preserving the existing positional API.
|
|
29
|
-
|
|
30
|
-
* Add keyword options for include directories, library directories, compile
|
|
31
|
-
flags, and link flags.
|
|
32
|
-
* Consider examples such as:
|
|
33
|
-
|
|
34
|
-
```ruby
|
|
35
|
-
have_header('foo.h', include_dirs: ['/usr/local/include'])
|
|
36
|
-
have_library(
|
|
37
|
-
'foo',
|
|
38
|
-
'foo_init',
|
|
39
|
-
headers: ['foo.h'],
|
|
40
|
-
lib_dirs: ['/usr/local/lib']
|
|
41
|
-
)
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
* Add access to the last failed compile command and diagnostics.
|
|
45
|
-
* Consider a small configuration API for global defaults such as compiler,
|
|
46
|
-
include paths, library paths, and extra flags.
|
|
47
|
-
* Keep memoized public probes, but document when memoization applies and how
|
|
48
|
-
callers should think about process lifetime.
|
|
49
|
-
|
|
50
|
-
## 1.0.0 - Stable Contract
|
|
17
|
+
* Avoided global `Dir.chdir` during probe compilation.
|
|
18
|
+
* Captured compiler diagnostics internally.
|
|
19
|
+
* Improved support for include directories with spaces.
|
|
20
|
+
* Added FreeBSD CI coverage.
|
|
51
21
|
|
|
52
|
-
|
|
22
|
+
## 0.9.0 - C Probe Correctness
|
|
53
23
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* Document compiler selection, probe memoization, error handling, and platform
|
|
57
|
-
support.
|
|
58
|
-
* Keep the library focused on lightweight compile/link probes rather than
|
|
59
|
-
becoming a replacement for stdlib `mkmf`.
|
|
24
|
+
Improve the generated C probes first, keeping the Ruby API stable and avoiding
|
|
25
|
+
changes that could surprise existing callers.
|
|
60
26
|
|
|
61
|
-
|
|
27
|
+
### Generated C Types
|
|
62
28
|
|
|
63
|
-
|
|
29
|
+
Improve generated C for sizes, offsets, and stricter compilers.
|
|
64
30
|
|
|
65
|
-
|
|
66
|
-
* Print `offsetof` results with an appropriate unsigned size format.
|
|
67
|
-
* Avoid casting sizes and offsets down to `int`.
|
|
68
|
-
* Review function probes under stricter C modes, where implicit declarations
|
|
69
|
-
and old-style function assumptions may fail.
|
|
70
|
-
* Consider compile-time assertions for probes that only need success or failure.
|
|
31
|
+
Status: Done.
|
|
71
32
|
|
|
72
|
-
|
|
33
|
+
* [x] Print `sizeof` results using `size_t` and `%zu`.
|
|
34
|
+
* [x] Print `offsetof` results using `size_t` and `%zu`.
|
|
35
|
+
* [x] Avoid casting sizes and offsets down to `int`.
|
|
36
|
+
* [x] Review `check_valueof` output formatting for constants wider than `int`.
|
|
37
|
+
* [x] Keep return values as Ruby integers.
|
|
73
38
|
|
|
74
|
-
|
|
75
|
-
foundation.
|
|
39
|
+
### Function Probes
|
|
76
40
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
41
|
+
Review function detection under stricter C modes.
|
|
42
|
+
|
|
43
|
+
* Avoid relying on implicit declarations.
|
|
44
|
+
* Avoid old-style function assumptions where practical.
|
|
45
|
+
* Keep support for checking functions with and without caller-provided headers.
|
|
46
|
+
* Preserve the current boolean behavior of `have_func`.
|
|
47
|
+
|
|
48
|
+
### Compile-Only Probes
|
|
49
|
+
|
|
50
|
+
Prefer compile-time checks where a probe only needs success or failure.
|
|
51
|
+
|
|
52
|
+
Status: Done.
|
|
81
53
|
|
|
82
|
-
|
|
54
|
+
* [x] Consider compile-time assertions for struct member checks.
|
|
55
|
+
* [x] Keep generated source small and readable for diagnostics.
|
|
56
|
+
* [x] Avoid adding platform-specific C unless no portable form exists.
|
|
83
57
|
|
|
84
|
-
|
|
85
|
-
successful local probes.
|
|
58
|
+
### Diagnostics
|
|
86
59
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*
|
|
90
|
-
|
|
60
|
+
Make failed probes easier to understand without printing unexpected output.
|
|
61
|
+
|
|
62
|
+
* Store the last compile command, stdout, stderr, exit status, and generated C
|
|
63
|
+
source for inspection.
|
|
64
|
+
* Add a public diagnostics reader with a small stable shape.
|
|
65
|
+
* Keep normal boolean probes quiet by default.
|
|
66
|
+
* Improve raised errors from `check_valueof`, `check_sizeof`, and
|
|
67
|
+
`check_offsetof` with captured compiler output.
|
|
68
|
+
|
|
69
|
+
### Tests
|
|
70
|
+
|
|
71
|
+
Broaden tests around generated C, failure modes, and platform config.
|
|
72
|
+
|
|
73
|
+
* [x] Add specs for `sizeof` and `offsetof` values that should not be truncated.
|
|
74
|
+
* [x] Add specs for generated compiler/linker arguments.
|
|
75
|
+
* [x] Test library names with and without a leading `lib` prefix.
|
|
76
|
+
* [x] Test parallel probe invocations.
|
|
91
77
|
* Add mocked `RbConfig` coverage for Linux, macOS, FreeBSD, Windows/MSVC, and
|
|
92
78
|
JRuby.
|
|
93
|
-
* Add
|
|
94
|
-
|
|
79
|
+
* Add specs for captured diagnostics from failed probes.
|
|
80
|
+
|
|
81
|
+
### Documentation
|
|
82
|
+
|
|
83
|
+
Document the portability model and diagnostic behavior.
|
|
95
84
|
|
|
96
|
-
|
|
85
|
+
Status: Done.
|
|
97
86
|
|
|
98
|
-
|
|
87
|
+
* [x] Explain that probes compile tiny C programs using Ruby's configured compiler.
|
|
88
|
+
* [x] Clarify how `mkmf-lite` differs from stdlib `mkmf`.
|
|
89
|
+
* [x] Add FFI-oriented examples for common Unix-like use cases.
|
|
90
|
+
* [x] Document memoization behavior and how it interacts with probe inputs.
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
## Later
|
|
93
|
+
|
|
94
|
+
### API Options
|
|
95
|
+
|
|
96
|
+
Keyword arguments may be useful, but they should wait until the lower-level
|
|
97
|
+
probe behavior is settled and the compatibility tradeoffs are clearer.
|
|
98
|
+
|
|
99
|
+
* Add `include_dirs:` as a keyword alternative to positional include directory
|
|
100
|
+
arguments.
|
|
101
|
+
* Add `lib_dirs:` for library search paths.
|
|
102
|
+
* Add `cflags:` for extra compile flags.
|
|
103
|
+
* Add `ldflags:` for extra link flags.
|
|
104
|
+
* Keep existing positional forms compatible.
|
|
105
|
+
* Make option handling consistent across `have_header`, `have_func`,
|
|
106
|
+
`have_library`, `have_struct_member`, `check_valueof`, `check_sizeof`, and
|
|
107
|
+
`check_offsetof`.
|
|
108
|
+
|
|
109
|
+
Example target API:
|
|
110
|
+
|
|
111
|
+
```ruby
|
|
112
|
+
have_header('foo.h', include_dirs: ['/usr/local/include'])
|
|
113
|
+
have_library(
|
|
114
|
+
'foo',
|
|
115
|
+
'foo_init',
|
|
116
|
+
headers: ['foo.h'],
|
|
117
|
+
lib_dirs: ['/usr/local/lib'],
|
|
118
|
+
cflags: ['-D_GNU_SOURCE']
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Configuration
|
|
123
|
+
|
|
124
|
+
Consider a small configuration API if repeated keyword arguments become noisy.
|
|
125
|
+
|
|
126
|
+
* Evaluate `Mkmf::Lite.configure` for global defaults.
|
|
127
|
+
* Support compiler, include directories, library directories, compile flags,
|
|
128
|
+
and link flags as possible defaults.
|
|
129
|
+
* Make configuration interaction with memoized probe results explicit.
|
|
130
|
+
|
|
131
|
+
### 1.0.0 - Stable Contract
|
|
132
|
+
|
|
133
|
+
Finalize the behavior expected by downstream users.
|
|
134
|
+
|
|
135
|
+
* Document the supported public API and compatibility expectations.
|
|
136
|
+
* Document compiler selection, probe memoization, error handling, and platform
|
|
137
|
+
support.
|
|
138
|
+
* Keep the library focused on lightweight compile/link probes rather than
|
|
139
|
+
becoming a replacement for stdlib `mkmf`.
|
|
140
|
+
|
|
141
|
+
### Dependency Reduction
|
|
142
|
+
|
|
143
|
+
Reducing dependencies is useful, but should not distract from the 0.9 API work.
|
|
144
|
+
|
|
145
|
+
* Remove `ptools` if it is only needed for `File.which`.
|
|
146
|
+
* Replace `File.which` with a small internal executable lookup based on
|
|
147
|
+
`ENV['PATH']`.
|
|
148
|
+
* Reevaluate `memoist` after the probe and command execution behavior is stable.
|
data/lib/mkmf/lite.rb
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
#include <stdio.h>
|
|
2
|
+
#include <stdint.h>
|
|
3
|
+
#include <inttypes.h>
|
|
2
4
|
|
|
3
5
|
<%= headers %>
|
|
4
6
|
|
|
5
7
|
int main(){
|
|
6
|
-
|
|
8
|
+
if ((<%= constant %>) < 0) {
|
|
9
|
+
printf("%" PRIdMAX "\n", (intmax_t)(<%= constant %>));
|
|
10
|
+
} else {
|
|
11
|
+
printf("%" PRIuMAX "\n", (uintmax_t)(<%= constant %>));
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
return 0;
|
|
8
15
|
}
|
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.8.
|
|
6
|
+
spec.version = '0.8.1'
|
|
7
7
|
spec.author = 'Daniel J. Berger'
|
|
8
8
|
spec.license = 'Apache-2.0'
|
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
data/spec/mkmf_lite_spec.rb
CHANGED
|
@@ -14,6 +14,24 @@ require 'tmpdir'
|
|
|
14
14
|
RSpec.describe Mkmf::Lite do
|
|
15
15
|
subject { Class.new{ |obj| obj.extend Mkmf::Lite } }
|
|
16
16
|
|
|
17
|
+
def new_probe
|
|
18
|
+
Class.new{ |obj| obj.extend Mkmf::Lite }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def template_source(file)
|
|
22
|
+
File.read(File.expand_path("../lib/mkmf/templates/#{file}", __dir__))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def parallel_probe_result
|
|
26
|
+
probe = new_probe
|
|
27
|
+
|
|
28
|
+
[probe.have_header('stdio.h'), probe.check_sizeof('int'), probe.check_valueof('EOF')]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def compile_command_with_linker_arguments(probe)
|
|
32
|
+
probe.send(:build_compile_command, nil, ['-L/tmp/lib dir', '-lfoo'])
|
|
33
|
+
end
|
|
34
|
+
|
|
17
35
|
let(:st_type) { 'struct stat' }
|
|
18
36
|
let(:st_member) { 'st_uid' }
|
|
19
37
|
let(:st_header) { 'sys/stat.h' }
|
|
@@ -21,7 +39,7 @@ RSpec.describe Mkmf::Lite do
|
|
|
21
39
|
|
|
22
40
|
describe 'constants' do
|
|
23
41
|
example 'version information' do
|
|
24
|
-
expect(described_class::MKMF_LITE_VERSION).to eq('0.8.
|
|
42
|
+
expect(described_class::MKMF_LITE_VERSION).to eq('0.8.1')
|
|
25
43
|
expect(described_class::MKMF_LITE_VERSION).to be_frozen
|
|
26
44
|
end
|
|
27
45
|
end
|
|
@@ -87,6 +105,14 @@ RSpec.describe Mkmf::Lite do
|
|
|
87
105
|
expect(subject.have_struct_member(st_type, st_member)).to be(false)
|
|
88
106
|
end
|
|
89
107
|
|
|
108
|
+
example 'have_struct_member generates a compile-only member check' do
|
|
109
|
+
source = template_source('have_struct_member.erb')
|
|
110
|
+
|
|
111
|
+
expect(source).to include('(void)sizeof(((')
|
|
112
|
+
expect(source).not_to include('(char *)&')
|
|
113
|
+
expect(source).not_to include('- (char *)0')
|
|
114
|
+
end
|
|
115
|
+
|
|
90
116
|
example 'have_struct_member requires at least two arguments' do
|
|
91
117
|
expect{ subject.have_struct_member() }.to raise_error(ArgumentError)
|
|
92
118
|
expect{ subject.have_struct_member('struct passwd') }.to raise_error(ArgumentError)
|
|
@@ -121,6 +147,23 @@ RSpec.describe Mkmf::Lite do
|
|
|
121
147
|
expect(value).to be_a(Integer)
|
|
122
148
|
expect(value).to eq(-1)
|
|
123
149
|
end
|
|
150
|
+
|
|
151
|
+
example 'check_valueof returns a wider than int integer value' do
|
|
152
|
+
char_bit = subject.check_valueof('CHAR_BIT', 'limits.h')
|
|
153
|
+
ullong_size = subject.check_sizeof('unsigned long long', 'limits.h')
|
|
154
|
+
value = subject.check_valueof('ULLONG_MAX', 'limits.h')
|
|
155
|
+
|
|
156
|
+
expect(value).to be_a(Integer)
|
|
157
|
+
expect(value).to eq((1 << (ullong_size * char_bit)) - 1)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
example 'check_valueof generates portable integer formatting' do
|
|
161
|
+
source = template_source('check_valueof.erb')
|
|
162
|
+
|
|
163
|
+
expect(source).to include('#include <stdint.h>', '#include <inttypes.h>')
|
|
164
|
+
expect(source).to include('PRIdMAX', 'PRIuMAX')
|
|
165
|
+
expect(source).not_to include('printf("%d')
|
|
166
|
+
end
|
|
124
167
|
end
|
|
125
168
|
|
|
126
169
|
context 'check_offsetof' do
|
|
@@ -148,6 +191,14 @@ RSpec.describe Mkmf::Lite do
|
|
|
148
191
|
expect(size1).to eq(0)
|
|
149
192
|
expect(size2).to be > size1
|
|
150
193
|
end
|
|
194
|
+
|
|
195
|
+
example 'check_offsetof generates size_t output formatting' do
|
|
196
|
+
source = template_source('check_offsetof.erb')
|
|
197
|
+
|
|
198
|
+
expect(source).to include('printf("%zu\\n", offsetof(')
|
|
199
|
+
expect(source).not_to include('(int)(offsetof')
|
|
200
|
+
expect(source).not_to include('printf("%d')
|
|
201
|
+
end
|
|
151
202
|
end
|
|
152
203
|
|
|
153
204
|
context 'check_sizeof' do
|
|
@@ -174,6 +225,14 @@ RSpec.describe Mkmf::Lite do
|
|
|
174
225
|
expect(size).to be_a(Integer)
|
|
175
226
|
expect(size).to be > 0
|
|
176
227
|
end
|
|
228
|
+
|
|
229
|
+
example 'check_sizeof generates size_t output formatting' do
|
|
230
|
+
source = template_source('check_sizeof.erb')
|
|
231
|
+
|
|
232
|
+
expect(source).to include('printf("%zu\\n", sizeof(')
|
|
233
|
+
expect(source).not_to include('(int)(sizeof')
|
|
234
|
+
expect(source).not_to include('printf("%d')
|
|
235
|
+
end
|
|
177
236
|
end
|
|
178
237
|
|
|
179
238
|
context 'have_library' do
|
|
@@ -187,6 +246,11 @@ RSpec.describe Mkmf::Lite do
|
|
|
187
246
|
expect(subject.have_library('nonexistent_library_xyz')).to be(false)
|
|
188
247
|
end
|
|
189
248
|
|
|
249
|
+
example 'have_library accepts a leading lib prefix' do
|
|
250
|
+
expect(subject.have_library('libm')).to be(true)
|
|
251
|
+
expect(subject.have_library('libm', 'sqrt', 'math.h')).to be(true)
|
|
252
|
+
end
|
|
253
|
+
|
|
190
254
|
example 'have_library with function argument returns expected boolean value' do
|
|
191
255
|
expect(subject.have_library('m', 'sqrt', 'math.h')).to be(true)
|
|
192
256
|
expect(subject.have_library('m', 'nonexistent_function_xyz', 'math.h')).to be(false)
|
|
@@ -229,5 +293,20 @@ RSpec.describe Mkmf::Lite do
|
|
|
229
293
|
expect(command).not_to include('-Lrt', '-Ldl', '-Lcrypt', '-Lm')
|
|
230
294
|
expect(command).not_to include('-lrt', '-ldl', '-lcrypt', '-lm')
|
|
231
295
|
end
|
|
296
|
+
|
|
297
|
+
example 'build_compile_command appends linker arguments' do
|
|
298
|
+
command_with_linker_arguments = compile_command_with_linker_arguments(subject)
|
|
299
|
+
|
|
300
|
+
expect(command_with_linker_arguments).to include('-L/tmp/lib dir', '-lfoo')
|
|
301
|
+
expect(command_with_linker_arguments.index('-lfoo')).to be > command_with_linker_arguments.index('conftest.c')
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
describe 'parallel probe invocations' do
|
|
306
|
+
example 'run independently without temporary file collisions' do
|
|
307
|
+
results = Array.new(6) { Thread.new { parallel_probe_result } }.map(&:value)
|
|
308
|
+
|
|
309
|
+
expect(results).to all(satisfy { |header, size, value| header && size.positive? && value == -1 })
|
|
310
|
+
end
|
|
232
311
|
end
|
|
233
312
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|