autorake 2.11 → 2.16

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: 4051898832a1813b071c7fc8c2ba9d52f5a02286175ea782daeb05c6e6d87450
4
- data.tar.gz: b31a976b71888e55642b8097f05b39e8e35d803f9425b9d30631312397ceeac9
3
+ metadata.gz: 4c57d09255cbaffc349b699a06573ebf909bf3446630aef0ce848bfc17b47b69
4
+ data.tar.gz: f1e818b4e4d9d49d70a20b4116054223e605d296514eea91e2f6ce75408089a1
5
5
  SHA512:
6
- metadata.gz: 5645e29411dd0836395a9ae40f2f7a6a0f1ab91c33123b02a525d73247194e822b4ff71a8809d9997417d431998bfc2eab9ff928f46e06e319fdf2d8a3095bb8
7
- data.tar.gz: f4905d715e7822db0915bb2a936c372e6521c6bbcc48af4c15c3d8549a96308eae12092d216ffb108ba3e5f185ba0bfccb0fc7a1afe4e88c82b80fbde1600dd0
6
+ metadata.gz: 9c4a5f2d9e636aadc321f1acc3ad6d7bf5b4ccb215ceaa0c248219b29f8569f5e04d4bb5e292bd8c4851436bba7e07f9552618ee4912e8570072374abc59cbed
7
+ data.tar.gz: 8f0fa7206134a843ff4816daa8b874cd8d846fca19318962fe576322982b570c252f1934c168821502d05743932477a9b3926e010803655ba678bd5e21925934
@@ -6,11 +6,14 @@
6
6
 
7
7
  require "autorake/mkconfig"
8
8
 
