bake-toolkit 1.8.0.1 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bake +14 -53
  3. data/bin/bakery +50 -43
  4. data/bin/createVSProjects +3 -3
  5. data/doc/cmd/install.html +1 -5
  6. data/doc/cmd/usecmd.html +29 -5
  7. data/doc/dyk/lint.html +21 -4
  8. data/doc/dyk/tipps.html +0 -6
  9. data/doc/eclipse/import.html +3 -1
  10. data/doc/eclipse/import/Import.png +0 -0
  11. data/doc/eclipse/use.html +8 -5
  12. data/doc/further/change.html +134 -1
  13. data/doc/further/issues.html +1 -0
  14. data/doc/further/wish.html +24 -21
  15. data/doc/index.html +1 -1
  16. data/doc/syntax/subst.html +8 -1
  17. data/doc/syntax/syntax.html +42 -14
  18. data/lib/bake/cache.rb +51 -59
  19. data/lib/bake/config/loader.rb +289 -0
  20. data/lib/bake/libElement.rb +134 -0
  21. data/lib/bake/mergeConfig.rb +1 -1
  22. data/lib/bake/model/language.rb +1 -1
  23. data/lib/bake/model/loader.rb +88 -0
  24. data/lib/bake/model/metamodel.rb +24 -16
  25. data/lib/bake/model/metamodel_ext.rb +9 -4
  26. data/lib/bake/options/options.rb +222 -0
  27. data/lib/bake/options/showConfigNames.rb +44 -0
  28. data/lib/bake/options/showDoc.rb +19 -0
  29. data/lib/bake/options/showLicense.rb +9 -0
  30. data/lib/bake/options/showToolchains.rb +39 -0
  31. data/lib/bake/options/usage.rb +54 -0
  32. data/lib/bake/process_output.rb +10 -0
  33. data/lib/bake/subst.rb +105 -40
  34. data/lib/bake/toolchain/clang.rb +44 -0
  35. data/lib/bake/toolchain/colorizing_formatter.rb +125 -0
  36. data/lib/bake/toolchain/diab.rb +53 -0
  37. data/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -0
  38. data/lib/bake/toolchain/errorparser/diab_linker_error_parser.rb +41 -0
  39. data/lib/bake/toolchain/errorparser/error_parser.rb +71 -0
  40. data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -0
  41. data/lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb +35 -0
  42. data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -0
  43. data/lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb +44 -0
  44. data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -0
  45. data/lib/bake/toolchain/errorparser/keil_linker_error_parser.rb +30 -0
  46. data/lib/bake/toolchain/errorparser/lint_error_parser.rb +34 -0
  47. data/lib/bake/toolchain/errorparser/process_output.rb +3 -0
  48. data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -0
  49. data/lib/bake/toolchain/errorparser/ti_linker_error_parser.rb +30 -0
  50. data/lib/bake/toolchain/gcc.rb +49 -0
  51. data/lib/bake/toolchain/gcc_param.rb +7 -0
  52. data/lib/bake/toolchain/greenhills.rb +52 -0
  53. data/lib/bake/toolchain/keil.rb +55 -0
  54. data/lib/bake/toolchain/lint.rb +20 -0
  55. data/lib/bake/toolchain/provider.rb +136 -0
  56. data/lib/bake/toolchain/ti.rb +47 -0
  57. data/lib/bake/util.rb +27 -15
  58. data/lib/bakery/buildPattern.rb +1 -1
  59. data/lib/bakery/model/language.rb +1 -1
  60. data/lib/bakery/model/loader.rb +56 -0
  61. data/lib/bakery/model/metamodel.rb +1 -1
  62. data/lib/bakery/options/options.rb +87 -0
  63. data/lib/bakery/toBake.rb +10 -6
  64. data/lib/blocks/block.rb +225 -0
  65. data/lib/blocks/blockBase.rb +155 -0
  66. data/lib/blocks/commandLine.rb +25 -0
  67. data/lib/blocks/compile.rb +382 -0
  68. data/lib/blocks/docu.rb +28 -0
  69. data/lib/blocks/executable.rb +143 -0
  70. data/lib/blocks/has_execute_command.rb +31 -0
  71. data/lib/blocks/library.rb +78 -0
  72. data/lib/blocks/lint.rb +53 -0
  73. data/lib/blocks/makefile.rb +87 -0
  74. data/lib/blocks/showIncludes.rb +114 -0
  75. data/lib/common/abortException.rb +4 -0
  76. data/lib/common/cleanup.rb +9 -0
  77. data/lib/common/exit_helper.rb +28 -0
  78. data/lib/common/ext/file.rb +88 -0
  79. data/lib/common/ext/stdout.rb +45 -0
  80. data/lib/common/ide_interface.rb +194 -0
  81. data/lib/common/options/option.rb +13 -0
  82. data/lib/common/options/parser.rb +59 -0
  83. data/lib/common/process.rb +64 -0
  84. data/lib/common/utils.rb +52 -0
  85. data/lib/{bake → common}/version.rb +3 -10
  86. data/lib/multithread/job.rb +44 -0
  87. data/lib/tocxx.rb +201 -932
  88. data/lib/vs/options.rb +3 -2
  89. data/license.txt +47 -22
  90. metadata +90 -30
  91. data/bin/bake-doc +0 -12
  92. data/lib/alias/loader.rb +0 -56
  93. data/lib/alias/model/language.rb +0 -22
  94. data/lib/alias/model/metamodel.rb +0 -29
  95. data/lib/bake/loader.rb +0 -92
  96. data/lib/bake/options.rb +0 -421
  97. data/lib/bakery/loader.rb +0 -57
  98. data/lib/bakery/options.rb +0 -105
  99. data/lib/option/parser.rb +0 -73
@@ -0,0 +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
+
data/lib/tocxx.rb CHANGED
@@ -1,1015 +1,284 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- gem 'rake', '>= 0.7.3'
4
3
 
5
- require 'rake'
6
- require 'rake/clean'
7
- require 'bake/loader'
8
4
  require 'bake/model/metamodel_ext'
5
+
9
6
  require 'bake/util'
10
7
  require 'bake/cache'
11
8
  require 'bake/subst'
12
9
  require 'bake/mergeConfig'
