mkmf-lite 0.4.2 → 0.5.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
2
  SHA256:
3
- metadata.gz: fb7fbb52c76d52fa9c2bced3b3c0927b2ba925286dd782816be821d8ee7bfaff
4
- data.tar.gz: 599dfa3155156bffc37448faf50dd75cf9c8f9712d776572227262796664b0d0
3
+ metadata.gz: 88d355dec9e35c8aeb5f4a8b4d4dd7a9fbcb5cd9b1e0c8bb834c145614da101a
4
+ data.tar.gz: c17345e5ad9278f73c30cd7ed8b9f71541eae5bd86626de21136dade61948e50
5
5
  SHA512:
6
- metadata.gz: 4b62df8f8e130e286f9bade23825c67a6fc3989e543080785afba148919fe6dc0bd7fdef36421922ecb81a43c80c5fcb2b924aae13eba4b663d063538c5c4b38
7
- data.tar.gz: 8188ae2ad183dc8113fbc4d3a86c72bc62eeb1efa587472a9bfd2f41f8d0edfcdb26576c909cdf58ba2f616bfd81db6fa96731c4353f8eef08ca7450416b2ae4
6
+ metadata.gz: 66a36e2889bc69802560be194ee77d5f4bde94302efa7f3db16ee60b335ddc7aa6a401ecc9b3486de803f1247b53868baea5b018192ab06211d1f232858d332d
7
+ data.tar.gz: 0e11e957998ef6870ce0dcfb2ac3440822311cb05912630f3559a1cbe70844fca48e89594d492f694fffc82def4b74e8afe645cfa6b131181da3996d955773bf
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,6 @@
1
+ == 0.5.0 - 6-Dec-2020
2
+ * Added the check_valueof method.
3
+
1
4
  == 0.4.2 - 31-Aug-2020
2
5
  * Did I say I didn't need ptools? Well I was wrong. It's back.
3
6
 
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org' do
2
+ gem 'rake'
3
+ gem 'ptools', '~> 1.4'
4
+ group 'test' do
5
+ gem 'rspec', '~> 3.9'
6
+ end
7
+ end
@@ -5,6 +5,8 @@
5
5
  * mkmf-lite.gemspec
6
6
  * certs/djberg96_pub.pem
7
7
  * lib/mkmf/lite.rb
8
+ * lib/mkmf/templates/check_sizeof.erb
9
+ * lib/mkmf/templates/check_valueof.erb
8
10
  * lib/mkmf/templates/have_func.erb
9
11
  * lib/mkmf/templates/have_func_pointer.erb
10
12
  * lib/mkmf/templates/have_header.erb
@@ -7,7 +7,7 @@ require 'ptools'
7
7
  module Mkmf
8
8
  module Lite
9
9
  # The version of the mkmf-lite library
10
- MKMF_LITE_VERSION = '0.4.2'.freeze
10
+ MKMF_LITE_VERSION = '0.5.0'.freeze
11
11
 
12
12
  private
13
13
 
@@ -95,6 +95,20 @@ module Mkmf
95
95
  try_to_compile(code)
96
96
  end
97
97
 
98
+ # Returns the value of the given +constant+ (which could also be a macro)
99
+ # using +headers+, or common headers if no headers are specified.
100
+ #
101
+ # If this method fails an error is raised. This could happen if the constant
102
+ # can't be found and/or the header files do not include the indicated constant.
103
+ #
104
+ def check_valueof(constant, headers = [])
105
+ headers = get_header_string(headers)
106
+ erb = ERB.new(read_template('check_valueof.erb'))
107
+ code = erb.result(binding)
108
+
109
+ try_to_execute(code)
110
+ end
111
+
98
112
  # Returns the sizeof +type+ using +headers+, or common headers if no
99
113
  # headers are specified.
100
114
  #
@@ -0,0 +1,8 @@
1
+ #include <stdio.h>
2
+
3
+ <%= headers %>
4
+
5
+ int main(){
6
+ printf("%d\n", <%= constant %>);
7
+ return 0;
8
+ }
@@ -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.4.2'
6
+ spec.version = '0.5.0'
7
7
  spec.author = 'Daniel J. Berger'
8
8
  spec.license = 'Apache-2.0'
9
9
  spec.email = 'djberg96@gmail.com'
@@ -13,10 +13,11 @@ describe Mkmf::Lite do
13
13
  let(:st_type) { 'struct stat' }
14
14
  let(:st_member) { 'st_uid' }
15
15
  let(:st_header) { 'sys/stat.h' }
16
+ let(:constant) { 'EOF' }
16
17
 
17
18
  describe "constants" do
18
19
  example "version information" do
19
- expect(described_class::MKMF_LITE_VERSION).to eq('0.4.2')
20
+ expect(described_class::MKMF_LITE_VERSION).to eq('0.5.0')
20
21
  expect(described_class::MKMF_LITE_VERSION).to be_frozen
21
22
  end
22
23
  end
@@ -82,6 +83,32 @@ describe Mkmf::Lite do
82
83
  end
83
84
  end
84
85
 
86
+ context "check_valueof" do
87
+ example "check_valueof basic functionality" do
88
+ expect(subject).to respond_to(:check_valueof)
89
+ expect{ subject.check_sizeof(constant) }.not_to raise_error
90
+ end
91
+
92
+ example "check_valueof requires at least one argument" do
93
+ expect{ subject.check_valueof }.to raise_error(ArgumentError)
94
+ end
95
+
96
+ example "check_valueof accepts a maximum of two arguments" do
97
+ expect{ subject.check_valueof(constant, 'stdio.h', 1) }.to raise_error(ArgumentError)
98
+ end
99
+
100
+ example "check_valueof works with one or two arguments" do
101
+ expect{ subject.check_valueof(constant) }.not_to raise_error
102
+ expect{ subject.check_valueof(constant, 'stdio.h') }.not_to raise_error
103
+ end
104
+
105
+ example "check_valueof returns an integer value" do
106
+ value = subject.check_valueof(constant)
107
+ expect(value).to be_kind_of(Integer)
108
+ expect(value).to eq(-1)
109
+ end
110
+ end
111
+
85
112
  context "check_sizeof" do
86
113
  example "check_sizeof basic functionality" do
87
114
  expect(subject).to respond_to(:check_sizeof)
@@ -90,7 +117,6 @@ describe Mkmf::Lite do
90
117
 
91
118
  example "check_sizeof requires at least one argument" do
92
119
  expect{ subject.check_sizeof }.to raise_error(ArgumentError)
93
- expect{ subject.check_sizeof('struct passwd', 'pw_name', 1) }.to raise_error(ArgumentError)
94
120
  end
95
121
 
96
122
  example "check_sizeof accepts a maximum of two arguments" do
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.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2020-08-31 00:00:00.000000000 Z
38
+ date: 2020-12-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ptools
@@ -80,6 +80,7 @@ extra_rdoc_files:
80
80
  - README.rdoc
81
81
  files:
82
82
  - CHANGES.rdoc
83
+ - Gemfile
83
84
  - LICENSE
84
85
  - MANIFEST.rdoc
85
86
  - README.rdoc
@@ -88,6 +89,7 @@ files:
88
89
  - lib/mkmf-lite.rb
89
90
  - lib/mkmf/lite.rb
90
91
  - lib/mkmf/templates/check_sizeof.erb
92
+ - lib/mkmf/templates/check_valueof.erb
91
93
  - lib/mkmf/templates/have_func.erb
92
94
  - lib/mkmf/templates/have_func_pointer.erb
93
95
  - lib/mkmf/templates/have_header.erb
metadata.gz.sig CHANGED
Binary file