Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions lib/pkg-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions test/test-pkg-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down