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,54 @@
1
+ module Bake
2
+
3
+ class Usage
4
+
5
+ def self.show
6
+ puts "\nUsage: bake [options]"
7
+ puts " [-b] <name> Config name of main project"
8
+ puts " -m <dir> Directory of main project (default is current directory)."
9
+ puts " -p <dir> Project to build/clean (default is main project)"
10
+ puts " -f <name> Build/Clean this file only."
11
+ puts " -c Clean the file/project."
12
+ puts " -a <scheme> Use ansi color sequences (console must support it). Possible values are 'white' and 'black'."
13
+ puts " -v<level> Verbose level from 0 to 2, whereas -v0 is less, -v1 is normal (default) and -v2 is more verbose."
14
+ puts " -r Stop on first error."
15
+ puts " -w <root> Add a workspace root (can be used multiple times)."
16
+ puts " If no root is specified, the parent directory of the main project is added automatically."
17
+ puts " --show_configs Shows all configs with DefaultToolchain."
18
+ puts " --rebuild Clean before build."
19
+ puts " --clobber Clean the file/project (same as option -c) AND the bake cache files."
20
+ puts " --prepro Stop after preprocessor."
21
+ puts " --link_only Only link executables - doesn't update objects and archives or start PreSteps and PostSteps."
22
+ puts " Forces executables to be relinked."
23
+ puts " --docu Builds docu instead of compiling sources."
24
+ puts " --lint Performs Lint checks instead of compiling sources."
25
+ puts " --lint_min <num> If number of files in a project is too large for lint to handle, it is possible"
26
+ puts " to specify only a part of the file list to lint (default -1)."
27
+ puts " --lint_max <num> See above (default -1)."
28
+ puts " --ignore_cache Rereads the original meta files - usefull if workspace structure has been changed."
29
+ puts " --threads <num> Set NUMBER of parallel compiled files (default is 8)."
30
+ puts " --socket <num> Set SOCKET for sending errors, receiving commands, etc. - used by e.g. Eclipse."
31
+ puts " --toolchain_info <name> Prints default values of a toolchain."
32
+ puts " --toolchain_names Prints available toolchains."
33
+ puts " --include_filter <name> Includes steps with this filter name (can be used multiple times)."
34
+ puts " 'PRE' or 'POST' includes all PreSteps respectively PostSteps."
35
+ puts " --exclude_filter <name> Excludes steps with this filter name (can be used multiple times)."
36
+ puts " 'PRE' or 'POST' excludes all PreSteps respectively PostSteps."
37
+ puts " --show_abs_paths Compiler prints absolute filename paths instead of relative paths."
38
+ puts " --no_autodir Disable auto completion of paths like in IncludeDir"
39
+ puts " --set <key>=<value> Sets a variable. Overwrites variables defined in Project.metas (can be used multiple times)."
40
+ puts " --show_include_paths Used by IDEs plugins"
41
+ puts " --show_incs_and_defs Used by IDEs plugins"
42
+ puts ""
43
+ puts " --version Print version."
44
+ puts " --doc Open documentation in browser"
45
+ puts " -h, --help Print this help."
46
+ puts " --show_license Print the license."
47
+ puts ""
48
+ puts " --debug Print out backtraces in some cases - used only for debugging bake."
49
+ ExitHelper.exit(0)
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,10 @@
1
+ module Bake
2
+
3
+ class ProcessOutput
4
+
5
+
6
+
7
+ end
8
+
9
+
10
+ end
data/lib/bake/subst.rb CHANGED
@@ -1,14 +1,48 @@
1
- module Cxxproject
1
+ module Bake
2
2
 
3
3
  class Subst
4
4
 
