mkmf-lite 0.2.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 48b0b919715a041d623a903a9107dd6f0b2d8e40
4
- data.tar.gz: 459a3be9465c9fd254b59e1710d1a3fcfd77a522
2
+ SHA256:
3
+ metadata.gz: 7b31149c447c19e46fb23c75314391a1ce130d13d3682a6c27c908f65b4ebf4c
4
+ data.tar.gz: 46e3d7df97248fe7e57f371b75ba3ecff658e1410d598c501d091f8cd8982117
5
5
  SHA512:
6
- metadata.gz: 3967b9feeb4c2d2497bceb3dd6cc5f086dab9bf55c9e9508f4e861600adeb1fa65e16b983a53e15c805493ee7d49e55b933bcb138c3b94cbc6a484dfd9c0fc0e
7
- data.tar.gz: 6d9d4f3d5672229b71b9a72a79a31d9bc2f1b246f8811f295c9e632777459956596ab0c0cc643606f9201211572f2733f6fc243a6251afb4073c5f9b1e8190f7
6
+ metadata.gz: 3421a088bf652b63d4ba22ab5ba488488527641dd3a2e37173373c6c182ded5bbb2a79f83e98719e0a09d6fb40db1180a4c41639130ef1c28a67159dc0dfa5f7
7
+ data.tar.gz: ceec89082d0e5a2e40347855d3934f425004a38753d0e9920e0ca98af50e39980c892aa0489e10524c48438dba40a5cec4d5fe070a16c245d2aad9528c737fe7
Binary file
Binary file
@@ -1,12 +1,34 @@
1
- = 0.2.5 - 2-Oct-2014
1
+ == 0.4.0 - 4-Jul-2020
2
+ * Replaced test-unit with rspec, rewrote the tests, and made relevant
3
+ changes to the gemspec, etc.
4
+ * Pinned the ptools version to 1.3.x.
5
+
6
+ == 0.3.2 - 19-Mar-2020
7
+ * Properly include a LICENSE file as per the Apache-2.0 license.
8
+
9
+ == 0.3.1 - 11-Dec-2019
10
+ * Added .rdoc extension to various text files so that they render more nicely
11
+ on github.
12
+
13
+ == 0.3.0 - 6-Jan-2019
14
+ * Changed license to Apache-2.0.
15
+ * Replaced class variables with methods.
16
+ * Updated cert.
17
+
18
+ == 0.2.6 - 6-Sep-2015
19
+ * Added an mkmf-lite.rb file for convenience.
20
+ * Assume Rubygems 2.x.
21
+ * This gem is now signed.
22
+
23
+ == 0.2.5 - 2-Oct-2014
2
24
  * The CC command for mingw now defaults to searching your path rather than
3
25
  relying on an environment variable because it wasn't trustworthy.
4
26
  * Updated the gem:install task for Rubygems 2.x.
5
27
 
6
- = 0.2.4 - 7-Mar-2013
28
+ == 0.2.4 - 7-Mar-2013
7
29
  * The have_header method now accepts an optional list of directories to search.
8
30
 
9
- = 0.2.3 - 25-Apr-2012
31
+ == 0.2.3 - 25-Apr-2012
10
32
  * No longer assumes mingw/gcc on Windows. Now passes all tests with a
11
33
  version of Ruby compiled with MSVC++.
12
34
  * Eliminate Config vs RbConfig warnings in 1.9.3.
@@ -14,17 +36,17 @@
14
36
  result in unwanted output.
15
37
  * Upgraded test-unit prerequisite to 2.4.0 or later.
16
38
 
17
- = 0.2.2 - 6-Dec-2011
39
+ == 0.2.2 - 6-Dec-2011
18
40
  * Added the check_sizeof method.
19
41
  * If CONFIG['COMMON_HEADERS'] is blank then stdio.h and stdlib.h are
20
42
  used instead. On MS Windows the windows.h header is also used.
21
43
 
22
- = 0.2.1 - 21-Jan-2011
44
+ == 0.2.1 - 21-Jan-2011
23
45
  * Minor platform detection adjustments for MS Windows.
24
46
 
25
- = 0.2.0 - 8-Jun-2010
47
+ == 0.2.0 - 8-Jun-2010
26
48
  * Now works properly with JRuby (though it still requires a compiler
27
49
  somewhere on your system).
28
50
 
