pkg-config 1.3.7 → 1.4.2

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: 4657b85e9f8971fcb4c962494770ad50f66f0517904e815f62a49b60bbced375
4
- data.tar.gz: fcd422845f64d152fa196a94a62b0d3c0136f2ca9dd1ab6f3beacbe692994dfc
3
+ metadata.gz: ca2690b236cb0845ff444ae843a41f4ad77532dc47eb65c984616398605510ed
4
+ data.tar.gz: 8434a6be7c364013b1a497406e797bebac4f7cb911764024bdd596e0b4c38f08
5
5
  SHA512:
6
- metadata.gz: ba1320c3c3f5f51ae3b5b51cf665d58d7c9f2c7b4fb384b329917d381d6dfc0f8908bf6408ddee6617c39cd5d3e96da4d6acf444852cfd805a883e45b7f2c5cd
7
- data.tar.gz: d05605e7648547cca52dbe9f0f474d84645b0d6905a7af766984c52818d346b23b5249cf20991f590430483dd65c2698fa9bee3d35430485d53b4be7e6490558
6
+ metadata.gz: 067f058cf005a0c6835d9648f0dbbc224873ee1fc3b7596988a93866389c487d33059abf6d94ed0d81ac326371db66c5c755362efb2292e74ad5701adcc4cb99
7
+ data.tar.gz: 78b5ec42683dd4e87f07221f84ae634e535aacab38fba199de6f72e8b197662cb80ac4ac23a950d9795c559f3d8628ab28e975d0a0bd753dd187ad3dfbf10ffd
data/NEWS CHANGED
@@ -1,5 +1,52 @@
1
1
  = NEWS
2
2
 
