pkg-config 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/NEWS +5 -0
  2. data/lib/pkg-config.rb +82 -66
  3. data/test/test_pkg_config.rb +1 -0
  4. metadata +3 -3
data/NEWS CHANGED
@@ -1,5 +1,10 @@
1
1
  = NEWS
2
2
 
3
+ == 1.0.5 - 2010/09/23
4
+
5
+ * suppress duplicated configure arguments processing.
6
+ * use mkmf.rb message functions.
7
+
3
8
  == 1.0.4 - 2010/09/23
4
9
 
5
10
  * add PKGConfig.variable.
data/lib/pkg-config.rb CHANGED
@@ -24,6 +24,75 @@ require 'pathname'
24
24
  class PackageConfig
25
25
  SEPARATOR = File::PATH_SEPARATOR
26
26
 
27
+ class << self
28
+ @native_pkg_config = nil
29
+ def native_pkg_config
30
+ return @native_pkg_config if @native_pkg_config
31
+ pkg_config = with_config("pkg-config", ENV["PKG_CONFIG"] || "pkg-config")
32
+ pkg_config = Pathname.new(pkg_config)
33
+ unless pkg_config.absolute?
34
+ found_pkg_config = search_pkg_config_from_path(pkg_config)
35
+ pkg_config = found_pkg_config if found_pkg_config
36
+ end
37
+ unless pkg_config.absolute?
38
+ found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config)
39
+ pkg_config = found_pkg_config if found_pkg_config
40
+ end
41
+ @native_pkg_config = pkg_config
42
+ end
43
+
44
+ @custom_override_variables = nil
45
+ def custom_override_variables
46
+ @custom_override_variables ||= with_config("override-variables", "")
47
+ end
48
+
49
+ def clear_configure_args_cache
50
+ @native_pkg_config = nil
51
+ @custom_override_variables = nil
52
+ end
53
+
54
+ private
55
+ def search_pkg_config_from_path(pkg_config)
56
+ (ENV["PATH"] || "").split(SEPARATOR).each do |path|
57
+ try_pkg_config = Pathname(path) + pkg_config
58
+ return try_pkg_config if try_pkg_config.exist?
59
+ end
60
+ nil
61
+ end
62
+
63
+ def search_pkg_config_by_dln_find_exe(pkg_config)
64
+ begin
65
+ require "dl/import"
66
+ rescue LoadError
67
+ return nil
68
+ end
69
+ dln = Module.new
70
+ dln.module_eval do
71
+ if DL.const_defined?(:Importer)
72
+ extend DL::Importer
73
+ else
74
+ extend DL::Importable
75
+ end
76
+ begin
77
+ dlload RbConfig::CONFIG["LIBRUBY"]
78
+ rescue RuntimeError
79
+ return nil if $!.message == "unknown error"
80
+ return nil if /: image not found\z/ =~ $!.message
81
+ raise
82
+ rescue DL::DLError
83
+ return nil
84
+ end
85
+ extern "const char *dln_find_exe(const char *, const char *)"
86
+ end
87
+ path = dln.dln_find_exe(pkg_config.to_s, nil)
88
+ if path.size.zero?
89
+ nil
90
+ else
91
+ Pathname(path.to_s)
92
+ end
93
+ end
94
+ end
95
+
27
96
  attr_reader :paths
28
97
  attr_accessor :msvc_syntax
29
98
  def initialize(name, options={})
@@ -34,7 +103,7 @@ class PackageConfig
34
103
  @paths.unshift(@options[:paths] || [])
35
104
  @msvc_syntax = @options[:msvc_syntax]
36
105
  @variables = @declarations = nil
37
- override_variables = with_config("override-variables", "")
106
+ override_variables = self.class.custom_override_variables
38
107
  @override_variables = parse_override_variables(override_variables)
39
108
  default_override_variables = @options[:override_variables] || {}
40
109
  @override_variables = default_override_variables.merge(@override_variables)
@@ -187,46 +256,6 @@ class PackageConfig
187
256
  end
188
257
  end
189
258
 
