pkg-config 1.3.8 → 1.4.3

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: a47d4bf798e1d6eb5ad3c16fad3ab29dead0f05b2d41e39d98ecb3b3642ac6ea
4
- data.tar.gz: 3ca7a21d13ffba40247e65134cbac57a07690c69312898af8e29fd5394616293
3
+ metadata.gz: de5fd5654e9bb6bcd643ec49f1c3a5e4dffeb8741663c7c5bcb1138bffcf2bfb
4
+ data.tar.gz: e9ade52de5043ccc219d0f5bcf0083048db0ac10cb5f022df7497f845793711a
5
5
  SHA512:
6
- metadata.gz: 21d73b0dd4803571c903e01410c1d199297af2d3c17a5254197511285f1f1807875c70d819e06cc1b28a6158c715111be694aae997799432af1eb4c41e657aaf
7
- data.tar.gz: 31a9e5bae18a521b65c6ba3b82cffb3197cd076e0318682b44b2f71c65dbd80fe40369ba09125ed3a4b2ad2ce1b9c39a11237922e798583fe94ed060bb329e06
6
+ metadata.gz: 345270f9e96221baed66995429b561c8e0264a65802846abf3d3aaf5be5cd489060dcfa3c6ff4cb9ca5539e0b3e3cb21fd01343d47bac60ee980ab37ae7c0d3d
7
+ data.tar.gz: 7a16605e05c797c5666a9005bdb75554afffe9fba4c36097e1378c1a5f735be215c4c643ecb64fa516780f8ba7f004ca7c606bf31e8a00dfb84e993e23699d7b
data/NEWS CHANGED
@@ -1,5 +1,41 @@
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
+
3
39
  == 1.3.8 - 2019-08-13
4
40
 
5
41
  === 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,17 +15,22 @@
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
28
+ class Error < StandardError
29
+ end
30
+
31
+ class NotFoundError < Error
32
+ end
33
+
29
34
  SEPARATOR = File::PATH_SEPARATOR
30
35
 
31
36
  class << self
@@ -122,6 +127,7 @@ class PackageConfig
122
127
  def compute_native_pkg_config_prefix
123
128
  pkg_config = native_pkg_config
124
129
  return nil unless pkg_config.absolute?
130
+ return nil unless pkg_config.exist?
125
131
 
126
132
  pkg_config_prefix = pkg_config.parent.parent
127
133
  if File::ALT_SEPARATOR
@@ -134,10 +140,19 @@ class PackageConfig
134
140
  end
135
141
  end
136
142
 
143
+ attr_reader :name
137
144
  attr_reader :paths
138
145
  attr_accessor :msvc_syntax
139
146
  def initialize(name, options={})
140
- @name = name
147
+ if Pathname(name).absolute?
148
+ @pc_path = name
149
+ @path_position = 0
150
+ @name = File.basename(@pc_path, ".*")
151
+ else
152
+ @pc_path = nil
153
+ @path_position = nil
154
+ @name = name
155
+ end
141
156
  @options = options
142
157
  path = @options[:path] || ENV["PKG_CONFIG_PATH"]
143
158
  @paths = [path, guess_default_path].compact.join(SEPARATOR).split(SEPARATOR)
@@ -220,29 +235,63 @@ class PackageConfig
220
235
  end
221
236
 
222
237
  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)
238
+ if @pc_path
239
+ return @pc_path if File.exist?(@pc_path)
240
+ else
241
+ @paths.each_with_index do |path, i|
242
+ _pc_path = File.join(path, "#{@name}.pc")
243
+ if File.exist?(_pc_path)
244
+ @path_position = i + 1
245
+ return _pc_path
246
+ end
247
+ end
226
248
  end
227
249
  nil
228
250
  end
229
251
 
