bake-toolkit 2.32.0 → 2.33.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,30 @@
1
- require 'bake/toolchain/errorparser/error_parser'
2
-
3
- module Bake
4
- class TICompilerErrorParser < ErrorParser
5
-
6
- def initialize()
7
- @error_expression = /\"([^,^\"]+)\", line ([0-9]+)[:0-9]* (catastrophic |fatal )*([A-Za-z]+): (.+)/
8
- end
9
-
10
- def scan_lines(consoleOutput, proj_dir)
11
- res = []
12
- consoleOutputFullnames = ""
13
- consoleOutput[0].each_line do |l|
14
- d = ErrorDesc.new
15
- scan_res = l.gsub(/\r\n?/, "").scan(@error_expression)
16
- if scan_res.length > 0
17
- d.file_name = File.expand_path(scan_res[0][0])
18
- d.line_number = scan_res[0][1].to_i
19
- d.message = scan_res[0][4]
20
- d.severity = get_severity(scan_res[0][3])
21
- l.gsub!(scan_res[0][0],d.file_name)
22
- end
23
- res << d
24
- consoleOutputFullnames << l
25
- end
26
- [res, consoleOutputFullnames]
27
- end
28
-
29
- end
30
- end
1
+ require 'bake/toolchain/errorparser/error_parser'
2
+
3
+ module Bake
4
+ class TICompilerErrorParser < ErrorParser
5
+
6
+ def initialize()
7
+ @error_expression = /\"([^,^\"]+)\", line ([0-9]+)[:0-9]* (catastrophic |fatal )*([A-Za-z]+): (.+)/
8
+ end
9
+
10
+ def scan_lines(consoleOutput, proj_dir)
11
+ res = []
12
+ consoleOutputFullnames = ""
13
+ consoleOutput[0].each_line do |l|
14
+ d = ErrorDesc.new
15
+ scan_res = l.gsub(/\r\n?/, "").scan(@error_expression)
16
+ if scan_res.length > 0
17
+ d.file_name = File.expand_path(scan_res[0][0], proj_dir)
18
+ d.line_number = scan_res[0][1].to_i
19
+ d.message = scan_res[0][4]
20
+ d.severity = get_severity(scan_res[0][3])
21
+ l.gsub!(scan_res[0][0],d.file_name)
22
+ end
23
+ res << d
24
+ consoleOutputFullnames << l
25
+ end
26
+ [res, consoleOutputFullnames]
27
+ end
28
+
29
+ end
30
+ end
@@ -1,6 +1,8 @@
1
1
  require 'bake/libElement'
2
2
  require 'bake/model/metamodel'
3
3
  require 'common/abortException'
4
+ require "multithread/job"
5
+ require "thwait"
4
6
 
5
7
  module Bake
6
8
 
@@ -16,6 +18,10 @@ module Bake
16
18
 
17
19
  class Block
18
20
 
21
+ @@block_counter = 0
22
+ @@delayed_result = true
23
+ @@threads = []
24
+
19
25
  attr_reader :lib_elements, :projectDir, :library, :config, :projectName, :prebuild, :output_dir, :tcs
20
26
  attr_accessor :visited, :inDeps, :result
21
27
 
@@ -73,7 +79,6 @@ module Bake
73
79
  @projectName = config.parent.name
74
80
  @configName = config.name
75
81
  @projectDir = config.get_project_dir
76
- @@block_counter = 0
77
82
  @result = true
78
83
  @tcs = tcs
79
84
 
@@ -99,7 +104,9 @@ module Bake
99
104
  inc = d.split("/")
100
105
  if (inc[0] == "..") # very simple check, but should be okay for 99.9 % of the cases
101
106
  if elem and Bake.options.verbose >= 2
102
- Bake.formatter.printInfo("path starts with \"..\"", elem)
107
+ SyncOut.mutex.synchronize do
108
+ Bake.formatter.printInfo("path starts with \"..\"", elem)
109
+ end
103
110
  end