13
- require 'cxxproject/buildingblocks/module'
14
- require 'cxxproject/buildingblocks/makefile'
15
- require 'cxxproject/buildingblocks/executable'
16
- require 'cxxproject/buildingblocks/lint'
17
- require 'cxxproject/buildingblocks/binary_library'
18
- require 'cxxproject/buildingblocks/custom_building_block'
19
- require 'cxxproject/buildingblocks/command_line'
20
- require 'cxxproject/buildingblocks/single_source'
21
- require 'cxxproject/utils/exit_helper'
22
- require 'cxxproject/ide_interface'
23
- require 'cxxproject/ext/file'
24
- require 'cxxproject/toolchain/provider'
25
- require 'cxxproject/ext/stdout'
26
- require 'cxxproject/ext/rake'
27
- require 'cxxproject/utils/utils'
28
- require 'cxxproject/utils/printer'
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/library'
25
+ require 'blocks/executable'
26
+ require 'blocks/lint'
27
+ require 'blocks/docu'
29
28
 
30
29
  require 'set'
31
30
  require 'socket'
32
31
 
33
- #require 'ruby-prof'
32
+ require 'blocks/showIncludes'
33
+ require 'common/abortException'
34
34
 
35
- module Cxxproject
35
+ module Bake
36
36
 
37
+ class SystemCommandFailed < Exception
38
+ end
39
+
37
40
  class ToCxx
38
41
 
39
- def initialize(options)
40
- @options = options
42
+ def initialize
41
43
  @configTcMap = {}
42
-
43
- RakeFileUtils.verbose_flag = @options.verbose
44
- end
45
-
46
- def set_output_taskname(bb)
47
- return if not bb.instance_of?ModuleBuildingBlock
48
- outputTaskname = task "Print #{bb.get_task_name}" do
49
- num = Rake.application.idei.get_number_of_projects
50
- @numCurrent ||= 0
51
- @numCurrent += 1
52
-
53
- unless @options.printLess
54
- Printer.printAdditionalInfo "**** Building #{@numCurrent} of #{num}: #{bb.name.gsub("Project ","")} (#{bb.config_name}) ****"
55
- end
56
-
57
- Rake.application.idei.set_build_info(bb.name.gsub("Project ",""), bb.config_name)
58
- Rake.application.addEmptyLine = true if @options.verbose
59
- end
60
- outputTaskname.type = Rake::Task::UTIL
61
- outputTaskname.transparent_timestamp = true
62
- insertAt = 0
63
- t = Rake.application[bb.last_content.get_task_name]
64
- t.prerequisites.each do |p|
65
- pname = String === p ? p : p.name
66
- if pname.index("Project ") == 0
67
- insertAt = insertAt + 1
68
- else
69
- break
70
- end
71
- end
72
- t.prerequisites.insert(insertAt, outputTaskname)
73
- end
74
-
75
-
76
- def calc_needed_bbs(bbChildName, needed_bbs)
77
- bbChild = ALL_BUILDING_BLOCKS[bbChildName]
78
- isModule = (ModuleBuildingBlock === bbChild ? 1 : 0)
79
- return 0 if needed_bbs.include?bbChild
80
- needed_bbs << bbChild
81
- bbChild.dependencies.each { |d| isModule += calc_needed_bbs(d, needed_bbs) }
82
- return isModule
83
44
  end
84
45
 
85
- # PRE and POST CONDITIONS
86
- def addSteps(steps, bbModule, projDir, globalFilterStr, tcs)
87
- if steps
88
- array = (Metamodel::Step === steps ? [steps] : steps.step)
89
- array.reverse.each do |m|
90
-
91
- checkDefault = true
92
- if m.filter != "" # explicit filter = 1. prio
93
- next if @options.exclude_filter.include?m.filter
94
- checkDefault = false if @options.include_filter.include?m.filter
95
- end
96
-
97
- if globalFilterStr != nil
98
- if checkDefault == true # global filter = 2. prio
99
- next if @options.exclude_filter.include?globalFilterStr
100
- checkDefault = false if @options.include_filter.include?globalFilterStr
101
- end
102
- end
103
-
104
- if checkDefault # default = 3. prio
105
- next if m.default == "off"
106
- end
107
-
108
- if Cxxproject::Metamodel::Makefile === m
109
- nameOfBB = m.name+"_"+m.target
110
- bb = Makefile.new(m.name, m.target)
111
- if m.pathTo != ""
112
- pathHash = {}
113
- m.pathTo.split(",").each do |p|
114
- nameOfP = p.strip
115
- dirOfP = nil
116
- if not @project2config.include?nameOfP
117
- @options.roots.each do |r|
118
- absIncDir = r+"/"+nameOfP
119
- if File.exists?(absIncDir)
120
- dirOfP = absIncDir
121
- break
122
- end
123
- end
124
- else
125
- dirOfP = @project2config[nameOfP].parent.get_project_dir
126
- end
127
- if dirOfP == nil
128
- Printer.printError "Error: Project '#{nameOfP}' not found for makefile #{projDir}/#{m.name}"
129
- ExitHelper.exit(1)
130
- end
131
- pathHash[nameOfP] = File.rel_from_to_project(File.dirname(projDir),File.dirname(dirOfP))
132
- end
133
- bb.set_path_to(pathHash)
134
- bb.pre_step = true if globalFilterStr
135
- end
136
- bb.set_flags(adjustFlags(tcs[:MAKE][:FLAGS],m.flags)) if m.flags
137
-
138
- @lib_elements[m.line_number] = [HasLibraries::LIB_WITH_PATH, m.lib] if m.lib != ""
139
- elsif Cxxproject::Metamodel::CommandLine === m
140
- nameOfBB = m.name
141
- bb = CommandLine.new(nameOfBB)
142
- bb.set_defined_in_file(m.file_name.to_s)
143
- bb.set_defined_in_line(m.line_number)
144
- bb.pre_step = true if globalFilterStr
145
- else
146
- next
147
- end
148
- bbModule.last_content.dependencies << bb.name
149
- bbModule.contents << bb
150
- bbModule.last_content = bb
151
- end
46
+ def createBaseTcsForConfig
47
+ @loadedConfig.referencedConfigs.each do |projName, configs|
48
+ configs.each do |config|
49
+ tcs = Utils.deep_copy(@defaultToolchain)
50
+ @configTcMap[config] = tcs
51
+ end
152
52
  end
153
53
  end
154
54
 