190
- def search_pkg_config_from_path(pkg_config)
191
- (ENV["PATH"] || "").split(SEPARATOR).each do |path|
192
- try_pkg_config = Pathname(path) + pkg_config
193
- return try_pkg_config if try_pkg_config.exist?
194
- end
195
- nil
196
- end
197
-
198
- def search_pkg_config_by_dln_find_exe(pkg_config)
199
- begin
200
- require "dl/import"
201
- rescue LoadError
202
- return nil
203
- end
204
- dln = Module.new
205
- dln.module_eval do
206
- if DL.const_defined?(:Importer)
207
- extend DL::Importer
208
- else
209
- extend DL::Importable
210
- end
211
- begin
212
- dlload RbConfig::CONFIG["LIBRUBY"]
213
- rescue RuntimeError
214
- return nil if $!.message == "unknown error"
215
- return nil if /: image not found\z/ =~ $!.message
216
- raise
217
- rescue DL::DLError
218
- return nil
219
- end
220
- extern "const char *dln_find_exe(const char *, const char *)"
221
- end
222
- path = dln.dln_find_exe(pkg_config.to_s, nil)
223
- if path.size.zero?
224
- nil
225
- else
226
- Pathname(path.to_s)
227
- end
228
- end
229
-
230
259
  def guess_default_path
231
260
  default_path = ["/usr/local/lib64/pkgconfig",
232
261
  "/usr/local/lib/pkgconfig",
@@ -239,17 +268,7 @@ class PackageConfig
239
268
  libdir = ENV["PKG_CONFIG_LIBDIR"]
240
269
  default_path = [libdir, default_path].join(SEPARATOR) if libdir
241
270
 
242
- pkg_config = with_config("pkg-config", ENV["PKG_CONFIG"] || "pkg-config")
243
- pkg_config = Pathname.new(pkg_config)
244
- unless pkg_config.absolute?
245
- found_pkg_config = search_pkg_config_from_path(pkg_config)
246
- pkg_config = found_pkg_config if found_pkg_config
247
- end
248
- unless pkg_config.absolute?
249
- found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config)
250
- pkg_config = found_pkg_config if found_pkg_config
251
- end
252
-
271
+ pkg_config = self.class.native_pkg_config
253
272
  return default_path unless pkg_config.absolute?
254
273
  [(pkg_config.parent.parent + "lib" + "pkgconfig").to_s,
255
274
  (pkg_config.parent.parent + "libdata" + "pkgconfig").to_s,
@@ -258,7 +277,7 @@ class PackageConfig
258
277
  end
259
278
 
260
279
  module PKGConfig
261
- VERSION = "1.0.4"
280
+ VERSION = "1.0.5"
262
281
 
263
282
  @@paths = []
264
283
  @@override_variables = {}
@@ -327,15 +346,15 @@ module PKGConfig
327
346
  end
328
347
 
329
348
  def have_package(pkg, major = nil, minor = 0, micro = 0)
330
- if major.nil?
331
- STDOUT.print("checking for #{pkg}... ")
332
- else
333
- STDOUT.print("checking for #{pkg} version (>= #{major}.#{minor}.#{micro})... ")
349
+ message = "#{pkg}"
350
+ unless major.nil?
351
+ message << "version (>= #{major}.#{minor}.#{micro})"
334
352
  end
335
353
  major ||= 0
336
- STDOUT.flush
337
- if check_version?(pkg, major, minor, micro)
338
- STDOUT.print "yes\n"
354
+ enough_version = checking_for(checking_message(message)) do
355
+ check_version?(pkg, major, minor, micro)
356
+ end
357
+ if enough_version
339
358
  libraries = libs_only_l(pkg)
340
359
  dldflags = libs(pkg)
341
360
  dldflags = (Shellwords.shellwords(dldflags) -
@@ -343,15 +362,12 @@ module PKGConfig
343
362
  dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ')
344
363
  $libs += ' ' + libraries
345
364
  if /mswin32/ =~ RUBY_PLATFORM
346
- $DLDFLAGS += ' ' + dldflags
365
+ $DLDFLAGS += ' ' + dldflags
347
366
  else
348
- $LDFLAGS += ' ' + dldflags
367
+ $LDFLAGS += ' ' + dldflags
349
368
  end
350
369
  $CFLAGS += ' ' + cflags(pkg)
351
- true
352
- else
353
- STDOUT.print "no\n"
354
- false
355
370
  end
371
+ enough_version
356
372
  end
357
373
  end
@@ -108,6 +108,7 @@ class PkgConfigTest < Test::Unit::TestCase
108
108
  else
109
109
  args = {"--with-override-variables" => override_variables}
110
110
  end
111
+ PackageConfig.clear_configure_args_cache
111
112
  configure_args(args) do
112
113
  yield
113
114
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkg-config
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kouhei Sutou