104
111
  end
105
112
 
@@ -138,9 +145,11 @@ module Bake
138
145
 
139
146
  if warnIfLocal && res.length > 1
140
147
  if elem and Bake.options.verbose >= 2
141
- Bake.formatter.printInfo("#{d} matches several paths:", elem)
142
- puts " #{res[0]} (chosen)"
143
- res[1..-1].each { |r| puts " #{r}" }
148
+ SyncOut.mutex.synchronize do
149
+ Bake.formatter.printInfo("#{d} matches several paths:", elem)
150
+ puts " #{res[0]} (chosen)"
151
+ res[1..-1].each { |r| puts " #{r}" }
152
+ end
144
153
  end
145
154
  end
146
155
 
@@ -159,6 +168,18 @@ module Bake
159
168
  @@block_counter = 0
160
169
  end
161
170
 
171
+ def self.reset_delayed_result
172
+ @@delayed_result = true
173
+ end
174
+
175
+ def self.delayed_result
176
+ @@delayed_result
177
+ end
178
+
179
+ def self.threads
180
+ @@threads
181
+ end
182
+
162
183
  def calcIsBuildBlock
163
184
  @startupSteps ||= []
164
185
 
@@ -207,8 +228,10 @@ module Bake
207
228
  rescue Exception => ex1
208
229
  @result = false
209
230
  if not Bake::IDEInterface.instance.get_abort
210
- Bake.formatter.printError("Error: #{ex1.message}")
211
- puts ex1.backtrace if Bake.options.debug
231
+ SyncOut.mutex.synchronize do
232
+ Bake.formatter.printError("Error: #{ex1.message}")
233
+ puts ex1.backtrace if Bake.options.debug
234
+ end
212
235
  end
213
236
  end
214
237
 
@@ -248,26 +271,88 @@ module Bake
248
271
  return depResult
249
272
  end
250
273
 
274
+ def execute_in_thread(method)
275
+ if method == :execute
276
+ @@mutex.synchronize do
277
+ if @@threads.length == Bake.options.threads
278
+ endedThread = ThreadsWait.new(@@threads).next_wait
279
+ @@threads.delete(endedThread)
280
+ end
281
+ end
282
+ thread = Thread.new() {
283
+
284
+ exceptionOccured = false
285
+ begin
286
+ yield
287
+ exceptionOccured = true
288
+ rescue Bake::SystemCommandFailed => scf # normal compilation error
289
+ rescue SystemExit => exSys
290
+ rescue Exception => ex1
291
+ if not Bake::IDEInterface.instance.get_abort
292
+ SyncOut.mutex.synchronize do
293
+ Bake.formatter.printError("Error: #{ex1.message}")
294
+ puts ex1.backtrace if Bake.options.debug
295
+ end
296
+ end
297
+ end
298
+ if !exceptionOccured
299
+ @result = false
300
+ @@delayed_result = false
301
+ end
302
+ }
303
+ @@mutex.synchronize do
304
+ @@threads << thread
305
+ end
306
+ else
307
+ yield
308
+ end
309
+ raise AbortException.new if Bake::IDEInterface.instance.get_abort
310
+ end
311
+
312
+ def blockAbort?(res)
313
+ ((not res) || !@@delayed_result) and Bake.options.stopOnFirstError or Bake::IDEInterface.instance.get_abort
314
+ end
315
+
251
316
  def callSteps(method)
252
317
 
253
318
  @config.writeEnvVars()
254
319
  Thread.current[:lastCommand] = nil
255
320
 
256
321
  preSteps.each do |step|
322
+ ThreadsWait.all_waits(Blocks::Block::threads)
257
323
  @result = executeStep(step, method) if @result
258
- return false if not @result and Bake.options.stopOnFirstError
324
+ return false if blockAbort?(@result)
259
325
  end unless @prebuild
260
326
 
