bake-toolkit 2.20.4 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile.rb +3 -3
  3. data/bin/bake +46 -46
  4. data/bin/bake-doc +11 -11
  5. data/bin/bakery +179 -179
  6. data/bin/createVSProjects +213 -213
  7. data/documentation/_build/html/_sources/changelog.txt +456 -451
  8. data/documentation/_build/html/_sources/commandline/commandline.txt +107 -107
  9. data/documentation/_build/html/_sources/concepts/build_hierarchy.txt +34 -34
  10. data/documentation/_build/html/_sources/concepts/concepts.txt +14 -14
  11. data/documentation/_build/html/_sources/concepts/inject.txt +65 -65
  12. data/documentation/_build/html/_sources/concepts/link_order.txt +91 -91
  13. data/documentation/_build/html/_sources/concepts/prebuild.txt +56 -56
  14. data/documentation/_build/html/_sources/concepts/the_main_project.txt +45 -45
  15. data/documentation/_build/html/_sources/concepts/the_project_meta_file.txt +72 -72
  16. data/documentation/_build/html/_sources/ide/eclipse/eclipse.txt +25 -25
  17. data/documentation/_build/html/_sources/ide/eclipse/how_to_convert_existing_cdt_workspace.txt +31 -31
  18. data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_new_project_in_eclipse.txt +18 -18
  19. data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_workspace_in_eclipse.txt +27 -27
  20. data/documentation/_build/html/_sources/ide/eclipse/how_to_debug_in_eclipse.txt +38 -38
  21. data/documentation/_build/html/_sources/ide/eclipse/how_to_install_eclipse_plugin.txt +44 -44
  22. data/documentation/_build/html/_sources/ide/eclipse/how_to_use_bake_in_eclipse.txt +86 -86
  23. data/documentation/_build/html/_sources/ide/ide_integrations.txt +8 -8
  24. data/documentation/_build/html/_sources/ide/vs/how_to_create_vs_projects.txt +15 -15
  25. data/documentation/_build/html/_sources/ide/vs/how_to_debug_in_vs.txt +35 -35
  26. data/documentation/_build/html/_sources/ide/vs/how_to_used_bake_in_vs.txt +35 -35
  27. data/documentation/_build/html/_sources/ide/vs/vs.txt +10 -10
  28. data/documentation/_build/html/_sources/ide/vs/vs_install.txt +43 -43
  29. data/documentation/_build/html/_sources/index.txt +33 -33
  30. data/documentation/_build/html/_sources/install/install_bake.txt +112 -112
  31. data/documentation/_build/html/_sources/internal.txt +50 -50
  32. data/documentation/_build/html/_sources/known_issues.txt +9 -9
  33. data/documentation/_build/html/_sources/license.txt +4 -4
  34. data/documentation/_build/html/_sources/performance/performance.txt +104 -104
  35. data/documentation/_build/html/_sources/quickstart/quickstart.txt +70 -70
  36. data/documentation/_build/html/_sources/syntax/adapt_configs.txt +143 -143
  37. data/documentation/_build/html/_sources/syntax/auto_adjustment.txt +43 -43
  38. data/documentation/_build/html/_sources/syntax/derive_configs.txt +93 -94
  39. data/documentation/_build/html/_sources/syntax/project_meta_syntax.txt +19 -19
  40. data/documentation/_build/html/_sources/syntax/syntax.txt +11 -11
  41. data/documentation/_build/html/_sources/syntax/variable_substitutions.txt +147 -147
  42. data/documentation/_build/html/_sources/tips_and_tricks/dot.txt +34 -34
  43. data/documentation/_build/html/_sources/tips_and_tricks/how_to_use_bake_with_cygwin.txt +62 -62
  44. data/documentation/_build/html/_sources/tips_and_tricks/static_code_analysis.txt +122 -122
  45. data/documentation/_build/html/_sources/tips_and_tricks/the_bakery.txt +72 -72
  46. data/documentation/_build/html/_sources/tips_and_tricks/the_clang.txt +43 -43
  47. data/documentation/_build/html/_sources/tips_and_tricks/tips_and_tricks.txt +34 -34
  48. data/documentation/_build/html/_sources/why_bake/why_bake.txt +40 -40
  49. data/documentation/_build/html/changelog.html +7 -0
  50. data/documentation/_build/html/commandline/commandline.html +2 -2
  51. data/documentation/_build/html/concepts/link_order.html +2 -2
  52. data/documentation/_build/html/concepts/prebuild.html +2 -2
  53. data/documentation/_build/html/index.html +4 -4
  54. data/documentation/_build/html/performance/performance.html +2 -2
  55. data/documentation/_build/html/searchindex.js +1 -1
  56. data/documentation/_build/html/syntax/adapt_configs.html +2 -2
  57. data/documentation/_build/html/syntax/syntax.html +2 -2
  58. data/documentation/_build/html/tips_and_tricks/the_clang.html +2 -2
  59. data/documentation/_build/html/why_bake/why_bake.html +2 -2
  60. data/lib/adapt/config/loader.rb +112 -112
  61. data/lib/bake/bundle.rb +158 -158
  62. data/lib/bake/cache.rb +179 -180
  63. data/lib/bake/config/checks.rb +68 -68
  64. data/lib/bake/config/loader.rb +363 -363
  65. data/lib/bake/libElement.rb +176 -176
  66. data/lib/bake/mergeConfig.rb +208 -208
  67. data/lib/bake/model/language.rb +45 -45
  68. data/lib/bake/model/loader.rb +99 -99
  69. data/lib/bake/model/metamodel.rb +307 -307
  70. data/lib/bake/model/metamodel_ext.rb +27 -27
  71. data/lib/bake/options/create.rb +95 -95
  72. data/lib/bake/options/options.rb +315 -310
  73. data/lib/bake/options/showDoc.rb +20 -20
  74. data/lib/bake/options/showLicense.rb +9 -9
  75. data/lib/bake/options/showToolchains.rb +38 -38
  76. data/lib/bake/options/usage.rb +79 -68
  77. data/lib/bake/subst.rb +313 -313
  78. data/lib/bake/toolchain/clang.rb +44 -44
  79. data/lib/bake/toolchain/clang_analyze.rb +31 -31
  80. data/lib/bake/toolchain/colorizing_formatter.rb +125 -125
  81. data/lib/bake/toolchain/diab.rb +53 -53
  82. data/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -40
  83. data/lib/bake/toolchain/errorparser/diab_linker_error_parser.rb +41 -41
  84. data/lib/bake/toolchain/errorparser/error_parser.rb +71 -71
  85. data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -35
  86. data/lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb +35 -35
  87. data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -32
  88. data/lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb +44 -44
  89. data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -40
  90. data/lib/bake/toolchain/errorparser/keil_linker_error_parser.rb +30 -30
  91. data/lib/bake/toolchain/errorparser/lint_error_parser.rb +34 -34
  92. data/lib/bake/toolchain/errorparser/msvc_compiler_error_parser.rb +63 -63
  93. data/lib/bake/toolchain/errorparser/msvc_linker_error_parser.rb +42 -42
  94. data/lib/bake/toolchain/errorparser/process_output.rb +2 -2
  95. data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -30
  96. data/lib/bake/toolchain/errorparser/ti_linker_error_parser.rb +30 -30
  97. data/lib/bake/toolchain/gcc.rb +49 -49
  98. data/lib/bake/toolchain/gcc_env.rb +55 -55
  99. data/lib/bake/toolchain/greenhills.rb +52 -52
  100. data/lib/bake/toolchain/keil.rb +53 -53
  101. data/lib/bake/toolchain/lint.rb +20 -20
  102. data/lib/bake/toolchain/msvc.rb +58 -58
  103. data/lib/bake/toolchain/provider.rb +146 -146
  104. data/lib/bake/toolchain/ti.rb +47 -47
  105. data/lib/bake/util.rb +149 -149
  106. data/lib/bakery/buildPattern.rb +24 -24
  107. data/lib/bakery/model/language.rb +22 -22
  108. data/lib/bakery/model/loader.rb +55 -55
  109. data/lib/bakery/model/metamodel.rb +48 -48
  110. data/lib/bakery/options/options.rb +87 -87
  111. data/lib/bakery/toBake.rb +81 -81
  112. data/lib/blocks/block.rb +324 -324
  113. data/lib/blocks/blockBase.rb +204 -204
  114. data/lib/blocks/commandLine.rb +38 -38
  115. data/lib/blocks/compile.rb +529 -528
  116. data/lib/blocks/convert.rb +41 -41
  117. data/lib/blocks/docu.rb +30 -30
  118. data/lib/blocks/executable.rb +174 -174
  119. data/lib/blocks/has_execute_command.rb +31 -31
  120. data/lib/blocks/library.rb +114 -114
  121. data/lib/blocks/lint.rb +56 -56
  122. data/lib/blocks/makefile.rb +100 -100
  123. data/lib/blocks/showIncludes.rb +140 -125
  124. data/lib/common/abortException.rb +4 -4
  125. data/lib/common/cleanup.rb +10 -10
  126. data/lib/common/exit_helper.rb +38 -38
  127. data/lib/common/ext/file.rb +88 -88
  128. data/lib/common/ext/rtext.rb +11 -11
  129. data/lib/common/ext/stdout.rb +45 -45
  130. data/lib/common/ide_interface.rb +194 -194
  131. data/lib/common/options/parser.rb +95 -85
  132. data/lib/common/process.rb +64 -64
  133. data/lib/common/utils.rb +52 -52
  134. data/lib/common/version.rb +31 -23
  135. data/lib/multithread/job.rb +44 -44
  136. data/lib/tocxx.rb +558 -555
  137. data/lib/vs/options.rb +69 -69
  138. data/license.txt +90 -90
  139. metadata +2 -2
@@ -1,44 +1,44 @@
1
- require 'common/ext/stdout'
2
- require 'stringio'
3
- require 'thread'
4
-
5
- module Bake
6
- module Multithread
7
-
8
- class Jobs
9
- def initialize(jobs, &block)
10
- nr_of_threads = [Bake.options.threads, jobs.length].min
11
- @jobs = jobs
12
- @threads = []
13
- nr_of_threads.times do
14
- @threads << ::Thread.new do
15
- block.call(self)
16
- end
17
- end
18
- end
19
-
20
- def failed
21
- @failed ||= false
22
- end
23
- def set_failed
24
- @failed = true
25
- end
26
-
27
- def get_next_or_nil
28
- the_next = nil
29
- mutex.synchronize {
30
- the_next = @jobs.shift
31
- }
32
- the_next
33
- end
34
- def join
35
- @threads.each{|t| while not t.join(2) do end}
36
- end
37
- def mutex
38
- @mutex ||= Mutex.new
39
- end
40
- end
41
-
42
- end
43
- end
44
-
1
+ require 'common/ext/stdout'
2
+ require 'stringio'
3
+ require 'thread'
4
+
5
+ module Bake
6
+ module Multithread
7
+
8
+ class Jobs
9
+ def initialize(jobs, &block)
10
+ nr_of_threads = [Bake.options.threads, jobs.length].min
11
+ @jobs = jobs
12
+ @threads = []
13
+ nr_of_threads.times do
14
+ @threads << ::Thread.new do
15
+ block.call(self)
16
+ end
17
+ end
18
+ end
19
+
20
+ def failed
21
+ @failed ||= false
22
+ end
23
+ def set_failed
24
+ @failed = true
25
+ end
26
+
27
+ def get_next_or_nil
28
+ the_next = nil
29
+ mutex.synchronize {
30
+ the_next = @jobs.shift
31
+ }
32
+ the_next
33
+ end
34
+ def join
35
+ @threads.each{|t| while not t.join(2) do end}
36
+ end
37
+ def mutex
38
+ @mutex ||= Mutex.new
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+
@@ -1,556 +1,559 @@
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
- taskType = "Building"
394
- if Bake.options.lint
395
- taskType = "Linting"
396
- elsif Bake.options.conversion_info
397
- taskType = "Showing conversion infos"
398
- elsif Bake.options.docu
399
- taskType = "Generating documentation"
400
- elsif Bake.options.prepro
401
- taskType = "Preprocessing"
402
- elsif Bake.options.linkOnly
403
- taskType = "Linking"
404
- elsif Bake.options.rebuild
405
- taskType = "Rebuilding"
406
- elsif Bake.options.clean
407
- taskType = "Cleaning"
408
- end
409
-
410
- begin
411
- al = AdaptConfig.new
412
- adaptConfigs = al.load()
413
-
414
- @loadedConfig = Config.new
415
- @loadedConfig.load(adaptConfigs)
416
-
417
- taskType = "Analyzing" if Bake.options.analyze
418
-
419
- @mainConfig = @loadedConfig.referencedConfigs[Bake.options.main_project_name].select { |c| c.name == Bake.options.build_config }.first
420
-
421
- if Bake.options.lint
422
- @defaultToolchain = Utils.deep_copy(Bake::Toolchain::Provider["Lint"])
423
- else
424
- basedOn = @mainConfig.defaultToolchain.basedOn
425
- basedOnToolchain = Bake::Toolchain::Provider[basedOn]
426
- if basedOnToolchain.nil?
427
- Bake.formatter.printError("DefaultToolchain based on unknown compiler '#{basedOn}'", @mainConfig.defaultToolchain)
428
- ExitHelper.exit(1)
429
- end
430
-
431
- # The flag "-FS" must only be set for VS2013 and above
432
- ENV["MSVC_FORCE_SYNC_PDB_WRITES"] = ""
433
- if basedOn == "MSVC"
434
- begin
435
- res = `cl.exe 2>&1`
436
- raise Exception.new unless $?.success?
437
- scan_res = res.scan(/ersion (\d+).(\d+).(\d+)/)
438
- if scan_res.length > 0
439
- ENV["MSVC_FORCE_SYNC_PDB_WRITES"] = "-FS" if scan_res[0][0].to_i >= 18 # 18 is the compiler major version in VS2013
440
- else
441
- Bake.formatter.printError("Could not read MSVC version")
442
- ExitHelper.exit(1)
443
- end
444
- rescue SystemExit
445
- raise
446
- rescue Exception => e
447
- Bake.formatter.printError("Could not detect MSVC compiler")
448
- ExitHelper.exit(1)
449
- end
450
- end
451
-
452
- @defaultToolchain = Utils.deep_copy(basedOnToolchain)
453
- Bake.options.envToolchain = true if (basedOn.include?"_ENV")
454
- end
455
- integrateToolchain(@defaultToolchain, @mainConfig.defaultToolchain)
456
-
457
- # todo: cleanup this hack
458
- Bake.options.analyze = @defaultToolchain[:COMPILER][:CPP][:COMPILE_FLAGS].include?"analyze"
459
- Bake.options.eclipseOrder = @mainConfig.defaultToolchain.eclipseOrder
460
-
461
- createBaseTcsForConfig
462
- substVars
463
- createTcsForConfig
464
-
465
- @@linkBlock = 0
466
-
467
- @prebuild = nil
468
- calcPrebuildBlocks if Bake.options.prebuild
469
-
470
- makeBlocks
471
- makeGraph
472
- makeDot if Bake.options.dot
473
-
474
- convert2bb
475
-
476
- Blocks::Show.includes if Bake.options.show_includes
477
- Blocks::Show.includesAndDefines(@mainConfig, @configTcMap[@mainConfig]) if Bake.options.show_includes_and_defines
478
-
479
- startBlocks = calcStartBlocks
480
-
481
- Bake::IDEInterface.instance.set_build_info(@mainConfig.parent.name, @mainConfig.name, Blocks::ALL_BLOCKS.length)
482
-
483
- ideAbort = false
484
- begin
485
- result = callBlocks(startBlocks, :startup, true)
486
- if Bake.options.clean or Bake.options.rebuild
487
- if not Bake.options.stopOnFirstError or result
488
- result = callBlocks(startBlocks, :clean) && result
489
- end
490
- end
491
- if Bake.options.rebuild or not Bake.options.clean
492
- if not Bake.options.stopOnFirstError or result
493
- result = callBlocks(startBlocks, :execute) && result
494
- end
495
- end
496
- rescue AbortException
497
- ideAbort = true
498
- end
499
- result = callBlocks(startBlocks, :exits, true) && result
500
-
501
- if ideAbort
502
- Bake.formatter.printError("\n#{taskType} aborted.")
503
- ExitHelper.set_exit_code(1)
504
- return
505
- end
506
-
507
- if Bake.options.cc2j_filename
508
- Blocks::BlockBase.prepareOutput(Bake.options.cc2j_filename)
509
- File.open(Bake.options.cc2j_filename, 'w') do |f|
510
- f.puts "["
511
- noComma = Blocks::CC2J.length - 1
512
- Blocks::CC2J.each_with_index do |c, index|
513
- cmd = c[:command].is_a?(Array) ? c[:command].join(' ') : c[:command]
514
- f.puts " { \"directory\": \"" + c[:directory] + "\","
515
- f.puts " \"command\": \"" + cmd + "\","
516
- f.puts " \"file\": \"" + c[:file] + "\" }#{index == noComma ? "" : ","}"
517
- end
518
- f.puts "]"
519
- end
520
- end
521
-
522
- if result == false
523
- Bake.formatter.printError("\n#{taskType} failed.")
524
- ExitHelper.set_exit_code(1)
525
- return
526
- else
527
- if Bake.options.linkOnly and @@linkBlock == 0
528
- Bake.formatter.printSuccess("\nNothing to link.")
529
- else
530
- Bake.formatter.printSuccess("\n#{taskType} done.")
531
- end
532
- end
533
- rescue SystemExit
534
- Bake.formatter.printError("\n#{taskType} failed.") if ExitHelper.exit_code != 0
535
- end
536
-
537
- end
538
-
539
- def connect()
540
- if Bake.options.socket != 0
541
- Bake::IDEInterface.instance.connect(Bake.options.socket)
542
- end
543
- end
544
-
545
- def disconnect()
546
- if Bake.options.socket != 0
547
- Bake::IDEInterface.instance.disconnect()
548
- end
549
- end
550
-
551
- end
552
- end
553
-
554
- trap("SIGINT") do
555
- 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
+ @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)
556
559
  end