5
- def self.itute(config, projName, options, isMainProj, toolchain)
5
+ # this is done lazy because usually there is no need to calculate that
6
+ def self.lazyPathes
7
+ return unless @@lazy
8
+
9
+ cppCmd = @@toolchain[:COMPILER][:CPP][:COMMAND]
10
+ cCmd = @@toolchain[:COMPILER][:C][:COMMAND]
11
+ asmCmd = @@toolchain[:COMPILER][:ASM][:COMMAND]
12
+ archiverCmd = @@toolchain[:ARCHIVER][:COMMAND]
13
+ linkerCmd = @@toolchain[:LINKER][:COMMAND]
14
+
15
+ if @@config.toolchain
16
+ linkerCmd = @@config.toolchain.linker.command if @@config.toolchain.linker and @@config.toolchain.linker.command != ""
17
+ archiverCmd = @@config.toolchain.archiver.command if @@config.toolchain.linker and @@config.toolchain.archiver.command != ""
18
+ @@config.toolchain.compiler.each do |c|
19
+ if c.ctype == :CPP
20
+ cppCmd = c.command
21
+ elsif c.ctype == :C
22
+ cCmd = c.command
23
+ elsif c.ctype == :ASM
24
+ asmCmd = c.command
25
+ end
26
+ end
27
+ end
28
+
29
+ @@cppExe = File.which(cppCmd)
30
+ @@cExe = File.which(cCmd)
31
+ @@asmExe = File.which(asmCmd)
32
+ @@archiverExe = File.which(archiverCmd)
33
+ @@linkerExe = File.which(linkerCmd)
34
+
35
+ @@lazy = false
36
+ end
6
37
 
38
+ def self.itute(config, projName, isMainProj, toolchain)
39
+ @@lazy = true
40
+ @@config = config
41
+ @@toolchain = toolchain
42
+
7
43
  @@configName = config.name
8
44
  @@projDir = config.parent.get_project_dir
9
45
  @@projName = projName
10
- @@options = options
11
- @@mainProjectName = File::basename(options.main_dir)
12
46
  @@resolvedVars = 0
13
47
  @@configFilename = config.file_name
14
48
 
@@ -17,7 +51,7 @@ module Cxxproject
17
51
  if not config.artifactName.nil?
18
52
  @@artifactName = config.artifactName.name
19
53
  elsif config.defaultToolchain != nil
20
- basedOnToolchain = Cxxproject::Toolchain::Provider[config.defaultToolchain.basedOn]
54
+ basedOnToolchain = Bake::Toolchain::Provider[config.defaultToolchain.basedOn]
21
55
  if basedOnToolchain != nil
22
56
  @@artifactName = projName+basedOnToolchain[:LINKER][:OUTPUT_ENDING]
23
57
  end
@@ -33,30 +67,30 @@ module Cxxproject
33
67
  config.set.each do |s|
34
68
 
35
69
  if (s.value != "" and s.cmd != "")
36
- Printer.printError "Error: #{config.file_name}(#{s.line_number}): value and cmd attributes must be used exclusively"
70
+ Bake.formatter.printError("value and cmd attributes must be used exclusively", s)
37
71
  ExitHelper.exit(1)
38
72
  end
39
73
 
40
74
  if (s.value != "")
41
- @@userVarMap[s.name] = substString(s.value)
75
+ setName = substString(s.name, s)
76
+ if (setName.empty?)
77
+ Bake.formatter.printWarning("Name of variable must not be empty - variable will be ignored", s)
78
+ else
79
+ @@userVarMap[s.name] = substString(s.value, s)
80
+ end
42
81
  else
43
82
  cmd_result = false
44
83
  begin
45
- rd, wr = IO.pipe
46
- cmd = [substString(s.cmd)]
47
- cmd << {
48
- :err=>wr,
49
- :out=>wr
50
- }
51
- consoleOutput = ""
52
84
  Dir.chdir(@@projDir) do
53
- cmd_result, consoleOutput = ProcessHelper.safeExecute() { sp = spawn(*cmd); ProcessHelper.readOutput(sp, rd, wr) }
85
+ cmd = [substString(s.cmd, s)]
86
+ cmd_result, consoleOutput = ProcessHelper.run(cmd)
87
+ @@userVarMap[s.name] = consoleOutput.chomp
54
88
  end
55
- @@userVarMap[s.name] = consoleOutput.chomp
56
- rescue
89
+ rescue Exception=>e
90
+ consoleOutput = e.message
57
91
  end
58
92
  if (cmd_result == false)
59
- Printer.printWarning "Warning: #{config.file_name}(#{s.line_number}): command not successful, variable #{s.name} wil be set to \"\" (#{consoleOutput.chomp})."
93
+ Bake.formatter.printWarning("Command not successful, variable #{s.name} wil be set to \"\" (#{consoleOutput.chomp}).", s)
60
94
  @@userVarMap[s.name] = ""
61
95
  end
62
96
  end