261
- mainSteps.each do |step|
327
+ threadableSteps = mainSteps.select { |step| method == :execute && (Library === step || Compile === step) }
328
+ nonThreadableSteps = mainSteps.select { |step| method != :execute || !(Library === step || Compile === step) }
329
+
330
+ execute_in_thread(method) {
331
+ threadableSteps.each do |step|
332
+ if !@prebuild || (Library === step)
333
+ Multithread::Jobs.incThread() if Library === step
334
+ begin
335
+ @result = executeStep(step, method) if @result
336
+ ensure
337
+ Multithread::Jobs.decThread() if Library === step
338
+ end
339
+ @@delayed_result &&= @result
340
+ end
341
+ break if blockAbort?(@result)
342
+ end
343
+ } if !threadableSteps.empty?
344
+ nonThreadableSteps.each do |step|
262
345
  if !@prebuild || (Library === step)
346
+ ThreadsWait.all_waits(Blocks::Block::threads)
263
347
  @result = executeStep(step, method) if @result
264
348
  end
265
- return false if not @result and Bake.options.stopOnFirstError
349
+ return false if blockAbort?(@result)
266
350
  end
267
351
 
268
352
  postSteps.each do |step|
353
+ ThreadsWait.all_waits(Blocks::Block::threads)
269
354
  @result = executeStep(step, method) if @result
270
- return false if not @result and Bake.options.stopOnFirstError
355
+ return false if blockAbort?(@result)
271
356
  end unless @prebuild
272
357
 
273
358
  return @result
@@ -276,7 +361,9 @@ module Bake
276
361
  def execute
277
362
  if (@inDeps)
278
363
  if Bake.options.verbose >= 3
279
- Bake.formatter.printWarning("While calculating next config, a circular dependency was found including project #{@projectName} with config #{@configName}", @config)
364
+ SyncOut.mutex.synchronize do
365
+ Bake.formatter.printWarning("While calculating next config, a circular dependency was found including project #{@projectName} with config #{@configName}", @config)
366
+ end
280
367
  end
281
368
  return true
282
369
  end
@@ -287,21 +374,23 @@ module Bake
287
374
  @inDeps = true
288
375
  depResult = callDeps(:execute)
289
376
  @inDeps = false
290
- return false if not depResult and Bake.options.stopOnFirstError
377
+ return false if blockAbort?(depResult)
291
378
 
292
379
  Bake::IDEInterface.instance.set_build_info(@projectName, @configName)
293
380
 
294
- if Bake.options.verbose >= 2 || isBuildBlock? || @prebuild
295
- typeStr = "Building"
296
- if @prebuild
297
- typeStr = "Using"
298
- elsif not isBuildBlock?
299
- typeStr = "Applying"
381
+ SyncOut.mutex.synchronize do
382
+ if Bake.options.verbose >= 2 || isBuildBlock? || @prebuild
383
+ typeStr = "Building"
384
+ if @prebuild
385
+ typeStr = "Using"
386
+ elsif not isBuildBlock?
387
+ typeStr = "Applying"
388
+ end
389
+ Block.inc_block_counter()
390
+ Bake.formatter.printAdditionalInfo "**** #{typeStr} #{Block.block_counter} of #{@@num_projects}: #{@projectName} (#{@configName}) ****"
300
391
  end
301
- Block.inc_block_counter()
302
- Bake.formatter.printAdditionalInfo "**** #{typeStr} #{Block.block_counter} of #{@@num_projects}: #{@projectName} (#{@configName}) ****"
392
+ puts "Project path: #{@projectDir}" if Bake.options.projectPaths
303
393
  end
304
- puts "Project path: #{@projectDir}" if Bake.options.projectPaths
305
394
 
306
395
  @result = callSteps(:execute)
307
396
  return (depResult && @result)
@@ -315,6 +404,10 @@ module Bake
315
404
  return false if not depResult and Bake.options.stopOnFirstError
316
405
 
