Class: Xcode::Builder::XcodebuildParser

Inherits:
Object
  • Object
show all
Includes:
TerminalOutput
Defined in:
lib/xcode/builder/build_parser.rb

Constant Summary collapse

KNOWN_STEPS =
[
  'Clean.Remove',
  'Build',
  'Check',
  'ProcessInfoPlistFile',
  'CpResource',
  'ProcessPCH', 
  'CompileC', 
  'Ld', 
  'CreateUniversalBinary',
  'GenerateDSYMFile',
  'CopyPNGFile',
  'CompileXIB',
  'CopyStringsFile',
  'ProcessProductPackaging',
  'Touch',
  'CodeSign',
  'Libtool',
  'PhaseScriptExecution',
  'Validate'
  # 'SymLink'
]

Constants included from TerminalOutput

TerminalOutput::LEVELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TerminalOutput

#color_output=, #color_output?, #format_lhs, included, #log_level, log_level=, #print, #print_input, #print_output, #print_system, #print_task, #puts, terminal_supports_colors?

Constructor Details

#initializeXcodebuildParser

Returns a new instance of XcodebuildParser.



33
34
35
36
37
38
# File 'lib/xcode/builder/build_parser.rb', line 33

def initialize
  @last_good_index = 0
  @last_step_name = nil
  @last_step_params = []
  @suppress_warnings = false
end

Instance Attribute Details

#suppress_warningsObject

Returns the value of attribute suppress_warnings.



8
9
10
# File 'lib/xcode/builder/build_parser.rb', line 8

def suppress_warnings
  @suppress_warnings
end

Instance Method Details

#<<(piped_row) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/xcode/builder/build_parser.rb', line 43

def << piped_row
  piped_row = piped_row.force_encoding("UTF-8").gsub(/\n$/,'')

  if piped_row=~/^\s+/
    @last_step_params << piped_row
  else
    if piped_row=~/\=\=\=\s/
      # This is just an info
    elsif piped_row=~/Build settings from command line/
      # Ignore
    elsif piped_row=~/Check dependencies/
      # Ignore
    elsif piped_row==''
      # Empty line, ignore
    elsif piped_row=~/[A-Z]+\s\=\s/
      # some build env info
    elsif piped_row=~/^warning:/i
      log_xcode "#{piped_row.gsub(/^warning:\s/i,'')}", :warning
    elsif piped_row=~/^\[BEROR\](.*)/
      log_xcode "#{$1}", :error            
    elsif piped_row=~/^ld: warning:/i
      log_xcode "#{piped_row.gsub(/^ld: warning:\s/i,'')}", :warning       
    elsif piped_row=~/Unable to validate your application/
      log_xcode piped_row, :warning
      # print "\n warning: ", :yellow
      # print " #{piped_row}"
    elsif piped_row=~/bin\/libtool\:\s(.*)/
      log_xcode $1, :warning, :libtool

    # Pick up success
    elsif piped_row=~/\*\*\s.*SUCCEEDED\s\*\*/
      # yay, all good
      print "\n"

    elsif piped_row=~/^cp\s\-R/
      # Ignore 

    elsif piped_row=~/\sdeclared\shere$/
      # Ignore 

    # Pick up warnings/notes/errors
    elsif piped_row=~/^(.*:\d+:\d+): (\w+): (.*)$/
      # This is a warning/note/error
      type = $2.downcase
      level = :info
      if type=="warning"
        level = :warning
      elsif type=="error"
        level = :error
      end
      
      if (level==:warning or level==:note) and @suppress_warnings
        # ignore
      else
        log_xcode $3, level
        log_xcode "  at #{$1}", level
        # print "\n#{level.rjust(8)}: ", color
        # print $3
        # print "\n          at #{$1}"
      end

    # If there were warnings, this will be output
    elsif piped_row=~/\d+\swarning(s?)\sgenerated\./
      # TODO: is this safe to ignore?


    # This might be a build step 
    else
      step = piped_row.scan(/^(\S+)/).first.first
      if KNOWN_STEPS.include? step
        unless @last_step_name==step
          # print "\n" unless @last_step_name.nil?
          @last_step_name = step
          @last_step_params = []
          # print "#{"run".rjust(8)}: ", :green
          # print "#{step} "
        end
        unless @need_cr
          log_xcode step+" ", :info, false
        end
        print '.', :green
      else
        # Echo unknown output
        unless @suppress_warnings
          log_xcode piped_row, :info
          # print "\n        > ", :blue
          # print "#{piped_row}"
        end
      end
    end
  end
rescue => e
  puts "Failed to parse '#{piped_row}' because #{e}", :red
end

#closeObject



40
41
# File 'lib/xcode/builder/build_parser.rb', line 40

def close
end

#log_xcode(message, level, cr = true, task = :xcode) ⇒ Object

<<



138
139
140
141
142
# File 'lib/xcode/builder/build_parser.rb', line 138

def log_xcode message, level, cr=true, task = :xcode
  print "\n" if @need_cr
  print_task task, message, level, cr
  @need_cr = !cr
end