@@ -78,13 +112,13 @@ module Cxxproject
78
112
  lastFoundInVar = @@resolvedVars
79
113
  end
80
114
  if (@@resolvedVars > 0)
81
- Printer.printError "Error: #{config.file_name}: cyclic variable substitution detected"
115
+ Bake.formatter.printError("Cyclic variable substitution detected", config.file_name)
82
116
  ExitHelper.exit(1)
83
117
  end
84
118
 
85
119
  end
86
120
 
87
- def self.substString(str)
121
+ def self.substString(str, elem=nil)
88
122
  substStr = ""
89
123
  posSubst = 0
90
124
  while (true)
@@ -97,16 +131,16 @@ module Cxxproject
97
131
  @@resolvedVars += 1
98
132
  var = str[posStart+2..posEnd-1]
99
133
 
100
- if @@options.vars.has_key?(var)
101
- substStr << @@options.vars[var]
134
+ if Bake.options.vars.has_key?(var)
135
+ substStr << Bake.options.vars[var]
102
136
  elsif @@userVarMap.has_key?(var)
103
137
  substStr << @@userVarMap[var]
104
138
  elsif var == "MainConfigName"
105
- substStr << @@options.build_config
139
+ substStr << Bake.options.build_config
106
140
  elsif var == "MainProjectName"
107
- substStr << @@mainProjectName
141
+ substStr << Bake.options.main_project_name
108
142
  elsif var == "MainProjectDir"
109
- substStr << @@options.main_dir
143
+ substStr << Bake.options.main_dir
110
144
  elsif var == "ConfigName"
111
145
  substStr << @@configName
112
146
  elsif var == "ProjectName"
@@ -114,10 +148,10 @@ module Cxxproject
114
148
  elsif var == "ProjectDir"
115
149
  substStr << @@projDir
116
150
  elsif var == "OutputDir"
117
- if @@projName == @@mainProjectName
118
- substStr << @@options.build_config
151
+ if @@projName == Bake.options.main_project_name
152
+ substStr << Bake.options.build_config
119
153
  else
120
- substStr << (@@options.build_config + "_" + @@mainProjectName)
154
+ substStr << @@configName + "_" + Bake.options.main_project_name + "_" + Bake.options.build_config
121
155
  end
122
156
  elsif var == "Time"
123
157
  substStr << Time.now.to_s
@@ -127,10 +161,25 @@ module Cxxproject
127
161
  substStr << @@artifactName
128
162
  elsif var == "ArtifactNameBase"
129
163
  substStr << @@artifactName.chomp(File.extname(@@artifactName))
164
+ elsif var == "CPPPath"
165
+ self.lazyPathes
166
+ substStr << @@cppExe
167
+ elsif var == "CPath"
168
+ self.lazyPathes
169
+ substStr << @@cExe
170
+ elsif var == "ASMPath"
171
+ self.lazyPathes
172
+ substStr << @@asmExe
173
+ elsif var == "ArchiverPath"
174
+ self.lazyPathes
175
+ substStr << @@archiverExe
176
+ elsif var == "LinkerPath"
177
+ self.lazyPathes
178
+ substStr << @@linkerExe
130
179
  elsif var == "Roots"
131
180
  substStr << "___ROOTS___"
132
181
  elsif var == "/"
133
- if Cxxproject::OS.windows?
182
+ if Bake::Utils::OS.windows?
134
183
  substStr << "\\"
135
184
  else
136
185
  substStr << "/"
@@ -138,8 +187,13 @@ module Cxxproject
138
187
  elsif ENV[var]
139
188
  substStr << ENV[var]
140
189
  else
141
- if @@options.verbose
142
- Printer.printInfo "Info: #{@@configFilename}: substitute variable '$(#{var})' with empty string"
190
+ if Bake.options.verboseHigh
191
+ msg = "Substitute variable '$(#{var})' with empty string"
192
+ if elem
193
+ Bake.formatter.printInfo(msg, elem)
194
+ else
195
+ Bake.formatter.printInfo(msg + " in the toolchain", @@config)
196
+ end
143
197
  end
144
198
  substStr << ""
145
199
  end
@@ -151,22 +205,33 @@ module Cxxproject
151
205
  end
152
206
 
153
207
  def self.substToolchain(elem)