317
406
  if Bake.options.verbose >= 2 || isBuildBlock? || @prebuild
407
+ Block.inc_block_counter()
408
+ end
409
+
410
+ if Bake.options.verbose >= 2
318
411
  typeStr = "Cleaning"
319
412
  if @prebuild
320
413
  typeStr = "Checking"
@@ -346,6 +439,12 @@ module Bake
346
439
  return (depResult && @result)
347
440
  end
348
441
 
442
+ def self.init_threads()
443
+ @@threads = []
444
+ @@result = true
445
+ @@mutex = Mutex.new
446
+ end
447
+
349
448
  def startup
350
449
  return true if (@visited)
351
450
  @visited = true
@@ -1,205 +1,206 @@
1
- module Bake
2
- module Blocks
3
-
4
- class BlockBase
5
-
6
- attr_reader :projectDir, :block
7
-
8
- def initialize(block, config, referencedConfigs)
9
- @block = block
10
- @config = config
11
- @referencedConfigs = referencedConfigs
12
- @projectName = config.parent.name
13
- @projectDir = config.get_project_dir
14
- @config_date = Time.now
15
- end
16
-
17
- def check_config_file()
18
- if File.exists?(@config.file_name) and File.mtime(@config.file_name) > @config_date
19
- begin
20
- FileUtils.touch(@config.file_name) if !Bake.options.dry
21
- rescue Exception=>e
22
- if Bake.options.verbose >= 2
23
- Bake.formatter.printWarning("Could not touch #{@config.file_name}: #{e.message}", @config.file_name)
24
- end
25
- end
26
- end
27
- end
28
-
29
- def self.prepareOutput(filename)
30
- return if Bake.options.dry
31
- begin
32
- if File.exists?(filename)
33
- FileUtils.rm(filename)
34
- else
35
- FileUtils.mkdir_p(File.dirname(filename))
36
- end
37
- rescue Exception => e
38
- if Bake.options.debug
39
- puts e.message
40
- puts e.backtrace
41
- end
42
- end
43
- end
44
-
45
- def defaultToolchainTime
46
- @defaultToolchainTime ||= File.mtime(Bake.options.main_dir+"/Project.meta")
47
- end
48
-
49
- def config_changed?(cmdLineFile)
50
- return "because command line file does not exist" if not File.exist?(cmdLineFile)
51
- cmdTime = File.mtime(cmdLineFile)
52
- return "because config file has been changed" if cmdTime < File.mtime(@config.file_name)
53
- return "because DefaultToolchain has been changed" if cmdTime < defaultToolchainTime
54
- return "because command line has been changed"
55
- end
56
-
57
- def self.isCmdLineEqual?(cmd, cmdLineFile)
58
- begin
59
- if File.exist?cmdLineFile
60
- lastCmdLineArray = File.readlines(cmdLineFile)[0];
61
- if lastCmdLineArray == cmd.join(" ")
62
- FileUtils.touch(cmdLineFile) if !Bake.options.dry
63
- return true
64
- end
65
- end
66
- rescue Exception => e
67
- if Bake.options.debug
68
- puts e.message
69
- puts e.backtrace
70
- end
71
- end
72
- return false
73
- end
74
-
75
- def self.writeCmdLineFile(cmd, cmdLineFile)
76
- begin
77
- if !Bake.options.dry
78
- File.open(cmdLineFile, 'w') { |f| f.write(cmd.join(" ")) }
79
- end
80
- rescue Exception => e
81
- if Bake.options.debug
82
- puts e.message
83
- puts e.backtrace
84
- end
85
- end
86
- end
87
-
88
- def printCmd(cmd, alternate, reason, forceVerbose)
89
- if (cmd == Thread.current[:lastCommand])
90
- if (Bake.options.verbose >= 2 or (Thread.current[:printedCmdAlternate] and not forceVerbose))
91
- return
92
- end
93
- end
94
-
95
- Thread.current[:lastCommand] = cmd
96
-
97
- return if Bake.options.verbose == 0 and not forceVerbose
98
-
99
- if forceVerbose or Bake.options.verbose >= 2 or not alternate
100
- Thread.current[:printedCmdAlternate] = false
101
- puts "" if Bake.options.verbose >= 2 # for A.K. :-)
102
- if Bake.options.verbose >= 3
103
- exedIn = "\n(executed in '#{@projectDir}')"
104
- because = reason ? "\n(#{reason})" : ""
105
- else
106
- exedIn = ""
107
- because = ""
108
- end
109
-
110
- if cmd.is_a?(Array)
111
- puts cmd.join(' ') + exedIn + because
112
- else
113
- puts cmd + exedIn + because
114
- end
115
- else
116
- Thread.current[:printedCmdAlternate] = true
117
- puts alternate
118
- end
119
-
120
- end
121
-
122
- def process_console_output(console_output, error_parser)
123
- ret = false
124
- incList = nil
125
- #if not console_output.empty?
126
- if error_parser
127
- begin
128
- x = [console_output]
129
- error_descs, console_output_full, incList = error_parser.scan_lines(x, @projectDir)
130
-
131
- console_output = x[0]
132
- console_output = console_output_full if Bake.options.consoleOutput_fullnames
133
-
134
- if Bake.options.consoleOutput_visualStudio
135
- console_output_VS = ""
136
- descCounter = 0
137
- console_output.each_line do |l|
138
- d = error_descs[descCounter]
139
- console_output_VS << error_parser.makeVsError(l.rstrip, d) << "\n"
140
- descCounter = descCounter + 1
141
- end
142
- console_output = console_output_VS
143
- end
144
-
145
- ret = error_descs.any? { |e| e.severity == ErrorParser::SEVERITY_ERROR }
146
-
147
- console_output.gsub!(/[\r]/, "")
148
- Bake.formatter.format(console_output, error_descs, error_parser) unless console_output.empty?
149
-
150
- Bake::IDEInterface.instance.set_errors(error_descs)
151
- rescue Exception => e
152
- Bake.formatter.printWarning("Parsing output failed (maybe language not set to English?): " + e.message)
153
- Bake.formatter.printWarning("Original output:")
154
- Bake.formatter.printWarning(console_output)
155
- raise e
156
- end
157
- else
158
- puts console_output # fallback
159
- end
160
- #end
161
- [ret, incList]
162
- end
163
-
164
- def process_result(cmd, console_output, error_parser, alternate, reason, success)
165
- hasError = (success == false)
166
- printCmd(cmd, alternate, reason, hasError)
167
- errorPrinted, incList = process_console_output(console_output, error_parser)
168
- if hasError and not errorPrinted
169
- Bake.formatter.printError("System command failed", @projectDir)
170
- end
171
- if hasError or (Bake.options.wparse and errorPrinted)
172
- raise SystemCommandFailed.new
173
- end
174
- incList
175
- end
176
-
177
-
178
- def cleanProjectDir
179
- if !Bake.options.filename
180
- Dir.chdir(@projectDir) do
181
- if File.exist?@block.output_dir
182
- puts "Deleting folder #{@block.output_dir}" if Bake.options.verbose >= 2
183
- if !Bake.options.dry
184
- FileUtils.rm_rf(@block.output_dir)
185
- end
186
-
187
- if (@block.tcs[:OUTPUT_DIR] == nil) && (Bake.options.buildDirDelimiter == "/") # in this case all builds are placed in a "build" folder
188
- buildDir = File.dirname(@block.output_dir)
189
- if (File.basename(buildDir) == "build") && (Dir.entries(buildDir).size == 2)# double check if it's really "build" and check if it's empty (except "." and "..")
190
- puts "Deleting folder #{buildDir}" if Bake.options.verbose >= 2
191
- if !Bake.options.dry
192
- FileUtils.rm_rf(buildDir)
193
- end
194
- end
195
- end
196
-
197
- end
198
- end
199
- end
200
- return true
201
- end
202
-
203
- end
204
- end
205
- end
1
+ module Bake
2
+ module Blocks
3
+
4
+ class BlockBase
5
+
6
+ attr_reader :projectDir, :block
7
+
8
+ def initialize(block, config, referencedConfigs)
9
+ @block = block
10
+ @config = config
11
+ @referencedConfigs = referencedConfigs
12
+ @projectName = config.parent.name
13
+ @projectDir = config.get_project_dir
14
+ @config_date = Time.now
15
+ end
16
+
17
+ def check_config_file()
18
+ if File.exists?(@config.file_name) and File.mtime(@config.file_name) > @config_date
19
+ begin
20
+ FileUtils.touch(@config.file_name) if !Bake.options.dry
21
+ rescue Exception=>e
22
+ if Bake.options.verbose >= 2
23
+ Bake.formatter.printWarning("Could not touch #{@config.file_name}: #{e.message}", @config.file_name)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def self.prepareOutput(filename)
30
+ return if Bake.options.dry
31
+ filename = File.expand_path(filename, @projectDir)
32
+ begin
33
+ if File.exists?(filename)
34
+ FileUtils.rm(filename)
35
+ else
36
+ FileUtils.mkdir_p(File.dirname(filename))
37
+ end
38
+ rescue Exception => e
39
+ if Bake.options.debug
40
+ puts e.message
41
+ puts e.backtrace
42
+ end
43
+ end
44
+ end
45
+
46
+ def defaultToolchainTime
47
+ @defaultToolchainTime ||= File.mtime(Bake.options.main_dir+"/Project.meta")
48
+ end
49
+
50
+ def config_changed?(cmdLineFile)
51
+ return "because command line file does not exist" if not File.exist?(cmdLineFile)
52
+ cmdTime = File.mtime(cmdLineFile)
53
+ return "because config file has been changed" if cmdTime < File.mtime(@config.file_name)
54
+ return "because DefaultToolchain has been changed" if cmdTime < defaultToolchainTime
55
+ return "because command line has been changed"
56
+ end
57
+
58
+ def self.isCmdLineEqual?(cmd, cmdLineFile)
59
+ begin
60
+ if File.exist?cmdLineFile
61
+ lastCmdLineArray = File.readlines(cmdLineFile)[0];
62
+ if lastCmdLineArray == cmd.join(" ")
63
+ FileUtils.touch(cmdLineFile) if !Bake.options.dry
64
+ return true
65
+ end
66
+ end
67
+ rescue Exception => e
68
+ if Bake.options.debug
69
+ puts e.message
70
+ puts e.backtrace
71
+ end
72
+ end
73
+ return false
74
+ end
75
+
76
+ def self.writeCmdLineFile(cmd, cmdLineFile)
77
+ begin
78
+ if !Bake.options.dry
79
+ File.open(cmdLineFile, 'w') { |f| f.write(cmd.join(" ")) }
80
+ end
81
+ rescue Exception => e
82
+ if Bake.options.debug
83
+ puts e.message
84
+ puts e.backtrace
85
+ end
86
+ end
87
+ end
88
+
89
+ def printCmd(cmd, alternate, reason, forceVerbose)
90
+ if (cmd == Thread.current[:lastCommand])
91
+ if (Bake.options.verbose >= 2 or (Thread.current[:printedCmdAlternate] and not forceVerbose))
92
+ return
93
+ end
94
+ end
95
+
96
+ Thread.current[:lastCommand] = cmd
97
+
98
+ return if Bake.options.verbose == 0 and not forceVerbose
99
+
100
+ if forceVerbose or Bake.options.verbose >= 2 or not alternate
101
+ Thread.current[:printedCmdAlternate] = false
102
+ puts "" if Bake.options.verbose >= 2 # for A.K. :-)
103
+ if Bake.options.verbose >= 3
104
+ exedIn = "\n(executed in '#{@projectDir}')"
105
+ because = reason ? "\n(#{reason})" : ""
106
+ else
107
+ exedIn = ""
108
+ because = ""
109
+ end
110
+
111
+ if cmd.is_a?(Array)
112
+ puts cmd.join(' ') + exedIn + because
113
+ else
114
+ puts cmd + exedIn + because
115
+ end
116
+ else
117
+ Thread.current[:printedCmdAlternate] = true
118
+ puts alternate
119
+ end
120
+
121
+ end
122
+
123
+ def process_console_output(console_output, error_parser)
124
+ ret = false
125
+ incList = nil
126
+ #if not console_output.empty?
127
+ if error_parser
128
+ begin
129
+ x = [console_output]
130
+ error_descs, console_output_full, incList = error_parser.scan_lines(x, @projectDir)
131
+
132
+ console_output = x[0]
133
+ console_output = console_output_full if Bake.options.consoleOutput_fullnames
134
+
135
+ if Bake.options.consoleOutput_visualStudio
136
+ console_output_VS = ""
137
+ descCounter = 0
138
+ console_output.each_line do |l|
139
+ d = error_descs[descCounter]
140
+ console_output_VS << error_parser.makeVsError(l.rstrip, d) << "\n"
141
+ descCounter = descCounter + 1
142
+ end
143
+ console_output = console_output_VS
144
+ end
145
+
146
+ ret = error_descs.any? { |e| e.severity == ErrorParser::SEVERITY_ERROR }
147
+
148
+ console_output.gsub!(/[\r]/, "")
149
+ Bake.formatter.format(console_output, error_descs, error_parser) unless console_output.empty?
150
+
151
+ Bake::IDEInterface.instance.set_errors(error_descs)
152
+ rescue Exception => e
153
+ Bake.formatter.printWarning("Parsing output failed (maybe language not set to English?): " + e.message)
154
+ Bake.formatter.printWarning("Original output:")
155
+ Bake.formatter.printWarning(console_output)
156
+ raise e
157
+ end
158
+ else
159
+ puts console_output # fallback
160
+ end
161
+ #end
162
+ [ret, incList]
163
+ end
164
+
165
+ def process_result(cmd, console_output, error_parser, alternate, reason, success)
166
+ hasError = (success == false)
167
+ printCmd(cmd, alternate, reason, hasError)
168
+ errorPrinted, incList = process_console_output(console_output, error_parser)
169
+ if hasError and not errorPrinted
170
+ Bake.formatter.printError("System command failed", @projectDir)
171
+ end
172
+ if hasError or (Bake.options.wparse and errorPrinted)
173
+ raise SystemCommandFailed.new
174
+ end
175
+ incList
176
+ end
177
+
178
+
179
+ def cleanProjectDir
180
+ if !Bake.options.filename
181
+ Dir.chdir(@projectDir) do
182
+ if File.exist?@block.output_dir
183
+ puts "Deleting folder #{@block.output_dir}" if Bake.options.verbose >= 2
184
+ if !Bake.options.dry
185
+ FileUtils.rm_rf(@block.output_dir)
186
+ end
187
+
188
+ if (@block.tcs[:OUTPUT_DIR] == nil) && (Bake.options.buildDirDelimiter == "/") # in this case all builds are placed in a "build" folder
189
+ buildDir = File.dirname(@block.output_dir)
190
+ if (File.basename(buildDir) == "build") && (Dir.entries(buildDir).size == 2)# double check if it's really "build" and check if it's empty (except "." and "..")
191
+ puts "Deleting folder #{buildDir}" if Bake.options.verbose >= 2
192
+ if !Bake.options.dry
193
+ FileUtils.rm_rf(buildDir)
194
+ end
195
+ end
196
+ end
197
+
198
+ end
199
+ end
200
+ end
201
+ return true
202
+ end
203
+
204
+ end
205
+ end
206
+ end