class Gem::Ext::CargoBuilder::LinkFlagConverter

将 Ruby 链接标志转换为 cargo 可理解的内容

常量

FILTERED_PATTERNS

公共类方法

convert(arg) 点击切换源代码
# File rubygems/ext/cargo_builder/link_flag_converter.rb, line 10
def self.convert(arg)
  return [] if FILTERED_PATTERNS.any? {|p| p.match?(arg) }

  case arg.chomp
  when /^-L\s*(.+)$/
    ["-L", "native=#{$1}"]
  when /^--library=(\w+\S+)$/, /^-l\s*(\w+\S+)$/
    ["-l", $1]
  when /^-l\s*([^:\s])+/ # -lfoo, but not -l:libfoo.a
    ["-l", $1]
  when /^-F\s*(.*)$/
    ["-l", "framework=#{$1}"]
  else
    ["-C", "link-args=#{arg}"]
  end
end