pkg-config 1.6.3 → 1.6.5

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: 53a3d87cdf57d9d78a5458eb6743ae3dd175e0760284c0ed6b885149ef3ebd53
4
- data.tar.gz: d6c27bc63a6e3191ee88b53387428cfedbced08104f8d5c71a68f6deb75a82a8
3
+ metadata.gz: 0a4a54b361004652d84f50b2d4f2cfaaf447ffd2fc97c44490ed7c7751763721
4
+ data.tar.gz: 3ae709328a845092794bca9d2753e5d7867170b5832d7f85023c0692ec1e8178
5
5
  SHA512:
6
- metadata.gz: 488102c7ff0f8d6bfb6ba89d28a3db6bc98a1ecf4bcfa78df1d04020b1fede9e4517549830214fcd941832fe2db878a643951b7943b4d2edfee9d59a0777fd89
7
- data.tar.gz: b3d212d31f385b43dbf5e24d2632fc99b0523d1b1f1defc458daceae11bb4021ecfc9a3fc34e7609c3fd94638c970dc9f34e6c6f4abee14c2f1e33a6f9dc4da3
6
+ metadata.gz: 748e225bef3d590013e8bf3efcc2c0422d6d2a802a65f104f15feebd01bcf526d29b0909b922d444b261c5354a2b6101d549871867f7e5bb95c0bd01da12ba48
7
+ data.tar.gz: 0203aee2b542ca94a0dbf18e7515ff73339b3910931eeb209d19e791f30a63d8a70bf36c500271f68b73a2045abfc60fe6c0a5727e265df01843c893c95e7936
data/NEWS.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # NEWS
2
2
 
