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
@@ -1,7 +1,7 @@
1
1
  require 'rgen/metamodel_builder'
2
2
  require 'rgen/metamodel_builder/data_types'
3
3
 
4
- module Cxxproject
4
+ module Bake
5
5
 
6
6
  module Metamodel
7
7
  extend RGen::MetamodelBuilder::ModuleExtension
@@ -15,13 +15,13 @@ module Cxxproject
15
15
  annotation :details => {'internal' => 'true'}
16
16
  end
17
17
  module ClassModule
18
- attr_accessor :fragment_ref
19
-
20
- def id
18
+ attr_accessor :fragment_ref
19
+
20
+ def id
21
21
  splitted = file_name.split("/")
22
22
  splitted[splitted.length-2]
23
- end
24
-
23
+ end
24
+
25
25
  end
26
26
  end
27
27
 
@@ -78,6 +78,10 @@ module Cxxproject
78
78
  has_attr 'name', String, :defaultValueLiteral => ""
79
79
  end
80
80
 
81
+ class Docu < ModelElement
82
+ has_attr 'name', String, :defaultValueLiteral => ""
83
+ end
84
+
81
85
  class DefaultToolchain < ModelElement
82
86
  has_attr 'basedOn', String, :defaultValueLiteral => ""
83
87
  has_attr 'outputDir', String, :defaultValueLiteral => ""
@@ -86,6 +90,7 @@ module Cxxproject
86
90
  contains_one 'linker', Linker, 'parent'
87
91
  contains_many 'lintPolicy', LintPolicy, 'parent'
88
92
  contains_one 'internalIncludes', InternalIncludes, 'parent'
93
+ contains_one 'docu', Docu, 'parent'
89
94
  end
90
95
 
91
96
  class Toolchain < ModelElement
@@ -94,6 +99,7 @@ module Cxxproject
94
99
  contains_one 'archiver', Archiver, 'parent'
95
100
  contains_one 'linker', Linker, 'parent'
96
101
  contains_many 'lintPolicy', LintPolicy, 'parent'
102
+ contains_one 'docu', Docu, 'parent'
97
103
  end
98
104
 
99
105
  class Person < ModelElement
@@ -104,7 +110,7 @@ module Cxxproject
104
110
  class Description < ModelElement
105
111
  has_attr 'text', String, :defaultValueLiteral => ""
106
112
  end
107
-
113
+
108
114
  class Responsible < ModelElement
109
115
  contains_many "person", Person, 'parent'
110
116
  end
@@ -187,13 +193,14 @@ module Cxxproject
187
193
  contains_many 'exLib', ExternalLibrary, 'parent'
188
194
  contains_many 'exLibSearchPath', ExternalLibrarySearchPath, 'parent'
189
195
  contains_one 'defaultToolchain', DefaultToolchain, 'parent'
196
+ contains_one 'toolchain', Toolchain, 'parent'
190
197
  contains_many 'set', Set, 'parent'
191
198
 
192
199
  module ClassModule
193
- def ident
194
- s = file_name.split("/")
200
+ def ident
201
+ s = file_name.split("/")
195
202
  s[s.length-2] + "/" + name
196
- end
203
+ end
197
204
  end
198
205
 
199
206
  end
@@ -202,13 +209,13 @@ module Cxxproject
202
209
  contains_many 'files', Files, 'parent'
203
210
  contains_many 'excludeFiles', ExcludeFiles, 'parent'
204
211
  contains_many 'includeDir', IncludeDir, 'parent'
205
- contains_one 'toolchain', Toolchain, 'parent'
212
+
206
213
 
207
214
  module ClassModule
208
- def ident
209
- s = file_name.split("/")
215
+ def ident
216
+ s = file_name.split("/")
210
217
  s[s.length-2] + "/" + name
211
- end
218
+ end
212
219
  end
213
220
 
214
221
  end
@@ -227,16 +234,17 @@ module Cxxproject
227
234
  end
228
235
 
229
236
  class Project < ModelElement
237
+ has_attr 'default', String, :defaultValueLiteral => ""
230
238
  contains_one 'description', Description, 'parent'
231
239
  contains_one 'responsible', Responsible, 'parent'
232
240
  contains_many 'config', BaseConfig_INTERNAL, 'parent'
233
241
 
234
242
  module ClassModule
235
- def name
243
+ def name
236
244
  splitted = file_name.split("/")
237
245
  x = splitted[splitted.length-2]
238
246
  x
239
- end
247
+ end
240
248
  end
241
249
 
242
250
  end
@@ -1,15 +1,20 @@
1
1
  require 'bake/model/metamodel'