154
- elem.each do |k, e|
155
- if Hash === e or Array === e
156
- substToolchain(e)
157
- elsif String === e
158
- elem[k] = substString(e)
159
- end
208
+ if Hash === elem
209
+ elem.each do |k, e|
210
+ if Hash === e or Array === e
211
+ substToolchain(e)
212
+ elsif String === e
213
+ elem[k] = substString(e)
214
+ end
215
+ end
216
+ elsif Array === elem
217
+ elem.each_with_index do |e, i|
218
+ if Hash === e or Array === e
219
+ substToolchain(e)
220
+ elsif String === e
221
+ elem[i] = substString(e)
222
+ end
223
+ end
160
224
  end
161
225
  end
162
-
163
226
 
164
227
  def self.subst(elem)
165
228
  elem.class.ecore.eAllAttributes_derived.each do |a|
166
229
  next if a.name == "file_name" or a.name == "line_number"
167
- #next if Metamodel::DefaultToolchain === elem
230
+ return if Metamodel::Set === elem.class
231
+ return if Metamodel::DefaultToolchain === elem
232
+ return if Metamodel::Toolchain === elem.class
168
233
  next if a.eType.name != "EString"
169
- substStr = substString(elem.getGeneric(a.name))
234
+ substStr = substString(elem.getGeneric(a.name), elem)
170
235
  elem.setGeneric(a.name, substStr)
171
236
  end
172
237
 