3
+ ## 1.6.5 - 2025-12-01
4
+
5
+ ### Improvements
6
+
7
+ * Improved pkgconf compatibility: Removed duplicated `-D`/`-W` flags.
8
+ * [ruby-gnome/pkg-config#43](https://github.com/ruby-gnome/pkg-config/issues/43)
9
+ * Patch by takuya kodama
10
+
11
+ ### Thanks
12
+
13
+ * takuya kodama
14
+
15
+ ## 1.6.4 - 2025-09-03
16
+
17
+ ### Improvements
18
+
19
+ * Added support for continuous line.
20
+ * [ruby-gnome/ruby-gnome#1686](https://github.com/ruby-gnome/ruby-gnome/issues/1686)
21
+ * Reported by Vincent Garrigues
22
+
23
+ ### Thanks
24
+
25
+ * Vincent Garrigues
26
+
3
27
  ## 1.6.3 - 2025-08-27
4
28
 
5
29
  ### Improvements
data/lib/pkg-config.rb CHANGED
@@ -19,7 +19,7 @@ require "rbconfig"
19
19
  require "shellwords"
20
20
 
21
21
  module PKGConfig
22
- VERSION = "1.6.3"
22
+ VERSION = "1.6.5"
23
23
 
24
24
  @@paths = []
25
25
  @@override_variables = {}
@@ -545,6 +545,7 @@ class PackageConfig
545
545
  flag.gsub(/\A-I/, "/I")
546
546
  end
547
547
  end
548
+ other_flags = merge_back_cflags(other_flags)
548
549
  [path_flags, other_flags]
549
550
  end
550
551
 
@@ -579,6 +580,32 @@ class PackageConfig
579
580
  normalized_cflags
580
581
  end
581
582
 
583
+ # Implementing behavior compatible with pkgconf's pkgconf_fragment_copy().
584
+ # This is not a complete reproduction yet, but the goal is to stay compatible.
585
+ # https://github.com/pkgconf/pkgconf/blob/pkgconf-2.5.1/libpkgconf/fragment.c#L381-L416
586
+ def merge_back_cflags(cflags)
587
+ merge_backed_cflags = []
588
+ cflags.each do |cflag|
589
+ if mergeable_flag?(cflag)
590
+ # NOTE: This may be slow because this checks merge_back_cflags N times
591
+ # (where N is the number of mergeable flags).
592
+ merge_backed_cflags.delete(cflag)
593
+ end
594
+ merge_backed_cflags << cflag
595
+ end
596
+ merge_backed_cflags
597
+ end
598
+
599
+ def mergeable_flag?(flag)
600
+ return false unless flag.start_with?("-")
601
+ return true if flag.start_with?("-D")
602
+ if flag.start_with?("-W")
603
+ return false if flag.start_with?("-Wa,", "-Wl,", "-Wp,")
604
+ return true
605
+ end
606
+ false
607
+ end
608
+
582
609
  def collect_libs
583
610
  target_packages = [*required_packages, self]
584
611
  libs_set = []
@@ -637,13 +664,18 @@ class PackageConfig
637
664
  @variables = {}
638
665
  @declarations = {}
639
666
  File.open(pc_path) do |input|
667
+ current_line = +""
640
668
  input.each_line do |line|
641
669
  if line.dup.force_encoding("UTF-8").valid_encoding?
642
670
  line.force_encoding("UTF-8")
643
671
  end
644
672
  line = line.gsub(/#.*/, "").strip
645
- next if line.empty?
646
- case line
673
+ if line.end_with?("\\")
674
+ current_line += line[0..-2]
675
+ next
676
+ end
677
+ current_line += line
678
+ case current_line
647
679
  when /^(#{IDENTIFIER_RE})\s*=\s*/
648
680
  match = Regexp.last_match
649
681
  @variables[match[1]] = match.post_match.strip
@@ -651,6 +683,7 @@ class PackageConfig
651
683
  match = Regexp.last_match
652
684
  @declarations[match[1]] = match.post_match.strip
653
685
  end
686
+ current_line = +""
654
687
  end
655
688
  end
656
689
  end
@@ -1,4 +1,6 @@
1
1
  require "mkmf"
2
+ require "tempfile"
3
+
2
4
  require "pkg-config"
3
5
 
4
6
  class PkgConfigTest < Test::Unit::TestCase
@@ -227,6 +229,56 @@ class PkgConfigTest < Test::Unit::TestCase
227
229
  $configure_args = original_configure_args
228
230
  end
229
231
 
232
+ sub_test_case("#parse_pc") do
233
+ def parse_pc(content)
234
+ Tempfile.create(["pkg-config", ".pc"]) do |file|
235
+ file.puts(content)
236
+ file.close
237
+ package_config = PackageConfig.new(file.path)
238
+ package_config.__send__(:parse_pc)
239
+ [
240
+ package_config.instance_variable_get(:@variables),
241
+ package_config.instance_variable_get(:@declarations),
242
+ ]
243
+ end
244
+ end
245
+
246
+ def test_continuous_line
247
+ assert_equal([
248
+ {
249
+ "prefix" => "/usr/local",
250
+ "libdir" => "/usr/local/lib",
251
+ "includedir" => "/usr/local/include",
252
+ },
253
+ {
254
+ "Name" => "my-package",
255
+ "Description" => "This is my package",
256
+ "Version" => "1.0.0",
257
+ "Requires" => "glib-2.0 >= 2.72 gobject-2.0 >= 2.72",
258
+ "Requires.private" => "gio-2.0 >= 2.72 " +
259
+ " cairo",
260
+ "Libs" => "-L${libdir} -lmy-package",
261
+ "Cflags" => "-I${includedir}/my-package",
262
+ },
263
+ ],
264
+ parse_pc(<<-PC))
265
+ prefix=/usr/local
266
+ libdir=/usr/local/lib
267
+ includedir=/usr/local/include
268
+
269
+ Name: my-package
270
+ Description: This is my package
271
+ Version: 1.0.0
272
+ Requires: glib-2.0 >= 2.72 gobject-2.0 >= 2.72
273
+ Requires.private: gio-2.0 >= 2.72 \
274
+ cairo
275
+
276
+ Libs: -L${libdir} -lmy-package
277
+ Cflags: -I${includedir}/my-package
278
+ PC
279
+ end
280
+ end
281
+
230
282
  sub_test_case("#parse_requires") do
231
283
  def parse_requires(requires)
232
284
  @glib.__send__(:parse_requires, requires)
@@ -262,4 +314,34 @@ class PkgConfigTest < Test::Unit::TestCase
262
314
  parse_requires("fribidi = 1.0"))
263
315
  end
264
316
  end
317
+
318
+ sub_test_case("#merge_back_cflags") do
319
+ def merge_back_cflags(cflags)
320
+ @glib.__send__(:merge_back_cflags, cflags)
321
+ end
322
+
323
+ def test_d
324
+ assert_equal(["-DFOO"],
325
+ merge_back_cflags(["-DFOO", "-DFOO"]))
326
+ end
327
+
328
+ def test_w
329
+ assert_equal(["-Wno-unknown-warning-option"],
330
+ merge_back_cflags(["-Wno-unknown-warning-option",
331
+ "-Wno-unknown-warning-option"]))
332
+ end
333
+
334
+ def test_wa_wl_wp
335
+ assert_equal(["-Wa,--noexecstack", "-Wl,--as-needed", "-Wp,-DFOO",
336
+ "-Wa,--noexecstack", "-Wl,--as-needed", "-Wp,-DFOO"],
337
+ merge_back_cflags(["-Wa,--noexecstack", "-Wl,--as-needed", "-Wp,-DFOO",
338
+ "-Wa,--noexecstack", "-Wl,--as-needed", "-Wp,-DFOO"]))
339
+ end
340
+
341
+ def test_mixed
342
+ assert_equal(["-Wl,--as-needed", "-DFOO", "-Wall", "-Wl,--as-needed"],
343
+ merge_back_cflags(["-DFOO", "-Wall", "-Wl,--as-needed",
344
+ "-DFOO", "-Wall", "-Wl,--as-needed"]))
345
+ end
346
+ end
265
347
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkg-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sutou Kouhei
@@ -29,7 +29,7 @@ homepage: https://github.com/ruby-gnome/pkg-config
29
29
  licenses:
30
30
  - LGPLv2+
31
31
  metadata:
32
- msys2_mingw_dependencies: pkg-config
32
+ msys2_mingw_dependencies: pkgconf
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib