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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 221bc258ee206eb8c19c1705bdcaa769326508d901d8f8720d1b60e7e704ca5c
4
- data.tar.gz: 3383b7a19d218372b56c2e8a1938af79dcdd2b4636c4fc555069190ccfcb5cb5
3
+ metadata.gz: b780dd7e2e0e1b2be89941ce19c6cd891de5318b53cb199e6b3cbfead5c174be
4
+ data.tar.gz: 7b8afafe384f433f17b309416b24a467c488696b6b2e98560c4f2e545bfd9c77
5
5
  SHA512:
6
- metadata.gz: 53fd358a2dcdab183376c2d809e4c305b5ff022a81e0aa21a75041019745194adc946e1ed54005ea74a0a17f3b7b476efc7227576ae40bf0b3533b64ebce84b6
7
- data.tar.gz: 291f1e2ac0b2eb7c84501dd5d82d8309569951230f5742f712ab6951bc8bcc7e2c164e96cf944923d93b61d486e9863ccaf9413bfe00cc3b0c4ecdd41c614f12
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
- 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
+ ## 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-2025 Daniel J. Berger
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 making `mkmf-lite` more platform-neutral, safer to use
4
- inside applications, and easier to validate across Unix-like systems. The main
5
- goal is to avoid FreeBSD-specific special cases where a more general portability
6
- improvement would solve the same problem.
7
-
8
- ## 0.8.0 - Portability Foundation
9
-
10
- Keep the public API stable and harden the existing implementation.
11
-
12
- * Replace hard-coded default libraries in `cpp_libraries`.
13
- * Stop assuming Linux-style `rt`, `dl`, `crypt`, and `m` availability.
14
- * Fix the clang branch that currently emits `-Lrt`, `-Ldl`, `-Lcrypt`, and
15
- `-Lm`; these are library search path flags, not library link flags.
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
- * Avoid global `Dir.chdir` during probe compilation when practical.
21
- * Replace shell-built compiler command strings with argv-style execution.
22
- * Capture compiler diagnostics internally without emitting unwanted output.
23
- * Add FreeBSD CI coverage, likely through Cirrus CI or a GitHub Actions
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
- Finalize the behavior expected by downstream users.
22
+ ## 0.9.0 - C Probe Correctness
53
23
 
54
- * Document the supported public API and compatibility expectations.
55
- * Remove unnecessary runtime dependencies where feasible.
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
- ## C Probe Correctness
27
+ ### Generated C Types
62
28
 
63
- These improvements can land in the earliest release where they fit cleanly.
29
+ Improve generated C for sizes, offsets, and stricter compilers.
64
30
 
65
- * Print `sizeof` results using `size_t` and `%zu`.
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
- ## Dependency Reduction
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
- Reducing dependencies is useful, but should not distract from the portability
75
- foundation.
39
+ ### Function Probes
76
40
 
77
- * Remove `ptools` if it is only needed for `File.which`.
78
- * Replace `File.which` with a small internal executable lookup based on
79
- `ENV['PATH']`.
80
- * Reevaluate `memoist` after the probe and command execution behavior is stable.
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
- ## Test Coverage
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
- The test suite should exercise command construction and failure modes, not only
85
- successful local probes.
58
+ ### Diagnostics
86
59
 
87
- * Add specs for generated compiler/linker arguments.
88
- * Test include and library directories containing spaces.
89
- * Test library names with and without a leading `lib` prefix.
90
- * Test parallel probe invocations to catch temporary file collisions.
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 a regression test proving clang does not receive bogus `-Lrt`-style
94
- flags.
79
+ * Add specs for captured diagnostics from failed probes.
80
+
81
+ ### Documentation
82
+
83
+ Document the portability model and diagnostic behavior.
95
84
 
96
- ## Documentation
85
+ Status: Done.
97
86
 
98
- Documentation should make the portability model explicit.
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
- * Explain that probes compile tiny C programs using Ruby's configured compiler.
101
- * Clarify how `mkmf-lite` differs from stdlib `mkmf`.
102
- * Add FFI-oriented examples for common Unix-like use cases.
103
- * Document how to pass include and library paths for ports-installed libraries,
104
- especially `/usr/local/include` and `/usr/local/lib` on FreeBSD.
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
@@ -16,7 +16,7 @@ module Mkmf
16
16
  extend Memoist
17
17
 
18
18
  # The version of the mkmf-lite library
19
- MKMF_LITE_VERSION = '0.8.0'
19
+ MKMF_LITE_VERSION = '0.8.1'
20
20
 
21
21
  private
22
22
 
@@ -3,9 +3,7 @@
3
3
 
4
4
  <%= headers %>
5
5
 
6
- int conftest_const = (int)(offsetof(<%= struct_type %>, <%= field %>));
7
-
8
6
  int main(){
9
- printf("%d\n", conftest_const);
7
+ printf("%zu\n", offsetof(<%= struct_type %>, <%= field %>));
10
8
  return 0;
11
9
  }
@@ -1,10 +1,9 @@
1
1
  #include <stdio.h>
2
+ #include <stddef.h>
2
3
 
3
4
  <%= headers %>
4
5
 
5
- int conftest_const = (int)(sizeof(<%= type %>));
6
-
7
6
  int main(){
8
- printf("%d\n", conftest_const);
7
+ printf("%zu\n", sizeof(<%= type %>));
9
8
  return 0;
10
9
  }
@@ -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
- printf("%d\n", <%= constant %>);
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
  }
@@ -1,6 +1,6 @@
1
1
  <%= headers %>
2
2
 
3
3
  int main(){
4
- int s = (char *)&((<%= struct_type %>*)0)-><%= struct_member %> - (char *)0;
4
+ (void)sizeof(((<%= struct_type %>*)0)-><%= struct_member %>);
5
5
  return 0;
6
6
  }
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.0'
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'
@@ -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.0')
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
@@ -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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
metadata.gz.sig CHANGED
Binary file