9
+ Autorake::Builder.verbose = :keep
10
+
11
+
9
12
  Autorake.configure {
10
13
 
11
14
  # Normal header and library lookup
12
15
  have_header "stdio.h" # Look if there is a header of this name.
13
- have_library "curses" # Look for library
16
+ need_library "curses" # Look for library
14
17
 
15
18
  # We #include from there.
16
19
  incdir :bar, "INCLUDE/anotherproject"
@@ -27,7 +30,7 @@ Autorake.configure {
27
30
 
28
31
  disable :weirdfeature do
29
32
  # Call it as "./mkrf_conf --enable-weirdfeature" to let it fail.
30
- have_library "nonexistent"
33
+ need_library "nonexistent"
31
34
  end
32
35
 
33
36
 
data/lib/autorake.rb CHANGED
@@ -5,13 +5,23 @@
5
5
  require "autorake/configure"
6
6
  require "autorake/compile"
7
7
 
8
+
9
+ class NilClass
10
+ method_defined? :notempty? or def notempty? ; end
11
+ end
12
+
13
+ class String
14
+ method_defined? :notempty? or def notempty? ; length.nonzero? and self ; end
15
+ end
16
+
17
+
8
18
  module Autorake
9
19
 
10
20
  module Rakefile
11
21
 
12
22
  class <<self
13
23
  def extended obj
14
- obj.load_autorake ENV[ "AUTORAKE_CONFIGURE"]
24
+ obj.load_autorake ENV[ "AUTORAKE_CONFIGURE"].notempty?
15
25
  Builder.verbose = true
16
26
  end
17
27
  end
@@ -124,13 +124,13 @@ module Autorake
124
124
 
125
125
  def version
126
126
  require "autorake/version"
127
- puts <<-EOT
128
- #{NAME} #{VERSION} -- #{SUMMARY}
127
+ puts <<~EOT
128
+ #{NAME} #{VERSION} -- #{SUMMARY}
129
129
 
130
- Copyright: #{COPYRIGHT}
131
- License: #{LICENSE}
130
+ Copyright: #{COPYRIGHT}
131
+ License: #{LICENSE}
132
132
 
133
- #{HOMEPAGE}
133
+ #{HOMEPAGE}
134
134
  EOT
135
135
  raise Done
136
136
  end
@@ -34,20 +34,67 @@ module Autorake
34
34
  a.flatten!
35
35
  a.compact!
36
36
  a.unshift @cmd
37
- if Builder.verbose then
38
- m = a.join " "
39
- puts m
40
- end
37
+ puts a.join " " if Builder.verbose
41
38
  f = fork do
42
- $stderr.reopen "/dev/null" if Builder.quiet
39
+ $stderr.reopen "/dev/null" if Builder.quiet and not Builder.verbose
43
40
  exec *a
44
41
  end
45
42
  Process.waitpid f
46
43
  $?.success? or raise Error, "#{self.class} failed."
47
44
  end
48
45
 
46
+
47
+ class <<self
48
+ def tmpfiles source
49
+ TmpFiles.open source, @verbose==:keep do |t|
50
+ yield t
51
+ end
52
+ end
53
+ end
54
+
55
+ class TmpFiles
56
+
57
+ class <<self
58
+ def open source, keep = nil
59
+ i = new source
60
+ yield i
61
+ ensure
62
+ i.cleanup unless keep
63
+ end
64
+ private :new
65
+ end
66
+
67
+ attr_reader :src
68
+
69
+ def initialize source
70
+ @plain = "autorake-tmp-0001"
71
+ begin
72
+ @src = "#@plain.c"
73
+ File.open @src, File::WRONLY|File::CREAT|File::EXCL do |c|
74
+ c.puts source
75
+ end
76
+ rescue Errno::EEXIST
77
+ @plain.succ!
78
+ retry
79
+ end
80
+ end
81
+
82
+ def cpp ; @cpp = "#@plain.cpp" ; end
83
+ def obj ; @obj = "#@plain.o" ; end
84
+ def bin ; @bin = "#@plain" ; end
85
+
86
+ def cleanup
87
+ File.delete @bin if @bin and File.exists? @bin
88
+ File.delete @obj if @obj and File.exists? @obj
89
+ File.delete @cpp if @cpp and File.exists? @cpp
90
+ File.delete @src
91
+ end
92
+
93
+ end
94
+
49
95
  end
50
96
 
97
+
51
98
  class Preprocessor < Builder
52
99
 
53
100
  def initialize incdirs, macros, *args
@@ -65,7 +112,7 @@ module Autorake
65
112
 
66
113
  def build obj, src
67
114
  io = [ "-o", obj.to_s, "-c", src.to_s]
68
- super @cflags, @macros, @incdirs, @args, opt_E, io
115
+ super @cflags, @args, @macros, @incdirs, opt_E, io
69
116
  end
70
117
 
71
118
  private
@@ -96,48 +143,7 @@ module Autorake
96
143
 
97
144
  def build bin, *objs
98
145
  io = [ "-o", bin.to_s, objs]
99
- super @ldflags, @libdirs, @libs, @args, io
100
- end
101
-
102
- end
103
-
104
-
105
- class TmpFiles
106
-
107
- class <<self
108
- def open source
109
- i = new source
110
- yield i
111
- ensure
112
- i.cleanup
113
- end
114
- private :new
115
- end
116
-
117
- attr_reader :src
118
-
119
- def initialize source
120
- @plain = "tmp-0001"
121
- begin
122
- @src = "#@plain.c"
123
- File.open @src, File::WRONLY|File::CREAT|File::EXCL do |c|
124
- c.puts source
125
- end
126
- rescue Errno::EEXIST
127
- @plain.succ!
128
- retry
129
- end
130
- end
131
-
132
- def cpp ; @cpp = "#@plain.cpp" ; end
133
- def obj ; @obj = "#@plain.o" ; end
134
- def bin ; @bin = "#@plain" ; end
135
-
136
- def cleanup
137
- File.delete @bin if @bin and File.exists? @bin
138
- File.delete @obj if @obj and File.exists? @obj
139
- File.delete @cpp if @cpp and File.exists? @cpp
140
- File.delete @src
146
+ super @args, @ldflags, io, @libdirs, @libs
141
147
  end
142
148
 
143
149
  end
@@ -84,11 +84,16 @@ module Autorake
84
84
  else
85
85
  l[ /\Alib(.*?)\.so(?:\..*)?\z/, 1]
86
86
  end
87
- have_library l
87
+ need_library l
88
88
  end
89
89
 
90
90
  def have_header name
91
- c = CheckHeader.new @current, name
91
+ c = CheckHeader.new @current, name, false
92
+ @checks.push c
93
+ end
94
+
95
+ def need_header name
96
+ c = CheckHeader.new @current, name, true
92
97
  @checks.push c
93
98
  end
94
99
 
@@ -103,7 +108,7 @@ module Autorake
103
108
  end
104
109
  alias have_func have_function
105
110
 
106
- def have_library name
111
+ def need_library name
107
112
  c = CheckLibrary.new @current, name
108
113
  @checks.push c
109
114
  end
@@ -193,7 +198,7 @@ module Autorake
193
198
  def check!
194
199
  super or return
195
200
  print "Checking for #{self.class::TYPE} #@name ... "
196
- res = TmpFiles.open build_source do |t|
201
+ res = Builder.tmpfiles build_source do |t|
197
202
  compile t
198
203
  end
199
204
  print "yes"
@@ -209,15 +214,24 @@ module Autorake
209
214
  class CheckHeader < Check
210
215
  TYPE = "header"
211
216
  private
217
+ def initialize feature, name, need = nil
218
+ super feature, name
219
+ @need = need
220
+ end
212
221
  def build_source
213
- <<-SRC
214
- #include <#@name>
222
+ <<~SRC
223
+ #include <#@name>
215
224
  SRC
216
225
  end
217
226
  def compile t
218
227
  c = Preprocessor.new @config.incdirs, @config.macros, "-w"
219
228
  c.cc t.cpp, t.src
220
229
  end
230
+ def check!
231
+ r = super
232
+ r or not @need or raise "Can't continue."
233
+ r
234
+ end
221
235
  def set!
222
236
  @config.macros[ "HAVE_HEADER_#{name_upcase}"] = true
223
237
  @config.headers.push @name
@@ -229,8 +243,8 @@ module Autorake
229
243
  def build_source
230
244
  src = ""
231
245
  @config.headers.each { |i|
232
- src << <<-SRC
233
- #include <#{i}>
246
+ src << <<~SRC
247
+ #include <#{i}>
234
248
  SRC
235
249
  }
236
250
  src
@@ -241,10 +255,10 @@ module Autorake
241
255
  TYPE = "macro"
242
256
  private
243
257
  def build_source
244
- super << <<-SRC
245
- #ifndef #@name
246
- #error not defined
247
- #endif
258
+ super << <<~SRC
259
+ #ifndef #@name
260
+ #error not defined
261
+ #endif
248
262
  SRC
249
263
  end
250
264
  def compile t
@@ -260,11 +274,11 @@ module Autorake
260
274
  TYPE = "function"
261
275
  private
262
276
  def build_source
263
- super << <<-SRC
264
- void dummy( void)
265
- {
266
- void (*f)( void) = (void (*)( void)) #@name;
267
- }
277
+ super << <<~SRC
278
+ void dummy( void)
279
+ {
280
+ void (*f)( void) = (void (*)( void)) #@name;
281
+ }
268
282
  SRC
269
283
  end
270
284
  def compile t
@@ -279,8 +293,8 @@ void dummy( void)
279
293
  class CheckLibrary < Check
280
294
  TYPE = "library"
281
295
  def build_source
282
- <<-SRC
283
- int main( int argc, char *argv[]) { return 0; }
296
+ <<~SRC
297
+ int main( int argc, char *argv[]) { return 0; }
284
298
  SRC
285
299
  end
286
300
  def compile t
@@ -31,7 +31,16 @@ module Autorake
31
31
  end
32
32
 
33
33
  attr_accessor :outfile
34
- attr_bang :clean, :verbose
34
+ attr_bang :clean
35
+
36
+ def verbose!
37
+ @verbose = true
38
+ Builder.verbose ||= @verbose
39
+ end
40
+ def keep!
41
+ Builder.verbose = :keep
42
+ end
43
+
35
44
 
36
45
  def initialize definition
37
46
  @definition = definition
@@ -47,6 +56,8 @@ module Autorake
47
56
  add_option %w(d dump), "just dump the results", nil, :dump
48
57
  add_option %w(v verbose), "lots of ugly debugging information",
49
58
  nil, :verbose!
59
+ add_option %w(k keep), "keep temporary files",
60
+ nil, :keep!
50
61
  super
51
62
  @definition.directories.each { |k,v|
52
63
  add_option %W(dir-#{k}), "set directory #{k}", v, :set_dir, k
@@ -5,15 +5,15 @@
5
5
  module Autorake
6
6
 
7
7
  NAME = "autorake"
8
- VERSION = "2.11".freeze
8
+ VERSION = "2.16".freeze
9
9
  SUMMARY = "Automake like project config before Rake build or install."
10
10
 
11
- DESCRIPTION = <<EOT
12
- This script allows you to write pretty mkrf_conf scripts
13
- with autocmd-like functionality.
11
+ DESCRIPTION = <<~EOT
12
+ This script allows you to write pretty mkrf_conf scripts
13
+ with autocmd-like functionality.
14
14
 
15
- The config scripts may be held short and readable.
16
- EOT
15
+ The config scripts may be held short and readable.
16
+ EOT
17
17
 
18
18
  COPYRIGHT = "(C) 2009-2019 Bertram Scharpf"
19
19
  LICENSE = "BSD-2-Clause"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autorake
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.11'
4
+ version: '2.16'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-31 00:00:00.000000000 Z
11
+ date: 2021-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -70,7 +70,7 @@ homepage: http://www.bertram-scharpf.de/software/autorake
70
70
  licenses:
71
71
  - BSD-2-Clause
72
72
  metadata: {}
73
- post_install_message:
73
+ post_install_message:
74
74
  rdoc_options:
75
75
  - "--charset"
76
76
  - utf-8
@@ -90,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements:
92
92
  - Rake
93
- rubygems_version: 3.0.6
94
- signing_key:
93
+ rubygems_version: 3.0.8
94
+ signing_key:
95
95
  specification_version: 4
96
96
  summary: Automake like project config before Rake build or install.
97
97
  test_files: []