29
- = 0.1.0 - 24-May-2010
51
+ == 0.1.0 - 24-May-2010
30
52
  * Initial release.
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -1,10 +1,12 @@
1
- * CHANGES
2
- * MANIFEST
3
- * Rakefile
4
- * mkmf-lite.gemspec
5
- * lib/mkmf/lite.rb
6
- * lib/mkmf/templates/have_func.erb
7
- * lib/mkmf/templates/have_func_pointer.erb
8
- * lib/mkmf/templates/have_header.erb
9
- * lib/mkmf/templates/have_struct_member.erb
10
- * test/test_mkmf_lite.rb
1
+ * CHANGES.rdoc
2
+ * LICENSE
3
+ * MANIFEST.rdoc
4
+ * Rakefile
5
+ * mkmf-lite.gemspec
6
+ * certs/djberg96_pub.pem
7
+ * lib/mkmf/lite.rb
8
+ * lib/mkmf/templates/have_func.erb
9
+ * lib/mkmf/templates/have_func_pointer.erb
10
+ * lib/mkmf/templates/have_header.erb
11
+ * lib/mkmf/templates/have_struct_member.erb
12
+ * spec/mkmf_lite_spec.rb
@@ -0,0 +1,59 @@
1
+ == Summary
2
+ A light version of mkmf designed for use within programs.
3
+
4
+ == Installation
5
+ gem install mkmf-lite
6
+
7
+ == Prerequisites
8
+ A C compiler somewhere on your system.
9
+
10
+ == Synopsis
11
+ require 'mkmf/lite'
12
+
13
+ class System
14
+ extend Mkmf::Lite
15
+
16
+ HAVE_PW_NAME = have_struct_member('struct passwd', 'pw_name', 'pwd.h')
17
+
18
+ def some_method
19
+ if HAVE_PW_NAME
20
+ # Do something
21
+ end
22
+ end
23
+ end
24
+
25
+ == Description
26
+ The mkmf library that ships as part of the Ruby standard library is not
27
+ meant for use as an internal library. It's strictly designed for building
28
+ C extensions. It's huge, its methods sit in a global namespace, it contains
29
+ many methods you don't care about, and it emits stuff to $stdout that cannot
30
+ easily be disabled. Also, the source code is monstrous.
31
+
32
+ The mkmf-lite library is a module, it's small, and it's designed to be mixed
33
+ into classes. It contains a handful of methods that, most likely, will be
34
+ used in conjunction with FFI. Also, the source code is quite readable.
35
+
36
+ It does not package C extensions, nor generate a log file or a Makefile. It
37
+ does, however, require that you have a C compiler somewhere on your system.
38
+
39
+ == Known Issues
40
+ You may see this warning from JRuby 1.4.x and earlier:
41
+
42
+ warning: Useless use of a variable in void context.
43
+
44
+ You can ignore these (or, upgrade your Jruby).
45
+
46
+ == License
47
+ Apache-2.0
48
+
49
+ == Copyright
50
+ (C) 2010-2020 Daniel J. Berger
51
+ All Rights Reserved
52
+
53
+ == Warranty
54
+ This library is provided "as is" and without any express or
55
+ implied warranties, including, without limitation, the implied
56
+ warranties of merchantability and fitness for a particular purpose.
57
+
58
+ == Author
59
+ Daniel Berger
data/Rakefile CHANGED
@@ -1,31 +1,26 @@
1
- require 'rake'
2
- require 'rake/clean'
3
- require 'rake/testtask'
4
-
5
- CLEAN.include("**/*.gem", "**/*.rbc")
6
-
7
- namespace 'gem' do
8
- desc 'Create the mkmf-lite gem.'
9
- task :create => [:clean] do
10
- spec = eval(IO.read('mkmf-lite.gemspec'))
11
- if Gem::VERSION.to_f < 2.0
12
- Gem::Builder.new(spec).build
13
- else
14
- require 'rubygems/package'
15
- Gem::Package.build(spec)
16
- end
17
- end
18
-
19
- desc 'Install the mkmf-lite gem.'
20
- task :install => [:create] do
21
- file = Dir["*.gem"].first
22
- sh "gem install -l #{file}"
23
- end
24
- end
25
-
26
- Rake::TestTask.new do |t|
27
- t.verbose = true
28
- t.warning = true
29
- end
30
-
31
- task :default => :test
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rspec/core/rake_task'
4
+
5
+ CLEAN.include("**/*.gem", "**/*.rbc")
6
+
7
+ namespace 'gem' do
8
+ desc 'Create the mkmf-lite gem.'
9
+ task :create => [:clean] do
10
+ require 'rubygems/package'
11
+ spec = eval(IO.read('mkmf-lite.gemspec'))
12
+ spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
+ Gem::Package.build(spec)
14
+ end
15
+
16
+ desc 'Install the mkmf-lite gem.'
17
+ task :install => [:create] do
18
+ file = Dir["*.gem"].first
19
+ sh "gem install -l #{file}"
20
+ end
21
+ end
22
+
23
+ desc "Run the test suite"
24
+ RSpec::Core::RakeTask.new(:spec)
25
+
26
+ task :default => :spec
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
5
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
7
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
8
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
9
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
10
+ 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
11
+ iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
12
+ ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
13
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
14
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
15
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
16
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
17
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
18
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
19
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
20
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
21
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
22
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
23
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
24
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
26
+ -----END CERTIFICATE-----
@@ -0,0 +1 @@
1
+ require_relative 'mkmf/lite'
@@ -2,52 +2,45 @@ require 'erb'
2
2
  require 'rbconfig'