252
+ protected
253
+ def path_position
254
+ @path_position
255
+ end
256
+
257
+ def collect_requires(processed_packages={}, &block)
258
+ packages = []
259
+ targets = yield(self)
260
+ targets.each do |name|
261
+ next if processed_packages.key?(name)
262
+ package = self.class.new(name, @options)
263
+ processed_packages[name] = package
264
+ packages << package
265
+ packages.concat(package.collect_requires(processed_packages, &block))
266
+ end
267
+ packages_without_self = packages.reject do |package|
268
+ package.name == @name
269
+ end
270
+ packages_without_self.uniq do |package|
271
+ package.name
272
+ end
273
+ end
274
+
230
275
  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
276
+ def sort_packages(packages)
277
+ packages.sort_by.with_index do |package, i|
278
+ [package.path_position, i]
235
279
  end
236
- cflags_set += required_packages.collect do |package|
237
- self.class.new(package, @options).cflags
280
+ end
281
+
282
+ def collect_cflags
283
+ target_packages = sort_packages([self, *all_required_packages])
284
+ cflags_set = []
285
+ target_packages.each do |package|
286
+ cflags_set << package.declaration("Cflags")
238
287
  end
239
288
  all_cflags = normalize_cflags(Shellwords.split(cflags_set.join(" ")))
240
289
  path_flags, other_flags = all_cflags.partition {|flag| /\A-I/ =~ flag}
241
290
  path_flags = normalize_path_flags(path_flags, "-I")
242
- path_flags = remove_duplicated_include_paths(path_flags)
243
291
  path_flags = path_flags.reject do |flag|
244
292
  flag == "-I/usr/include"
245
293
  end
294
+ path_flags = path_flags.uniq
246
295
  if @msvc_syntax
247
296
  path_flags = path_flags.collect do |flag|
248
297
  flag.gsub(/\A-I/, "/I")
@@ -284,21 +333,19 @@ class PackageConfig
284
333
  normalized_cflags
285
334
  end
286
335
 
287
- def remove_duplicated_include_paths(path_flags)
288
- path_flags.uniq
289
- end
290
-
291
336
  def collect_libs
292
- all_libs = required_packages.collect do |package|
293
- self.class.new(package, @options).libs
337
+ target_packages = sort_packages(required_packages + [self])
338
+ libs_set = []
339
+ target_packages.each do |package|
340
+ libs_set << package.declaration("Libs")
294
341
  end
295
- all_libs = [declaration("Libs")] + all_libs
296
- all_flags = split_lib_flags(all_libs.join(" "))
342
+ all_flags = split_lib_flags(libs_set.join(" "))
297
343
  path_flags, other_flags = all_flags.partition {|flag| /\A-L/ =~ flag}
298
344
  path_flags = normalize_path_flags(path_flags, "-L")
299
345
  path_flags = path_flags.reject do |flag|
300
346
  /\A-L\/usr\/lib(?:64|x32)?\z/ =~ flag
301
347
  end
348
+ path_flags = path_flags.uniq
302
349
  if @msvc_syntax
303
350
  path_flags = path_flags.collect do |flag|
304
351
  flag.gsub(/\A-L/, "/libpath:")
@@ -318,7 +365,7 @@ class PackageConfig
318
365
  all_flags = {}
319
366
  flags = []
320
367
  in_option = false
321
- libs_command_line.gsub(/-([Ll]) /, '\1').split.each do |arg|
368
+ libs_command_line.gsub(/-([Ll]) /, "\\1").split.each do |arg|
322
369
  if in_option
323
370
  flags << arg
324
371
  in_option = false
@@ -339,12 +386,12 @@ class PackageConfig
339
386
 
340
387
  IDENTIFIER_RE = /[a-zA-Z\d_\.]+/
341
388
  def parse_pc
342
- raise ".pc for #{@name} doesn't exist." unless exist?
389
+ raise NotFoundError ".pc for #{@name} doesn't exist." unless exist?
343
390
  @variables = {}
344
391
  @declarations = {}