155
- def convPath(dir, config, exe = nil)
156
- projName = config.parent.name
157
- projDir = config.parent.get_project_dir
158
-
159
- d = dir.respond_to?("name") ? dir.name : dir
160
- return d if @options.no_autodir
161
-
162
- inc = d.split("/")
163
- if (inc[0] == projName)
164
- res = inc[1..-1].join("/") # within self
165
- res = "." if res == ""
166
- elsif @project2config.include?(inc[0])
167
- dirOther = @project2config[inc[0]].parent.get_project_dir
168
- res = File.rel_from_to_project(projDir, dirOther)
169
- postfix = inc[1..-1].join("/")
170
- res = res + postfix if postfix != ""
171
- else
172
- if (inc[0] != "..")
173
- return d if File.exists?(projDir + "/" + d) # e.g. "include"
174
-
175
- # check if dir exists without Project.meta entry
176
- @options.roots.each do |r|
177
- absIncDir = r+"/"+d
178
- if File.exists?(absIncDir)
179
- res = File.rel_from_to_project(projDir,absIncDir)
180
- if not res.nil?
181
- return res
182
- end
183
- end
184
- end
185
- else
186
- Printer.printInfo "Info: #{projName} uses \"..\" in path name #{d}" if @options.verbose
187
- end
188
-
189
- res = d # relative from self as last resort
55
+ def createTcsForConfig
56
+ @loadedConfig.referencedConfigs.each do |projName, configs|
57
+ configs.each do |config|
58
+ integrateToolchain(@configTcMap[config], config.toolchain)
59
+ end
190
60
  end
191
- res
192
61
  end
193
-
194
-
195
- def getFullProject(configs, configname, filename)
196
- config = nil
197
- configs.each do |c|
198
- if c.name == configname
199
- if config
200
- Printer.printError "Error: Config '#{configname}' found more than once in '#{filename}'"
201
- ExitHelper.exit(1)
202
- end
203
- config = c
204
- end
205
- end
206
-
207
- if not config
208
- Printer.printError "Error: Config '#{configname}' not found in '#{filename}'"
209
- ExitHelper.exit(1)
210
- end
211
-
212
- if config.extends != ""
213
- parent = getFullProject(configs, config.extends, filename)
214
- MergeConfig.new(config, parent).merge()
215
- end
216
-
217
- config
218
- end
219
-
220
-
221
- def loadProjMeta(loader, filename, configname)
222
- @project_files << filename
223
- f = loader.load(filename)
224
-
225
- config = nil
226
-
227
- if f.root_elements.length != 1 or not Metamodel::Project === f.root_elements[0]
228
- Printer.printError "Error: '#{filename}' must have exactly one 'Project' element as root element"
229
- ExitHelper.exit(1)
230
- end
231
-
232
- f.root_elements.each do |e|
233
- x = e.getConfig
234
- config = getFullProject(x,configname,filename)
235
62
 
236
- x.each do |y|
237
- if y != config
238
- e.removeGeneric("Config", y)
239
- end
240
- end
241
- end
242
- f.mark_changed
243
- f.build_index
244
-
245
- if not config
246
- Printer.printError "Error: Config '#{configname}' not found in '#{filename}'"
247
- ExitHelper.exit(1)
63
+ def substVars
64
+ Subst.itute(@mainConfig, Bake.options.main_project_name, true, @configTcMap[@mainConfig])
65
+ @loadedConfig.referencedConfigs.each do |projName, configs|
66
+ configs.each do |config|
67
+ if config != @mainConfig
68
+ Subst.itute(config, projName, false, @configTcMap[config])
69
+ end
70
+ end
248
71
  end
249
-
250
- config
251
72
  end
252
-
253
- def load_meta
254
73
 
255
- loader = Loader.new(@options)
256
- @project_files = []
257
-
258
- @project2config = {}
259
-
260
- project2config_pending = {}
261
- project2config_pending[@mainProjectName] = @options.build_config
262
-
263
- if not File.exist?(@options.main_dir+"/Project.meta")
264
- Printer.printError "Error: #{@options.main_dir}/Project.meta not found"
265
- ExitHelper.exit(1)
266
- end
267
-
268
- potentialProjs = []
269
- @options.roots.each do |r|
270
- if (r.length == 3 && r.include?(":/"))
271
- r = r + @mainProjectName # glob would not work otherwise on windows (ruby bug?)
272
- end
273
- r = r+"/**{,/*/**}/Project.meta"
274
- potentialProjs.concat(Dir.glob(r))
275
- end
276
-
277
- potentialProjs = potentialProjs.uniq.sort unless potentialProjs.empty?
278
-
279
- while project2config_pending.length > 0
280
-
281
- pname_toload = project2config_pending.keys[0]
282
- cname_toload = project2config_pending[pname_toload]
283
- project2config_pending.delete(pname_toload)
284
-
285
- # check if file is in more than one root
286
- pmeta_filenames = []
287
-
288
- potentialProjs.each do |pp|
289
- if pp.include?("/" + pname_toload + "/Project.meta") or pp == pname_toload + "/Project.meta"
290
- pmeta_filenames << pp
291
- end
292
- end
293
74
 