3
3
  require 'tmpdir'
4
4
  require 'ptools'
5
-
6
- if File::ALT_SEPARATOR && RUBY_VERSION.to_f < 1.9
7
- require 'win32/open3'
8
- else
9
- require 'open3'
10
- end
5
+ require 'open3'
11
6
 
12
7
  module Mkmf
13
8
  module Lite
14
9
  # The version of the mkmf-lite library
15
- MKMF_LITE_VERSION = '0.2.5'
10
+ MKMF_LITE_VERSION = '0.4.0'.freeze
16
11
 
17
- @@cpp_command = RbConfig::CONFIG['CC'] || RbConfig::CONFIG['CPP']
18
- @@cpp_srcfile = 'conftest.c'
12
+ private
19
13
 
20
- if File::ALT_SEPARATOR && RbConfig::CONFIG['CPP'] =~ /^cl/
21
- @@cpp_outfile = '/Feconftest.exe'
22
- else
23
- @@cpp_outfile = '-o conftest.exe'
14
+ def cpp_command
15
+ command = RbConfig::CONFIG['CC'] || RbConfig::CONFIG['CPP'] || File.which('cc') || File.which('gcc') || File.which('cl')
16
+ raise "Compiler not found" unless command
17
+ command
24
18
  end
25
19
 
26
- if RbConfig::CONFIG['LIBS']
27
- @@cpp_libraries = RbConfig::CONFIG['LIBS'] + RbConfig::CONFIG['LIBRUBYARG']
28
- else
29
- # TODO: We should adjust this based on OS. For now we're using
30
- # arguments I think you'll typically see set on Linux and BSD.
31
- @@cpp_libraries = "-lrt -ldl -lcrypt -lm"
20
+ def cpp_source_file
21
+ 'conftest.c'
32
22
  end
33
23
 
34
- # JRuby, and possibly others
35
- unless @@cpp_command
36
- case RbConfig::CONFIG['host_os']
37
- when /msdos|mswin|win32|windows|mingw|cygwin/i
38
- @@cpp_command = File.which('cl') || File.which('gcc')
39
- when /sunos|solaris|hpux/i
40
- @@cpp_command = File.which('cc') || File.which('gcc')
41
- else
42
- @@cpp_command = 'gcc'
24
+ def cpp_out_file
25
+ if File::ALT_SEPARATOR && RbConfig::CONFIG['CPP'] =~ /^cl/
26
+ '/Feconftest.exe'
27
+ else
28
+ '-o conftest.exe'
43
29
  end
44
30
  end
45
31
 
46
- # Ruby installer can't be trusted to set a sane value
47
- if RbConfig::CONFIG['host_os'] =~ /mingw/i
48
- @@cpp_command = File.which('gcc')
32
+ # TODO: We should adjust this based on OS. For now we're using
33
+ # arguments I think you'll typically see set on Linux and BSD.
34
+ def cpp_libraries
35
+ if RbConfig::CONFIG['LIBS']
36
+ RbConfig::CONFIG['LIBS'] + RbConfig::CONFIG['LIBRUBYARG']
37
+ else
38
+ '-lrt -ldl -lcrypt -lm'
39
+ end
49
40
  end
50
41
 
42
+ public
43
+
51
44
  # Check for the presence of the given +header+ file. You may optionally
52
45
  # provide a list of directories to search.
53
46
  #
@@ -171,11 +164,11 @@ module Mkmf
171
164
  stdout_orig = $stdout.dup
172
165
 
173
166
  Dir.chdir(Dir.tmpdir){
174
- File.open(@@cpp_srcfile, 'w'){ |fh| fh.write(code) }
167
+ File.open(cpp_source_file, 'w'){ |fh| fh.write(code) }
175
168
 
176
- command = @@cpp_command + ' '
177
- command += @@cpp_outfile + ' '
178
- command += @@cpp_srcfile
169
+ command = cpp_command + ' '
170
+ command += cpp_out_file + ' '
171
+ command += cpp_source_file
179
172
 
180
173
  # Temporarily close these
181
174
  $stderr.reopen(File.null)
@@ -196,8 +189,8 @@ module Mkmf
196
189
  end
197
190
  }
