Module: Xcodeproj::Config::OtherLinkerFlagsParser

Defined in:
lib/xcodeproj/config/other_linker_flags_parser.rb

Overview

Parses other linker flags values.

Class Method Summary collapse

Class Method Details

.parse(flags) ⇒ Hash{Symbol, Array[String]}

Returns Splits the given other linker flags value by type.

Parameters:

  • flags (String, Array)

    The other linker flags value.

Returns:

  • (Hash{Symbol, Array[String]})

    Splits the given other linker flags value by type.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/xcodeproj/config/other_linker_flags_parser.rb', line 14

def self.parse(flags)
  result = {
    :frameworks => [],
    :weak_frameworks => [],
    :libraries => [],
    :simple => [],
    :force_load => [],
  }

  key = nil
  if flags.is_a? String
    flags = split(flags)
  end
  flags.each do |token|
    case token
    when '-framework'
      key = :frameworks
    when '-weak_framework'
      key = :weak_frameworks
    when '-l'
      key = :libraries
    when '-force_load'
      key = :force_load
    else
      if key
        result[key] << token
        key = nil
      else
        result[:simple] << token
      end
    end
  end
  result
end

.split(flags) ⇒ Array<String>

Returns Split the given other linker flags value, taking into account quoting and the fact that the `-l` flag might omit the space.

Parameters:

  • flags (String)

    The other linker flags value.

Returns:

  • (Array<String>)

    Split the given other linker flags value, taking into account quoting and the fact that the `-l` flag might omit the space.


57
58
59
60
61
62
63
64
65
# File 'lib/xcodeproj/config/other_linker_flags_parser.rb', line 57

def self.split(flags)
  flags.strip.shellsplit.flat_map do |string|
    if string =~ /\A-l.+/
      ['-l', string[2..-1]]
    else
      string
    end
  end
end