294
- if pmeta_filenames.empty?
295
- Printer.printError "Error: #{pname_toload}/Project.meta not found"
296
- ExitHelper.exit(1)
297
- end
298
-
299
- if pmeta_filenames.length > 1
300
- Printer.printWarning "Warning: #{pname_toload} exists more than once:"
301
- chosen = " (chosen)"
302
- pmeta_filenames.each do |f|
303
- Printer.printWarning " #{f}#{chosen}"
304
- chosen = ""
305
- end
306
- end
307
-
308
-
309
- config = loadProjMeta(loader, pmeta_filenames[0], cname_toload)
310
-
311
- @project2config[pname_toload] = config
312
-
313
- project2configLocal = {}
314
-
315
- if @project2config.length == 1
316
- if config.defaultToolchain == nil
317
- Printer.printError "Error: Main project configuration must contain DefaultToolchain"
318
- ExitHelper.exit(1)
319
- else
320
- basedOn = config.defaultToolchain.basedOn
321
- basedOn = "GCC_Lint" if @options.lint
322
- basedOnToolchain = Cxxproject::Toolchain::Provider[basedOn]
323
- if basedOnToolchain == nil
324
- Printer.printError "Error: DefaultToolchain based on unknown compiler '#{basedOn}'"
325
- ExitHelper.exit(1)
326
- end
327
- @defaultToolchain = Utils.deep_copy(basedOnToolchain)
328
- integrateToolchain(@defaultToolchain, config.defaultToolchain)
329
-
330
- if @defaultToolchainCached
331
- unless @defaultToolchain[:LINKER][:FLAGS] == @defaultToolchainCached[:LINKER][:FLAGS] and
332
- @defaultToolchain[:LINKER][:LIB_PREFIX_FLAGS] == @defaultToolchainCached[:LINKER][:LIB_PREFIX_FLAGS] and
333
- @defaultToolchain[:LINKER][:LIB_POSTFIX_FLAGS] == @defaultToolchainCached[:LINKER][:LIB_POSTFIX_FLAGS] and
334
- @defaultToolchain[:ARCHIVER][:FLAGS] == @defaultToolchainCached[:ARCHIVER][:FLAGS] and
335
- @defaultToolchain[:COMPILER][:CPP][:FLAGS] == @defaultToolchainCached[:COMPILER][:CPP][:FLAGS] and
336
- @defaultToolchain[:COMPILER][:CPP][:DEFINES].join("") == @defaultToolchainCached[:COMPILER][:CPP][:DEFINES].join("") and
337
- @defaultToolchain[:COMPILER][:C][:FLAGS] == @defaultToolchainCached[:COMPILER][:C][:FLAGS] and
338
- @defaultToolchain[:COMPILER][:C][:DEFINES].join("") == @defaultToolchainCached[:COMPILER][:C][:DEFINES].join("") and
339
- @defaultToolchain[:COMPILER][:ASM][:FLAGS] == @defaultToolchainCached[:COMPILER][:ASM][:FLAGS] and
340
- @defaultToolchain[:COMPILER][:ASM][:DEFINES].join("") == @defaultToolchainCached[:COMPILER][:ASM][:DEFINES].join("") and
341
- @defaultToolchain[:LINT_POLICY].join("") == @defaultToolchainCached[:LINT_POLICY].join("")
342
- @defaultToolchainTime = @mainMetaTime
343
- end
344
- end
345
-
346
- end
347
- end
348
-
349
- if config.respond_to?("toolchain") and config.toolchain
350
- config.toolchain.compiler.each do |c|
351
- if not c.internalDefines.nil? and c.internalDefines != ""
352
- Printer.printError "Error: #{c.file_name}(#{c.internalDefines.line_number}): InternalDefines only allowed in DefaultToolchain'"
353
- ExitHelper.exit(1)
354
- end
355
- end
356
- end
357
-
358
- config.dependency.each do |d|
359
- pname = d.name
360
- cname = d.config
361
-
362
- # check that a project is not dependent twice
363
- if project2configLocal.include?pname
364
- Printer.printError "Error: More than one dependencies found to '#{pname}' in config '#{config.name}'"
365
- ExitHelper.exit(1)
366
- end
367
- project2configLocal[pname] = cname
368
-
369
- # check pending loads
370
- inconsistentConfigs = nil
371
- if @project2config.include?pname
372
- inconsistentConfigs = @project2config[pname].name if @project2config[pname].name != cname
373
- else
374
- if project2config_pending.include?pname
375
- if project2config_pending[pname] != cname
376
- inconsistentConfigs = project2config_pending[pname]
377
- end
378
- else
379
- project2config_pending[pname] = cname
380
- end
381
- end
382
- if inconsistentConfigs
383
- Printer.printError "Error: dependency to config '#{cname}' of project '#{pname}' found (line #{d.line_number}), but config #{inconsistentConfigs} was requested earlier"
384
- ExitHelper.exit(1)
385
- end
75
+
76
+ def addSteps(block, blockSteps, configSteps)
77
+ Array(configSteps.step).each do |step|
78
+ if Bake::Metamodel::Makefile === step
79
+ blockSteps << Blocks::Makefile.new(step, @loadedConfig.referencedConfigs, block)
80
+ elsif Bake::Metamodel::CommandLine === step
81
+ blockSteps << Blocks::CommandLine.new(step, @loadedConfig.referencedConfigs)
386
82
  end
387
- end
388
-
83
+ end if configSteps
389
84
  end
390
85
 
391
- def writeCMake
392
- Printer.printError "Error: --cmake not supported by this version."
393
- end
394
-
395
- def getTc(config)
396
- tcs = nil
397
- if not Metamodel::CustomConfig === config
398
- tcs = Utils.deep_copy(@defaultToolchain)
399
- integrateToolchain(tcs, config.toolchain)
400
- else
401
- tcs = Utils.deep_copy(Cxxproject::Toolchain::Provider.default)
402
- end
403
- @configTcMap[config] = tcs
404
- end
405
-
406
- def substVars
407
- @mainConfig = @project2config[@mainProjectName]
408
-
409
- basedOn = @mainConfig.defaultToolchain.basedOn
410
- basedOn = "GCC_Lint" if @options.lint
411
-
412
- basedOnToolchain = Cxxproject::Toolchain::Provider[basedOn]
413
- @defaultToolchain = Utils.deep_copy(basedOnToolchain)
414
- integrateToolchain(@defaultToolchain, @mainConfig.defaultToolchain)
415
-
416
- Subst.itute(@mainConfig, @mainProjectName, @options, true, getTc(@mainConfig))
417
- @project2config.each do |projName, config|
418
- Subst.itute(config, projName, @options, false, getTc(config)) if projName != @mainProjectName
86
+ def addDependencies(block, configDeps)
87
+ configDeps.each do |dep|
88
+ @loadedConfig.referencedConfigs[dep.name].each do |config|
89
+ if config.name == dep.config
90
+ block.dependencies << config.qname
91
+ break
92
+ end
93
+ end
419
94
  end
420
- end
95
+ end
421
96
 
422
97
  def convert2bb
423
- @project2config.each do |projName, config|
424
-
425
- projDir = config.parent.get_project_dir
426
- @lib_elements = {}
427
-
428
- bbModule = ModuleBuildingBlock.new("Project "+projName)
429
- bbModule.contents = []
430
-
431
- tcs = @configTcMap[config]
432
-
433
- addSteps(config.postSteps, bbModule, projDir, "POST", tcs) if not @options.linkOnly
434
-
435
- if Metamodel::CustomConfig === config
436
- if config.step
437
- if config.step.filter != ""
438
- Printer.printError "Error: #{config.file_name}(#{config.step.line_number}): attribute filter not allowed here"
439
- ExitHelper.exit(1)
440
- end
441
- if config.step.default != "on"
442
- Printer.printError "Error: #{config.file_name}(#{config.step.line_number}): attribute default not allowed here"
443
- ExitHelper.exit(1)
444
- end
445
- addSteps(config.step, bbModule, projDir, nil, tcs)
446
- end
447
- bbModule.main_content = BinaryLibrary.new(projName, false)
448
- elsif @options.lint
449
- bbModule.main_content = Lint.new(projName)
450
- bbModule.main_content.set_lint_min(@options.lint_min).set_lint_max(@options.lint_max)
451
- elsif Metamodel::LibraryConfig === config
452
- bbModule.main_content = SourceLibrary.new(projName)
453
- elsif Metamodel::ExecutableConfig === config
454
- bbModule.main_content = Executable.new(projName)
455
- if not config.artifactName.nil?
456
- x = @options.build_config + "/" + config.artifactName.name
457
- bbModule.main_content.set_executable_name(x)
458
- end
459
- bbModule.main_content.set_linker_script(convPath(config.linkerScript, config)) unless config.linkerScript.nil?
460
- end
461
- bbModule.last_content.dependencies << bbModule.main_content.name
462
- bbModule.last_content = bbModule.main_content
463
- bbModule.contents << bbModule.main_content
464
-
465
- # PRE CONDITIONS
466
- addSteps(config.preSteps, bbModule, projDir, "PRE", tcs) if not @options.linkOnly
467
-
468
- ([bbModule] + bbModule.contents).each do |c|
469
- c.set_tcs(tcs)
470
- if (@defaultToolchainTime <= File.mtime(config.file_name))
471
- c.set_config_files([config.file_name])
472
- else
473
- xxx = file "ssss"
474
- $defaultToolchainTime = @defaultToolchainTime
475
- def xxx.timestamp
476
- $defaultToolchainTime
477
- end
478
- def xxx.needed?
479
- true
480
- end
481
- @defaultToolchainTime
98
+ @loadedConfig.referencedConfigs.each do |projName, configs|
99
+ configs.each do |config|
482
100
 