198
191
  ensure
199
- File.delete(@@cpp_srcfile) if File.exists?(@@cpp_srcfile)
200
- File.delete(@@cpp_outfile) if File.exists?(@@cpp_outfile)
192
+ File.delete(cpp_source_file) if File.exists?(cpp_source_file)
193
+ File.delete(cpp_out_file) if File.exists?(cpp_out_file)
201
194
  $stderr.reopen(stderr_orig)
202
195
  $stdout.reopen(stdout_orig)
203
196
  end
@@ -219,24 +212,24 @@ module Mkmf
219
212
  stdout_orig = $stdout.dup
220
213
 
221
214
  Dir.chdir(Dir.tmpdir){
222
- File.open(@@cpp_srcfile, 'w'){ |fh| fh.write(code) }
215
+ File.open(cpp_source_file, 'w'){ |fh| fh.write(code) }
223
216
 
224
217
  if command_options
225
- command = @@cpp_command + ' ' + command_options + ' '
218
+ command = cpp_command + ' ' + command_options + ' '
226
219
  else
227
- command = @@cpp_command + ' '
220
+ command = cpp_command + ' '
228
221
  end
229
222
 
230
- command += @@cpp_outfile + ' '
231
- command += @@cpp_srcfile
223
+ command += cpp_out_file + ' '
224
+ command += cpp_source_file
232
225
 
233
226
  $stderr.reopen(File.null)
234
227
  $stdout.reopen(File.null)
235
228
  boolean = system(command)
236
229
  }
237
230
  ensure
238
- File.delete(@@cpp_srcfile) if File.exists?(@@cpp_srcfile)
239
- File.delete(@@cpp_outfile) if File.exists?(@@cpp_outfile)
231
+ File.delete(cpp_source_file) if File.exists?(cpp_source_file)
232
+ File.delete(cpp_out_file) if File.exists?(cpp_out_file)
240
233
  $stdout.reopen(stdout_orig)
241
234
  $stderr.reopen(stderr_orig)
242
235
  end
@@ -1,10 +1,10 @@
1
- #include <stdio.h>
2
-
3
- <%= headers %>
4
-
5
- int conftest_const = (int)(sizeof(<%= type %>));
6
-
7
- int main(){
8
- printf("%d\n", conftest_const);
9
- return 0;
10
- }
1
+ #include <stdio.h>
2
+
3
+ <%= headers %>
4
+
5
+ int conftest_const = (int)(sizeof(<%= type %>));
6
+
7
+ int main(){
8
+ printf("%d\n", conftest_const);
9
+ return 0;
10
+ }
@@ -1,10 +1,10 @@
1
- <%= headers %>
2
-
3
- int try_func(){
4
- <%= function %>();
5
- return 0;
6
- }
7
-
8
- int main(){
9
- return 0;
10
- }
1
+ <%= headers %>
2
+
3
+ int try_func(){
4
+ <%= function %>();
5
+ return 0;
6
+ }
7
+
8
+ int main(){
9
+ return 0;
10
+ }
@@ -1,11 +1,11 @@
1
- <%= headers %>
2
-
3
- int check_for_function(){
4
- void ((*volatile p)());
5
- p = (void ((*)()))<%= function %>;
6
- return 0;
7
- }
8
-
9
- int main(){
10
- return 0;
11
- }
1
+ <%= headers %>
2
+
3
+ int check_for_function(){
4
+ void ((*volatile p)());
5
+ p = (void ((*)()))<%= function %>;
6
+ return 0;
7
+ }
8
+
9
+ int main(){
10
+ return 0;
11
+ }
@@ -1,5 +1,5 @@
1
- #include <<%= header %>>
2
-
3
- int main(){
4
- return 0;
5
- }
1
+ #include <<%= header %>>
2
+
3
+ int main(){
4
+ return 0;
5
+ }
@@ -1,6 +1,6 @@
1
- <%= headers %>
2
-
3
- int main(){
4
- int s = (char *)&((<%= struct_type %>*)0)-><%= struct_member %> - (char *)0;
5
- return 0;
6
- }
1
+ <%= headers %>
2
+
3
+ int main(){
4
+ int s = (char *)&((<%= struct_type %>*)0)-><%= struct_member %> - (char *)0;
5
+ return 0;
6
+ }
@@ -1,21 +1,30 @@
1
1
  require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = 'mkmf-lite'