3
+ == 1.4.2 - 2020-08-10
4
+
5
+ === Improvements
6
+
7
+ * Added support for detecting pkgconfig path on RubyInstaller
8
+ without "ridk exec".
9
+
10
+ == 1.4.1 - 2020-02-10
11
+
12
+ === Improvements
13
+
14
+ * Added support for cycled depended .pc such as freetype2.pc and
15
+ harfbuzz.pc on PLD Linux.
16
+ [Reported by Jakub Bogusz]
17
+
18
+ === Thanks
19
+
20
+ * Jakub Bogusz
21
+
22
+ == 1.4.0 - 2019-10-24
23
+
24
+ === Improvements
25
+
26
+ * Improved Homebrew detection.
27
+
28
+ == 1.3.9 - 2019-09-28
29
+
30
+ === Improvements
31
+
32
+ * Added support for absolute path in Requires.
33
+ [GitHub#18][Reported by Josh Huckabee]
34
+
35
+ === Thanks
36
+
37
+ * Josh Huckabee
38
+
39
+ == 1.3.8 - 2019-08-13
40
+
41
+ === Improvements
42
+
43
+ * Added support for -framework on macOS.
44
+ [GitHub:ruby-gnome2/ruby-gnome2#1287][Reported by Viko]
45
+
46
+ === Thanks
47
+
48
+ * Viko
49
+
3
50
  == 1.3.7 - 2019-03-17
4
51
 
5
52
  === Improvements
@@ -14,14 +14,8 @@ A pkg-config implementation by Ruby.
14
14
 
15
15
  == Install
16
16
 
17
- === Package
18
-
19
17
  # gem install pkg-config
20
18
 
21
- === No package
22
-
23
- # ruby setup.rb
24
-
25
19
  == Documents
26
20
 
27
21
  * TODO
@@ -29,11 +23,11 @@ A pkg-config implementation by Ruby.
29
23
  == Source
30
24
 
31
25
  There is the pkg-config repository at GitHub:
32
- http://github.com/rcairo/pkg-config
26
+ http://github.com/ruby-gnome/pkg-config
33
27
 
34
28
  == Copyright
35
29
 
36
- Copyright 2008-2011 Kouhei Sutou <kou@clear-code.com>
30
+ Copyright 2008-2019 Kouhei Sutou <kou@clear-code.com>
37
31
 
38
32
  This library is free software; you can redistribute it and/or
39
33
  modify it under the terms of the GNU Lesser General Public
@@ -1,4 +1,4 @@
1
- # Copyright 2008-2019 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright 2008-2020 Sutou Kouhei <kou@cozmixng.org>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -15,15 +15,14 @@
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
  begin
18
- require "pkg-config/version"
18
+ require_relative "pkg-config/version"
19
19
  rescue LoadError
20
20
  end
21
21
 
22
+ require "English"
23
+ require "pathname"
22
24
  require "rbconfig"
23
-
24
- require 'shellwords'
25
- require 'English'
26
- require 'pathname'
25
+ require "shellwords"
27
26
 
28
27
  class PackageConfig
29
28
  SEPARATOR = File::PATH_SEPARATOR
@@ -122,6 +121,7 @@ class PackageConfig
122
121
  def compute_native_pkg_config_prefix
123
122
  pkg_config = native_pkg_config
124
123
  return nil unless pkg_config.absolute?
124
+ return nil unless pkg_config.exist?
125
125
 
126
126
  pkg_config_prefix = pkg_config.parent.parent
127
127
  if File::ALT_SEPARATOR
@@ -134,10 +134,19 @@ class PackageConfig
134
134
  end
135
135
  end
136
136
 
137
+ attr_reader :name
137
138
  attr_reader :paths
138
139
  attr_accessor :msvc_syntax
139
140
  def initialize(name, options={})
140
- @name = name
141
+ if Pathname(name).absolute?
142
+ @pc_path = name
143
+ @path_position = 0
144
+ @name = File.basename(@pc_path, ".*")
145
+ else
146
+ @pc_path = nil
147
+ @path_position = nil
148
+ @name = name
149
+ end
141
150
  @options = options
142
151
  path = @options[:path] || ENV["PKG_CONFIG_PATH"]
143
152
  @paths = [path, guess_default_path].compact.join(SEPARATOR).split(SEPARATOR)
@@ -220,29 +229,63 @@ class PackageConfig
220
229
  end
221
230
 
222
231
  def pc_path
223
- @paths.each do |path|
224
- _pc_path = File.join(path, "#{@name}.pc")
225
- return _pc_path if File.exist?(_pc_path)
232
+ if @pc_path
233
+ return @pc_path if File.exist?(@pc_path)
234
+ else
235
+ @paths.each_with_index do |path, i|
236
+ _pc_path = File.join(path, "#{@name}.pc")
237
+ if File.exist?(_pc_path)
238
+ @path_position = i + 1
239
+ return _pc_path
240
+ end
241
+ end
226
242
  end
227
243
  nil
228
244
  end
229
245
 
246
+ protected
247
+ def path_position
248
+ @path_position
249
+ end
250
+
251
+ def collect_requires(processed_packages={}, &block)
252
+ packages = []
253
+ targets = yield(self)
254
+ targets.each do |name|
255
+ next if processed_packages.key?(name)
256
+ package = self.class.new(name, @options)
257
+ processed_packages[name] = package
258
+ packages << package
259
+ packages.concat(package.collect_requires(processed_packages, &block))
260
+ end
261
+ packages_without_self = packages.reject do |package|
262
+ package.name == @name
263
+ end
264
+ packages_without_self.uniq do |package|
265
+ package.name
266
+ end
267
+ end
268
+
230
269
  private
231
- def collect_cflags
232
- cflags_set = [declaration("Cflags")]
233
- cflags_set += private_required_packages.collect do |package|
234
- self.class.new(package, @options).cflags
270
+ def sort_packages(packages)
271
+ packages.sort_by.with_index do |package, i|
272
+ [package.path_position, i]
235
273
  end
236
- cflags_set += required_packages.collect do |package|
237
- self.class.new(package, @options).cflags
274
+ end
275
+
276
+ def collect_cflags
277
+ target_packages = sort_packages([self, *all_required_packages])
278
+ cflags_set = []
279
+ target_packages.each do |package|
280
+ cflags_set << package.declaration("Cflags")
238
281
  end
239
282
  all_cflags = normalize_cflags(Shellwords.split(cflags_set.join(" ")))
240
283
  path_flags, other_flags = all_cflags.partition {|flag| /\A-I/ =~ flag}
241
284
  path_flags = normalize_path_flags(path_flags, "-I")
242
- path_flags = remove_duplicated_include_paths(path_flags)
243
285
  path_flags = path_flags.reject do |flag|
244
286
  flag == "-I/usr/include"
245
287
  end
288
+ path_flags = path_flags.uniq
246
289
  if @msvc_syntax
247
290
  path_flags = path_flags.collect do |flag|
248
291
  flag.gsub(/\A-I/, "/I")
@@ -284,21 +327,19 @@ class PackageConfig
284
327
  normalized_cflags
285
328
  end
286
329
 
287
- def remove_duplicated_include_paths(path_flags)
288
- path_flags.uniq
289
- end
290
-
291
330
  def collect_libs
292
- all_libs = required_packages.collect do |package|
293
- self.class.new(package, @options).libs
331
+ target_packages = sort_packages(required_packages + [self])
332
+ libs_set = []
333
+ target_packages.each do |package|
334
+ libs_set << package.declaration("Libs")
294
335
  end
295
- all_libs = [declaration("Libs")] + all_libs
296
- all_libs = all_libs.join(" ").gsub(/-([Ll]) /, '\1').split.uniq
297
- path_flags, other_flags = all_libs.partition {|flag| /\A-L/ =~ flag}
336
+ all_flags = split_lib_flags(libs_set.join(" "))
337
+ path_flags, other_flags = all_flags.partition {|flag| /\A-L/ =~ flag}
298
338
  path_flags = normalize_path_flags(path_flags, "-L")
299
339
  path_flags = path_flags.reject do |flag|
300
340
  /\A-L\/usr\/lib(?:64|x32)?\z/ =~ flag
301
341
  end
342
+ path_flags = path_flags.uniq
302
343
  if @msvc_syntax
303
344
  path_flags = path_flags.collect do |flag|
304
345
  flag.gsub(/\A-L/, "/libpath:")
@@ -314,6 +355,29 @@ class PackageConfig
314
355
  [path_flags, other_flags]
315
356
  end
316
357
 
358
+ def split_lib_flags(libs_command_line)
359
+ all_flags = {}
360
+ flags = []
361
+ in_option = false
362
+ libs_command_line.gsub(/-([Ll]) /, "\\1").split.each do |arg|
363
+ if in_option
364
+ flags << arg
365
+ in_option = false
366
+ else
367
+ case arg
368
+ when /-[lL]/
369
+ next if all_flags.key?(arg)
370
+ all_flags[arg] = true
371
+ flags << arg
372
+ in_option = true
373
+ else
374
+ flags << arg
375
+ end
376
+ end
377
+ end
378
+ flags
379
+ end
380
+
317
381
  IDENTIFIER_RE = /[a-zA-Z\d_\.]+/
318
382
  def parse_pc
319
383
  raise ".pc for #{@name} doesn't exist." unless exist?
@@ -321,7 +385,7 @@ class PackageConfig
321
385
  @declarations = {}
322
386
  File.open(pc_path) do |input|
323
387
  input.each_line do |line|
324
- line = line.gsub(/#.*/, '').strip
388
+ line = line.gsub(/#.*/, "").strip
325
389
  next if line.empty?
326
390
  case line
327
391
  when /^(#{IDENTIFIER_RE})=/
@@ -335,7 +399,7 @@ class PackageConfig
335
399
 
336
400
  def parse_requires(requires)
337
401
  return [] if requires.nil?
338
- requires_without_version = requires.gsub(/[<>]?=\s*[\d.a-zA-Z_-]+\s*/, '')
402
+ requires_without_version = requires.gsub(/[<>]?=\s*[\d.a-zA-Z_-]+\s*/, "")
339
403
  requires_without_version.split(/[,\s]+/)
340
404
  end
341
405
 
@@ -375,6 +439,11 @@ class PackageConfig
375
439
  "/opt/X11/lib/pkgconfig",
376
440
  "/usr/share/pkgconfig",
377
441
  ]
442
+ if Object.const_defined?(:RubyInstaller)
443
+ mingw_bin_path = RubyInstaller::Runtime.msys2_installation.mingw_bin_path
444
+ mingw_pkgconfig_path = Pathname.new(mingw_bin_path) + "../lib/pkgconfig"
445
+ default_paths.unshift(mingw_pkgconfig_path.cleanpath.to_s)
446
+ end
378
447
  libdir = ENV["PKG_CONFIG_LIBDIR"]
379
448
  default_paths.unshift(libdir) if libdir
380
449
 
@@ -403,14 +472,13 @@ class PackageConfig
403
472
  homebrew_repository_candidates << pkg_config_prefix + "Homebrew"
404
473
  homebrew_repository_candidates << pkg_config_prefix
405
474
  end
406
- else
407
- brew = self.class.__send__(:search_executable_from_path, "brew")
408
- if brew
409
- homebrew_repository = `brew --repository`.chomp
410
- homebrew_repository_candidates << Pathname(homebrew_repository)
411
- end
412
475
  end
413
- homebrew_repository_candidates.each do |candidate|
476
+ brew = self.class.__send__(:search_executable_from_path, "brew")
477
+ if brew
478
+ homebrew_repository = `brew --repository`.chomp
479
+ homebrew_repository_candidates << Pathname(homebrew_repository)
480
+ end
481
+ homebrew_repository_candidates.uniq.each do |candidate|
414
482
  path = candidate + "Library/Homebrew/os/mac/pkgconfig/#{mac_os_version}"
415
483
  paths << path.to_s if path.exist?
416
484
  end
@@ -420,21 +488,15 @@ class PackageConfig
420
488
  end
421
489
 
422
490
  def required_packages
423
- requires.reject do |package|
424
- @name == package
425
- end.uniq
426
- end
427
-
428
- def private_required_packages
429
- requires_private.reject do |package|
430
- @name == package
431
- end.uniq
491
+ collect_requires do |package|
492
+ package.requires
493
+ end
432
494
  end
433
495
 
434
496
  def all_required_packages
435
- (requires_private + requires.reverse).reject do |package|
436
- @name == package
437
- end.uniq
497
+ collect_requires do |package|
498
+ package.requires_private + package.requires
499
+ end
438
500
  end
439
501
 
440
502
  def normalize_paths(paths)
@@ -458,7 +520,7 @@ module PKGConfig
458
520
  end
459
521
 
460
522
  def msvc?
461
- /mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG['CC'])
523
+ /mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG["CC"])
462
524
  end
463
525
 
464
526
  def package_config(package)
@@ -533,18 +595,18 @@ module PKGConfig
533
595
  dldflags = libs(pkg)
534
596
  dldflags = (Shellwords.shellwords(dldflags) -
535
597
  Shellwords.shellwords(libraries))
536
- dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ')
537
- $libs += ' ' + libraries
598
+ dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(" ")
599
+ $libs += " " + libraries
538
600
  if /mswin/ =~ RUBY_PLATFORM
539
- $DLDFLAGS += ' ' + dldflags
601
+ $DLDFLAGS += " " + dldflags
540
602
  else
541
- $LDFLAGS += ' ' + dldflags
603
+ $LDFLAGS += " " + dldflags
542
604
  end
543
- $CFLAGS += ' ' + cflags_only_other(pkg)
605
+ $CFLAGS += " " + cflags_only_other(pkg)
544
606
  if defined?($CXXFLAGS)
545
- $CXXFLAGS += ' ' + cflags_only_other(pkg)
607
+ $CXXFLAGS += " " + cflags_only_other(pkg)
546
608
  end
547
- $INCFLAGS += ' ' + cflags_only_I(pkg)
609
+ $INCFLAGS += " " + cflags_only_I(pkg)
548
610
  end
549
611
  enough_version
550
612
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2012-2019 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright 2012-2020 Sutou Kouhei <kou@cozmixng.org>
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -15,5 +15,5 @@
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
  module PKGConfig
18
- VERSION = "1.3.7"
18
+ VERSION = "1.4.2"
19
19
  end
@@ -17,10 +17,10 @@ class PkgConfigTest < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  def test_exist?
20
- assert(system('pkg-config --exists cairo'))
20
+ assert(system("pkg-config --exists cairo"))
21
21
  assert(@cairo.exist?)
22
22
 
23
- assert(system('pkg-config --exists cairo-png'))
23
+ assert(system("pkg-config --exists cairo-png"))
24
24
  assert(@cairo_png.exist?)
25
25
  end
26
26
 
@@ -36,14 +36,65 @@ class PkgConfigTest < Test::Unit::TestCase
36
36
  assert_pkg_config("cairo-png", ["--cflags-only-I"], @cairo_png.cflags_only_I)
37
37
  end
38
38
 
39
+ def split_lib_flags(libs_command_line)
40
+ @cairo.__send__(:split_lib_flags, libs_command_line)
41
+ end
42
+
43
+ def test_split_libs
44
+ assert_equal([
45
+ "-L/usr/local/Cellar/gtk+3/3.24.10/lib",
46
+ "-L/usr/local/Cellar/pango/1.44.3/lib",
47
+ "-L/usr/local/Cellar/harfbuzz/2.5.3/lib",
48
+ "-L/usr/local/Cellar/gdk-pixbuf/2.38.1_1/lib",
49
+ "-L/usr/local/Cellar/cairo/1.16.0_2/lib",
50
+ "-L/usr/local/Cellar/glib/2.60.6/lib",
51
+ "-L/usr/local/opt/gettext/lib",
52
+ "-lgdk-3",
53
+ "-framework", "Cocoa",
54
+ "-framework", "Carbon",
55
+ "-framework", "CoreGraphics",
56
+ "-lpangocairo-1.0",
57
+ "-lpango-1.0",
58
+ "-lharfbuzz",
59
+ "-lgdk_pixbuf-2.0",
60
+ "-lcairo-gobject",
61
+ "-lcairo",
62
+ "-lgobject-2.0",
63
+ "-lglib-2.0",
64
+ "-lintl"
65
+ ],
66
+ split_lib_flags("-L/usr/local/Cellar/gtk+3/3.24.10/lib " +
67
+ "-L/usr/local/Cellar/pango/1.44.3/lib " +
68
+ "-L/usr/local/Cellar/harfbuzz/2.5.3/lib " +
69
+ "-L/usr/local/Cellar/gdk-pixbuf/2.38.1_1/lib " +
70
+ "-L/usr/local/Cellar/cairo/1.16.0_2/lib " +
71
+ "-L/usr/local/Cellar/glib/2.60.6/lib " +
72
+ "-L/usr/local/opt/gettext/lib " +
73
+ "-lgdk-3 " +
74
+ "-framework Cocoa " +
75
+ "-framework Carbon " +
76
+ "-framework CoreGraphics " +
77
+ "-lpangocairo-1.0 " +
78
+ "-lpango-1.0 " +
79
+ "-lharfbuzz " +
80
+ "-lgdk_pixbuf-2.0 " +
81
+ "-lcairo-gobject " +
82
+ "-lcairo " +
83
+ "-lgobject-2.0 " +
84
+ "-lglib-2.0 " +
85
+ "-lintl"))
86
+ end
87
+
39
88
  def test_libs
40
89
  assert_pkg_config("cairo", ["--libs"], @cairo.libs)
41
90
  assert_pkg_config("cairo-png", ["--libs"], @cairo_png.libs)
91
+ end
42
92
 
93
+ def test_libs_msvc
43
94
  @cairo.msvc_syntax = true
44
95
  result = pkg_config("cairo", "--libs")
45
96
  msvc_result = result.gsub(/-lcairo\b/, "cairo.lib")
46
- msvc_result = msvc_result.gsub(/-L/, '/libpath:')
97
+ msvc_result = msvc_result.gsub(/-L/, "/libpath:")
47
98
  assert_not_equal(msvc_result, result)
48
99
  assert_equal(msvc_result, @cairo.libs)
49
100
  end
@@ -51,10 +102,12 @@ class PkgConfigTest < Test::Unit::TestCase
51
102
  def test_libs_only_l
52
103
  assert_pkg_config("cairo", ["--libs-only-l"], @cairo.libs_only_l)
53
104
  assert_pkg_config("cairo-png", ["--libs-only-l"], @cairo_png.libs_only_l)
105
+ end
54
106
 
107
+ def test_libs_only_l_msvc
55
108
  @cairo_png.msvc_syntax = true
56
109
  result = pkg_config("cairo-png", "--libs-only-l")
57
- msvc_result = result.gsub(/-l(cairo|png[0-9]+|z)\b/, '\1.lib')
110
+ msvc_result = result.gsub(/-l(cairo|png[0-9]+|z)\b/, "\\1.lib")
58
111
  assert_not_equal(msvc_result, result)
59
112
  assert_equal(msvc_result, @cairo_png.libs_only_l)
60
113
  end
@@ -62,10 +115,12 @@ class PkgConfigTest < Test::Unit::TestCase
62
115
  def test_libs_only_L
63
116
  assert_pkg_config("cairo", ["--libs-only-L"], @cairo.libs_only_L)
64
117
  assert_pkg_config("cairo-png", ["--libs-only-L"], @cairo_png.libs_only_L)
118
+ end
65
119
 
120
+ def test_libs_only_L_msvc
66
121
  @cairo_png.msvc_syntax = true
67
122
  result = pkg_config("cairo-png", "--libs-only-L")
68
- msvc_result = result.gsub(/-L/, '/libpath:')
123
+ msvc_result = result.gsub(/-L/, "/libpath:")
69
124
  assert_not_equal(msvc_result, result)
70
125
  assert_equal(msvc_result, @cairo_png.libs_only_L)
71
126
  end
@@ -112,7 +167,7 @@ class PkgConfigTest < Test::Unit::TestCase
112
167
  private
113
168
  def pkg_config(package, *args)
114
169
  args.unshift("--define-variable=libdir=#{@custom_libdir}")
115
- args = args.collect {|arg| arg.dump}.join(' ')
170
+ args = args.collect {|arg| arg.dump}.join(" ")
116
171
  `pkg-config #{args} #{package}`.strip
117
172
  end
118
173
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkg-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-17 00:00:00.000000000 Z
11
+ date: 2020-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -69,7 +69,7 @@ files:
69
69
  - lib/pkg-config/version.rb
70
70
  - test/run-test.rb
71
71
  - test/test_pkg_config.rb
72
- homepage: https://github.com/ruby-gnome2/pkg-config
72
+ homepage: https://github.com/ruby-gnome/pkg-config
73
73
  licenses:
74
74
  - LGPLv2+
75
75
  metadata:
@@ -89,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.7.6
92
+ rubygems_version: 3.2.0.rc.1
94
93
  signing_key:
95
94
  specification_version: 4
96
95
  summary: A pkg-config implementation for Ruby