483
- c.set_config_files([config.file_name, "ssss"])
484
- end
485
- c.set_project_dir(projDir)
101
+ block = Blocks::Block.new(config, @loadedConfig.referencedConfigs)
486
102
 
487
- if tcs[:OUTPUT_DIR] != nil
488
- p = convPath(tcs[:OUTPUT_DIR], config)
489
- c.set_output_dir(p)
490
- elsif projName == @mainProjectName
491
- c.set_output_dir(@options.build_config)
492
- else
493
- c.set_output_dir(@options.build_config + "_" + @mainProjectName)
494
- end
495
- c.set_config_name(config.name)
496
- end
497
-
498
- if HasLibraries === bbModule.main_content
499
- config.userLibrary.each do |l|
500
- ln = l.lib
501
- ls = nil
502
- if l.lib.include?("/")
503
- pos = l.lib.rindex("/")
504
- ls = convPath(l.lib[0..pos-1], config)
505
- ln = l.lib[pos+1..-1]
506
- end
507
- @lib_elements[l.line_number] = ls.nil? ? [] : [HasLibraries::SEARCH_PATH, ls]
508
- @lib_elements[l.line_number].concat [HasLibraries::USERLIB, ln]
509
- end
103
+ Blocks::ALL_BLOCKS[config.qname] = block
510
104
 
511
- config.exLib.each do |exLib|
512
- ln = exLib.name
513
- ls = nil
514
- if exLib.name.include?("/")
515
- pos = exLib.name.rindex("/")
516
- ls = convPath(exLib.name[0..pos-1], config)
517
- ln = exLib.name[pos+1..-1]
518
- end
519
- if exLib.search
520
- @lib_elements[exLib.line_number] = ls.nil? ? [] : [HasLibraries::SEARCH_PATH, ls]
521
- @lib_elements[exLib.line_number].concat [HasLibraries::LIB, ln]
522
- else
523
- @lib_elements[exLib.line_number] = [HasLibraries::LIB_WITH_PATH, (ls.nil? ? ln : (ls + "/" + ln))]
524
- end
105
+ if not Bake.options.linkOnly and not Bake.options.prepro and not Bake.options.lint and not Bake.options.docu and not Bake.options.filename
106
+ addSteps(block, block.preSteps, config.preSteps)
107
+ addSteps(block, block.postSteps, config.postSteps)
525
108
  end
526
109
 
527
- config.exLibSearchPath.each do |exLibSP|
528
- @lib_elements[exLibSP.line_number] = [HasLibraries::SEARCH_PATH, convPath(exLibSP, config)]
529
- end
530
- end
531
-
532
- if HasSources === bbModule.main_content
533
- srcs = config.files.map do |f|
534
- f.name
535
- end
536
- ex_srcs = config.excludeFiles.map {|f| f.name}
537
-
538
- bbModule.main_content.set_local_includes(
539
- config.includeDir.map do |dir|
540
- (dir.name == "___ROOTS___") ? (@options.roots.map { |r| File.rel_from_to_project(projDir,r,false) }) : convPath(dir, config)
541
- end.flatten
542
- )
543
-
544
- bbModule.main_content.set_source_patterns(srcs)
545
- bbModule.main_content.set_exclude_sources(ex_srcs)
546
-
547
- tcsMapConverted = {}
548
- srcs = config.files.each do |f|
549
- if (f.define.length > 0 or f.flags.length > 0)
550
- if f.name.include?"*"
551
- Printer.printWarning "Warning: #{config.file_name}(#{f.line_number}): toolchain settings not allowed for file pattern #{f.name}"
552
- err_res = ErrorDesc.new
553
- err_res.file_name = config.file_name
554
- err_res.line_number = f.line_number
555
- err_res.severity = ErrorParser::SEVERITY_WARNING
556
- err_res.message = "Toolchain settings not allowed for file patterns"
557
- Rake.application.idei.set_errors([err_res])
110
+ if Bake.options.docu
111
+ block.mainSteps << Blocks::Docu.new(config, @configTcMap[config])
112
+ elsif Metamodel::CustomConfig === config
113
+ if not Bake.options.linkOnly and not Bake.options.prepro and not Bake.options.lint and not Bake.options.docu and not Bake.options.filename
114
+ addSteps(block, block.mainSteps, config) if config.step
115
+ end
116
+ elsif Bake.options.lint
117
+ block.mainSteps << Blocks::Lint.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config])
118
+ else
119
+ compile = Blocks::Compile.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config])
120
+ (Blocks::ALL_COMPILE_BLOCKS[projName] ||= []) << compile
121
+ block.mainSteps << compile
122
+ if not Bake.options.filename
123
+ if Metamodel::LibraryConfig === config
124
+ block.mainSteps << Blocks::Library.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config], compile)
558
125
  else
559
- tcsMapConverted[f.name] = integrateCompilerFile(Utils.deep_copy(tcs),f)
126
+ block.mainSteps << Blocks::Executable.new(block, config, @loadedConfig.referencedConfigs, @configTcMap[config], compile)
560
127
  end
561
128
  end
562
129
  end