5
- spec.summary = 'A lighter version of mkmf designed for use as a library'
6
- spec.version = '0.2.5'
7
- spec.author = 'Daniel J. Berger'
8
- spec.license = 'Artistic 2.0'
9
- spec.email = 'djberg96@gmail.com'
10
- spec.homepage = 'http://github.com/djberg96/mkmf-lite'
11
- spec.test_file = 'test/test_mkmf_lite.rb'
12
- spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
4
+ spec.name = 'mkmf-lite'
5
+ spec.summary = 'A lighter version of mkmf designed for use as a library'
6
+ spec.version = '0.4.0'
7
+ spec.author = 'Daniel J. Berger'
8
+ spec.license = 'Apache-2.0'
9
+ spec.email = 'djberg96@gmail.com'
10
+ spec.homepage = 'http://github.com/djberg96/mkmf-lite'
11
+ spec.test_file = 'spec/mkmf_lite_spec.rb'
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
+ spec.cert_chain = ['certs/djberg96_pub.pem']
13
14
 
14
- spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
15
- spec.rubyforge_project = 'shards'
15
+ spec.extra_rdoc_files = Dir['*.rdoc']
16
16
 
17
- spec.add_dependency('ptools')
18
- spec.add_development_dependency('test-unit', '>= 2.4.0')
17
+ spec.add_dependency('ptools', '~> 1.3')
18
+ spec.add_development_dependency('rspec', '~> 3.9')
19
+
20
+ spec.metadata = {
21
+ 'homepage_uri' => 'https://github.com/djberg96/mkmf-lite',
22
+ 'bug_tracker_uri' => 'https://github.com/djberg96/mkmf-lite/issues',
23
+ 'changelog_uri' => 'https://github.com/djberg96/mkmf-lite/blob/master/CHANGES.rdoc',
24
+ 'documentation_uri' => 'https://github.com/djberg96/mkmf-lite/wiki',
25
+ 'source_code_uri' => 'https://github.com/djberg96/mkmf-lite',
26
+ 'wiki_uri' => 'https://github.com/djberg96/mkmf-lite/wiki'
27
+ }
19
28
 
20
29
  spec.description = <<-EOF
21
30
  The mkmf-lite library is a light version of the the mkmf library
