autorake 2.13 → 2.15

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: 0b95b008d4d21fcd53f281bab5cacdc883a2653a30366e04cac61ab11525a473
4
- data.tar.gz: 90448f01970bab9c3a97beac34c880d9726c56baf5855809e6a53c16101b7c5b
3
+ metadata.gz: 38b38d81398d9d978a224f9252d9cb15e2e2bec52904b85822c6adce9e9b5919
4
+ data.tar.gz: 9120db4495065ab5a21c9f04c40113df7be020aaffa4fad308c071e29a0c1b2e
5
5
  SHA512:
6
- metadata.gz: 027562f49fe9f62a8ba52846962b509e3642680eba89087933924acd63542a28ba5ed544cda885a06d1d7e3ecc0cf9a5008cc1d41163b2fa622e2dbbc29bcc0e
7
- data.tar.gz: d6b170435c6472d274fab3834ac7a669498ac0c3d9a031f9a20429526148045479ff9dee1e1140a9e14a6ef32a06fda950e8e7d09fac3f0258b74dd387381296
6
+ metadata.gz: d67224292371165f371d5c4ff1affce3675addef4c30dc5d0da255519cd1d47acf5e3250a057e6fecb4ba6304ab01ecea54b973308eaaa311859afd5882f1e66
7
+ data.tar.gz: 3c4340d8c10b40b66e69e4f2f47d1449f69ff807cdbff36dc341d46fba945fe6d17e8ee655fd408854a2fb56761536eedc1f67d7c2b40816c4ea30c9dde1582f
@@ -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
 
@@ -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
@@ -35,19 +35,70 @@ module Autorake
35
35
  a.compact!
36
36
  a.unshift @cmd
37
37
  if Builder.verbose then
38
- m = a.join " "
39
- puts m
38
+ puts
39
+ puts a.join " "
40
40
  end
41
41
  f = fork do
42
- $stderr.reopen "/dev/null" if Builder.quiet
42
+ $stderr.reopen "/dev/null" if Builder.quiet and not Builder.verbose
43
43
  exec *a
44
44
  end
45
45
  Process.waitpid f
46
+ print "..." if Builder.verbose
46
47
  $?.success? or raise Error, "#{self.class} failed."
47
48
  end
48
49
 
50
+
51
+ class <<self
52
+ def tmpfiles source
53
+ TmpFiles.open source, @verbose==:keep do |t|
54
+ yield t
55
+ end
56
+ end
57
+ end
58
+
59
+ class TmpFiles
60
+
61
+ class <<self
62
+ def open source, keep = nil
63
+ i = new source
64
+ yield i
65
+ ensure
66
+ i.cleanup unless keep
67
+ end
68
+ private :new
69
+ end
70
+
71
+ attr_reader :src
72
+
73
+ def initialize source
74
+ @plain = "autorake-tmp-0001"
75
+ begin
76
+ @src = "#@plain.c"
77
+ File.open @src, File::WRONLY|File::CREAT|File::EXCL do |c|
78
+ c.puts source
79
+ end
80
+ rescue Errno::EEXIST
81
+ @plain.succ!
82
+ retry
83
+ end
84
+ end
85
+
86
+ def cpp ; @cpp = "#@plain.cpp" ; end
87
+ def obj ; @obj = "#@plain.o" ; end
88
+ def bin ; @bin = "#@plain" ; end
89
+
90
+ def cleanup
91
+ File.delete @bin if @bin and File.exists? @bin
92
+ File.delete @obj if @obj and File.exists? @obj
93
+ File.delete @cpp if @cpp and File.exists? @cpp
94
+ File.delete @src
95
+ end
96
+
97
+ end
98
+
49
99
  end
50
100
 
101
+
51
102
  class Preprocessor < Builder
52
103
 
53
104
  def initialize incdirs, macros, *args
@@ -101,46 +152,5 @@ module Autorake
101
152
 
102
153
  end
103
154
 
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
141
- end
142
-
143
- end
144
-
145
155
  end
146
156
 
@@ -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.13".freeze
8
+ VERSION = "2.15".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.13'
4
+ version: '2.15'
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: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-12-04 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: []