2
- require 'cxxproject/ext/file'
2
+ require 'common/ext/file'
3
3
 
4
- module Cxxproject
4
+ module Bake
5
5
  module Metamodel
6
6
 
7
- module Project::ClassModule
7
+ module ModelElement::ClassModule
8
8
  def get_project_dir
9
- # todo: no. must be set from outside
10
9
  ::File.dirname(file_name)
11
10
  end
12
11
  end
12
+
13
+ module BaseConfig_INTERNAL::ClassModule
14
+ def qname
15
+ @qname ||= parent.name + "," + name
16
+ end
17
+ end
13
18
 
14
19
  end
15
20
  end
@@ -0,0 +1,222 @@
1
+ require 'bake/toolchain/colorizing_formatter'
2
+ require 'common/options/parser'
3
+ require 'bake/options/showToolchains'
4
+ require 'bake/options/showConfigNames'
5
+ require 'bake/options/showLicense'
6
+ require 'bake/options/showDoc'
7
+ require 'bake/options/usage'
8
+ require 'common/options/option'
9
+
10
+ module Bake
11
+
12
+ def self.options
13
+ @@options
14
+ end
15
+ def self.options=(options)
16
+ @@options = options
17
+ end
18
+
19
+ class Options < Parser
20
+ attr_accessor :build_config, :nocache
21
+ attr_reader :main_dir, :project, :filename, :main_project_name # String
22
+ attr_reader :roots, :include_filter, :exclude_filter # String List
23
+ attr_reader :stopOnFirstError, :clean, :rebuild, :show_includes, :show_includes_and_defines, :linkOnly, :no_autodir, :clobber, :lint, :docu, :debug, :prepro # Boolean
24
+ attr_reader :threads, :socket, :lint_min, :lint_max # Fixnum
25
+ attr_reader :vars # map
26
+ attr_reader :verboseLow
27
+ attr_reader :verboseHigh
28
+ attr_reader :consoleOutput_fullnames, :consoleOutput_visualStudio
29
+
30
+
31
+ def initialize(argv)
32
+ super(argv)
33
+
34
+ @showConfigs = false
35
+ @consoleOutput_fullnames = false
36
+ @consoleOutput_visualStudio = false
37
+ @prepro = false
38
+ @stopOnFirstError = false
39
+ @verboseLow = false
40
+ @verboseHigh = false
41
+ @vars = {}
42
+ @build_config = ""
43
+ @main_dir = nil
44
+ @project = nil
45
+ @filename = nil
46
+ @clean = false
47
+ @clobber = false
48
+ @lint = false
49
+ @docu = false
50
+ @debug = false
51
+ @rebuild = false
52
+ @nocache = false
53
+ @show_includes = false
54
+ @show_includes_and_defines = false
55
+ @linkOnly = false
56
+ @no_autodir = false
57
+ @threads = 8
58
+ @lint_min = 0
59
+ @lint_max = -1
60
+ @roots = []
61
+ @socket = 0
62
+ @include_filter = []
63
+ @exclude_filter = []
64
+ @def_roots = []
65
+ @main_project_name = ""
66
+
67
+ add_default(Proc.new{ |x| set_build_config_default(x) })
68
+
69
+ add_option(Option.new("-m",true) { |x| set_main_dir(x) })
70
+ add_option(Option.new("-b",true) { |x| set_build_config(x) })
71
+ add_option(Option.new("-p",true) { |x| @project = x;})
72
+ add_option(Option.new("-f",true) { |x| @filename = x.gsub(/[\\]/,'/') })
73
+ add_option(Option.new("-c",false) { @clean = true })
74
+ add_option(Option.new("-a",true) { |x| Bake.formatter.setColorScheme(x.to_sym) })
75
+ add_option(Option.new("-w",true) { |x| set_root(x) })
76
+ add_option(Option.new("-r",false) { @stopOnFirstError = true })
77
+ add_option(Option.new("--rebuild",false) { @rebuild = true })
78
+ add_option(Option.new("--prepro",false) { @prepro = true })
79
+ add_option(Option.new("--link_only",false) { @linkOnly = true; })
80
+ add_option(Option.new("--no_autodir",false) { @no_autodir = true })
81
+ add_option(Option.new("--lint",false) { @lint = true })
82
+ add_option(Option.new("--lint_min",true) { |x| @lint_min = String === x ? x.to_i : x })
83
+ add_option(Option.new("--lint_max",true) { |x| @lint_max = String === x ? x.to_i : x })
84
+
85
+ add_option(Option.new("--docu",false) { @docu = true })
86
+
87
+ add_option(Option.new("-v0",false) { @verboseLow = true; @verboseHigh = false })
88
+ add_option(Option.new("-v1",false) { @verboseLow = false; @verboseHigh = false })
89
+ add_option(Option.new("-v2",false) { @verboseLow = false; @verboseHigh = true })
90
+
91
+ add_option(Option.new("--debug",false) { @debug = true })
92
+ add_option(Option.new("--set",true) { |x| set_set(x) })
93
+
94
+ add_option(Option.new("--clobber",false) { @clobber = true; @clean = true })
95
+ add_option(Option.new("--ignore_cache",false) { @nocache = true })
96
+ add_option(Option.new("--threads",true) { |x| set_threads(x) })
97
+ add_option(Option.new("--socket",true) { |x| @socket = String === x ? x.to_i : x })
98
+ add_option(Option.new("--toolchain_info",true) { |x| ToolchainInfo.showToolchain(x) })
99
+ add_option(Option.new("--toolchain_names",false) { ToolchainInfo.showToolchainList })
100
+ add_option(Option.new("--include_filter",true) { |x| @include_filter << x })
101
+ add_option(Option.new("--exclude_filter",true) { |x| @exclude_filter << x })
102
+ add_option(Option.new("--show_abs_paths",false) { @consoleOutput_fullnames = true })
103
+ add_option(Option.new("--visualStudio",false) { @consoleOutput_visualStudio = true })
104
+ add_option(Option.new("-h",false) { Bake::Usage.show })
105
+ add_option(Option.new("--help",false) { Bake::Usage.show })
106
+ add_option(Option.new("--show_include_paths",false) { @show_includes = true })
107
+ add_option(Option.new("--show_incs_and_defs",false) { @show_includes_and_defines = true })
108
+ add_option(Option.new("--show_license",false) { License.show })
109
+ add_option(Option.new("--doc",false) { Doc.show })
110
+ add_option(Option.new("--version",false) { ExitHelper.exit(0) })
111
+ add_option(Option.new("--show_configs",false) { @showConfigs = true })
112
+
113
+
114
+ end
115
+
116
+ def parse_options()
117
+ parse_internal(false)
118
+ set_main_dir(Dir.pwd) if @main_dir.nil?
119
+ @roots = @def_roots if @roots.length == 0
120
+
121
+ if @project
122
+ if @project.split(',').length > 2
123
+ Bake.formatter.printError("Error: only one comma allowed for -p")
124
+ ExitHelper.exit(1)
125
+ end
126
+ end
127
+
128
+ if @linkOnly
129
+ if @rebuild
130
+ Bake.formatter.printError("Error: --link_only and --rebuild not allowed at the same time")
131
+ ExitHelper.exit(1)
132
+ end
133
+ if @clean
134
+ Bake.formatter.printError("Error: --link_only and -c not allowed at the same time")
135
+ ExitHelper.exit(1)
136
+ end
137
+ if @prepro
138
+ Bake.formatter.printError("Error: --link_only and --prepro not allowed at the same time")
139
+ ExitHelper.exit(1)
140
+ end
141
+ end
142
+
143
+ if @prepro
144
+ if @rebuild
145
+ Bake.formatter.printError("Error: --prepro and --rebuild not allowed at the same time")
146
+ ExitHelper.exit(1)
147
+ end
148
+ if @clean
149
+ Bake.formatter.printError("Error: --prepro and -c not allowed at the same time")
150
+ ExitHelper.exit(1)
151
+ end
152
+ end
153
+
154
+ if @lint and @docu
155
+ Bake.formatter.printError("Error: --lint and --docu not allowed at the same time")
156
+ ExitHelper.exit(1)
157
+ end
158
+
159
+ ConfigNames.show if @showConfigs
160
+ end
161
+
162
+ def check_valid_dir(dir)
163
+ if not File.exists?(dir)
164
+ Bake.formatter.printError("Error: Directory #{dir} does not exist")
165
+ ExitHelper.exit(1)
166
+ end
167
+ if not File.directory?(dir)
168
+ Bake.formatter.printError("Error: #{dir} is not a directory")
169
+ ExitHelper.exit(1)
170
+ end
171
+ end
172
+
173
+ def set_build_config_default(config)
174
+ index = config.index('-')
175
+ return false if (index != nil and index == 0)
176
+ set_build_config(config)
177
+ return true
178
+ end
179
+
180
+ def set_build_config(config)
181
+ if not @build_config.empty?
182
+ Bake.formatter.printError("Error: Cannot set build config '#{config}', because build config is already set to '#{@build_config}'")
183
+ ExitHelper.exit(1)
184
+ end
185
+ @build_config = config
186
+ end
187
+
188
+ def set_main_dir(dir)
189
+ check_valid_dir(dir)
190
+ @main_dir = File.expand_path(dir.gsub(/[\\]/,'/'))
191
+ @main_project_name = File::basename(@main_dir)
192
+ @def_roots = calc_def_roots(@main_dir)
193
+ end
194
+
195
+ def set_root(dir)
196
+ check_valid_dir(dir)
197
+ r = File.expand_path(dir.gsub(/[\\]/,'/'))
198
+ @roots << r if not @roots.include?r
199
+ end
200
+
201
+ def set_threads(num)
202
+ @threads = String === num ? num.to_i : num
203
+ if @threads <= 0
204
+ Bake.formatter.printError("Error: number of threads must be > 0")
205
+ ExitHelper.exit(1)
206
+ end
207
+ end
208
+
209
+ def set_set(str)
210
+ ar = str.split("=")
211
+ if not str.include?"=" or ar[0].length == 0
212
+ Bake.formatter.printError("Error: --set must be followed by key=value")
213
+ ExitHelper.exit(1)
214
+ end
215
+ @vars[ar[0]] = ar[1..-1].join("=")
216
+ end
217
+
218
+ end
219
+
220
+ end
221
+
222
+
@@ -0,0 +1,44 @@
1
+ require 'bake/model/loader'
2
+ require 'bake/options/options'
3
+
4
+ module Bake
5
+
6
+ class ConfigNames
7
+
8
+ def self.print(configs, default, filename)
9
+ validConfigs = []
10
+ configs.each do |c|
11
+ validConfigs << c.name unless c.defaultToolchain.nil?
12
+ end
13
+ if validConfigs.length > 0
14
+ validConfigs.each do |v|
15
+ d = ""
16
+ d = " (default)" if v == default
17
+ puts "* " + v + d
18
+ end
19
+ else
20
+ Bake.formatter.printWarning("No configuration with a DefaultToolchain found", filename)
21
+ end
22
+
23
+ ExitHelper.exit(0)
24
+ end
25
+
26
+ def self.show
27
+ loader = Loader.new
28
+ filename = Bake.options.main_dir+"/Project.meta"
29
+ f = loader.load(filename)
30
+
31
+ if f.root_elements.length != 1 or not Metamodel::Project === f.root_elements[0]
32
+ Bake.formatter.printError("Config file must have exactly one 'Project' element as root element", filename)
33
+ ExitHelper.exit(1)
34
+ end
35
+
36
+ default = f.root_elements[0].default
37
+ configs = f.root_elements[0].getConfig
38
+
39
+ ConfigNames.print(configs, default, filename)
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,19 @@
1
+ module Bake
2
+ class Doc
3
+ def self.show
4
+
5
+ link = File.expand_path(File.dirname(__FILE__)+"/../../../doc/index.html")
6
+ if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
7
+ system "start #{link}"
8
+ elsif RUBY_PLATFORM =~ /darwin/
9
+ system "open #{link}"
10
+ elsif RUBY_PLATFORM =~ /linux|bsd/
11
+ system "xdg-open #{link}"
12
+ else
13
+ puts "Please open #{link} manually in your browser."
14
+ end
15
+
16
+ ExitHelper.exit(0)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module Bake
2
+ class License
3
+ def self.show
4
+ licenseFile = File.join(File.dirname(__FILE__), "../../../license.txt")
5
+ puts "\n" + File.read(licenseFile)
6
+ ExitHelper.exit(0)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ module Bake
2
+ class ToolchainInfo
3
+
4
+ def self.printHash(x, level)
5
+ x.each do |k,v|
6
+ if Hash === v
7
+ if level > 0
8
+ level.times {print " "}
9
+ else
10
+ print "\n"
11
+ end
12
+ puts k
13
+ printHash(v,level+1)
14
+ elsif Array === v or String === v
15
+ level.times {print " "}
16
+ print "\n" if (level == 0)
17
+ puts "#{k} = #{v}"
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.showToolchain(x)
23
+ tcs = Bake::Toolchain::Provider[x]
24
+ if tcs.nil?
25
+ puts "Toolchain not available"
26
+ else
27
+ printHash(tcs, 0)
28
+ end
29
+ ExitHelper.exit(0)
30
+ end
31
+
32
+ def self.showToolchainList()
33
+ puts "Available toolchains:"
34
+ Bake::Toolchain::Provider.list.keys.each { |c| puts "* #{c}" }
35
+ ExitHelper.exit(0)
36
+ end
37
+
38
+ end
39
+ end