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.
- checksums.yaml +4 -4
- data/bin/bake +14 -53
- data/bin/bakery +50 -43
- data/bin/createVSProjects +3 -3
- data/doc/cmd/install.html +1 -5
- data/doc/cmd/usecmd.html +29 -5
- data/doc/dyk/lint.html +21 -4
- data/doc/dyk/tipps.html +0 -6
- data/doc/eclipse/import.html +3 -1
- data/doc/eclipse/import/Import.png +0 -0
- data/doc/eclipse/use.html +8 -5
- data/doc/further/change.html +134 -1
- data/doc/further/issues.html +1 -0
- data/doc/further/wish.html +24 -21
- data/doc/index.html +1 -1
- data/doc/syntax/subst.html +8 -1
- data/doc/syntax/syntax.html +42 -14
- data/lib/bake/cache.rb +51 -59
- data/lib/bake/config/loader.rb +289 -0
- data/lib/bake/libElement.rb +134 -0
- data/lib/bake/mergeConfig.rb +1 -1
- data/lib/bake/model/language.rb +1 -1
- data/lib/bake/model/loader.rb +88 -0
- data/lib/bake/model/metamodel.rb +24 -16
- data/lib/bake/model/metamodel_ext.rb +9 -4
- data/lib/bake/options/options.rb +222 -0
- data/lib/bake/options/showConfigNames.rb +44 -0
- data/lib/bake/options/showDoc.rb +19 -0
- data/lib/bake/options/showLicense.rb +9 -0
- data/lib/bake/options/showToolchains.rb +39 -0
- data/lib/bake/options/usage.rb +54 -0
- data/lib/bake/process_output.rb +10 -0
- data/lib/bake/subst.rb +105 -40
- data/lib/bake/toolchain/clang.rb +44 -0
- data/lib/bake/toolchain/colorizing_formatter.rb +125 -0
- data/lib/bake/toolchain/diab.rb +53 -0
- data/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -0
- data/lib/bake/toolchain/errorparser/diab_linker_error_parser.rb +41 -0
- data/lib/bake/toolchain/errorparser/error_parser.rb +71 -0
- data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -0
- data/lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb +35 -0
- data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -0
- data/lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb +44 -0
- data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -0
- data/lib/bake/toolchain/errorparser/keil_linker_error_parser.rb +30 -0
- data/lib/bake/toolchain/errorparser/lint_error_parser.rb +34 -0
- data/lib/bake/toolchain/errorparser/process_output.rb +3 -0
- data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -0
- data/lib/bake/toolchain/errorparser/ti_linker_error_parser.rb +30 -0
- data/lib/bake/toolchain/gcc.rb +49 -0
- data/lib/bake/toolchain/gcc_param.rb +7 -0
- data/lib/bake/toolchain/greenhills.rb +52 -0
- data/lib/bake/toolchain/keil.rb +55 -0
- data/lib/bake/toolchain/lint.rb +20 -0
- data/lib/bake/toolchain/provider.rb +136 -0
- data/lib/bake/toolchain/ti.rb +47 -0
- data/lib/bake/util.rb +27 -15
- data/lib/bakery/buildPattern.rb +1 -1
- data/lib/bakery/model/language.rb +1 -1
- data/lib/bakery/model/loader.rb +56 -0
- data/lib/bakery/model/metamodel.rb +1 -1
- data/lib/bakery/options/options.rb +87 -0
- data/lib/bakery/toBake.rb +10 -6
- data/lib/blocks/block.rb +225 -0
- data/lib/blocks/blockBase.rb +155 -0
- data/lib/blocks/commandLine.rb +25 -0
- data/lib/blocks/compile.rb +382 -0
- data/lib/blocks/docu.rb +28 -0
- data/lib/blocks/executable.rb +143 -0
- data/lib/blocks/has_execute_command.rb +31 -0
- data/lib/blocks/library.rb +78 -0
- data/lib/blocks/lint.rb +53 -0
- data/lib/blocks/makefile.rb +87 -0
- data/lib/blocks/showIncludes.rb +114 -0
- data/lib/common/abortException.rb +4 -0
- data/lib/common/cleanup.rb +9 -0
- data/lib/common/exit_helper.rb +28 -0
- data/lib/common/ext/file.rb +88 -0
- data/lib/common/ext/stdout.rb +45 -0
- data/lib/common/ide_interface.rb +194 -0
- data/lib/common/options/option.rb +13 -0
- data/lib/common/options/parser.rb +59 -0
- data/lib/common/process.rb +64 -0
- data/lib/common/utils.rb +52 -0
- data/lib/{bake → common}/version.rb +3 -10
- data/lib/multithread/job.rb +44 -0
- data/lib/tocxx.rb +201 -932
- data/lib/vs/options.rb +3 -2
- data/license.txt +47 -22
- metadata +90 -30
- data/bin/bake-doc +0 -12
- data/lib/alias/loader.rb +0 -56
- data/lib/alias/model/language.rb +0 -22
- data/lib/alias/model/metamodel.rb +0 -29
- data/lib/bake/loader.rb +0 -92
- data/lib/bake/options.rb +0 -421
- data/lib/bakery/loader.rb +0 -57
- data/lib/bakery/options.rb +0 -105
- data/lib/option/parser.rb +0 -73
@@ -0,0 +1,289 @@
|
|
1
|
+
require 'bake/model/loader'
|
2
|
+
|
3
|
+
module Bake
|
4
|
+
|
5
|
+
class Config
|
6
|
+
attr_reader :referencedConfigs
|
7
|
+
attr_reader :defaultToolchain
|
8
|
+
|
9
|
+
@@defaultToolchainTime = nil
|
10
|
+
|
11
|
+
def self.defaultToolchainTime
|
12
|
+
@@defaultToolchainTime
|
13
|
+
end
|
14
|
+
|
15
|
+
def getFullProject(configs, configname) # note: configs is never empty
|
16
|
+
|
17
|
+
if (configname == "")
|
18
|
+
if configs[0].parent.default != ""
|
19
|
+
configname = configs[0].parent.default
|
20
|
+
else
|
21
|
+
Bake.formatter.printError("No default config specified", configs[0].file_name)
|
22
|
+
ExitHelper.exit(1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
config = nil
|
27
|
+
configs.each do |c|
|
28
|
+
if c.name == configname
|
29
|
+
if config
|
30
|
+
Bake.formatter.printError("Config '#{configname}' found more than once",config.file_name)
|
31
|
+
ExitHelper.exit(1)
|
32
|
+
end
|
33
|
+
config = c
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if not config
|
38
|
+
Bake.formatter.printError("Config '#{configname}' not found", configs[0].file_name)
|
39
|
+
ExitHelper.exit(1)
|
40
|
+
end
|
41
|
+
|
42
|
+
if config.extends != ""
|
43
|
+
parent,parentConfigName = getFullProject(configs, config.extends)
|
44
|
+
MergeConfig.new(config, parent).merge()
|
45
|
+
end
|
46
|
+
|
47
|
+
[config, configname]
|
48
|
+
end
|
49
|
+
|
50
|
+
def symlinkCheck(filename)
|
51
|
+
dirOfProjMeta = File.dirname(filename)
|
52
|
+
Dir.chdir(dirOfProjMeta) do
|
53
|
+
if Dir.pwd != dirOfProjMeta and File.dirname(Dir.pwd) != File.dirname(dirOfProjMeta)
|
54
|
+
isSym = false
|
55
|
+
begin
|
56
|
+
isSym = File.symlink?(dirOfProjMeta)
|
57
|
+
rescue
|
58
|
+
end
|
59
|
+
if isSym
|
60
|
+
Bake.formatter.printError("Symlinks only allowed with the same parent dir as the target: #{dirOfProjMeta} --> #{Dir.pwd}", filename)
|
61
|
+
ExitHelper.exit(1)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def loadProjMeta(filename)
|
69
|
+
|
70
|
+
symlinkCheck(filename)
|
71
|
+
|
72
|
+
@project_files << filename
|
73
|
+
f = @loader.load(filename)
|
74
|
+
|
75
|
+
config = nil
|
76
|
+
|
77
|
+
if f.root_elements.length != 1 or not Metamodel::Project === f.root_elements[0]
|
78
|
+
Bake.formatter.printError("Config file must have exactly one 'Project' element as root element", filename)
|
79
|
+
ExitHelper.exit(1)
|
80
|
+
end
|
81
|
+
|
82
|
+
configs = f.root_elements[0].getConfig
|
83
|
+
|
84
|
+
if configs.length == 0
|
85
|
+
Bake.formatter.printError("No config found", filename)
|
86
|
+
ExitHelper.exit(1)
|
87
|
+
end
|
88
|
+
|
89
|
+
configs.each do |config|
|
90
|
+
if config.respond_to?("toolchain") and config.toolchain
|
91
|
+
config.toolchain.compiler.each do |c|
|
92
|
+
if not c.internalDefines.nil? and c.internalDefines != ""
|
93
|
+
Bake.formatter.printError("InternalDefines only allowed in DefaultToolchain", c.internalDefines)
|
94
|
+
ExitHelper.exit(1)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
configs
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def validateDependencies(config)
|
104
|
+
config.dependency.each do |dep|
|
105
|
+
if dep.name.include?"$" or dep.config.include?"$"
|
106
|
+
Bake.formatter.printError("No variables allowed in Dependency definition", dep)
|
107
|
+
ExitHelper.exit(1)
|
108
|
+
end
|
109
|
+
dep.name = config.parent.name if dep.name == ""
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def loadMeta(dep)
|
114
|
+
|
115
|
+
# file not loaded yet
|
116
|
+
if not @loadedConfigs.include?dep.name
|
117
|
+
|
118
|
+
pmeta_filenames = []
|
119
|
+
|
120
|
+
@potentialProjs.each do |pp|
|
121
|
+
if pp.include?("/" + dep.name + "/Project.meta") or pp == (dep.name + "/Project.meta")
|
122
|
+
pmeta_filenames << pp
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if pmeta_filenames.empty?
|
127
|
+
Bake.formatter.printError("#{dep.name}/Project.meta not found", dep)
|
128
|
+
ExitHelper.exit(1)
|
129
|
+
end
|
130
|
+
|
131
|
+
if pmeta_filenames.length > 1
|
132
|
+
Bake.formatter.printWarning("Project #{dep.name} exists more than once", dep)
|
133
|
+
chosen = " (chosen)"
|
134
|
+
pmeta_filenames.each do |f|
|
135
|
+
Bake.formatter.printWarning(" #{File.dirname(f)}#{chosen}")
|
136
|
+
chosen = ""
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
@loadedConfigs[dep.name] = loadProjMeta(pmeta_filenames[0])
|
141
|
+
end
|
142
|
+
|
143
|
+
# get config
|
144
|
+
config, dep.config = getFullProject(@loadedConfigs[dep.name],dep.config)
|
145
|
+
|
146
|
+
# config not referenced yet
|
147
|
+
if not @referencedConfigs.include?dep.name
|
148
|
+
@referencedConfigs[dep.name] = [config]
|
149
|
+
elsif @referencedConfigs[dep.name].index { |c| c.name == dep.config } == nil
|
150
|
+
@referencedConfigs[dep.name] << config
|
151
|
+
else
|
152
|
+
return
|
153
|
+
end
|
154
|
+
|
155
|
+
validateDependencies(config)
|
156
|
+
@depsPending += config.dependency
|
157
|
+
end
|
158
|
+
|
159
|
+
def loadMainMeta()
|
160
|
+
mainMeta = Bake.options.main_dir+"/Project.meta"
|
161
|
+
if not File.exist?(mainMeta)
|
162
|
+
Bake.formatter.printError("Error: #{mainMeta} not found")
|
163
|
+
ExitHelper.exit(1)
|
164
|
+
end
|
165
|
+
|
166
|
+
@project_files = []
|
167
|
+
|
168
|
+
configs = loadProjMeta(mainMeta)
|
169
|
+
@loadedConfigs = {}
|
170
|
+
@loadedConfigs[Bake.options.main_project_name] = configs
|
171
|
+
|
172
|
+
if (Bake.options.build_config == "" and configs[0].parent.default == "")
|
173
|
+
ConfigNames.print(configs, nil, mainMeta)
|
174
|
+
end
|
175
|
+
|
176
|
+
config, Bake.options.build_config = getFullProject(configs,Bake.options.build_config)
|
177
|
+
@referencedConfigs = {}
|
178
|
+
@referencedConfigs[Bake.options.main_project_name] = [config]
|
179
|
+
|
180
|
+
if config.defaultToolchain == nil
|
181
|
+
Bake.formatter.printError("Main project configuration must contain DefaultToolchain", config)
|
182
|
+
ExitHelper.exit(1)
|
183
|
+
end
|
184
|
+
|
185
|
+
basedOn = config.defaultToolchain.basedOn
|
186
|
+
@basedOnToolchain = Bake::Toolchain::Provider[basedOn]
|
187
|
+
if @basedOnToolchain.nil?
|
188
|
+
Bake.formatter.printError("DefaultToolchain based on unknown compiler '#{basedOn}'", config.defaultToolchain)
|
189
|
+
ExitHelper.exit(1)
|
190
|
+
end
|
191
|
+
@defaultToolchain = Utils.deep_copy(@basedOnToolchain)
|
192
|
+
integrateToolchain(@defaultToolchain, config.defaultToolchain)
|
193
|
+
@@defaultToolchainTime = File.mtime(mainMeta)
|
194
|
+
|
195
|
+
validateDependencies(config)
|
196
|
+
@depsPending = config.dependency
|
197
|
+
end
|
198
|
+
|
199
|
+
def checkRoots()
|
200
|
+
@potentialProjs = []
|
201
|
+
Bake.options.roots.each do |r|
|
202
|
+
if (r.length == 3 && r.include?(":/"))
|
203
|
+
r = r + Bake.options.main_project_name # glob would not work otherwise on windows (ruby bug?)
|
204
|
+
end
|
205
|
+
r = r+"/**{,/*/**}/Project.meta"
|
206
|
+
@potentialProjs.concat(Dir.glob(r))
|
207
|
+
end
|
208
|
+
|
209
|
+
@potentialProjs = @potentialProjs.uniq.sort
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
def filterStep(step, globalFilterStr)
|
214
|
+
|
215
|
+
# 1st prio: explicit single filter
|
216
|
+
if step.filter != ""
|
217
|
+
return true if Bake.options.exclude_filter.include?step.filter
|
218
|
+
return false if Bake.options.include_filter.include?step.filter
|
219
|
+
end
|
220
|
+
|
221
|
+
# 2nd prio: explicit global filter
|
222
|
+
if globalFilterStr != nil
|
223
|
+
return true if Bake.options.exclude_filter.include?globalFilterStr
|
224
|
+
return false if Bake.options.include_filter.include?globalFilterStr
|
225
|
+
end
|
226
|
+
|
227
|
+
# 3nd prio: default
|
228
|
+
return true if step.default == "off"
|
229
|
+
false
|
230
|
+
end
|
231
|
+
|
232
|
+
def filterSteps
|
233
|
+
@referencedConfigs.each do |projName, configs|
|
234
|
+
configs.each do |config|
|
235
|
+
config.preSteps.step = config.preSteps.step.delete_if { |step| filterStep(step, "PRE") } if config.preSteps
|
236
|
+
config.postSteps.step = config.postSteps.step.delete_if { |step| filterStep(step, "POST") } if config.postSteps
|
237
|
+
if Metamodel::CustomConfig === config and config.step
|
238
|
+
config.step = nil if filterStep(config.step, nil)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def load()
|
245
|
+
@loader = Loader.new
|
246
|
+
cache = CacheAccess.new()
|
247
|
+
@referencedConfigs = cache.load_cache unless Bake.options.nocache
|
248
|
+
|
249
|
+
# cache invalid or forced to reload
|
250
|
+
if @referencedConfigs.nil?
|
251
|
+
loadMainMeta
|
252
|
+
checkRoots
|
253
|
+
while dep = @depsPending.shift
|
254
|
+
loadMeta(dep)
|
255
|
+
end
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
if (cache.defaultToolchain)
|
260
|
+
if @defaultToolchain[:LINKER][:FLAGS] == cache.defaultToolchain[:LINKER][:FLAGS] and
|
261
|
+
@defaultToolchain[:LINKER][:LIB_PREFIX_FLAGS] == cache.defaultToolchain[:LINKER][:LIB_PREFIX_FLAGS] and
|
262
|
+
@defaultToolchain[:LINKER][:LIB_POSTFIX_FLAGS] == cache.defaultToolchain[:LINKER][:LIB_POSTFIX_FLAGS] and
|
263
|
+
@defaultToolchain[:ARCHIVER][:FLAGS] == cache.defaultToolchain[:ARCHIVER][:FLAGS] and
|
264
|
+
@defaultToolchain[:COMPILER][:CPP][:FLAGS] == cache.defaultToolchain[:COMPILER][:CPP][:FLAGS] and
|
265
|
+
@defaultToolchain[:COMPILER][:CPP][:DEFINES].join("") == cache.defaultToolchain[:COMPILER][:CPP][:DEFINES].join("") and
|
266
|
+
@defaultToolchain[:COMPILER][:C][:FLAGS] == cache.defaultToolchain[:COMPILER][:C][:FLAGS] and
|
267
|
+
@defaultToolchain[:COMPILER][:C][:DEFINES].join("") == cache.defaultToolchain[:COMPILER][:C][:DEFINES].join("") and
|
268
|
+
@defaultToolchain[:COMPILER][:ASM][:FLAGS] == cache.defaultToolchain[:COMPILER][:ASM][:FLAGS] and
|
269
|
+
@defaultToolchain[:COMPILER][:ASM][:DEFINES].join("") == cache.defaultToolchain[:COMPILER][:ASM][:DEFINES].join("") and
|
270
|
+
@defaultToolchain[:LINT_POLICY].join("") == cache.defaultToolchain[:LINT_POLICY].join("")
|
271
|
+
@defaultToolchain[:DOCU] == cache.defaultToolchain[:DOCU]
|
272
|
+
@@defaultToolchainTime = cache.defaultToolchainTime
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
filterSteps
|
277
|
+
|
278
|
+
cache.write_cache(@project_files, @referencedConfigs, @defaultToolchain, @@defaultToolchainTime)
|
279
|
+
else
|
280
|
+
@defaultToolchain = cache.defaultToolchain
|
281
|
+
@@defaultToolchainTime = cache.defaultToolchainTime
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
|
287
|
+
end
|
288
|
+
|
289
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Bake
|
2
|
+
|
3
|
+
class LibElement
|
4
|
+
|
5
|
+
LIB = 1
|
6
|
+
USERLIB = 2
|
7
|
+
LIB_WITH_PATH = 3
|
8
|
+
SEARCH_PATH = 4
|
9
|
+
DEPENDENCY = 5
|
10
|
+
|
11
|
+
attr_reader :type, :value
|
12
|
+
|
13
|
+
def initialize(type, value)
|
14
|
+
@type = type
|
15
|
+
@value = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class LibElements
|
20
|
+
|
21
|
+
def self.calc_linker_lib_string(block, tcs)
|
22
|
+
@@lib_path_set = []
|
23
|
+
@@dep_set = Set.new
|
24
|
+
@@linker = tcs[:LINKER]
|
25
|
+
@@projectDir = block.projectDir
|
26
|
+
@@source_libraries = []
|
27
|
+
@@linker_libs_array = []
|
28
|
+
|
29
|
+
collect_recursive(block)
|
30
|
+
|
31
|
+
if @@linker[:LIST_MODE] and not @@lib_path_set.empty?
|
32
|
+
@@linker_libs_array << (@@linker[:LIB_PATH_FLAG] + @@lib_path_set.join(","));
|
33
|
+
end
|
34
|
+
|
35
|
+
return [@@source_libraries, @@linker_libs_array]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.adaptPath(path, block, prefix)
|
39
|
+
adaptedPath = path
|
40
|
+
if not File.is_absolute?(path)
|
41
|
+
prefix ||= File.rel_from_to_project(@@projectDir,block.projectDir)
|
42
|
+
adaptedPath = prefix + path if prefix
|
43
|
+
end
|
44
|
+
#adaptedPath = "\"" + adaptedPath + "\"" if adaptedPath.include?(" ")
|
45
|
+
[adaptedPath, prefix]
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.collect_recursive(block)
|
49
|
+
return if @@dep_set.include?block
|
50
|
+
@@dep_set << block
|
51
|
+
|
52
|
+
prefix = nil
|
53
|
+
|
54
|
+
if block.library
|
55
|
+
adaptedPath, prefix = adaptPath(block.library.archive_name, block, prefix)
|
56
|
+
@@linker_libs_array << adaptedPath
|
57
|
+
@@source_libraries << adaptedPath
|
58
|
+
end
|
59
|
+
|
60
|
+
block.lib_elements.each_key.sort.each do |line_num|
|
61
|
+
block.lib_elements[line_num].each do |elem|
|
62
|
+
|
63
|
+
case elem.type
|
64
|
+
when LibElement::LIB
|
65
|
+
@@linker_libs_array << "#{@@linker[:LIB_FLAG]}#{elem.value}"
|
66
|
+
when LibElement::USERLIB
|
67
|
+
@@linker_libs_array << "#{@@linker[:USER_LIB_FLAG]}#{elem.value}"
|
68
|
+
when LibElement::LIB_WITH_PATH
|
69
|
+
adaptedPath, prefix = adaptPath(elem.value, block, prefix)
|
70
|
+
@@linker_libs_array << adaptedPath
|
71
|
+
when LibElement::SEARCH_PATH
|
72
|
+
adaptedPath, prefix = adaptPath(elem.value, block, prefix)
|
73
|
+
if not @@lib_path_set.include?adaptedPath
|
74
|
+
@@lib_path_set << adaptedPath
|
75
|
+
@@linker_libs_array << "#{@@linker[:LIB_PATH_FLAG]}#{adaptedPath}" if @@linker[:LIST_MODE] == false
|
76
|
+
end
|
77
|
+
when LibElement::DEPENDENCY
|
78
|
+
if Blocks::ALL_BLOCKS.include?elem.value
|
79
|
+
bb = Blocks::ALL_BLOCKS[elem.value]
|
80
|
+
collect_recursive(bb)
|
81
|
+
else
|
82
|
+
# TODO: warning or error?
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
def self.calcLibElements(block)
|
93
|
+
lib_elements = {} # key = line number, value = array pairs [type, name/path string]
|
94
|
+
|
95
|
+
block.config.userLibrary.each do |l|
|
96
|
+
ln = l.lib
|
97
|
+
ls = nil
|
98
|
+
if l.lib.include?("/")
|
99
|
+
pos = l.lib.rindex("/")
|
100
|
+
ls = block.convPath(l.lib[0..pos-1], l)
|
101
|
+
ln = l.lib[pos+1..-1]
|
102
|
+
end
|
103
|
+
lib_elements[l.line_number] = ls.nil? ? [] : [LibElement.new(LibElement::SEARCH_PATH, ls)]
|
104
|
+
lib_elements[l.line_number] << LibElement.new(LibElement::USERLIB, ln)
|
105
|
+
end
|
106
|
+
|
107
|
+
block.config.exLib.each do |exLib|
|
108
|
+
ln = exLib.name
|
109
|
+
ls = nil
|
110
|
+
if exLib.name.include?("/")
|
111
|
+
pos = exLib.name.rindex("/")
|
112
|
+
ls = block.convPath(exLib.name[0..pos-1], exLib)
|
113
|
+
ln = exLib.name[pos+1..-1]
|
114
|
+
end
|
115
|
+
if exLib.search
|
116
|
+
lib_elements[exLib.line_number] = ls.nil? ? [] : [LibElement.new(LibElement::SEARCH_PATH, ls)]
|
117
|
+
lib_elements[exLib.line_number] << LibElement.new(LibElement::LIB, ln)
|
118
|
+
else
|
119
|
+
ln = ls + "/" + ln unless ls.nil?
|
120
|
+
lib_elements[exLib.line_number] = [LibElement.new(LibElement::LIB_WITH_PATH, ln)]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
block.config.exLibSearchPath.each do |exLibSP|
|
125
|
+
lib_elements[exLibSP.line_number] = [LibElement.new(LibElement::SEARCH_PATH, block.convPath(exLibSP))]
|
126
|
+
end
|
127
|
+
|
128
|
+
block.config.dependency.each { |dep| lib_elements[dep.line_number] = [LibElement.new(LibElement::DEPENDENCY, dep.name+","+dep.config)]}
|
129
|
+
return lib_elements
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
data/lib/bake/mergeConfig.rb
CHANGED
data/lib/bake/model/language.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'bake/model/metamodel'
|
2
|
+
require 'bake/model/language'
|
3
|
+
require 'common/version'
|
4
|
+
|
5
|
+
require 'rgen/environment'
|
6
|
+
require 'rgen/fragment/dump_file_cache'
|
7
|
+
require 'rgen/fragment/fragmented_model'
|
8
|
+
require 'rgen/util/file_cache_map'
|
9
|
+
|
10
|
+
require 'rtext/default_loader'
|
11
|
+
|
12
|
+
require 'common/exit_helper'
|
13
|
+
require 'bake/toolchain/colorizing_formatter'
|
14
|
+
require 'bake/options/options'
|
15
|
+
|
16
|
+
module Bake
|
17
|
+
|
18
|
+
class Loader
|
19
|
+
|
20
|
+
attr_reader :model
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@env = RGen::Environment.new
|
24
|
+
|
25
|
+
fcm = RGen::Util::FileCacheMap.new(".bake", ".cache")
|
26
|
+
fcm.version_info = Version.number
|
27
|
+
@DumpFileCache = RGen::Fragment::DumpFileCache.new(fcm)
|
28
|
+
@model = RGen::Fragment::FragmentedModel.new(:env => @env)
|
29
|
+
end
|
30
|
+
|
31
|
+
def load(filename)
|
32
|
+
sumErrors = 0
|
33
|
+
|
34
|
+
if Bake.options.nocache
|
35
|
+
def @DumpFileCache.load(fragment)
|
36
|
+
:invalid
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if not File.exists?filename
|
41
|
+
Bake.formatter.printError("Error: #{filename} does not exist")
|
42
|
+
ExitHelper.exit(1)
|
43
|
+
end
|
44
|
+
|
45
|
+
loader = RText::DefaultLoader.new(
|
46
|
+
Bake::Language,
|
47
|
+
@model,
|
48
|
+
:file_provider => proc { [filename] },
|
49
|
+
:cache => @DumpFileCache)
|
50
|
+
loader.load(:before_load => proc {|fragment, kind|
|
51
|
+
case kind
|
52
|
+
when :load_update_cache
|
53
|
+
if Bake.options.verboseHigh
|
54
|
+
puts "Loading and caching #{fragment.location}"
|
55
|
+
else
|
56
|
+
puts "Loading #{fragment.location}"
|
57
|
+
end
|
58
|
+
when :load_cached
|
59
|
+
if Bake.options.verboseHigh
|
60
|
+
puts "Loading cached #{fragment.location}"
|
61
|
+
else
|
62
|
+
puts "Loading #{fragment.location}"
|
63
|
+
end
|
64
|
+
when :load
|
65
|
+
puts "Loading #{fragment.location}"
|
66
|
+
else
|
67
|
+
Bake.formatter.printError("Error: Could not load #{fragment.location}")
|
68
|
+
ExitHelper.exit(1)
|
69
|
+
end
|
70
|
+
})
|
71
|
+
|
72
|
+
f = @model.fragments[0]
|
73
|
+
@model.remove_fragment(f)
|
74
|
+
|
75
|
+
f.data[:problems].each do |p|
|
76
|
+
Bake.formatter.printError(p.message, p.file, p.line)
|
77
|
+
end
|
78
|
+
|
79
|
+
if f.data[:problems].length > 0
|
80
|
+
ExitHelper.exit(1)
|
81
|
+
end
|
82
|
+
|
83
|
+
return f
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|