563
- bbModule.main_content.set_tcs4source(tcsMapConverted)
564
-
565
- end
566
-
567
- # special exe stuff
568
- if Metamodel::ExecutableConfig === config and not @options.lint
569
- if not config.mapFile.nil?
570
- if config.mapFile.name == ""
571
- exeName = bbModule.main_content.get_executable_name
572
- mapfileName = exeName.chomp(File.extname(exeName)) + ".map"
573
- else
574
- mapfileName = config.mapFile.name
575
- end
576
-
577
- bbModule.main_content.set_mapfile(mapfileName)
578
- end
579
- end
580
-
581
- bbModule.contents.each do |c|
582
- if Cxxproject::CommandLine === c
583
- cmdLine = convPath(c.get_command_line, config, bbModule.main_content)
584
- c.set_command_line(cmdLine)
585
- end
586
- end
587
-
588
- # DEPS
589
- projDeps = config.dependency.map { |dd| "Project "+dd.name }
590
- projDeps.concat(bbModule.main_content.dependencies)
591
- bbModule.main_content.set_dependencies(projDeps)
592
- config.dependency.each { |dd| @lib_elements[dd.line_number] = [HasLibraries::DEPENDENCY, dd.name] }
593
-
594
130
 
595
- @lib_elements.sort.each do |x|
596
- v = x[1]
597
- elem = 0
598
- while elem < v.length do
599
- bbModule.main_content.add_lib_elements([v[elem..elem+1]])
600
- elem = elem + 2
131
+ if not Bake.options.project# and not Bake.options.filename
132
+ addDependencies(block, config.dependency)
601
133
  end
134
+
602
135
  end
603
-
604
- end
605
-
606
- ALL_BUILDING_BLOCKS.each do |bbname,bb|
607
- bb.complete_init
608
136
  end
609
-
610
137
  end
611
138
 
612
- def showConfigNames()
613
- loader = Loader.new(@options)
614
-
615
- f = loader.load(@options.main_dir+"/Project.meta")
616
-
617
- if f.root_elements.length != 1 or not Metamodel::Project === f.root_elements[0]
618
- Printer.printError "Error: '#{filename}' must have exactly one 'Project' element as root element"
619
- ExitHelper.exit(1)
620
- end
621
-
622
- validConfigs = []
623
- f.root_elements[0].getConfig.each do |c|
624
- validConfigs << c.name unless c.defaultToolchain.nil?
625
- end
626
- puts "Please specify a config name (with -b)!"
627
- puts "Possible values are:"
628
- if validConfigs.length > 0
629
- validConfigs.each { |v| puts "* " + v }
630
- else
631
- puts " No main config found!"
632
- end
633
-
634
- ExitHelper.exit(0)
635
- end
636
-
637
- def doit()
638
- CLEAN.clear
639
- CLOBBER.clear
640
- parsingOk = false
641
- ex = nil
139
+ def callBlock(block, method)
642
140
  begin
643
- parsingOk = doit_internal
644
- rescue Exception => e
645
- ex = e
646
- end
647
- if not parsingOk and Rake.application.idei
648
- Rake.application.idei.set_build_info(@mainProjectName, @options.build_config.nil? ? "Not set" : @options.build_config, 0)
649
- err_res = ErrorDesc.new
650
- err_res.file_name = @options.main_dir
651
- err_res.line_number = 0
652
- err_res.severity = ErrorParser::SEVERITY_ERROR
653
- err_res.message = "Parsing configurations failed, see log output."
654
- Rake.application.idei.set_errors([err_res])
141
+ return block.send(method)
142
+ rescue AbortException
143
+ raise
144
+ rescue Exception => ex
145
+ if Bake.options.debug
146
+ puts ex.message
147
+ puts ex.backtrace
148
+ end
149
+ return false
655
150
  end
656
-
657
- raise ex if ex
658
- parsingOk
659
151
  end
660
-
661
- def doit_internal()
662
-
663
- @mainProjectName = File::basename(@options.main_dir)
664
-
665
- if @options.build_config == ""
666
- showConfigNames()
667
- ExitHelper.exit(1)
668
- end
669
-
670
- @startupFilename = @options.filename
671
-
672
- @mainMeta = @options.main_dir + "/Project.meta"
673
-
674
- cache = CacheAccess.new(@mainMeta, @options.build_config, @options)
675
-
676
- if File.exists? @mainMeta
677
- @defaultToolchainTime = File.mtime(@mainMeta)
678
- @mainMetaTime = @defaultToolchainTime
679
- else
680
- @defaultToolchainTime = Time.now
681
- end
682
-
683
- forceLoadMeta = @options.nocache
684
-
685
- @defaultToolchainCached = nil
686
-
687
- if not forceLoadMeta
688
- @project2config = cache.load_cache
689
- @defaultToolchainCached = cache.defaultToolchain
690
- @defaultToolchainTime = cache.defaultToolchainTime unless cache.defaultToolchainTime.nil?
691
- if @project2config.nil?
692
- forceLoadMeta = true
693
- else
694
- @defaultToolchain = @defaultToolchainCached
152
+
153
+ def callBlocks(startBlocks, method)
154
+ Blocks::ALL_BLOCKS.each {|name,block| block.visited = false; block.result = false; block.inDeps = false }
155
+ Blocks::Block.reset_block_counter
156
+ result = true
157
+ startBlocks.each do |block|
158
+ result = callBlock(block, method) && result
159
+ return false if not result and Bake.options.stopOnFirstError
160
+ end
161
+ return result
162
+ end
163
+
164
+ def calcStartBlocks
165
+ startProjectName = nil
166
+ startConfigName = nil
167
+ if Bake.options.project
168
+ splitted = Bake.options.project.split(',')
169
+ startProjectName = splitted[0]
170
+ startConfigName = splitted[1] if splitted.length == 2
171
+ end
172
+
173
+ if startConfigName
174
+ blockName = startProjectName+","+startConfigName
175
+ if not Blocks::ALL_BLOCKS.include?(startProjectName+","+startConfigName)
176
+ Bake.formatter.printError("Error: project #{startProjectName} with config #{startConfigName} not found")
177
+ ExitHelper.exit(1)
695
178
  end