@@ -0,0 +1,111 @@
1
+ ########################################################################
2
+ # mkmf_lite_spec.rb
3
+ #
4
+ # Tests for the mkmf-lite library.
5
+ ########################################################################
6
+ require 'rubygems'
7
+ require 'rspec'
8
+ require 'mkmf/lite'
9
+
10
+ describe Mkmf::Lite do
11
+ subject { Class.new{ |obj| obj.extend Mkmf::Lite } }
12
+
13
+ let(:st_type) { 'struct stat' }
14
+ let(:st_member) { 'st_uid' }
15
+ let(:st_header) { 'sys/stat.h' }
16
+
17
+ describe "constants" do
18
+ example "version information" do
19
+ expect(described_class::MKMF_LITE_VERSION).to eq('0.4.0')
20
+ expect(described_class::MKMF_LITE_VERSION).to be_frozen
21
+ end
22
+ end
23
+
24
+ describe "have_header" do
25
+ example "have_header basic functionality" do
26
+ expect(subject).to respond_to(:have_header)
27
+ end
28
+
29
+ example "have_header returns expected boolean value" do
30
+ expect(subject.have_header('stdio.h')).to eq(true)
31
+ expect(subject.have_header('foobar.h')).to eq(false)
32
+ end
33
+
34
+ example "have_header accepts an array of directories as a second argument" do
35
+ expect{ subject.have_header('stdio.h', '/usr/local/include') }.not_to raise_error
36
+ expect{ subject.have_header('stdio.h', '/usr/local/include', '/usr/include') }.not_to raise_error
37
+ end
38
+ end
39
+
40
+ context "have_func" do
41
+ example "have_func basic functionality" do
42
+ expect(subject).to respond_to(:have_func)
43
+ end
44
+
45
+ example "have_func with no arguments returns expected boolean value" do
46
+ expect(subject.have_func('abort')).to eq(true)
47
+ expect(subject.have_func('abortxyz')).to eq(false)
48
+ end
49
+
50
+ example "have_func with arguments returns expected boolean value" do
51
+ expect(subject.have_func('printf', 'stdio.h')).to eq(true)
52
+ expect(subject.have_func('printfx', 'stdio.h')).to eq(false)
53
+ end
54
+
55
+ example "have_func requires at least one argument" do
56
+ expect{ subject.have_func }.to raise_error(ArgumentError)
57
+ end
58
+
59
+ example "have_func accepts a maximum of two arguments" do
60
+ expect{ subject.have_func('printf', 'stdio.h', 'bogus') }.to raise_error(ArgumentError)
61
+ end
62
+ end
63
+
64
+ context "have_struct_member" do
65
+ example "have_struct_member basic functionality" do
66
+ expect(subject).to respond_to(:have_struct_member)
67
+ end
68
+
69
+ example "have_struct_member returns expected boolean value" do
70
+ expect(subject.have_struct_member(st_type, st_member, st_header)).to eq(true)
71
+ expect(subject.have_struct_member(st_type, 'pw_bogus', st_header)).to eq(false)
72
+ expect(subject.have_struct_member(st_type, st_member)).to eq(false)
73
+ end
74
+
75
+ example "have_struct_member requires at least two arguments" do
76
+ expect{ subject.have_struct_member() }.to raise_error(ArgumentError)
77
+ expect{ subject.have_struct_member('struct passwd') }.to raise_error(ArgumentError)
78
+ end
79
+
80
+ example "have_struct_member accepts a maximum of three arguments" do
81
+ expect{ subject.have_struct_member('struct passwd', 'pw_name', 'pwd.h', true) }.to raise_error(ArgumentError)
82
+ end
83
+ end
84
+
85
+ context "check_sizeof" do
86
+ example "check_sizeof basic functionality" do
87
+ expect(subject).to respond_to(:check_sizeof)
88
+ expect{ subject.check_sizeof(st_type, st_header) }.not_to raise_error
89
+ end
90
+
91
+ example "check_sizeof requires at least one argument" do
92
+ expect{ subject.check_sizeof }.to raise_error(ArgumentError)
93
+ expect{ subject.check_sizeof('struct passwd', 'pw_name', 1) }.to raise_error(ArgumentError)
94
+ end
95
+
96
+ example "check_sizeof accepts a maximum of two arguments" do
97
+ expect{ subject.check_sizeof('div_t', 'stdlib.h', 1) }.to raise_error(ArgumentError)
98
+ end
99
+
100
+ example "check_sizeof works with one or two arguments" do
101
+ expect{ subject.check_sizeof('div_t') }.not_to raise_error
102
+ expect{ subject.check_sizeof('div_t', 'stdlib.h') }.not_to raise_error
103
+ end
104
+
105
+ example "check_sizeof returns an integer value" do
106
+ size = subject.check_sizeof(st_type, st_header)
107
+ expect(size).to be_kind_of(Integer)
108
+ expect(size).to be > 0
109
+ end
110
+ end
111
+ end
metadata CHANGED
@@ -1,43 +1,70 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkmf-lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2014-10-02 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
14
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
16
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
18
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
19
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
20
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
21
+ 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
22
+ iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
23
+ ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
24
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
25
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
26
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
27
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
28
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
29
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
30
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
31
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
32
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
33
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
34
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
35
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
+ -----END CERTIFICATE-----
38
+ date: 2020-07-05 00:00:00.000000000 Z
12
39
  dependencies:
13
40
  - !ruby/object:Gem::Dependency
14
41
  name: ptools
15
42
  requirement: !ruby/object:Gem::Requirement
16
43
  requirements:
17
- - - '>='
44
+ - - "~>"
18
45
  - !ruby/object:Gem::Version
19
- version: '0'
46
+ version: '1.3'
20
47
  type: :runtime
21
48
  prerelease: false
22
49
  version_requirements: !ruby/object:Gem::Requirement
23
50
  requirements:
24
- - - '>='
51
+ - - "~>"
25
52
  - !ruby/object:Gem::Version
26
- version: '0'
53
+ version: '1.3'
27
54
  - !ruby/object:Gem::Dependency
28
- name: test-unit
55
+ name: rspec
29
56
  requirement: !ruby/object:Gem::Requirement
30
57
  requirements:
31
- - - '>='
58
+ - - "~>"
32
59
  - !ruby/object:Gem::Version
33
- version: 2.4.0
60
+ version: '3.9'
34
61
  type: :development
35
62
  prerelease: false
36
63
  version_requirements: !ruby/object:Gem::Requirement
37
64
  requirements:
38
- - - '>='
65
+ - - "~>"
39
66
  - !ruby/object:Gem::Version
40
- version: 2.4.0
67
+ version: '3.9'
41
68
  description: |2
42
69
  The mkmf-lite library is a light version of the the mkmf library
43
70
  designed for use as a library. It does not create packages, builds,
@@ -48,14 +75,17 @@ email: djberg96@gmail.com
48
75
  executables: []