345
392
  File.open(pc_path) do |input|
346
393
  input.each_line do |line|
347
- line = line.gsub(/#.*/, '').strip
394
+ line = line.gsub(/#.*/, "").strip
348
395
  next if line.empty?
349
396
  case line
350
397
  when /^(#{IDENTIFIER_RE})=/
@@ -358,7 +405,7 @@ class PackageConfig
358
405
 
359
406
  def parse_requires(requires)
360
407
  return [] if requires.nil?
361
- requires_without_version = requires.gsub(/[<>]?=\s*[\d.a-zA-Z_-]+\s*/, '')
408
+ requires_without_version = requires.gsub(/[<>]?=\s*[\d.a-zA-Z_-]+\s*/, "")
362
409
  requires_without_version.split(/[,\s]+/)
363
410
  end
364
411
 
@@ -398,6 +445,11 @@ class PackageConfig
398
445
  "/opt/X11/lib/pkgconfig",
399
446
  "/usr/share/pkgconfig",
400
447
  ]
448
+ if Object.const_defined?(:RubyInstaller)
449
+ mingw_bin_path = RubyInstaller::Runtime.msys2_installation.mingw_bin_path
450
+ mingw_pkgconfig_path = Pathname.new(mingw_bin_path) + "../lib/pkgconfig"
451
+ default_paths.unshift(mingw_pkgconfig_path.cleanpath.to_s)
452
+ end
401
453
  libdir = ENV["PKG_CONFIG_LIBDIR"]
402
454
  default_paths.unshift(libdir) if libdir
403
455
 
@@ -426,14 +478,13 @@ class PackageConfig
426
478
  homebrew_repository_candidates << pkg_config_prefix + "Homebrew"
427
479
  homebrew_repository_candidates << pkg_config_prefix
428
480
  end
429
- else
430
- brew = self.class.__send__(:search_executable_from_path, "brew")
431
- if brew
432
- homebrew_repository = `brew --repository`.chomp
433
- homebrew_repository_candidates << Pathname(homebrew_repository)
434
- end
435
481
  end
436
- homebrew_repository_candidates.each do |candidate|
482
+ brew = self.class.__send__(:search_executable_from_path, "brew")
483
+ if brew
484
+ homebrew_repository = `brew --repository`.chomp
485
+ homebrew_repository_candidates << Pathname(homebrew_repository)
486
+ end
487
+ homebrew_repository_candidates.uniq.each do |candidate|
437
488
  path = candidate + "Library/Homebrew/os/mac/pkgconfig/#{mac_os_version}"
438
489
  paths << path.to_s if path.exist?
439
490
  end
@@ -443,21 +494,15 @@ class PackageConfig
443
494
  end
444
495
 
445
496
  def required_packages
446
- requires.reject do |package|
447
- @name == package
448
- end.uniq
449
- end
450
-
451
- def private_required_packages
452
- requires_private.reject do |package|
453
- @name == package
454
- end.uniq
497
+ collect_requires do |package|
498
+ package.requires
499
+ end
455
500
  end
456
501
 
457
502
  def all_required_packages
458
- (requires_private + requires.reverse).reject do |package|
459
- @name == package
460
- end.uniq
503
+ collect_requires do |package|
504
+ package.requires_private + package.requires
505
+ end
461
506
  end
462
507
 
463
508
  def normalize_paths(paths)
@@ -481,7 +526,7 @@ module PKGConfig
481
526
  end
482
527
 
483
528
  def msvc?
484
- /mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG['CC'])
529
+ /mswin/.match(RUBY_PLATFORM) and /^cl\b/.match(RbConfig::CONFIG["CC"])
485
530
  end
486
531
 
487
532
  def package_config(package)
@@ -556,18 +601,18 @@ module PKGConfig
556
601
  dldflags = libs(pkg)
557
602
  dldflags = (Shellwords.shellwords(dldflags) -
558
603
  Shellwords.shellwords(libraries))
559
- dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ')
560
- $libs += ' ' + libraries
604
+ dldflags = dldflags.map {|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(" ")
605
+ $libs += " " + libraries
561
606
  if /mswin/ =~ RUBY_PLATFORM
562
- $DLDFLAGS += ' ' + dldflags
607
+ $DLDFLAGS += " " + dldflags
563
608
  else
564
- $LDFLAGS += ' ' + dldflags
609
+ $LDFLAGS += " " + dldflags
565
610
  end
566
- $CFLAGS += ' ' + cflags_only_other(pkg)
611
+ $CFLAGS += " " + cflags_only_other(pkg)
567
612
  if defined?($CXXFLAGS)
568
- $CXXFLAGS += ' ' + cflags_only_other(pkg)
613
+ $CXXFLAGS += " " + cflags_only_other(pkg)
569
614
  end
570
- $INCFLAGS += ' ' + cflags_only_I(pkg)
615
+ $INCFLAGS += " " + cflags_only_I(pkg)
571
616
  end
572
617
  enough_version
573
618
  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.8"
18
+ VERSION = "1.4.3"
19
19
  end
@@ -6,9 +6,6 @@ base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
6
  lib_dir = File.join(base_dir, "lib")
7
7
  test_dir = File.join(base_dir, "test")
8
8
 
9
- ENV["BUNDLE_GEMFILE"] ||= File.join(base_dir, "Gemfile")
10
- require "bundler/setup"
11
-
12
9
  require 'test-unit'
13
10
 
14
11
  $LOAD_PATH.unshift(lib_dir)
@@ -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
 
@@ -94,7 +94,7 @@ class PkgConfigTest < Test::Unit::TestCase
94
94
  @cairo.msvc_syntax = true
95
95
  result = pkg_config("cairo", "--libs")
96
96
  msvc_result = result.gsub(/-lcairo\b/, "cairo.lib")
97
- msvc_result = msvc_result.gsub(/-L/, '/libpath:')
97
+ msvc_result = msvc_result.gsub(/-L/, "/libpath:")
98
98
  assert_not_equal(msvc_result, result)
99
99
  assert_equal(msvc_result, @cairo.libs)
100
100
  end
@@ -107,7 +107,7 @@ class PkgConfigTest < Test::Unit::TestCase
107
107
  def test_libs_only_l_msvc
108
108
  @cairo_png.msvc_syntax = true
109
109
  result = pkg_config("cairo-png", "--libs-only-l")
110
- 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")
111
111
  assert_not_equal(msvc_result, result)
112
112
  assert_equal(msvc_result, @cairo_png.libs_only_l)
113
113
  end
@@ -120,7 +120,7 @@ class PkgConfigTest < Test::Unit::TestCase
120
120
  def test_libs_only_L_msvc
121
121
  @cairo_png.msvc_syntax = true
122
122
  result = pkg_config("cairo-png", "--libs-only-L")
123
- msvc_result = result.gsub(/-L/, '/libpath:')
123
+ msvc_result = result.gsub(/-L/, "/libpath:")
124
124
  assert_not_equal(msvc_result, result)
125
125
  assert_equal(msvc_result, @cairo_png.libs_only_L)
126
126
  end
@@ -167,7 +167,7 @@ class PkgConfigTest < Test::Unit::TestCase
167
167
  private
168
168
  def pkg_config(package, *args)
169
169
  args.unshift("--define-variable=libdir=#{@custom_libdir}")
170
- args = args.collect {|arg| arg.dump}.join(' ')
170
+ args = args.collect {|arg| arg.dump}.join(" ")
171
171
  `pkg-config #{args} #{package}`.strip
172
172
  end
173
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.8
4
+ version: 1.4.3
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-08-13 00:00:00.000000000 Z
11
+ date: 2020-09-14 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.2
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