diff --git a/lib/pkg-config.rb b/lib/pkg-config.rb index 542d67c..149b1bd 100644 --- a/lib/pkg-config.rb +++ b/lib/pkg-config.rb @@ -620,7 +620,6 @@ def collect_libs flags = flags.reject do |flag| /\A-L\/usr\/lib(?:64|x32)?\z/ =~ flag end - flags = flags.uniq if @msvc_syntax flags = flags.collect do |flag| if flag.start_with?("-L") @@ -638,22 +637,12 @@ def collect_libs def split_lib_flags(libs_command_line) all_flags = {} flags = [] - in_option = false libs_command_line.gsub(/-([Ll]) /, "\\1").split.each do |arg| - if in_option - flags << arg - in_option = false - else - case arg - when /-[lL]/ - next if all_flags.key?(arg) - all_flags[arg] = true - flags << arg - in_option = true - else - flags << arg - end + if /\A-[lL]/ =~ arg + next if all_flags.key?(arg) + all_flags[arg] = true end + flags << arg end flags end diff --git a/test/test-pkg-config.rb b/test/test-pkg-config.rb index 67893b3..d0711f5 100644 --- a/test/test-pkg-config.rb +++ b/test/test-pkg-config.rb @@ -46,6 +46,22 @@ def split_lib_flags(libs_command_line) @glib.__send__(:split_lib_flags, libs_command_line) end + def test_split_preserves_repeated_multiargument_options + assert_equal([ + "-framework", "Cocoa", + "-framework", "Carbon", + "-Xlinker", "--as-needed", + "-Xlinker", "--no-as-needed", + "-Wl,--start-group", "-lfoo", "-Wl,--end-group", + "-Wl,--start-group", "-lbar", "-Wl,--end-group", + ], + split_lib_flags("-framework Cocoa -framework Carbon " + + "-Xlinker --as-needed " + + "-Xlinker --no-as-needed " + + "-Wl,--start-group -lfoo -Wl,--end-group " + + "-Wl,--start-group -lbar -Wl,--end-group")) + end + def test_split_libs assert_equal([ "-L/usr/local/Cellar/gtk+3/3.24.10/lib",