696
- end
697
-
698
- if forceLoadMeta
699
- load_meta
700
- cache.write_cache(@project_files, @project2config, @defaultToolchain, @defaultToolchainTime)
701
- end
702
-
703
- substVars
704
-
705
- if (@options.cmake)
706
- writeCMake
707
- ExitHelper.exit(0)
708
- end
709
-
710
- convert2bb
711
-
712
- #################################################
713
-
714
- startBBName = "Project "+@options.project
715
- startBB = ALL_BUILDING_BLOCKS[startBBName]
716
- if startBB.nil?
717
- Printer.printError "Error: Project #{@options.project} is not a dependency of #{@mainProjectName}"
718
- ExitHelper.exit(1)
719
- end
720
-
721
-
722
- #################################################
723
-
724
- if @options.single or @startupFilename
725
- content_names = startBB.contents.map { |c| c.name }
726
- startBB.main_content.set_helper_dependencies(startBB.main_content.dependencies.dup) if Executable === startBB.main_content
727
- startBB.main_content.dependencies.delete_if { |d| not content_names.include?d}
728
- end
729
-
730
- if @startupFilename
731
- startBB.contents.each do |c|
732
- if SourceLibrary === c or Executable === c
733
-
734
- # check that the file is REALLY included and glob if file does not exist and guess what file can be meant
735
- Dir.chdir(startBB.project_dir) do
736
-
737
- theFile = []
738
- if not File.exists?(@startupFilename)
739
- Dir.chdir(startBB.project_dir) do
740
- theFile = Dir.glob("**/#{@startupFilename}")
741
- theFile.map! {|tf| startBB.project_dir + "/" + tf}
742
- end
743
- if theFile.length == 0
744
- Printer.printError "Error: #{@startupFilename} not found in project #{@options.project}"
745
- ExitHelper.exit(1)
746
- end
747
- else
748
- if File.is_absolute?(@startupFilename)
749
- theFile << @startupFilename
750
- else
751
- theFile << startBB.project_dir + "/" + @startupFilename
752
- end
753
-
754
- end
755
-
756
- exclude_files = []
757
- c.exclude_sources.each do |e|
758
- Dir.glob(e).each {|f| exclude_files << f}
759
- end
760
- theFile.delete_if { |f| exclude_files.any? {|e| e==f} }
761
- if theFile.length == 0
762
- Printer.printError "Error: #{@startupFilename} excluded in config #{@options.build_config} of project #{@options.project}"
763
- ExitHelper.exit(1)
764
- end
765
-
766
- source_files = c.sources.dup
767
- c.source_patterns.each do |p|
768
- Dir.glob(p).each {|f| source_files << (startBB.project_dir + "/" + f)}
769
- end
770
-
771
- theFile.delete_if { |f| source_files.all? {|e| e!=f} }
772
- if theFile.length == 0
773
- Printer.printError "Error: #{@startupFilename} is no source file in config #{@options.build_config} of project #{@options.project}"
774
- ExitHelper.exit(1)
775
- elsif theFile.length > 1
776
- Printer.printError "Error: #{@startupFilename} is ambiguous in project #{@options.project}"
777
- ExitHelper.exit(1)
778
- else
779
- @startupFilename = theFile[0]
780
- end
781
- end
782
-
783
- c.set_sources([@startupFilename])
784
- c.set_source_patterns([])
785
- c.set_exclude_sources([])
786
- c.extend(SingleSourceModule) unless @options.lint
787
- break
788
- else
789
- def c.needed?
790
- false
791
- end
179
+ startBlocks = [Blocks::ALL_BLOCKS[startProjectName+","+startConfigName]]
180
+ Blocks::Block.set_num_projects(1)
181
+ elsif startProjectName
182
+ startBlocks = []
183
+ Blocks::ALL_BLOCKS.each do |blockName, block|
184
+ if blockName.start_with? startProjectName
185
+ startBlocks << block
792
186
  end
793
187
  end
794
- end
795
-
796
-
797
- Rake.application.check_unnecessary_includes = (@startupFilename == nil) if @options.check_uninc
798
-
799
-
800
- #################################################
801
-
802
-
803
- startBB.contents.each do |b|
804
- if SourceLibrary === b or Executable === b or BinaryLibrary === b
805
- @parseBB = b
188
+ if startBlocks.length == 0
189
+ Bake.formatter.printError("Error: project #{startProjectName} not found")
190
+ ExitHelper.exit(1)
806
191
  end
807
- end
808
-
809
-
810
- @bbs = []
811
- @num_modules = 1
812
- if @options.single or @startupFilename
813
- @bbs << startBB
814
- @bbs.concat(startBB.contents)
192
+ startBlocks.reverse! # most probably the order of dependencies if any
193
+ Blocks::Block.set_num_projects(startBlocks.length)
815
194
  else
816
- @num_modules = calc_needed_bbs(startBBName, @bbs)
195
+ startBlocks = [Blocks::ALL_BLOCKS[Bake.options.main_project_name+","+Bake.options.build_config]]
196
+ Blocks::Block.set_num_projects(Blocks::ALL_BLOCKS.length)
817
197
  end
198
+ return startBlocks
199
+ end
200
+
201
+ def doit()
818
202
 
819
- begin # show incs and stuff
820
- if @options.show_includes
821
- @bbs.each do |bb|
822
- if HasIncludes === bb
823
- print bb.name
824
- li = bb.local_includes
825
- li.each { |i| print "##{i}" }
826
- print "\n"
827
- end
828
- end
829
- ExitHelper.exit(0)
830
- end
831
-
832
- if @options.show_includes_and_defines
833
- intIncs = []
834
- intDefs = {:CPP => [], :C => [], :ASM => []}
835
- Dir.chdir(@options.main_dir) do
836
-
837
- if (@mainConfig.defaultToolchain.internalIncludes)
838
- iname = convPath(@mainConfig.defaultToolchain.internalIncludes.name, @mainConfig)
839
- if iname != ""
840
- if not File.exists?(iname)
841
- Printer.printError "Error: InternalIncludes file #{iname} does not exist"
842
- ExitHelper.exit(1)
843
- end
844
- IO.foreach(iname) {|x| add_line_if_no_comment(intIncs,x) }
845
- end
846
- end
847
-
848
- @mainConfig.defaultToolchain.compiler.each do |c|
849
- if (c.internalDefines)
850
- dname = convPath(c.internalDefines.name, @mainConfig)
851
- if dname != ""
852
- if not File.exists?(dname)
853
- Printer.printError "Error: InternalDefines file #{dname} does not exist"
854
- ExitHelper.exit(1)
855
- end
856
- IO.foreach(dname) {|x| add_line_if_no_comment(intDefs[c.ctype],x) }
857
- end
858
- end
859
- end
860
-
861
- end
862
-
863
-
864
- @bbs.each do |bb|
865
- if HasIncludes === bb
866
- puts bb.name
867
-
868
- puts " includes"
869
- (bb.local_includes + intIncs).each { |i| puts " #{i}" }
870
-
871
- [:CPP, :C, :ASM].each do |type|
872
- puts " #{type} defines"
873
- (bb.tcs[:COMPILER][type][:DEFINES] + intDefs[type]).each { |d| puts " #{d}" }
874
- end
875
- puts " done"
876
- end
877
- end
878
- ExitHelper.exit(0)
879
- end
880
- rescue Exception => e
881
- if (not SystemExit === e)
882
- puts e
883
- puts e.backtrace
884
- ExitHelper.exit(1)
885
- else
886
- raise e
887
- end
203
+ taskType = "Building"
204
+ if Bake.options.lint
205
+ taskType = "Linting"
206
+ elsif Bake.options.docu
207
+ taskType = "Generating documentation"
208
+ elsif Bake.options.prepro
209
+ taskType = "Preprocessing"
210
+ elsif Bake.options.linkOnly
211
+ taskType = "Linking"
212
+ elsif Bake.options.rebuild
213
+ taskType = "Rebuilding"
214
+ elsif Bake.options.clean
215
+ taskType = "Cleaning"
888
216
  end