49
76
  extensions: []
50
77
  extra_rdoc_files:
51
- - CHANGES
52
- - README
53
- - MANIFEST
78
+ - README.rdoc
79
+ - CHANGES.rdoc
80
+ - MANIFEST.rdoc
54
81
  files:
55
- - CHANGES
56
- - MANIFEST
57
- - README
82
+ - CHANGES.rdoc
83
+ - LICENSE
84
+ - MANIFEST.rdoc
85
+ - README.rdoc
58
86
  - Rakefile
87
+ - certs/djberg96_pub.pem
88
+ - lib/mkmf-lite.rb
59
89
  - lib/mkmf/lite.rb
60
90
  - lib/mkmf/templates/check_sizeof.erb
61
91
  - lib/mkmf/templates/have_func.erb
@@ -63,30 +93,35 @@ files:
63
93
  - lib/mkmf/templates/have_header.erb
64
94
  - lib/mkmf/templates/have_struct_member.erb
65
95
  - mkmf-lite.gemspec
66
- - test/test_mkmf_lite.rb
96
+ - spec/mkmf_lite_spec.rb
67
97
  homepage: http://github.com/djberg96/mkmf-lite
68
98
  licenses:
69
- - Artistic 2.0
70
- metadata: {}
99
+ - Apache-2.0
100
+ metadata:
101
+ homepage_uri: https://github.com/djberg96/mkmf-lite
102
+ bug_tracker_uri: https://github.com/djberg96/mkmf-lite/issues
103
+ changelog_uri: https://github.com/djberg96/mkmf-lite/blob/master/CHANGES.rdoc
104
+ documentation_uri: https://github.com/djberg96/mkmf-lite/wiki
105
+ source_code_uri: https://github.com/djberg96/mkmf-lite
106
+ wiki_uri: https://github.com/djberg96/mkmf-lite/wiki
71
107
  post_install_message:
72
108
  rdoc_options: []
73
109
  require_paths:
74
110
  - lib
75
111
  required_ruby_version: !ruby/object:Gem::Requirement
76
112
  requirements:
77
- - - '>='
113
+ - - ">="
78
114
  - !ruby/object:Gem::Version
79
115
  version: '0'
80
116
  required_rubygems_version: !ruby/object:Gem::Requirement
81
117
  requirements:
82
- - - '>='
118
+ - - ">="
83
119
  - !ruby/object:Gem::Version
84
120
  version: '0'
85
121
  requirements: []
86
- rubyforge_project: shards
87
- rubygems_version: 2.2.2
122
+ rubygems_version: 3.0.6
88
123
  signing_key:
89
124
  specification_version: 4
90
125
  summary: A lighter version of mkmf designed for use as a library
91
126
  test_files:
92
- - test/test_mkmf_lite.rb
127
+ - spec/mkmf_lite_spec.rb
Binary file
data/README DELETED
@@ -1,59 +0,0 @@
1
- == Summary
2
- A light version of mkmf designed for use within programs.
3
-
4
- == Installation
5
- gem install mkmf-lite
6
-
7
- == Prerequisites
8
- A C compiler somewhere on your system.
9
-
10
- == Synopsis
11
- require 'mkmf/lite'
12
-
13
- class System
14
- extend Mkmf::Lite
15
-
16
- HAVE_PW_NAME = have_struct_member('struct passwd', 'pw_name', 'pwd.h')
17
-
18
- def some_method
19
- if HAVE_PW_NAME
20
- # Do something
21
- end
22
- end
23
- end
24
-
25
- == Description
26
- The mkmf library that ships as part of the Ruby standard library is not
27
- meant for use as an internal library. It's strictly designed for building
28
- C extensions. It's huge, its methods sit in a global namespace, it contains
29
- many methods you don't care about, and it emits stuff to $stdout that cannot
30
- easily be disabled. Also, the source code is monstrous.
31
-
32
- The mkmf-lite library is a module, it's small, and it's designed to be mixed
33
- into classes. It contains a handful of methods that, most likely, will be
34
- used in conjunction with FFI. Also, the source code is quite readable.
35
-
36
- It does not package C extensions, nor generate a log file or a Makefile. It
37
- does, however, require that you have a C compiler somewhere on your system.
38
-
39
- == Known Issues
40
- You may see this warning from JRuby 1.4.x and earlier:
41
-
42
- warning: Useless use of a variable in void context.
43
-
44
- You can ignore these (or, upgrade your Jruby).
45
-
46
- == License
47
- Artistic 2.0
48
-
49
- == Copyright
50
- (C) 2010-2014 Daniel J. Berger
51
- All Rights Reserved
52
-
53
- == Warranty
54
- This library is provided "as is" and without any express or
55
- implied warranties, including, without limitation, the implied
56
- warranties of merchantability and fitness for a particular purpose.
57
-
58
- == Author
59
- Daniel Berger
@@ -1,118 +0,0 @@
1
- ########################################################################
2
- # test_mkmf_lite.rb
3
- #
4
- # Tests for the mkmf-lite library.
5
- ########################################################################
6
- require 'rubygems'
7
- require 'test-unit'
8
- require 'mkmf/lite'
9
-
10
- class TC_Mkmf_Lite < Test::Unit::TestCase
11
- include Mkmf::Lite
12
-
13
- def self.startup
14
- @@windows = File::ALT_SEPARATOR
15
- end
16
-
17
- def setup
18
- @st_type = 'struct stat'
19
- @st_member = 'st_uid'
20
- @st_header = 'sys/stat.h'
21
- end
22
-
23
- test "version information" do
24
- assert_equal('0.2.5', MKMF_LITE_VERSION)
25
- end
26
-
27
- test "have_header basic functionality" do
28
- assert_respond_to(self, :have_header)
29
- end
30
-
31
- test "have_header returns expected boolean value" do
32
- assert_true(have_header('stdio.h'))
33
- assert_false(have_header('foobar.h'))
34
- end
35
-
36
- test "have_header accepts an array of directories as a second argument" do
37
- assert_nothing_raised{ have_header('stdio.h', '/usr/local/include') }
38
- assert_nothing_raised{ have_header('stdio.h', '/usr/local/include', '/usr/include') }
39
- end
40
-
41
- test "have_func basic functionality" do
42
- assert_respond_to(self, :have_func)
43
- end
44
-
45
- test "have_func with no arguments returns expected boolean value" do
46
- assert_true(have_func('abort'))
47
- assert_false(have_func('abortxyz'))
48
- end
49
-
50
- test "have_func with arguments returns expected boolean value" do
51
- assert_true(have_func('printf', 'stdio.h'))
52
- assert_false(have_func('printfx', 'stdio.h'))
53
- end
54
-
55
- test "have_func requires at least one argument" do
56
- assert_raise(ArgumentError){ have_func }
57
- end
58
-
59
- test "have_func accepts a maximum of two arguments" do
60
- assert_raise(ArgumentError){ have_func('printf', 'stdio.h', 'bogus') }
61
- end
62
-
63
- test "have_struct_member basic functionality" do
64
- assert_respond_to(self, :have_struct_member)
65
- end
66
-
67
- test "have_struct_member returns expected boolean value" do
68
- assert_true(have_struct_member(@st_type, @st_member, @st_header))
69
- assert_false(have_struct_member(@st_type, 'pw_bogus', @st_header))
70
- assert_false(have_struct_member(@st_type, @st_member))
71
- end
72
-
73
- test "have_struct_member requires at least two arguments" do
74
- assert_raise(ArgumentError){ have_struct_member() }
75
- assert_raise(ArgumentError){ have_struct_member('struct passwd') }
76
- end
77
-
78
- test "have_struct_member accepts a maximum of three arguments" do
79
- assert_raise(ArgumentError){
80
- have_struct_member('struct passwd', 'pw_name', 'pwd.h', true)
81
- }
82
- end
83
-
84
- test "check_sizeof basic functionality" do
85
- assert_respond_to(self, :check_sizeof)
86
- assert_nothing_raised{ check_sizeof(@st_type, @st_header) }
87
- end
88
-
89
- test "check_sizeof requires at least one argument" do
90
- assert_raise(ArgumentError){ check_sizeof }
91
- assert_raise(ArgumentError){ check_sizeof('struct passwd', 'pw_name', 1) }
92
- end
93
-
94
- test "check_sizeof accepts a maximum of two arguments" do
95
- assert_raise(ArgumentError){ check_sizeof('div_t', 'stdlib.h', 1) }
96
- end
97
-
98
- test "check_sizeof works with one or two arguments" do
99
- assert_nothing_raised{ check_sizeof('div_t') }
100
- assert_nothing_raised{ check_sizeof('div_t', 'stdlib.h') }
101
- end
102
-
103
- test "check_sizeof returns an integer value" do
104
- size = check_sizeof(@st_type, @st_header)
105
- assert_kind_of(Integer, size)
106
- assert_true(size > 0)
107
- end
108
-
109
- def teardown
110
- @st_type = nil
111
- @st_member = nil
112
- @st_header = nil
113
- end
114
-
115
- def self.shutdown
116
- @@windows = nil
117
- end
118
- end