bake-toolkit 2.24.6 → 2.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bake-doc +11 -11
  3. data/bin/bake-format +2 -2
  4. data/bin/bakeclean +32 -32
  5. data/bin/bakeqac +77 -6
  6. data/documentation/_build/html/_images/eclipse.png +0 -0
  7. data/documentation/_build/html/_images/emacs.png +0 -0
  8. data/documentation/_build/html/_images/notepad.png +0 -0
  9. data/documentation/_build/html/_images/vim.png +0 -0
  10. data/documentation/_build/html/_images/visualstudio-pro.png +0 -0
  11. data/documentation/_build/html/_sources/changelog.txt +10 -0
  12. data/documentation/_build/html/_sources/ide/ide_integrations.txt +40 -8
  13. data/documentation/_build/html/_sources/index.txt +1 -1
  14. data/documentation/_build/html/_sources/tips_and_tricks/qac.txt +159 -152
  15. data/documentation/_build/html/_static/eclipse.png +0 -0
  16. data/documentation/_build/html/_static/emacs.png +0 -0
  17. data/documentation/_build/html/_static/notepad.png +0 -0
  18. data/documentation/_build/html/_static/syntax.html +8 -1
  19. data/documentation/_build/html/_static/vim.png +0 -0
  20. data/documentation/_build/html/_static/visualstudio-pro.png +0 -0
  21. data/documentation/_build/html/changelog.html +12 -0
  22. data/documentation/_build/html/ide/ide_integrations.html +22 -20
  23. data/documentation/_build/html/index.html +5 -4
  24. data/documentation/_build/html/searchindex.js +1 -1
  25. data/documentation/_build/html/syntax/project_meta_syntax.html +8 -1
  26. data/documentation/_build/html/tips_and_tricks/qac.html +10 -3
  27. data/lib/bake/cache.rb +16 -28
  28. data/lib/bake/config/loader.rb +14 -24
  29. data/lib/bake/model/metamodel.rb +311 -307
  30. data/lib/bake/model/metamodel_ext.rb +33 -27
  31. data/lib/bake/subst.rb +4 -4
  32. data/lib/bake/toolchain/clang.rb +43 -44
  33. data/lib/bake/toolchain/clang_analyze.rb +30 -31
  34. data/lib/bake/toolchain/diab.rb +52 -53
  35. data/lib/bake/toolchain/gcc.rb +1 -1
  36. data/lib/bake/toolchain/gcc_env.rb +54 -55
  37. data/lib/bake/toolchain/greenhills.rb +51 -52
  38. data/lib/bake/toolchain/keil.rb +54 -55
  39. data/lib/bake/toolchain/lint.rb +19 -20
  40. data/lib/bake/toolchain/msvc.rb +57 -58
  41. data/lib/bake/toolchain/provider.rb +6 -3
  42. data/lib/bake/toolchain/ti.rb +50 -49
  43. data/lib/bakeqac/options/options.rb +2 -2
  44. data/lib/blocks/block.rb +4 -0
  45. data/lib/blocks/compile.rb +36 -19
  46. data/lib/common/version.rb +1 -1
  47. data/lib/format/bake_format.rb +1 -1
  48. data/lib/tocxx.rb +576 -558
  49. metadata +26 -2
@@ -62,7 +62,7 @@ module Bake
62
62
  puts " --acf <file> Set a specific analysis config file, otherwise $(QAC_HOME)/config/acf/default.acf will be used."
63
63
  puts " --qaccctpatch If specified, some adaptions to cct are made. Might improve the result - no guarantee."
64
64
  puts " --qacdata <dir> QAC writes data into this folder. Default is <working directory>/.qacdata."
65
- puts " --qacstep admin|analyze|view Steps can be ORed. Per default all steps will be executed."
65
+ puts " --qacstep admin|analyze|view|report Steps can be ORed. Per default admin|analyze|view will be executed."
66
66
  puts " --qacnofilter Output will be printed immediately and unfiltered. Per default filters are used to reduce noise."
67
67
  puts " --qacrawformat Raw QAC output (with incomplete MISRA rules!)."
68
68
  puts " --qacretry <seconds> If build or result step fail due to refused license, the step will be retried until timeout."
@@ -120,7 +120,7 @@ module Bake
120
120
 
121
121
  if !@qacstep.nil?
122
122
  @qacstep.split("|").each do |s|
123
- if not ["admin", "analyze", "view"].include?s
123
+ if not ["admin", "analyze", "view", "report"].include?s
124
124
  Bake.formatter.printError("Error: incorrect qacstep name.")
125
125
  ExitHelper.exit(1)
126
126
  end
data/lib/blocks/block.rb CHANGED
@@ -50,6 +50,10 @@ module Bake
50
50
  @parents ||= []
51
51
  end
52
52
 
53
+ def depToBlock
54
+ @depToBlock ||= {}
55
+ end
56
+
53
57
  def set_library(library)
54
58
  @library = library
55
59
  end
@@ -17,6 +17,7 @@ module Bake
17
17
  super(block, config, referencedConfigs, tcs)
18
18
  @objects = []
19
19
  @object_files = {}
20
+ @system_includes = Set.new
20
21
 
21
22
  calcFileTcs
22
23
  calcIncludes
@@ -431,31 +432,41 @@ module Bake
431
432
  Pathname.new(i).cleanpath
432
433
  end
433
434
 
434
- def calcIncludes
435
- @include_list = @config.includeDir.uniq.map do |dir|
436
- mapInclude(dir, @block)
437
- end
438
-
439
- @block.getBlocks(:childs).each do |b|
440
- b.config.includeDir.each do |inc|
441
- if inc.inherit == true
442
- @include_list << mapInclude(inc, b)
435
+ def calcIncludesInternal(block)
436
+ @blocksRead << block
437
+ block.config.baseElement.each do |be|
438
+ if Metamodel::IncludeDir === be
439
+ if be.inherit == true || block == @block
440
+ mappedInc = mapInclude(be, block)
441
+ @include_list << mappedInc
442
+ @system_includes << mappedInc if be.system
443
443
  end
444
- end if b.config.respond_to?("includeDir")
444
+ elsif Metamodel::Dependency === be
445
+ childBlock = block.depToBlock[be.name + "," + be.config]
446
+ calcIncludesInternal(childBlock) if !@blocksRead.include?(childBlock)
447
+ end
445
448
  end
449
+ end
450
+
451
+ def calcIncludes
452
+
453
+ @blocksRead = Set.new
454
+ @include_list = []
455
+ @system_includes = Set.new
456
+ calcIncludesInternal(@block) # includeDir and child dependencies with inherit: true
446
457
 
447
458
  @block.getBlocks(:parents).each do |b|
448
459
  if b.config.respond_to?("includeDir")
449
460
  include_list_front = []
450
461
  b.config.includeDir.each do |inc|
451
- if inc.inject == "front"
452
- include_list_front << mapInclude(inc, b)
453
- elsif inc.inject == "back"
454
- @include_list << mapInclude(inc, b)
455
- elsif inc.infix == "front"
456
- include_list_front << mapInclude(inc, b)
457
- elsif inc.infix == "back"
458
- @include_list << mapInclude(inc, b)
462
+ if inc.inject == "front" || inc.infix == "front"
463
+ mappedInc = mapInclude(inc, b)
464
+ include_list_front << mappedInc
465
+ @system_includes << mappedInc if inc.system
466
+ elsif inc.inject == "back" || inc.infix == "back"
467
+ mappedInc = mapInclude(inc, b)
468
+ @include_list << mappedInc
469
+ @system_includes << mappedInc if inc.system
459
470
  end
460
471
  end
461
472
  @include_list = include_list_front + @include_list
@@ -466,7 +477,13 @@ module Bake
466
477
 
467
478
  @include_array = {}
468
479
  [:CPP, :C, :ASM].each do |type|
469
- @include_array[type] = @include_list.map {|k| "#{@tcs[:COMPILER][type][:INCLUDE_PATH_FLAG]}#{k}"}
480
+ @include_array[type] = @include_list.map do |k|
481
+ if @system_includes.include?(k)
482
+ "#{@tcs[:COMPILER][type][:SYSTEM_INCLUDE_PATH_FLAG]}#{k}"
483
+ else
484
+ "#{@tcs[:COMPILER][type][:INCLUDE_PATH_FLAG]}#{k}"
485
+ end
486
+ end
470
487
  end
471
488
  end
472
489
 
@@ -1,7 +1,7 @@
1
1
  module Bake
2
2
  class Version
3
3
  def self.number
4
- "2.24.6"
4
+ "2.25.0"
5
5
  end
6
6
 
7
7
  def self.printBakeVersion(ry = "")
@@ -13,7 +13,7 @@ def bake_format(data, output, indent)
13
13
  else
14
14
  indent * indent_level
15
15
  end
16
- output.puts(prefix + l)
16
+ output.puts((prefix + l).rstrip)
17
17
  end
18
18
  output.close
19
19
  end
data/lib/tocxx.rb CHANGED
@@ -1,559 +1,577 @@
1
- #!/usr/bin/env ruby
2
-
3
-
4
- require 'bake/model/metamodel_ext'
5
-
6
- require 'bake/util'
7
- require 'bake/cache'
8
- require 'bake/subst'
9
- require 'bake/mergeConfig'
10
-
11
- require 'common/exit_helper'
12
- require 'common/ide_interface'
13
- require 'common/ext/file'
14
- require 'bake/toolchain/provider'
15
- require 'common/ext/stdout'
16
- require 'common/utils'
17
- require 'bake/toolchain/colorizing_formatter'
18
- require 'bake/config/loader'
19
-
20
- require 'blocks/block'
21
- require 'blocks/commandLine'
22
- require 'blocks/makefile'
23
- require 'blocks/compile'
24
- require 'blocks/convert'
25
- require 'blocks/library'
26
- require 'blocks/executable'
27
- require 'blocks/lint'
28
- require 'blocks/convert'
29
- require 'blocks/docu'
30
-
31
- require 'set'
32
- require 'socket'
33
-
34
- require 'blocks/showIncludes'
35
- require 'common/abortException'
36
-
37
- require 'adapt/config/loader'
38
-
39
- module Bake
40
-
41
- class SystemCommandFailed < Exception
42
- end
43
-
44
- class ToCxx
45
-
46
- @@linkBlock = 0
47
-
48
- def self.linkBlock
49
- @@linkBlock = 1
50
- end
51
-
52
- def initialize
53
- @configTcMap = {}
54
- end
55
-
56
- def createBaseTcsForConfig
57
- @loadedConfig.referencedConfigs.each do |projName, configs|
58
- configs.each do |config|
59
- tcs = Utils.deep_copy(@defaultToolchain)
60
- @configTcMap[config] = tcs
61
- end
62
- end
63
- end
64
-
65
- def createTcsForConfig
66
- @loadedConfig.referencedConfigs.each do |projName, configs|
67
- configs.each do |config|
68
- integrateToolchain(@configTcMap[config], config.toolchain)
69
- end
70
- end
71
- end
72
-
73
- def substVars
74
- Subst.itute(@mainConfig, Bake.options.main_project_name, true, @configTcMap[@mainConfig], @loadedConfig, @configTcMap)
75
- @loadedConfig.referencedConfigs.each do |projName, configs|
76
- configs.each do |config|
77
- if config != @mainConfig
78
- Subst.itute(config, projName, false, @configTcMap[config], @loadedConfig, @configTcMap)
79
- end
80
- end
81
- end
82
- end
83
-
84
-
85
-
86
- def addSteps(block, blockSteps, configSteps)
87
- Array(configSteps.step).each do |step|
88
- if Bake::Metamodel::Makefile === step
89
- blockSteps << Blocks::Makefile.new(step, @loadedConfig.referencedConfigs, block)
90
- elsif Bake::Metamodel::CommandLine === step
91
- blockSteps << Blocks::CommandLine.new(step, @loadedConfig.referencedConfigs)
92
- end
93
- end if configSteps
94
- end
95
-
96
- def addDependencies(block, config)
97
- config.dependency.each do |dep|
98
- @loadedConfig.referencedConfigs[dep.name].each do |configRef|
99
- if configRef.name == dep.config
100
- block.dependencies << configRef.qname if not Bake.options.project# and not Bake.options.filename
101
- blockRef = Blocks::ALL_BLOCKS[configRef.qname]
102
- block.childs << blockRef
103
- blockRef.parents << block
104
- break
105
- end
106
- end
107
- end
108
- end
109
-
110
- def calcPrebuildBlocks
111
- @loadedConfig.referencedConfigs.each do |projName, configs|
112
- configs.each do |config|
113
- if config.prebuild
114
- @prebuild ||= {}
115
- config.prebuild.except.each do |except|
116
- pName = projName
117
- if not except.name.empty?
118
- if not @loadedConfig.referencedConfigs.keys.include? except.name
119
- Bake.formatter.printWarning("Warning: prebuild project #{except.name} not found")
120
- next
121
- end
122
- pName = except.name
123
- end
124
- if except.config != "" && !@loadedConfig.referencedConfigs[pName].any? {|config| config.name == except.config}
125
- Bake.formatter.printWarning("Warning: prebuild config #{except.config} of project #{pName} not found")
126
- next
127
- end
128
-
129
- if not @prebuild.include?pName
130
- @prebuild[pName] = [except.config]
131
- else
132
- @prebuild[pName] << except.config
133
- end
134
- end
135
- end
136
- end
137
- end
138
- end
139
-
140
- def makeBlocks
141
- @loadedConfig.referencedConfigs.each do |projName, configs|
142
- configs.each do |config|
143
-
144
- prebuild = !@prebuild.nil?
145
- if @prebuild and @prebuild.has_key?projName
146
- prebuild = false if (@prebuild[projName].include?"" or @prebuild[projName].include?config.name)
147
- end
148
-
149
- block = Blocks::Block.new(config, @loadedConfig.referencedConfigs, prebuild)
150
- Blocks::ALL_BLOCKS[config.qname] = block
151
- end
152
- end
153
- end
154
-
155
- def makeGraph
156
- @loadedConfig.referencedConfigs.each do |projName, configs|
157
- configs.each do |config|
158
- block = Blocks::ALL_BLOCKS[config.qname]
159
- addDependencies(block, config)
160
- end
161
- end
162
- Blocks::ALL_BLOCKS.each do |name,block|
163
- block.dependencies.uniq!
164
- block.childs.uniq!
165
- block.parents.uniq!
166
- end
167
-
168
- # inject dependencies
169
- num_interations = 0
170
- begin
171
- if (num_interations > 0) and Bake.options.debug and Bake.options.verbose >= 3
172
- puts "Inject dependencies, iteration #{num_interations}:"
173
- Blocks::ALL_BLOCKS.each do |name,block|
174
- puts block.config.qname
175
- block.dependencies.each { |d| puts "- #{d}" }
176
- end
177
- end
178
-
179
- counter = 0
180
- Blocks::ALL_BLOCKS.each do |name,block|
181
- block.getBlocks(:parents).each do |b|
182
- b.config.dependency.each do |d|
183
- next if d.inject == ""
184
-
185
- dqname = "#{d.name},#{d.config}"
186
- next if name == dqname
187
- next if block.dependencies.include? dqname
188
- dblock = Blocks::ALL_BLOCKS[dqname]
189
- counter += 1
190
- newD = MergeConfig::cloneModelElement(d)
191
- newD.setInject("")
192
- ls = block.config.getLibStuff
193
- dblock.parents << block
194
-
195
- if d.inject == "front"
196
- block.config.setLibStuff(ls.unshift(newD))
197
- block.childs.unshift dblock
198
- block.dependencies.unshift dqname
199
- else
200
- block.config.setLibStuff(ls + [newD])
201
- block.childs << dblock
202
- block.dependencies << dqname
203
- end
204
- end
205
- end
206
- end
207
- num_interations += 1
208
- end while counter > 0
209
- end
210
-
211
- def makeDot
212
-
213
- File.open(Bake.options.dot, 'w') do |file|
214
- puts "Creating #{Bake.options.dot}"
215
-
216
- file.write "# Generated by bake\n"
217
- file.write "# Example to show the graph: dot #{Bake.options.dot} -Tpng -o out.png\n"
218
- file.write "# Example to reduce the graph: tred #{Bake.options.dot} | dot -Tpng -o out.png\n\n"
219
-
220
- file.write "digraph \"#{Bake.options.main_project_name}_#{Bake.options.build_config}\" {\n\n"
221
-
222
- file.write " concentrate = true\n\n"
223
-
224
- onlyProjectName = nil
225
- onlyConfigName = nil
226
- if Bake.options.project
227
- splitted = Bake.options.project.split(',')
228
- onlyProjectName = splitted[0]
229
- onlyConfigName = splitted[1] if splitted.length == 2
230
- end
231
-
232
- if onlyProjectName
233
- if not @loadedConfig.referencedConfigs.include? onlyProjectName
234
- Bake.formatter.printError("Error: project #{onlyProjectName} not found")
235
- ExitHelper.exit(1)
236
- end
237
- if onlyConfigName
238
- if not @loadedConfig.referencedConfigs[onlyProjectName].any? {|c| c.name == onlyConfigName}
239
- Bake.formatter.printError("Error: project #{onlyProjectName} with config #{onlyConfigName} not found")
240
- ExitHelper.exit(1)
241
- end
242
- end
243
- end
244
-
245
- foundProjs = {}
246
- @loadedConfig.referencedConfigs.each do |projName, configs|
247
- configs.each do |config|
248
- config.dependency.each do |d|
249
- if onlyProjectName
250
- next if config.parent.name != onlyProjectName && d.name != onlyProjectName
251
- if onlyConfigName
252
- leftSide = config.name == onlyConfigName && config.parent.name == onlyProjectName
253
- rightSide = d.config == onlyConfigName && d.name == onlyProjectName
254
- next if not leftSide and not rightSide
255
- end
256
- end
257
- file.write " \"#{config.qname}\" -> \"#{d.name},#{d.config}\"\n"
258
-
259
- foundProjs[config.parent.name] = [] if not foundProjs.include? config.parent.name
260
- foundProjs[config.parent.name] << config.name if not foundProjs[config.parent.name].include? config.name
261
- foundProjs[d.name] = [] if not foundProjs.include? d.name
262
- foundProjs[d.name] << d.config if not foundProjs[config.parent.name].include? d.config
263
- end
264
- end
265
- end
266
- file.write "\n"
267
-
268
- @loadedConfig.referencedConfigs.each do |projName, configs|
269
- next if Bake.options.project and not foundProjs.include?projName
270
- file.write " subgraph \"cluster_#{projName}\" {\n"
271
- file.write " label =\"#{projName}\"\n"
272
- configs.each do |config|
273
- next if Bake.options.project and not foundProjs[projName].include? config.name
274
- file.write " \"#{projName},#{config.name}\" [label = \"#{config.name}\", style = filled, fillcolor = #{config.color}]\n"
275
- end
276
- file.write " }\n\n"
277
- end
278
-
279
- file.write "}\n"
280
- end
281
-
282
- ExitHelper.exit(0)
283
- end
284
-
285
- def convert2bb
286
- @loadedConfig.referencedConfigs.each do |projName, configs|
287
- configs.each do |config|
288
- block = Blocks::ALL_BLOCKS[config.qname]
289
-
290
- addSteps(block, block.startupSteps, config.startupSteps)
291
- addSteps(block, block.exitSteps, config.exitSteps)
292
-
293
- if not Bake.options.prepro and not Bake.options.lint and not Bake.options.conversion_info and not Bake.options.docu and not Bake.options.filename and not Bake.options.analyze
294
- addSteps(block, block.preSteps, config.preSteps)
295
- addSteps(block, block.postSteps, config.postSteps)
296
- end
297
-
298
- if Bake.options.docu
299
- block.mainSteps << Blocks::Docu.new(config, @configTcMap[config])
300
- elsif Metamodel::CustomConfig === config
301
- if not Bake.options.prepro and not Bake.options.lint and not Bake.options.conversion_info and not Bake.options.docu and not Bake.options.filename and not Bake.options.analyze
302
- addSteps(block, block.mainSteps, config) if config.step
303
- end
304
- elsif Bake.options.conversion_info
305
- block.mainSteps << Blocks::Convert.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config])
306
- elsif Bake.options.lint
307
- block.mainSteps << Blocks::Lint.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config])
308
- else
309
- compile = Blocks::Compile.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config])
310
- (Blocks::ALL_COMPILE_BLOCKS[projName] ||= []) << compile
311
- block.mainSteps << compile
312
- if not Bake.options.filename and not Bake.options.analyze
313
- if Metamodel::LibraryConfig === config
314
- block.mainSteps << Blocks::Library.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config], compile)
315
- else
316
- block.mainSteps << Blocks::Executable.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config], compile)
317
- end
318
- end
319
- end
320
-
321
-
322
-
323
- end
324
- end
325
- end
326
-
327
- def callBlock(block, method)
328
- begin
329
- return block.send(method)
330
- rescue AbortException
331
- raise
332
- rescue Exception => ex
333
- if Bake.options.debug
334
- puts ex.message
335
- puts ex.backtrace
336
- end
337
- return false
338
- end
339
- end
340
-
341
- def callBlocks(startBlocks, method, ignoreStopOnFirstError = false)
342
- Blocks::ALL_BLOCKS.each {|name,block| block.visited = false; block.result = true; block.inDeps = false }
343
- Blocks::Block.reset_block_counter
344
- result = true
345
- startBlocks.each do |block|
346
- result = callBlock(block, method) && result
347
- if not ignoreStopOnFirstError
348
- return false if not result and Bake.options.stopOnFirstError
349
- end
350
- end
351
- return result
352
- end
353
-
354
- def calcStartBlocks
355
- startProjectName = nil
356
- startConfigName = nil
357
- if Bake.options.project
358
- splitted = Bake.options.project.split(',')
359
- startProjectName = splitted[0]
360
- startConfigName = splitted[1] if splitted.length == 2
361
- end
362
-
363
- if startConfigName
364
- blockName = startProjectName+","+startConfigName
365
- if not Blocks::ALL_BLOCKS.include?(startProjectName+","+startConfigName)
366
- Bake.formatter.printError("Error: project #{startProjectName} with config #{startConfigName} not found")
367
- ExitHelper.exit(1)
368
- end
369
- startBlocks = [Blocks::ALL_BLOCKS[startProjectName+","+startConfigName]]
370
- Blocks::Block.set_num_projects(1)
371
- elsif startProjectName
372
- startBlocks = []
373
- Blocks::ALL_BLOCKS.each do |blockName, block|
374
- if blockName.start_with?(startProjectName + ",")
375
- startBlocks << block
376
- end
377
- end
378
- if startBlocks.length == 0
379
- Bake.formatter.printError("Error: project #{startProjectName} not found")
380
- ExitHelper.exit(1)
381
- end
382
- startBlocks.reverse! # most probably the order of dependencies if any
383
- Blocks::Block.set_num_projects(startBlocks.length)
384
- else
385
- startBlocks = [Blocks::ALL_BLOCKS[Bake.options.main_project_name+","+Bake.options.build_config]]
386
- Blocks::Block.set_num_projects(Blocks::ALL_BLOCKS.length)
387
- end
388
- return startBlocks
389
- end
390
-
391
- def doit()
392
-
393
- if Bake.options.show_includes or Bake.options.show_includes_and_defines
394
- s = StringIO.new
395
- tmp = Thread.current[:stdout]
396
- Thread.current[:stdout] = s unless tmp
397
- end
398
-
399
- taskType = "Building"
400
- if Bake.options.lint
401
- taskType = "Linting"
402
- elsif Bake.options.conversion_info
403
- taskType = "Showing conversion infos"
404
- elsif Bake.options.docu
405
- taskType = "Generating documentation"
406
- elsif Bake.options.prepro
407
- taskType = "Preprocessing"
408
- elsif Bake.options.linkOnly
409
- taskType = "Linking"
410
- elsif Bake.options.rebuild
411
- taskType = "Rebuilding"
412
- elsif Bake.options.clean
413
- taskType = "Cleaning"
414
- end
415
-
416
- begin
417
- al = AdaptConfig.new
418
- adaptConfigs = al.load()
419
-
420
- @loadedConfig = Config.new
421
- @loadedConfig.load(adaptConfigs)
422
-
423
- taskType = "Analyzing" if Bake.options.analyze
424
-
425
- @mainConfig = @loadedConfig.referencedConfigs[Bake.options.main_project_name].select { |c| c.name == Bake.options.build_config }.first
426
-
427
- if Bake.options.lint
428
- @defaultToolchain = Utils.deep_copy(Bake::Toolchain::Provider["Lint"])
429
- else
430
- basedOn = @mainConfig.defaultToolchain.basedOn
431
- basedOnToolchain = Bake::Toolchain::Provider[basedOn]
432
- if basedOnToolchain.nil?
433
- Bake.formatter.printError("DefaultToolchain based on unknown compiler '#{basedOn}'", @mainConfig.defaultToolchain)
434
- ExitHelper.exit(1)
435
- end
436
-
437
- # The flag "-FS" must only be set for VS2013 and above
438
- ENV["MSVC_FORCE_SYNC_PDB_WRITES"] = ""
439
- if basedOn == "MSVC"
440
- begin
441
- res = `cl.exe 2>&1`
442
- raise Exception.new unless $?.success?
443
- scan_res = res.scan(/ersion (\d+).(\d+).(\d+)/)
444
- if scan_res.length > 0
445
- ENV["MSVC_FORCE_SYNC_PDB_WRITES"] = "-FS" if scan_res[0][0].to_i >= 18 # 18 is the compiler major version in VS2013
446
- else
447
- Bake.formatter.printError("Could not read MSVC version")
448
- ExitHelper.exit(1)
449
- end
450
- rescue SystemExit
451
- raise
452
- rescue Exception => e
453
- Bake.formatter.printError("Could not detect MSVC compiler")
454
- ExitHelper.exit(1)
455
- end
456
- end
457
-
458
- @defaultToolchain = Utils.deep_copy(basedOnToolchain)
459
- Bake.options.envToolchain = true if (basedOn.include?"_ENV")
460
- end
461
- integrateToolchain(@defaultToolchain, @mainConfig.defaultToolchain)
462
-
463
- # todo: cleanup this hack
464
- Bake.options.analyze = @defaultToolchain[:COMPILER][:CPP][:COMPILE_FLAGS].include?"analyze"
465
- Bake.options.eclipseOrder = @mainConfig.defaultToolchain.eclipseOrder
466
-
467
- createBaseTcsForConfig
468
- substVars
469
- createTcsForConfig
470
-
471
- @@linkBlock = 0
472
-
473
- @prebuild = nil
474
- calcPrebuildBlocks if Bake.options.prebuild
475
-
476
- makeBlocks
477
- makeGraph
478
- makeDot if Bake.options.dot
479
-
480
- convert2bb
481
-
482
- if Bake.options.show_includes
483
- Thread.current[:stdout] = tmp
484
- Blocks::Show.includes
485
- end
486
-
487
- if Bake.options.show_includes_and_defines
488
- Thread.current[:stdout] = tmp
489
- Blocks::Show.includesAndDefines(@mainConfig, @configTcMap[@mainConfig])
490
- end
491
-
492
- startBlocks = calcStartBlocks
493
-
494
- Bake::IDEInterface.instance.set_build_info(@mainConfig.parent.name, @mainConfig.name, Blocks::ALL_BLOCKS.length)
495
-
496
- ideAbort = false
497
- begin
498
- result = callBlocks(startBlocks, :startup, true)
499
- if Bake.options.clean or Bake.options.rebuild
500
- if not Bake.options.stopOnFirstError or result
501
- result = callBlocks(startBlocks, :clean) && result
502
- end
503
- end
504
- if Bake.options.rebuild or not Bake.options.clean
505
- if not Bake.options.stopOnFirstError or result
506
- result = callBlocks(startBlocks, :execute) && result
507
- end
508
- end
509
- rescue AbortException
510
- ideAbort = true
511
- end
512
- result = callBlocks(startBlocks, :exits, true) && result
513
-
514
- if ideAbort
515
- Bake.formatter.printError("\n#{taskType} aborted.")
516
- ExitHelper.set_exit_code(1)
517
- return
518
- end
519
-
520
- if Bake.options.cc2j_filename
521
- require "json"
522
- File.write(Bake.options.cc2j_filename, JSON.pretty_generate(Blocks::CC2J))
523
- end
524
-
525
- if result == false
526
- Bake.formatter.printError("\n#{taskType} failed.")
527
- ExitHelper.set_exit_code(1)
528
- return
529
- else
530
- if Bake.options.linkOnly and @@linkBlock == 0
531
- Bake.formatter.printSuccess("\nNothing to link.")
532
- else
533
- Bake.formatter.printSuccess("\n#{taskType} done.")
534
- end
535
- end
536
- rescue SystemExit
537
- Bake.formatter.printError("\n#{taskType} failed.") if ExitHelper.exit_code != 0
538
- end
539
-
540
- end
541
-
542
- def connect()
543
- if Bake.options.socket != 0
544
- Bake::IDEInterface.instance.connect(Bake.options.socket)
545
- end
546
- end
547
-
548
- def disconnect()
549
- if Bake.options.socket != 0
550
- Bake::IDEInterface.instance.disconnect()
551
- end
552
- end
553
-
554
- end
555
- end
556
-
557
- trap("SIGINT") do
558
- Bake::IDEInterface.instance.set_abort(1)
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require 'bake/model/metamodel_ext'
5
+
6
+ require 'bake/util'
7
+ require 'bake/cache'
8
+ require 'bake/subst'
9
+ require 'bake/mergeConfig'
10
+
11
+ require 'common/exit_helper'
12
+ require 'common/ide_interface'
13
+ require 'common/ext/file'
14
+ require 'bake/toolchain/provider'
15
+ require 'common/ext/stdout'
16
+ require 'common/utils'
17
+ require 'bake/toolchain/colorizing_formatter'
18
+ require 'bake/config/loader'
19
+
20
+ require 'blocks/block'
21
+ require 'blocks/commandLine'
22
+ require 'blocks/makefile'
23
+ require 'blocks/compile'
24
+ require 'blocks/convert'
25
+ require 'blocks/library'
26
+ require 'blocks/executable'
27
+ require 'blocks/lint'
28
+ require 'blocks/convert'
29
+ require 'blocks/docu'
30
+
31
+ require 'set'
32
+ require 'socket'
33
+
34
+ require 'blocks/showIncludes'
35
+ require 'common/abortException'
36
+
37
+ require 'adapt/config/loader'
38
+
39
+ module Bake
40
+
41
+ class SystemCommandFailed < Exception
42
+ end
43
+
44
+ class ToCxx
45
+
46
+ @@linkBlock = 0
47
+
48
+ def self.linkBlock
49
+ @@linkBlock = 1
50
+ end
51
+
52
+ def initialize
53
+ @configTcMap = {}
54
+ end
55
+
56
+ def createBaseTcsForConfig
57
+ @referencedConfigs.each do |projName, configs|
58
+ configs.each do |config|
59
+ tcs = Utils.deep_copy(@defaultToolchain)
60
+ @configTcMap[config] = tcs
61
+ end
62
+ end
63
+ end
64
+
65
+ def createTcsForConfig
66
+ @referencedConfigs.each do |projName, configs|
67
+ configs.each do |config|
68
+ integrateToolchain(@configTcMap[config], config.toolchain)
69
+ end
70
+ end
71
+ end
72
+
73
+ def substVars
74
+ Subst.itute(@mainConfig, Bake.options.main_project_name, true, @configTcMap[@mainConfig], @referencedConfigs, @configTcMap)
75
+ @referencedConfigs.each do |projName, configs|
76
+ configs.each do |config|
77
+ if config != @mainConfig
78
+ Subst.itute(config, projName, false, @configTcMap[config], @referencedConfigs, @configTcMap)
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+
85
+
86
+ def addSteps(block, blockSteps, configSteps)
87
+ Array(configSteps.step).each do |step|
88
+ if Bake::Metamodel::Makefile === step
89
+ blockSteps << Blocks::Makefile.new(step, @referencedConfigs, block)
90
+ elsif Bake::Metamodel::CommandLine === step
91
+ blockSteps << Blocks::CommandLine.new(step, @referencedConfigs)
92
+ end
93
+ end if configSteps
94
+ end
95
+
96
+ def addDependencies(block, config)
97
+ config.dependency.each do |dep|
98
+ @referencedConfigs[dep.name].each do |configRef|
99
+ if configRef.name == dep.config
100
+ block.dependencies << configRef.qname if not Bake.options.project# and not Bake.options.filename
101
+ blockRef = Blocks::ALL_BLOCKS[configRef.qname]
102
+ block.childs << blockRef
103
+ block.depToBlock[dep.name + "," + dep.config] = blockRef
104
+ blockRef.parents << block
105
+ break
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ def calcPrebuildBlocks
112
+ @referencedConfigs.each do |projName, configs|
113
+ configs.each do |config|
114
+ if config.prebuild
115
+ @prebuild ||= {}
116
+ config.prebuild.except.each do |except|
117
+ pName = projName
118
+ if not except.name.empty?
119
+ if not @referencedConfigs.keys.include? except.name
120
+ Bake.formatter.printWarning("Warning: prebuild project #{except.name} not found")
121
+ next
122
+ end
123
+ pName = except.name
124
+ end
125
+ if except.config != "" && !@referencedConfigs[pName].any? {|config| config.name == except.config}
126
+ Bake.formatter.printWarning("Warning: prebuild config #{except.config} of project #{pName} not found")
127
+ next
128
+ end
129
+
130
+ if not @prebuild.include?pName
131
+ @prebuild[pName] = [except.config]
132
+ else
133
+ @prebuild[pName] << except.config
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ def makeBlocks
142
+ @referencedConfigs.each do |projName, configs|
143
+ configs.each do |config|
144
+
145
+ prebuild = !@prebuild.nil?
146
+ if @prebuild and @prebuild.has_key?projName
147
+ prebuild = false if (@prebuild[projName].include?"" or @prebuild[projName].include?config.name)
148
+ end
149
+
150
+ block = Blocks::Block.new(config, @referencedConfigs, prebuild)
151
+ Blocks::ALL_BLOCKS[config.qname] = block
152
+ end
153
+ end
154
+ end
155
+
156
+ def makeGraph
157
+ @referencedConfigs.each do |projName, configs|
158
+ configs.each do |config|
159
+ block = Blocks::ALL_BLOCKS[config.qname]
160
+ addDependencies(block, config)
161
+ end
162
+ end
163
+ Blocks::ALL_BLOCKS.each do |name,block|
164
+ block.dependencies.uniq!
165
+ block.childs.uniq!
166
+ block.parents.uniq!
167
+ end
168
+
169
+
170
+ # inject dependencies
171
+ num_interations = 0
172
+ begin
173
+ if (num_interations > 0) and Bake.options.debug and Bake.options.verbose >= 3
174
+ puts "Inject dependencies, iteration #{num_interations}:"
175
+ Blocks::ALL_BLOCKS.each do |name,block|
176
+ puts block.config.qname
177
+ block.dependencies.each { |d| puts "- #{d}" }
178
+ end
179
+ end
180
+
181
+ counter = 0
182
+ Blocks::ALL_BLOCKS.each do |name,block|
183
+ block.getBlocks(:parents).each do |b|
184
+ b.config.dependency.each do |d|
185
+ next if d.inject == ""
186
+
187
+ dqname = "#{d.name},#{d.config}"
188
+ dblock = Blocks::ALL_BLOCKS[dqname]
189
+ next if name == dqname
190
+ next if block.childs.include? dblock
191
+ counter += 1
192
+ newD = MergeConfig::cloneModelElement(d)
193
+ newD.setInject("")
194
+ ls = block.config.getBaseElement
195
+ dblock.parents << block
196
+
197
+ if d.inject == "front"
198
+ block.config.setBaseElement(ls.unshift(newD))
199
+ block.childs.unshift dblock
200
+ block.dependencies.unshift dqname if not Bake.options.project
201
+ else
202
+ block.config.setBaseElement(ls + [newD])
203
+ block.childs << dblock
204
+ block.dependencies << dqname if not Bake.options.project
205
+ end
206
+ block.depToBlock[d.name + "," + d.config] = dblock
207
+
208
+ end
209
+ end
210
+ end
211
+ num_interations += 1
212
+ end while counter > 0
213
+ end
214
+
215
+ def makeDot
216
+
217
+ File.open(Bake.options.dot, 'w') do |file|
218
+ puts "Creating #{Bake.options.dot}"
219
+
220
+ file.write "# Generated by bake\n"
221
+ file.write "# Example to show the graph: dot #{Bake.options.dot} -Tpng -o out.png\n"
222
+ file.write "# Example to reduce the graph: tred #{Bake.options.dot} | dot -Tpng -o out.png\n\n"
223
+
224
+ file.write "digraph \"#{Bake.options.main_project_name}_#{Bake.options.build_config}\" {\n\n"
225
+
226
+ file.write " concentrate = true\n\n"
227
+
228
+ onlyProjectName = nil
229
+ onlyConfigName = nil
230
+ if Bake.options.project
231
+ splitted = Bake.options.project.split(',')
232
+ onlyProjectName = splitted[0]
233
+ onlyConfigName = splitted[1] if splitted.length == 2
234
+ end
235
+
236
+ if onlyProjectName
237
+ if not @referencedConfigs.include? onlyProjectName
238
+ Bake.formatter.printError("Error: project #{onlyProjectName} not found")
239
+ ExitHelper.exit(1)
240
+ end
241
+ if onlyConfigName
242
+ if not @referencedConfigs[onlyProjectName].any? {|c| c.name == onlyConfigName}
243
+ Bake.formatter.printError("Error: project #{onlyProjectName} with config #{onlyConfigName} not found")
244
+ ExitHelper.exit(1)
245
+ end
246
+ end
247
+ end
248
+
249
+ foundProjs = {}
250
+ @referencedConfigs.each do |projName, configs|
251
+ configs.each do |config|
252
+ config.dependency.each do |d|
253
+ if onlyProjectName
254
+ next if config.parent.name != onlyProjectName && d.name != onlyProjectName
255
+ if onlyConfigName
256
+ leftSide = config.name == onlyConfigName && config.parent.name == onlyProjectName
257
+ rightSide = d.config == onlyConfigName && d.name == onlyProjectName
258
+ next if not leftSide and not rightSide
259
+ end
260
+ end
261
+ file.write " \"#{config.qname}\" -> \"#{d.name},#{d.config}\"\n"
262
+
263
+ foundProjs[config.parent.name] = [] if not foundProjs.include? config.parent.name
264
+ foundProjs[config.parent.name] << config.name if not foundProjs[config.parent.name].include? config.name
265
+ foundProjs[d.name] = [] if not foundProjs.include? d.name
266
+ foundProjs[d.name] << d.config if not foundProjs[config.parent.name].include? d.config
267
+ end
268
+ end
269
+ end
270
+ file.write "\n"
271
+
272
+ @referencedConfigs.each do |projName, configs|
273
+ next if Bake.options.project and not foundProjs.include?projName
274
+ file.write " subgraph \"cluster_#{projName}\" {\n"
275
+ file.write " label =\"#{projName}\"\n"
276
+ configs.each do |config|
277
+ next if Bake.options.project and not foundProjs[projName].include? config.name
278
+ file.write " \"#{projName},#{config.name}\" [label = \"#{config.name}\", style = filled, fillcolor = #{config.color}]\n"
279
+ end
280
+ file.write " }\n\n"
281
+ end
282
+
283
+ file.write "}\n"
284
+ end
285
+
286
+ ExitHelper.exit(0)
287
+ end
288
+
289
+ def convert2bb
290
+ @referencedConfigs.each do |projName, configs|
291
+ configs.each do |config|
292
+ block = Blocks::ALL_BLOCKS[config.qname]
293
+
294
+ addSteps(block, block.startupSteps, config.startupSteps)
295
+ addSteps(block, block.exitSteps, config.exitSteps)
296
+
297
+ if not Bake.options.prepro and not Bake.options.lint and not Bake.options.conversion_info and not Bake.options.docu and not Bake.options.filename and not Bake.options.analyze
298
+ addSteps(block, block.preSteps, config.preSteps)
299
+ addSteps(block, block.postSteps, config.postSteps)
300
+ end
301
+
302
+ if Bake.options.docu
303
+ block.mainSteps << Blocks::Docu.new(config, @configTcMap[config])
304
+ elsif Metamodel::CustomConfig === config
305
+ if not Bake.options.prepro and not Bake.options.lint and not Bake.options.conversion_info and not Bake.options.docu and not Bake.options.filename and not Bake.options.analyze
306
+ addSteps(block, block.mainSteps, config) if config.step
307
+ end
308
+ elsif Bake.options.conversion_info
309
+ block.mainSteps << Blocks::Convert.new(block, config, @referencedConfigs, @configTcMap[config])
310
+ elsif Bake.options.lint
311
+ block.mainSteps << Blocks::Lint.new(block, config, @referencedConfigs, @configTcMap[config])
312
+ else
313
+ compile = Blocks::Compile.new(block, config, @referencedConfigs, @configTcMap[config])
314
+ (Blocks::ALL_COMPILE_BLOCKS[projName] ||= []) << compile
315
+ block.mainSteps << compile
316
+ if not Bake.options.filename and not Bake.options.analyze
317
+ if Metamodel::LibraryConfig === config
318
+ block.mainSteps << Blocks::Library.new(block, config, @referencedConfigs, @configTcMap[config], compile)
319
+ else
320
+ block.mainSteps << Blocks::Executable.new(block, config, @referencedConfigs, @configTcMap[config], compile)
321
+ end
322
+ end
323
+ end
324
+
325
+
326
+
327
+ end
328
+ end
329
+ end
330
+
331
+ def callBlock(block, method)
332
+ begin
333
+ return block.send(method)
334
+ rescue AbortException
335
+ raise
336
+ rescue Exception => ex
337
+ if Bake.options.debug
338
+ puts ex.message
339
+ puts ex.backtrace
340
+ end
341
+ return false
342
+ end
343
+ end
344
+
345
+ def callBlocks(startBlocks, method, ignoreStopOnFirstError = false)
346
+ Blocks::ALL_BLOCKS.each {|name,block| block.visited = false; block.result = true; block.inDeps = false }
347
+ Blocks::Block.reset_block_counter
348
+ result = true
349
+ startBlocks.each do |block|
350
+ result = callBlock(block, method) && result
351
+ if not ignoreStopOnFirstError
352
+ return false if not result and Bake.options.stopOnFirstError
353
+ end
354
+ end
355
+ return result
356
+ end
357
+
358
+ def calcStartBlocks
359
+ startProjectName = nil
360
+ startConfigName = nil
361
+ if Bake.options.project
362
+ splitted = Bake.options.project.split(',')
363
+ startProjectName = splitted[0]
364
+ startConfigName = splitted[1] if splitted.length == 2
365
+ end
366
+
367
+ if startConfigName
368
+ blockName = startProjectName+","+startConfigName
369
+ if not Blocks::ALL_BLOCKS.include?(startProjectName+","+startConfigName)
370
+ Bake.formatter.printError("Error: project #{startProjectName} with config #{startConfigName} not found")
371
+ ExitHelper.exit(1)
372
+ end
373
+ startBlocks = [Blocks::ALL_BLOCKS[startProjectName+","+startConfigName]]
374
+ Blocks::Block.set_num_projects(1)
375
+ elsif startProjectName
376
+ startBlocks = []
377
+ Blocks::ALL_BLOCKS.each do |blockName, block|
378
+ if blockName.start_with?(startProjectName + ",")
379
+ startBlocks << block
380
+ end
381
+ end
382
+ if startBlocks.length == 0
383
+ Bake.formatter.printError("Error: project #{startProjectName} not found")
384
+ ExitHelper.exit(1)
385
+ end
386
+ startBlocks.reverse! # most probably the order of dependencies if any
387
+ Blocks::Block.set_num_projects(startBlocks.length)
388
+ else
389
+ startBlocks = [Blocks::ALL_BLOCKS[Bake.options.main_project_name+","+Bake.options.build_config]]
390
+ Blocks::Block.set_num_projects(Blocks::ALL_BLOCKS.length)
391
+ end
392
+ return startBlocks
393
+ end
394
+
395
+ def doit()
396
+
397
+ if Bake.options.show_includes or Bake.options.show_includes_and_defines
398
+ s = StringIO.new
399
+ tmp = Thread.current[:stdout]
400
+ Thread.current[:stdout] = s unless tmp
401
+ end
402
+
403
+ taskType = "Building"
404
+ if Bake.options.lint
405
+ taskType = "Linting"
406
+ elsif Bake.options.conversion_info
407
+ taskType = "Showing conversion infos"
408
+ elsif Bake.options.docu
409
+ taskType = "Generating documentation"
410
+ elsif Bake.options.prepro
411
+ taskType = "Preprocessing"
412
+ elsif Bake.options.linkOnly
413
+ taskType = "Linking"
414
+ elsif Bake.options.rebuild
415
+ taskType = "Rebuilding"
416
+ elsif Bake.options.clean
417
+ taskType = "Cleaning"
418
+ end
419
+
420
+ begin
421
+
422
+ if Bake.options.showConfigs
423
+ al = AdaptConfig.new
424
+ adaptConfigs = al.load()
425
+ Config.new.printConfigs(adaptConfigs)
426
+ else
427
+ cache = CacheAccess.new()
428
+ @referencedConfigs = cache.load_cache unless Bake.options.nocache
429
+
430
+ if @referencedConfigs.nil?
431
+ al = AdaptConfig.new
432
+ adaptConfigs = al.load()
433
+
434
+ @loadedConfig = Config.new
435
+ @referencedConfigs = @loadedConfig.load(adaptConfigs)
436
+
437
+ cache.write_cache(@referencedConfigs, adaptConfigs)
438
+ end
439
+ end
440
+
441
+ taskType = "Analyzing" if Bake.options.analyze
442
+
443
+ @mainConfig = @referencedConfigs[Bake.options.main_project_name].select { |c| c.name == Bake.options.build_config }.first
444
+
445
+ if Bake.options.lint
446
+ @defaultToolchain = Utils.deep_copy(Bake::Toolchain::Provider["Lint"])
447
+ else
448
+ basedOn = @mainConfig.defaultToolchain.basedOn
449
+ basedOnToolchain = Bake::Toolchain::Provider[basedOn]
450
+ if basedOnToolchain.nil?
451
+ Bake.formatter.printError("DefaultToolchain based on unknown compiler '#{basedOn}'", @mainConfig.defaultToolchain)
452
+ ExitHelper.exit(1)
453
+ end
454
+
455
+ # The flag "-FS" must only be set for VS2013 and above
456
+ ENV["MSVC_FORCE_SYNC_PDB_WRITES"] = ""
457
+ if basedOn == "MSVC"
458
+ begin
459
+ res = `cl.exe 2>&1`
460
+ raise Exception.new unless $?.success?
461
+ scan_res = res.scan(/ersion (\d+).(\d+).(\d+)/)
462
+ if scan_res.length > 0
463
+ ENV["MSVC_FORCE_SYNC_PDB_WRITES"] = "-FS" if scan_res[0][0].to_i >= 18 # 18 is the compiler major version in VS2013
464
+ else
465
+ Bake.formatter.printError("Could not read MSVC version")
466
+ ExitHelper.exit(1)
467
+ end
468
+ rescue SystemExit
469
+ raise
470
+ rescue Exception => e
471
+ Bake.formatter.printError("Could not detect MSVC compiler")
472
+ ExitHelper.exit(1)
473
+ end
474
+ end
475
+
476
+ @defaultToolchain = Utils.deep_copy(basedOnToolchain)
477
+ Bake.options.envToolchain = true if (basedOn.include?"_ENV")
478
+ end
479
+ integrateToolchain(@defaultToolchain, @mainConfig.defaultToolchain)
480
+
481
+ # todo: cleanup this hack
482
+ Bake.options.analyze = @defaultToolchain[:COMPILER][:CPP][:COMPILE_FLAGS].include?"analyze"
483
+ Bake.options.eclipseOrder = @mainConfig.defaultToolchain.eclipseOrder
484
+
485
+ createBaseTcsForConfig
486
+ substVars
487
+ createTcsForConfig
488
+
489
+ @@linkBlock = 0
490
+
491
+ @prebuild = nil
492
+ calcPrebuildBlocks if Bake.options.prebuild
493
+
494
+ makeBlocks
495
+ makeGraph
496
+ makeDot if Bake.options.dot
497
+
498
+ convert2bb
499
+
500
+ if Bake.options.show_includes
501
+ Thread.current[:stdout] = tmp
502
+ Blocks::Show.includes
503
+ end
504
+
505
+ if Bake.options.show_includes_and_defines
506
+ Thread.current[:stdout] = tmp
507
+ Blocks::Show.includesAndDefines(@mainConfig, @configTcMap[@mainConfig])
508
+ end
509
+
510
+ startBlocks = calcStartBlocks
511
+
512
+ Bake::IDEInterface.instance.set_build_info(@mainConfig.parent.name, @mainConfig.name, Blocks::ALL_BLOCKS.length)
513
+
514
+ ideAbort = false
515
+ begin
516
+ result = callBlocks(startBlocks, :startup, true)
517
+ if Bake.options.clean or Bake.options.rebuild
518
+ if not Bake.options.stopOnFirstError or result
519
+ result = callBlocks(startBlocks, :clean) && result
520
+ end
521
+ end
522
+ if Bake.options.rebuild or not Bake.options.clean
523
+ if not Bake.options.stopOnFirstError or result
524
+ result = callBlocks(startBlocks, :execute) && result
525
+ end
526
+ end
527
+ rescue AbortException
528
+ ideAbort = true
529
+ end
530
+ result = callBlocks(startBlocks, :exits, true) && result
531
+
532
+ if ideAbort
533
+ Bake.formatter.printError("\n#{taskType} aborted.")
534
+ ExitHelper.set_exit_code(1)
535
+ return
536
+ end
537
+
538
+ if Bake.options.cc2j_filename
539
+ require "json"
540
+ File.write(Bake.options.cc2j_filename, JSON.pretty_generate(Blocks::CC2J))
541
+ end
542
+
543
+ if result == false
544
+ Bake.formatter.printError("\n#{taskType} failed.")
545
+ ExitHelper.set_exit_code(1)
546
+ return
547
+ else
548
+ if Bake.options.linkOnly and @@linkBlock == 0
549
+ Bake.formatter.printSuccess("\nNothing to link.")
550
+ else
551
+ Bake.formatter.printSuccess("\n#{taskType} done.")
552
+ end
553
+ end
554
+ rescue SystemExit
555
+ Bake.formatter.printError("\n#{taskType} failed.") if ExitHelper.exit_code != 0
556
+ end
557
+
558
+ end
559
+
560
+ def connect()
561
+ if Bake.options.socket != 0
562
+ Bake::IDEInterface.instance.connect(Bake.options.socket)
563
+ end
564
+ end
565
+
566
+ def disconnect()
567
+ if Bake.options.socket != 0
568
+ Bake::IDEInterface.instance.disconnect()
569
+ end
570
+ end
571
+
572
+ end
573
+ end
574
+
575
+ trap("SIGINT") do
576
+ Bake::IDEInterface.instance.set_abort(1)
559
577
  end