889
217
 
890
-
891
- theExeBB = nil
892
- @bbs.each do |bb|
893
- res = bb.convert_to_rake()
894
- theExeBB = res if Executable === bb
895
- end
896
-
897
- if @options.linkOnly
898
- if theExeBB.nil?
899
- Printer.printError "Error: no executable to link"
900
- ExitHelper.exit(1)
218
+ begin
219
+ @loadedConfig = Config.new
220
+ @loadedConfig.load
221
+
222
+ @mainConfig = @loadedConfig.referencedConfigs[Bake.options.main_project_name].select { |c| c.name == Bake.options.build_config }.first
223
+
224
+ if Bake.options.lint
225
+ @defaultToolchain = Utils.deep_copy(Bake::Toolchain::Provider["Lint"])
226
+ integrateToolchain(@defaultToolchain, @mainConfig.defaultToolchain)
901
227
  else
902
- theExeBB.prerequisites.delete_if {|p| Rake::Task::SOURCEMULTI == Rake.application[p].type}
228
+ @defaultToolchain = @loadedConfig.defaultToolchain
903
229
  end
904
- end
905
-
906
- @bbs.each do |bb|
907
- set_output_taskname(bb)
908
- end
909
-
910
- if @startupFilename
911
- runTaskName = @parseBB.get_task_name
912
- else
913
- runTaskName = startBB.get_task_name
914
- end
915
-
916
-
917
- @runTask = Rake.application[runTaskName]
918
-
919
- if @startupFilename
920
- @runTask.prerequisites.clear
921
- end
922
-
923
- return true
924
- end
925
-
926
- def start()
927
-
928
- if @options.clean
929
- cleanTask = nil
930
- if @startupFilename
931
- Dir.chdir(@parseBB.project_dir) do
932
230
 
933
- if File.is_absolute?(@startupFilename)
934
- @startupFilename = File.rel_from_to_project(@parseBB.project_dir, @startupFilename, false)
935
- end
936
-
937
- of = @parseBB.get_object_file(@startupFilename)
938
- object = File.expand_path(of)
231
+ createBaseTcsForConfig
232
+ substVars
233
+ createTcsForConfig
234
+
235
+ convert2bb
236
+
237
+ Blocks::Show.includes if Bake.options.show_includes
238
+ Blocks::Show.includesAndDefines(@mainConfig, @configTcMap[@mainConfig]) if Bake.options.show_includes_and_defines
239
+
240
+ startBlocks = calcStartBlocks
939
241
 
940
- FileUtils.rm object, :force => true
941
- FileUtils.rm @parseBB.get_dep_file(object), :force => true
942
- end
943
- else
944
- if @options.clobber
945
- cleanTask = Rake.application[:clobber]
946
- cleanType = "Clobber"
947
- else
948
- cleanTask = Rake.application[:clean]
949
- cleanType = "Clean"
950
- end
951
- cleanTask.invoke
952
- end
242
+ Bake::IDEInterface.instance.set_build_info(@mainConfig.parent.name, @mainConfig.name, Blocks::ALL_BLOCKS.length)
953
243
 
954
- if Rake.application.idei and Rake.application.idei.get_abort
955
- Printer.printError "\#{cleanType} aborted."
956
- return false
957
- elsif cleanTask != nil and cleanTask.failure
958
- Printer.printError "\n#{cleanType} failed."
959
- return false
960
- elsif not @options.rebuild
961
- Printer.printSuccess "\n#{cleanType} done."
962
- return true
244
+ begin
245
+ result = true
246
+ if Bake.options.clean or Bake.options.rebuild
247
+ result = callBlocks(startBlocks, :clean)
248
+ end
249
+ if Bake.options.rebuild or not Bake.options.clean
250
+ result = callBlocks(startBlocks, :execute) && result
251
+ end
252
+ rescue AbortException
253
+ Bake.formatter.printError("\n#{taskType} aborted.")
254
+ ExitHelper.set_exit_code(1)
255
+ return
963
256
  end
964
-
965
- end
966
- Rake::application.idei.set_build_info(@parseBB.name, @parseBB.config_name, @num_modules)
967
-
968
- @runTask.invoke
969
-
970
- buildType = @options.rebuild ? "Rebuild" : "Build"
971
-
972
- if Rake.application.idei and Rake.application.idei.get_abort
973
- Printer.printError "\n#{buildType} aborted."
974
- return false
975
- elsif @runTask.failure
976
- if Rake::application.preproFlags
977
- Printer.printSuccess "\nPreprocessing done."
978
- return true
257
+
258
+ if result == false
259
+ Bake.formatter.printError("\n#{taskType} failed.")
260
+ ExitHelper.set_exit_code(1)
261
+ return
979
262
  else
980
- Printer.printError "\n#{buildType} failed."
981
- return false
263
+ Bake.formatter.printSuccess("\n#{taskType} done.")
982
264
  end
983
- else
984
- text = ""
985
- # this "fun part" shall not fail in any case!
986
- begin
987
- #if Time.now.year == 2012 and Time.now.month == 1
988
- # text = " -- The munich software team wishes you a happy new year 2012!"
989
- #end
990
- rescue Exception
991
- end
992
- Printer.printSuccess("\n#{buildType} done." + text)
993
- return true
265
+ rescue SystemExit
266
+ Bake.formatter.printError("\n#{taskType} failed.")
994
267
  end
268
+
995
269
  end
996
270
 
997
271
  def connect()
998
- if @options.socket != 0
999
- Rake.application.idei.connect(@options.socket)
272
+ if Bake.options.socket != 0
273
+ Bake::IDEInterface.instance.connect(Bake.options.socket)
1000
274
  end
1001
275
  end
1002
276
 
1003
277
  def disconnect()
1004
- if @options.socket != 0
1005
- Rake.application.idei.disconnect()
278
+ if Bake.options.socket != 0
279
+ Bake::IDEInterface.instance.disconnect()
1006
280
  end
1007
281
  end
1008
282
 
1009
-
1010
283
  end
1011
284
  end
1012
-
1013
-
1014
- # metamodel Files vs File vs Dir vs Make vs ... ? merge?
1015
-