@@ -0,0 +1,44 @@
1
+ require 'common/utils'
2
+ require 'bake/toolchain/provider'
3
+ require 'bake/toolchain/errorparser/error_parser'
4
+ require 'bake/toolchain/errorparser/gcc_compiler_error_parser'
5
+ require 'bake/toolchain/errorparser/gcc_linker_error_parser'
6
+
7
+ module Bake
8
+ module Toolchain
9
+ gccCompilerErrorParser = GCCCompilerErrorParser.new
10
+
11
+ CLANG_CHAIN = Provider.add("CLANG")
12
+
13
+ CLANG_CHAIN[:COMPILER][:CPP].update({
14
+ :COMMAND => "llvm-g++",
15
+ :DEFINE_FLAG => "-D",
16
+ :OBJECT_FILE_FLAG => "-o",
17
+ :OBJ_FLAG_SPACE => true,
18
+ :INCLUDE_PATH_FLAG => "-I",
19
+ :COMPILE_FLAGS => "-c ",
20
+ :DEP_FLAGS => "-MD -MF ", # empty space at the end is important!
21
+ :ERROR_PARSER => gccCompilerErrorParser
22
+ })
23
+
24
+ CLANG_CHAIN[:COMPILER][:C] = Utils.deep_copy(CLANG_CHAIN[:COMPILER][:CPP])
25
+ CLANG_CHAIN[:COMPILER][:C][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:C][:SOURCE_FILE_ENDINGS]
26
+ CLANG_CHAIN[:COMPILER][:C][:COMMAND] = "llvm-gcc"
27
+
28
+ CLANG_CHAIN[:COMPILER][:ASM] = Utils.deep_copy(CLANG_CHAIN[:COMPILER][:C])
29
+ CLANG_CHAIN[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
30
+
31
+ CLANG_CHAIN[:ARCHIVER][:COMMAND] = "ar"
32
+ CLANG_CHAIN[:ARCHIVER][:ARCHIVE_FLAGS] = "r"
33
+ CLANG_CHAIN[:ARCHIVER][:ERROR_PARSER] = gccCompilerErrorParser
34
+
35
+ CLANG_CHAIN[:LINKER][:COMMAND] = "llvm-g++"
36
+ CLANG_CHAIN[:LINKER][:SCRIPT] = "-T"
37
+ CLANG_CHAIN[:LINKER][:USER_LIB_FLAG] = "-l:"
38
+ CLANG_CHAIN[:LINKER][:EXE_FLAG] = "-o"
39
+ CLANG_CHAIN[:LINKER][:LIB_FLAG] = "-l"
40
+ CLANG_CHAIN[:LINKER][:LIB_PATH_FLAG] = "-L"
41
+
42
+ CLANG_CHAIN[:LINKER][:ERROR_PARSER] = GCCLinkerErrorParser.new
43
+ end
44
+ end
@@ -0,0 +1,125 @@
1
+ require 'colored'
2
+
3
+ module Bake
4
+ #include Utils ????
5
+
6
+ class ColorizingFormatter
7
+
8
+ def initialize
9
+ @scheme = :none
10
+ end
11
+
12
+ def setColorScheme(scheme)
13
+
14
+ if (scheme != :black and scheme != :white and scheme != :none)
15
+ Bake.formatter.printError("Error: color scheme must be 'black' or 'white'")
16
+ ExitHelper.exit(1)
17
+ end
18
+ @scheme = scheme
19
+
20
+ if @scheme == :black
21
+ @warning_color = :yellow
22
+ @error_color = :red
23
+ @info_color = :white
24
+ @additional_info_color = :cyan
25
+ @success_color = :green
26
+ elsif @scheme == :white
27
+ @warning_color = :magenta
28
+ @error_color = :red
29
+ @info_color = :black
30
+ @additional_info_color = :blue
31
+ @success_color = :green
32
+ end
33
+ end
34
+
35
+ def printInternal(col, str)
36
+ puts(@scheme == :none ? str : [col,:bold].inject(str) {|m,x| m.send(x)})
37
+ end
38
+
39
+ def createIdeError(str, file_name, line_number, severity)
40
+ if (file_name)
41
+ d = ErrorDesc.new
42
+ d.file_name = file_name
43
+ d.line_number = (line_number ? line_number : 0)
44
+ d.message = str
45
+ d.severity = severity
46
+ Bake::IDEInterface.instance.set_errors([d])
47
+ end
48
+ end
49
+
50
+ def processString(prefix, str, file_name_or_elem, line_num, severity)
51
+ if file_name_or_elem.respond_to?("file_name")
52
+ file_name = file_name_or_elem.file_name
53
+ line_num = file_name_or_elem.line_number
54
+ elsif String === file_name_or_elem
55
+ file_name = file_name_or_elem
56
+ else
57
+ file_name = nil
58
+ end
59
+
60
+ createIdeError(str, file_name, line_num, severity)
61
+
62
+ line = (line_num ? ":#{line_num}" : "")
63
+ file = (file_name ? "#{file_name}#{line}: " : "")
64
+ return file + prefix + ": " + str
65
+ end
66
+
67
+ def printError(str, file_name_or_elem=nil, line_num=nil)
68
+ str = processString("Error", str, file_name_or_elem, line_num, Bake::ErrorParser::SEVERITY_ERROR) if file_name_or_elem
69
+ printInternal(@error_color, str)
70
+ end
71
+
72
+ def printWarning(str, file_name=nil, line_num=nil)
73
+ str = processString("Warning", str, file_name, line_num, Bake::ErrorParser::SEVERITY_WARNING) if file_name
74
+ printInternal(@warning_color, str)
75
+ end
76
+
77
+ def printInfo(str, file_name=nil, line_num=nil)
78
+ str = processString("Info", str, file_name, line_num, Bake::ErrorParser::SEVERITY_INFO) if file_name
79
+ printInternal(@info_color, str)
80
+ end
81
+
82
+ def printAdditionalInfo(str)
83
+ printInternal(@additional_info_color, str)
84
+ end
85
+
86
+ def printSuccess(str)
87
+ printInternal(@success_color, str)
88
+ end
89
+
90
+ # formats several lines of compiler output
91
+ def format(compiler_output, error_descs, error_parser)
92
+ if @scheme == :none
93
+ puts compiler_output
94
+ else
95
+ begin
96
+ zipped = compiler_output.split($/).zip(error_descs)
97
+ zipped.each do |l,desc|
98
+ if desc.severity != 255
99
+ coloring = {}
100
+ if desc.severity == ErrorParser::SEVERITY_WARNING
101
+ printWarning(l)
102
+ elsif desc.severity == ErrorParser::SEVERITY_ERROR
103
+ printError(l)
104
+ else
105
+ printInfo(l)
106
+ end
107
+ else
108
+ puts l
109
+ end
110
+ end
111
+ rescue Exception => e
112
+ puts "Error while parsing output: #{e}"
113
+ puts e.backtrace if Bake.options.debug
114
+ puts compiler_output
115
+ end
116
+ end
117
+ end
118
+ end
119
+
120
+ def self.formatter
121
+ @@formatter ||= ColorizingFormatter.new
122
+ end
123
+
124
+
125
+ end