bake-toolkit 2.44.0 → 2.44.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bake/config/loader.rb +393 -393
- data/lib/bake/options/options.rb +1 -1
- data/lib/bake/options/usage.rb +1 -1
- data/lib/blocks/compile.rb +6 -1
- data/lib/common/version.rb +1 -1
- data/license.txt +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63594dff72adc9e2399d3e5b3e61c10cfa428937
|
4
|
+
data.tar.gz: b5ac0b63c555016846e26bb62db52e609d70db63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75df6bc8056a67e5250a0600149f9fcd356d86a51c20ecf0868f266062f918d0b8738d5703f8e4f506a6d4013174bc4fac0aaf7de53886200e863ccb01780646
|
7
|
+
data.tar.gz: d728f32ae07a50f727d93b8c9842c2d43c0bf2460d78908cc3abb370d69c8d25e687ab0ce1e0fb2f7a1b27aaa2c1cf76016dac171cfd98ccd41712e970e989d0
|
data/lib/bake/config/loader.rb
CHANGED
@@ -1,393 +1,393 @@
|
|
1
|
-
require 'bake/model/loader'
|
2
|
-
require 'bake/config/checks'
|
3
|
-
require 'adapt/config/loader'
|
4
|
-
|
5
|
-
module Bake
|
6
|
-
|
7
|
-
class Config
|
8
|
-
attr_reader :referencedConfigs
|
9
|
-
|
10
|
-
def initialize()
|
11
|
-
@fullProjects = {}
|
12
|
-
@defaultToolchainName = ""
|
13
|
-
@mainProjectName = ""
|
14
|
-
@mainConfigName = ""
|
15
|
-
end
|
16
|
-
|
17
|
-
def resolveConfigName(configs, configname)
|
18
|
-
if (configname == "")
|
19
|
-
if configs[0].parent.default != ""
|
20
|
-
configname = configs[0].parent.default
|
21
|
-
else
|
22
|
-
Bake.formatter.printError("No default config specified", configs[0].file_name)
|
23
|
-
ExitHelper.exit(1)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
return configname
|
27
|
-
end
|
28
|
-
|
29
|
-
def getFullProjectInternal(configs, configname, isMain) # note: configs is never empty
|
30
|
-
|
31
|
-
configname = resolveConfigName(configs, configname)
|
32
|
-
|
33
|
-
if isMain
|
34
|
-
if Bake.options.qac
|
35
|
-
configs.each do |c|
|
36
|
-
if c.name == (configname + "Qac")
|
37
|
-
configname = configname + "Qac"
|
38
|
-
break
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
config = nil
|
45
|
-
configs.each do |c|
|
46
|
-
if c.name == configname
|
47
|
-
if config
|
48
|
-
Bake.formatter.printError("Config '#{configname}' found more than once",config.file_name)
|
49
|
-
ExitHelper.exit(1)
|
50
|
-
end
|
51
|
-
config = c
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
if not config
|
56
|
-
Bake.formatter.printError("Config '#{configname}' not found", configs[0].file_name)
|
57
|
-
ExitHelper.exit(1)
|
58
|
-
end
|
59
|
-
|
60
|
-
if config.extends != ""
|
61
|
-
config.extends.split(",").map {|ex| ex.strip}.reverse.each do |ex|
|
62
|
-
if (ex != "")
|
63
|
-
parent,parentConfigName = getFullProjectInternal(configs, ex, isMain)
|
64
|
-
MergeConfig.new(config, parent).merge(:merge)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
[config, configname]
|
70
|
-
end
|
71
|
-
|
72
|
-
def getFullProject(projName, configs, configname, isMain)
|
73
|
-
|
74
|
-
configname = resolveConfigName(configs, configname)
|
75
|
-
|
76
|
-
if @fullProjects.has_key?(projName + "," + configname)
|
77
|
-
return @fullProjects[projName + "," + configname]
|
78
|
-
end
|
79
|
-
|
80
|
-
config, configname = getFullProjectInternal(configs, configname, isMain)
|
81
|
-
|
82
|
-
if isMain
|
83
|
-
@defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
|
84
|
-
@mainProjectName = config.parent.name
|
85
|
-
@mainConfigName = config.name
|
86
|
-
end
|
87
|
-
|
88
|
-
# check if config has to be manipulated
|
89
|
-
@adaptConfigs.each do |c|
|
90
|
-
|
91
|
-
if isMain
|
92
|
-
@defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
|
93
|
-
@mainProjectName = config.parent.name
|
94
|
-
@mainConfigName = config.name
|
95
|
-
end
|
96
|
-
|
97
|
-
projPattern = /\A#{c.project.gsub("*", "(\\w*)")}\z/
|
98
|
-
confPattern = /\A#{c.name.gsub("*", "(\\w*)")}\z/
|
99
|
-
|
100
|
-
if projPattern.match(config.parent.name) or (
|
101
|
-
if confPattern.match(config.name) or (isMain and c.name == "__MAIN__") or c.name == "__ALL__"
|
102
|
-
|
103
|
-
conditionProjPattern = /\A#{c.parent.mainProject.gsub("*", "(\\w*)")}\z/
|
104
|
-
conditionConfPattern = /\A#{c.parent.mainConfig.gsub("*", "(\\w*)")}\z/
|
105
|
-
|
106
|
-
adaptCondition = (c.parent.toolchain == "" || c.parent.toolchain == @defaultToolchainName) &&
|
107
|
-
(c.parent.os == "" || c.parent.os == Utils::OS.name) &&
|
108
|
-
(c.parent.mainProject == "" || !conditionProjPattern.match(@mainProjectName).nil?) &&
|
109
|
-
(c.parent.mainConfig == "" || !conditionConfPattern.match(@mainConfigName).nil?)
|
110
|
-
|
111
|
-
invertLogic = (Bake::Metamodel::Unless === c.parent)
|
112
|
-
next if (adaptCondition && invertLogic) || (!adaptCondition && !invertLogic)
|
113
|
-
|
114
|
-
MergeConfig.new(c, config).merge(c.type.to_sym)
|
115
|
-
|
116
|
-
if isMain # can be changed after adapt
|
117
|
-
@defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
@fullProjects[projName + "," + configname] = [config, configname]
|
125
|
-
[config, configname]
|
126
|
-
end
|
127
|
-
|
128
|
-
def symlinkCheck(filename)
|
129
|
-
dirOfProjMeta = File.dirname(filename)
|
130
|
-
Dir.chdir(dirOfProjMeta) do
|
131
|
-
if Dir.pwd != dirOfProjMeta and File.dirname(Dir.pwd) != File.dirname(dirOfProjMeta)
|
132
|
-
isSym = false
|
133
|
-
begin
|
134
|
-
isSym = File.symlink?(dirOfProjMeta)
|
135
|
-
rescue
|
136
|
-
end
|
137
|
-
if isSym
|
138
|
-
Bake.formatter.printError("Symlinks only allowed with the same parent dir as the target: #{dirOfProjMeta} --> #{Dir.pwd}", filename)
|
139
|
-
ExitHelper.exit(1)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
def checkVerFormat(ver)
|
146
|
-
return true if ver.empty?
|
147
|
-
return false if ver.length > 3
|
148
|
-
ver.each do |v|
|
149
|
-
return false if not /\A\d+\z/.match(v)
|
150
|
-
end
|
151
|
-
true
|
152
|
-
end
|
153
|
-
|
154
|
-
def bailOutVer(reqVersion)
|
155
|
-
text1 = (reqVersion.minimum.empty? ? "" : "minimum = #{reqVersion.minimum}")
|
156
|
-
text2 = ((reqVersion.minimum.empty? or reqVersion.maximum.empty?) ? "" : ", ")
|
157
|
-
text3 = (reqVersion.maximum.empty? ? "" : "maximum = #{reqVersion.maximum}")
|
158
|
-
Bake.formatter.printError("Not compatible with installed bake version: #{text1 + text2 + text3}", reqVersion)
|
159
|
-
ExitHelper.exit(1)
|
160
|
-
end
|
161
|
-
|
162
|
-
def checkVer(reqVersion)
|
163
|
-
return if reqVersion.nil?
|
164
|
-
min = reqVersion.minimum.split(".")
|
165
|
-
max = reqVersion.maximum.split(".")
|
166
|
-
cur = Bake::Version.number.split(".")
|
167
|
-
|
168
|
-
if !checkVerFormat(min) or !checkVerFormat(max)
|
169
|
-
Bake.formatter.printError("Version must be <major>.<minor>.<patch> whereas minor and patch are optional and all numbers >= 0.", reqVersion)
|
170
|
-
ExitHelper.exit(1)
|
171
|
-
end
|
172
|
-
|
173
|
-
[min,max,cur].each { |arr| arr.map! {|x| x.to_i} }
|
174
|
-
min.each_with_index do |v,i|
|
175
|
-
break if v < cur[i]
|
176
|
-
bailOutVer(reqVersion) if v > cur[i]
|
177
|
-
end
|
178
|
-
max.each_with_index do |v,i|
|
179
|
-
break if v > cur[i]
|
180
|
-
bailOutVer(reqVersion) if v < cur[i]
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def loadProjMeta(filename)
|
185
|
-
|
186
|
-
Bake::Configs::Checks.symlinkCheck(filename)
|
187
|
-
|
188
|
-
f = @loader.load(filename)
|
189
|
-
|
190
|
-
config = nil
|
191
|
-
|
192
|
-
projRoots = f.root_elements.select { |re| Metamodel::Project === re }
|
193
|
-
if projRoots.length != 1
|
194
|
-
Bake.formatter.printError("Config file must have exactly one 'Project' element as root element", filename)
|
195
|
-
ExitHelper.exit(1)
|
196
|
-
end
|
197
|
-
proj = projRoots[0]
|
198
|
-
|
199
|
-
reqVersion = proj.getRequiredBakeVersion
|
200
|
-
checkVer(reqVersion)
|
201
|
-
|
202
|
-
configs = proj.getConfig
|
203
|
-
Bake::Configs::Checks::commonMetamodelCheck(configs, filename)
|
204
|
-
|
205
|
-
configs.each do |c|
|
206
|
-
if not c.project.empty?
|
207
|
-
Bake.formatter.printError("Attribute 'project' must only be used in adapt config.",c)
|
208
|
-
ExitHelper.exit(1)
|
209
|
-
end
|
210
|
-
if not c.type.empty?
|
211
|
-
Bake.formatter.printError("Attribute 'type' must only be used in adapt config.",c)
|
212
|
-
ExitHelper.exit(1)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
adaptRoots = f.root_elements.select { |re| Metamodel::Adapt === re }
|
217
|
-
if adaptRoots.length > 0
|
218
|
-
adaptRoots.each do |adapt|
|
219
|
-
adapt.mainProject = @mainProjectName if adapt.mainProject == "__THIS__"
|
220
|
-
adaptConfigs = adapt.getConfig
|
221
|
-
AdaptConfig.checkSyntax(adaptConfigs, filename, true)
|
222
|
-
adaptConfigs.each do |ac|
|
223
|
-
ac.project = proj.name if ac.project == "__THIS__" || ac.project == ""
|
224
|
-
end
|
225
|
-
@adaptConfigs.concat(adaptConfigs)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
configs
|
230
|
-
end
|
231
|
-
|
232
|
-
|
233
|
-
def validateDependencies(config)
|
234
|
-
config.dependency.each do |dep|
|
235
|
-
if dep.name.include?"$" or dep.config.include?"$"
|
236
|
-
Bake.formatter.printError("No variables allowed in Dependency definition", dep)
|
237
|
-
ExitHelper.exit(1)
|
238
|
-
end
|
239
|
-
dep.name = config.parent.name if dep.name == ""
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
def loadMeta(dep)
|
244
|
-
dep_subbed = dep.name.gsub(/\\/,"/")
|
245
|
-
if dep_subbed.include?":" or dep_subbed.include?"../" or dep_subbed.start_with?"/" or dep_subbed.end_with?"/"
|
246
|
-
Bake.formatter.printError("#{dep.name} is invalid", dep)
|
247
|
-
ExitHelper.exit(1)
|
248
|
-
end
|
249
|
-
dep_path, dismiss, dep_name = dep_subbed.rpartition("/")
|
250
|
-
|
251
|
-
# file not loaded yet
|
252
|
-
if not @loadedConfigs.include?dep_name
|
253
|
-
|
254
|
-
if Bake.options.verbose >= 3
|
255
|
-
puts "First referenced by #{dep.parent.parent.name} (#{dep.parent.name}):"
|
256
|
-
end
|
257
|
-
|
258
|
-
pmeta_filenames = []
|
259
|
-
|
260
|
-
@potentialProjs.each do |pp|
|
261
|
-
if pp.include?("/" + dep_subbed + "/Project.meta") or pp == (dep_subbed + "/Project.meta")
|
262
|
-
pmeta_filenames << pp
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
if pmeta_filenames.empty?
|
267
|
-
Bake.formatter.printError("#{dep.name}/Project.meta not found", dep)
|
268
|
-
ExitHelper.exit(1)
|
269
|
-
end
|
270
|
-
|
271
|
-
if pmeta_filenames.length > 1
|
272
|
-
Bake.formatter.printWarning("Project #{dep.name} exists more than once", dep)
|
273
|
-
chosen = " (chosen)"
|
274
|
-
pmeta_filenames.each do |f|
|
275
|
-
Bake.formatter.printWarning(" #{File.dirname(f)}#{chosen}")
|
276
|
-
chosen = ""
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
@loadedConfigs[dep_name] = loadProjMeta(pmeta_filenames[0])
|
281
|
-
else
|
282
|
-
folder = @loadedConfigs[dep_name][0].get_project_dir
|
283
|
-
if not folder.include?dep_subbed
|
284
|
-
Bake.formatter.printError("Cannot load #{dep.name}, because #{folder} already loaded", dep)
|
285
|
-
ExitHelper.exit(1)
|
286
|
-
end
|
287
|
-
|
288
|
-
end
|
289
|
-
# get config
|
290
|
-
if Bake.options.verbose >= 3
|
291
|
-
puts " #{dep_name} #{dep.config.empty? ? "<default>" : "("+dep.config+")"} referenced by #{dep.parent.parent.name} (#{dep.parent.name})"
|
292
|
-
end
|
293
|
-
config, dep.config = getFullProject(dep_name, @loadedConfigs[dep_name], dep.config, false)
|
294
|
-
dep.name = dep_name
|
295
|
-
|
296
|
-
# config not referenced yet
|
297
|
-
if not @referencedConfigs.include?dep_name
|
298
|
-
@referencedConfigs[dep_name] = [config]
|
299
|
-
elsif @referencedConfigs[dep_name].index { |c| c.name == dep.config } == nil
|
300
|
-
@referencedConfigs[dep_name] << config
|
301
|
-
else
|
302
|
-
return
|
303
|
-
end
|
304
|
-
|
305
|
-
validateDependencies(config)
|
306
|
-
@depsPending += config.dependency
|
307
|
-
end
|
308
|
-
|
309
|
-
def loadMainMeta()
|
310
|
-
mainMeta = Bake.options.main_dir+"/Project.meta"
|
311
|
-
configs = loadProjMeta(mainMeta)
|
312
|
-
@loadedConfigs = {}
|
313
|
-
@loadedConfigs[Bake.options.main_project_name] = configs
|
314
|
-
|
315
|
-
if not showConfigNames?
|
316
|
-
config, Bake.options.build_config = getFullProject(Bake.options.main_project_name, configs,Bake.options.build_config, true)
|
317
|
-
|
318
|
-
@referencedConfigs = {}
|
319
|
-
@referencedConfigs[Bake.options.main_project_name] = [config]
|
320
|
-
|
321
|
-
validateDependencies(config)
|
322
|
-
@depsPending = config.dependency
|
323
|
-
|
324
|
-
if Bake.options.build_config != "" and config.defaultToolchain == nil
|
325
|
-
Bake.formatter.printError("Main project configuration must contain DefaultToolchain", config)
|
326
|
-
ExitHelper.exit(1)
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
end
|
331
|
-
|
332
|
-
def checkRoots()
|
333
|
-
@potentialProjs = []
|
334
|
-
Bake.options.roots.each do |root|
|
335
|
-
r = root.dir
|
336
|
-
if (r.length == 3 && r.include?(":/"))
|
337
|
-
r = r + Bake.options.main_project_name # glob would not work otherwise on windows (ruby bug?)
|
338
|
-
end
|
339
|
-
depthStr = root.depth.nil? ? "max" : root.depth.to_s
|
340
|
-
puts "Checking root #{r} (depth: #{depthStr})" if Bake.options.verbose >= 1
|
341
|
-
@potentialProjs.concat(Root.search_to_depth(r, "Project.meta", root.depth))
|
342
|
-
end
|
343
|
-
@potentialProjs.uniq!
|
344
|
-
end
|
345
|
-
|
346
|
-
def defaultConfigName
|
347
|
-
@loadedConfigs[Bake.options.main_project_name].first.parent.default
|
348
|
-
end
|
349
|
-
|
350
|
-
def showConfigNames?
|
351
|
-
Bake.options.showConfigs or (Bake.options.build_config == "" and defaultConfigName == "")
|
352
|
-
end
|
353
|
-
|
354
|
-
def printConfigNames
|
355
|
-
mainConfigName = Bake.options.build_config != "" ? Bake.options.build_config : defaultConfigName
|
356
|
-
configs = @loadedConfigs[Bake.options.main_project_name]
|
357
|
-
foundValidConfig = false
|
358
|
-
configs.each do |c|
|
359
|
-
config, tmp = getFullProject(Bake.options.main_project_name, configs, c.name, c.name == mainConfigName)
|
360
|
-
next if config.defaultToolchain.nil?
|
361
|
-
Kernel.print "* #{config.name}"
|
362
|
-
Kernel.print " (default)" if config.name == defaultConfigName
|
363
|
-
Kernel.print ": #{config.description.text}" if config.description
|
364
|
-
Kernel.print "\n"
|
365
|
-
foundValidConfig = true
|
366
|
-
end
|
367
|
-
|
368
|
-
Bake.formatter.printWarning("No configuration with a DefaultToolchain found", Bake.options.main_dir+"/Project.meta") unless foundValidConfig
|
369
|
-
ExitHelper.exit(0)
|
370
|
-
end
|
371
|
-
|
372
|
-
def printConfigs(adaptConfigs)
|
373
|
-
@adaptConfigs = adaptConfigs
|
374
|
-
@loader = Loader.new
|
375
|
-
loadMainMeta # note.in cache only needed configs are stored
|
376
|
-
printConfigNames
|
377
|
-
end
|
378
|
-
|
379
|
-
def load(adaptConfigs)
|
380
|
-
@adaptConfigs = adaptConfigs
|
381
|
-
@loader = Loader.new
|
382
|
-
loadMainMeta
|
383
|
-
printConfigNames if showConfigNames? # if neither config name nor default is set, list the configs with DefaultToolchain
|
384
|
-
checkRoots
|
385
|
-
while dep = @depsPending.shift
|
386
|
-
loadMeta(dep)
|
387
|
-
end
|
388
|
-
|
389
|
-
return @referencedConfigs
|
390
|
-
end
|
391
|
-
|
392
|
-
end
|
393
|
-
end
|
1
|
+
require 'bake/model/loader'
|
2
|
+
require 'bake/config/checks'
|
3
|
+
require 'adapt/config/loader'
|
4
|
+
|
5
|
+
module Bake
|
6
|
+
|
7
|
+
class Config
|
8
|
+
attr_reader :referencedConfigs
|
9
|
+
|
10
|
+
def initialize()
|
11
|
+
@fullProjects = {}
|
12
|
+
@defaultToolchainName = ""
|
13
|
+
@mainProjectName = ""
|
14
|
+
@mainConfigName = ""
|
15
|
+
end
|
16
|
+
|
17
|
+
def resolveConfigName(configs, configname)
|
18
|
+
if (configname == "")
|
19
|
+
if configs[0].parent.default != ""
|
20
|
+
configname = configs[0].parent.default
|
21
|
+
else
|
22
|
+
Bake.formatter.printError("No default config specified", configs[0].file_name)
|
23
|
+
ExitHelper.exit(1)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
return configname
|
27
|
+
end
|
28
|
+
|
29
|
+
def getFullProjectInternal(configs, configname, isMain) # note: configs is never empty
|
30
|
+
|
31
|
+
configname = resolveConfigName(configs, configname)
|
32
|
+
|
33
|
+
if isMain
|
34
|
+
if Bake.options.qac
|
35
|
+
configs.each do |c|
|
36
|
+
if c.name == (configname + "Qac")
|
37
|
+
configname = configname + "Qac"
|
38
|
+
break
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
config = nil
|
45
|
+
configs.each do |c|
|
46
|
+
if c.name == configname
|
47
|
+
if config
|
48
|
+
Bake.formatter.printError("Config '#{configname}' found more than once",config.file_name)
|
49
|
+
ExitHelper.exit(1)
|
50
|
+
end
|
51
|
+
config = c
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if not config
|
56
|
+
Bake.formatter.printError("Config '#{configname}' not found", configs[0].file_name)
|
57
|
+
ExitHelper.exit(1)
|
58
|
+
end
|
59
|
+
|
60
|
+
if config.extends != ""
|
61
|
+
config.extends.split(",").map {|ex| ex.strip}.reverse.each do |ex|
|
62
|
+
if (ex != "")
|
63
|
+
parent,parentConfigName = getFullProjectInternal(configs, ex, isMain)
|
64
|
+
MergeConfig.new(config, parent).merge(:merge)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
[config, configname]
|
70
|
+
end
|
71
|
+
|
72
|
+
def getFullProject(projName, configs, configname, isMain)
|
73
|
+
|
74
|
+
configname = resolveConfigName(configs, configname)
|
75
|
+
|
76
|
+
if @fullProjects.has_key?(projName + "," + configname)
|
77
|
+
return @fullProjects[projName + "," + configname]
|
78
|
+
end
|
79
|
+
|
80
|
+
config, configname = getFullProjectInternal(configs, configname, isMain)
|
81
|
+
|
82
|
+
if isMain
|
83
|
+
@defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
|
84
|
+
@mainProjectName = config.parent.name
|
85
|
+
@mainConfigName = config.name
|
86
|
+
end
|
87
|
+
|
88
|
+
# check if config has to be manipulated
|
89
|
+
@adaptConfigs.each do |c|
|
90
|
+
|
91
|
+
if isMain
|
92
|
+
@defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
|
93
|
+
@mainProjectName = config.parent.name
|
94
|
+
@mainConfigName = config.name
|
95
|
+
end
|
96
|
+
|
97
|
+
projPattern = /\A#{c.project.gsub("*", "(\\w*)")}\z/
|
98
|
+
confPattern = /\A#{c.name.gsub("*", "(\\w*)")}\z/
|
99
|
+
|
100
|
+
if projPattern.match(config.parent.name) or (projName == Bake.options.main_project_name and c.project == "__MAIN__") or c.project == "__ALL__"
|
101
|
+
if confPattern.match(config.name) or (isMain and c.name == "__MAIN__") or c.name == "__ALL__"
|
102
|
+
|
103
|
+
conditionProjPattern = /\A#{c.parent.mainProject.gsub("*", "(\\w*)")}\z/
|
104
|
+
conditionConfPattern = /\A#{c.parent.mainConfig.gsub("*", "(\\w*)")}\z/
|
105
|
+
|
106
|
+
adaptCondition = (c.parent.toolchain == "" || c.parent.toolchain == @defaultToolchainName) &&
|
107
|
+
(c.parent.os == "" || c.parent.os == Utils::OS.name) &&
|
108
|
+
(c.parent.mainProject == "" || !conditionProjPattern.match(@mainProjectName).nil?) &&
|
109
|
+
(c.parent.mainConfig == "" || !conditionConfPattern.match(@mainConfigName).nil?)
|
110
|
+
|
111
|
+
invertLogic = (Bake::Metamodel::Unless === c.parent)
|
112
|
+
next if (adaptCondition && invertLogic) || (!adaptCondition && !invertLogic)
|
113
|
+
|
114
|
+
MergeConfig.new(c, config).merge(c.type.to_sym)
|
115
|
+
|
116
|
+
if isMain # can be changed after adapt
|
117
|
+
@defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
@fullProjects[projName + "," + configname] = [config, configname]
|
125
|
+
[config, configname]
|
126
|
+
end
|
127
|
+
|
128
|
+
def symlinkCheck(filename)
|
129
|
+
dirOfProjMeta = File.dirname(filename)
|
130
|
+
Dir.chdir(dirOfProjMeta) do
|
131
|
+
if Dir.pwd != dirOfProjMeta and File.dirname(Dir.pwd) != File.dirname(dirOfProjMeta)
|
132
|
+
isSym = false
|
133
|
+
begin
|
134
|
+
isSym = File.symlink?(dirOfProjMeta)
|
135
|
+
rescue
|
136
|
+
end
|
137
|
+
if isSym
|
138
|
+
Bake.formatter.printError("Symlinks only allowed with the same parent dir as the target: #{dirOfProjMeta} --> #{Dir.pwd}", filename)
|
139
|
+
ExitHelper.exit(1)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def checkVerFormat(ver)
|
146
|
+
return true if ver.empty?
|
147
|
+
return false if ver.length > 3
|
148
|
+
ver.each do |v|
|
149
|
+
return false if not /\A\d+\z/.match(v)
|
150
|
+
end
|
151
|
+
true
|
152
|
+
end
|
153
|
+
|
154
|
+
def bailOutVer(reqVersion)
|
155
|
+
text1 = (reqVersion.minimum.empty? ? "" : "minimum = #{reqVersion.minimum}")
|
156
|
+
text2 = ((reqVersion.minimum.empty? or reqVersion.maximum.empty?) ? "" : ", ")
|
157
|
+
text3 = (reqVersion.maximum.empty? ? "" : "maximum = #{reqVersion.maximum}")
|
158
|
+
Bake.formatter.printError("Not compatible with installed bake version: #{text1 + text2 + text3}", reqVersion)
|
159
|
+
ExitHelper.exit(1)
|
160
|
+
end
|
161
|
+
|
162
|
+
def checkVer(reqVersion)
|
163
|
+
return if reqVersion.nil?
|
164
|
+
min = reqVersion.minimum.split(".")
|
165
|
+
max = reqVersion.maximum.split(".")
|
166
|
+
cur = Bake::Version.number.split(".")
|
167
|
+
|
168
|
+
if !checkVerFormat(min) or !checkVerFormat(max)
|
169
|
+
Bake.formatter.printError("Version must be <major>.<minor>.<patch> whereas minor and patch are optional and all numbers >= 0.", reqVersion)
|
170
|
+
ExitHelper.exit(1)
|
171
|
+
end
|
172
|
+
|
173
|
+
[min,max,cur].each { |arr| arr.map! {|x| x.to_i} }
|
174
|
+
min.each_with_index do |v,i|
|
175
|
+
break if v < cur[i]
|
176
|
+
bailOutVer(reqVersion) if v > cur[i]
|
177
|
+
end
|
178
|
+
max.each_with_index do |v,i|
|
179
|
+
break if v > cur[i]
|
180
|
+
bailOutVer(reqVersion) if v < cur[i]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def loadProjMeta(filename)
|
185
|
+
|
186
|
+
Bake::Configs::Checks.symlinkCheck(filename)
|
187
|
+
|
188
|
+
f = @loader.load(filename)
|
189
|
+
|
190
|
+
config = nil
|
191
|
+
|
192
|
+
projRoots = f.root_elements.select { |re| Metamodel::Project === re }
|
193
|
+
if projRoots.length != 1
|
194
|
+
Bake.formatter.printError("Config file must have exactly one 'Project' element as root element", filename)
|
195
|
+
ExitHelper.exit(1)
|
196
|
+
end
|
197
|
+
proj = projRoots[0]
|
198
|
+
|
199
|
+
reqVersion = proj.getRequiredBakeVersion
|
200
|
+
checkVer(reqVersion)
|
201
|
+
|
202
|
+
configs = proj.getConfig
|
203
|
+
Bake::Configs::Checks::commonMetamodelCheck(configs, filename)
|
204
|
+
|
205
|
+
configs.each do |c|
|
206
|
+
if not c.project.empty?
|
207
|
+
Bake.formatter.printError("Attribute 'project' must only be used in adapt config.",c)
|
208
|
+
ExitHelper.exit(1)
|
209
|
+
end
|
210
|
+
if not c.type.empty?
|
211
|
+
Bake.formatter.printError("Attribute 'type' must only be used in adapt config.",c)
|
212
|
+
ExitHelper.exit(1)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
adaptRoots = f.root_elements.select { |re| Metamodel::Adapt === re }
|
217
|
+
if adaptRoots.length > 0
|
218
|
+
adaptRoots.each do |adapt|
|
219
|
+
adapt.mainProject = @mainProjectName if adapt.mainProject == "__THIS__"
|
220
|
+
adaptConfigs = adapt.getConfig
|
221
|
+
AdaptConfig.checkSyntax(adaptConfigs, filename, true)
|
222
|
+
adaptConfigs.each do |ac|
|
223
|
+
ac.project = proj.name if ac.project == "__THIS__" || ac.project == ""
|
224
|
+
end
|
225
|
+
@adaptConfigs.concat(adaptConfigs)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
configs
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
def validateDependencies(config)
|
234
|
+
config.dependency.each do |dep|
|
235
|
+
if dep.name.include?"$" or dep.config.include?"$"
|
236
|
+
Bake.formatter.printError("No variables allowed in Dependency definition", dep)
|
237
|
+
ExitHelper.exit(1)
|
238
|
+
end
|
239
|
+
dep.name = config.parent.name if dep.name == ""
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def loadMeta(dep)
|
244
|
+
dep_subbed = dep.name.gsub(/\\/,"/")
|
245
|
+
if dep_subbed.include?":" or dep_subbed.include?"../" or dep_subbed.start_with?"/" or dep_subbed.end_with?"/"
|
246
|
+
Bake.formatter.printError("#{dep.name} is invalid", dep)
|
247
|
+
ExitHelper.exit(1)
|
248
|
+
end
|
249
|
+
dep_path, dismiss, dep_name = dep_subbed.rpartition("/")
|
250
|
+
|
251
|
+
# file not loaded yet
|
252
|
+
if not @loadedConfigs.include?dep_name
|
253
|
+
|
254
|
+
if Bake.options.verbose >= 3
|
255
|
+
puts "First referenced by #{dep.parent.parent.name} (#{dep.parent.name}):"
|
256
|
+
end
|
257
|
+
|
258
|
+
pmeta_filenames = []
|
259
|
+
|
260
|
+
@potentialProjs.each do |pp|
|
261
|
+
if pp.include?("/" + dep_subbed + "/Project.meta") or pp == (dep_subbed + "/Project.meta")
|
262
|
+
pmeta_filenames << pp
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
if pmeta_filenames.empty?
|
267
|
+
Bake.formatter.printError("#{dep.name}/Project.meta not found", dep)
|
268
|
+
ExitHelper.exit(1)
|
269
|
+
end
|
270
|
+
|
271
|
+
if pmeta_filenames.length > 1
|
272
|
+
Bake.formatter.printWarning("Project #{dep.name} exists more than once", dep)
|
273
|
+
chosen = " (chosen)"
|
274
|
+
pmeta_filenames.each do |f|
|
275
|
+
Bake.formatter.printWarning(" #{File.dirname(f)}#{chosen}")
|
276
|
+
chosen = ""
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
@loadedConfigs[dep_name] = loadProjMeta(pmeta_filenames[0])
|
281
|
+
else
|
282
|
+
folder = @loadedConfigs[dep_name][0].get_project_dir
|
283
|
+
if not folder.include?dep_subbed
|
284
|
+
Bake.formatter.printError("Cannot load #{dep.name}, because #{folder} already loaded", dep)
|
285
|
+
ExitHelper.exit(1)
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
# get config
|
290
|
+
if Bake.options.verbose >= 3
|
291
|
+
puts " #{dep_name} #{dep.config.empty? ? "<default>" : "("+dep.config+")"} referenced by #{dep.parent.parent.name} (#{dep.parent.name})"
|
292
|
+
end
|
293
|
+
config, dep.config = getFullProject(dep_name, @loadedConfigs[dep_name], dep.config, false)
|
294
|
+
dep.name = dep_name
|
295
|
+
|
296
|
+
# config not referenced yet
|
297
|
+
if not @referencedConfigs.include?dep_name
|
298
|
+
@referencedConfigs[dep_name] = [config]
|
299
|
+
elsif @referencedConfigs[dep_name].index { |c| c.name == dep.config } == nil
|
300
|
+
@referencedConfigs[dep_name] << config
|
301
|
+
else
|
302
|
+
return
|
303
|
+
end
|
304
|
+
|
305
|
+
validateDependencies(config)
|
306
|
+
@depsPending += config.dependency
|
307
|
+
end
|
308
|
+
|
309
|
+
def loadMainMeta()
|
310
|
+
mainMeta = Bake.options.main_dir+"/Project.meta"
|
311
|
+
configs = loadProjMeta(mainMeta)
|
312
|
+
@loadedConfigs = {}
|
313
|
+
@loadedConfigs[Bake.options.main_project_name] = configs
|
314
|
+
|
315
|
+
if not showConfigNames?
|
316
|
+
config, Bake.options.build_config = getFullProject(Bake.options.main_project_name, configs,Bake.options.build_config, true)
|
317
|
+
|
318
|
+
@referencedConfigs = {}
|
319
|
+
@referencedConfigs[Bake.options.main_project_name] = [config]
|
320
|
+
|
321
|
+
validateDependencies(config)
|
322
|
+
@depsPending = config.dependency
|
323
|
+
|
324
|
+
if Bake.options.build_config != "" and config.defaultToolchain == nil
|
325
|
+
Bake.formatter.printError("Main project configuration must contain DefaultToolchain", config)
|
326
|
+
ExitHelper.exit(1)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
def checkRoots()
|
333
|
+
@potentialProjs = []
|
334
|
+
Bake.options.roots.each do |root|
|
335
|
+
r = root.dir
|
336
|
+
if (r.length == 3 && r.include?(":/"))
|
337
|
+
r = r + Bake.options.main_project_name # glob would not work otherwise on windows (ruby bug?)
|
338
|
+
end
|
339
|
+
depthStr = root.depth.nil? ? "max" : root.depth.to_s
|
340
|
+
puts "Checking root #{r} (depth: #{depthStr})" if Bake.options.verbose >= 1
|
341
|
+
@potentialProjs.concat(Root.search_to_depth(r, "Project.meta", root.depth))
|
342
|
+
end
|
343
|
+
@potentialProjs.uniq!
|
344
|
+
end
|
345
|
+
|
346
|
+
def defaultConfigName
|
347
|
+
@loadedConfigs[Bake.options.main_project_name].first.parent.default
|
348
|
+
end
|
349
|
+
|
350
|
+
def showConfigNames?
|
351
|
+
Bake.options.showConfigs or (Bake.options.build_config == "" and defaultConfigName == "")
|
352
|
+
end
|
353
|
+
|
354
|
+
def printConfigNames
|
355
|
+
mainConfigName = Bake.options.build_config != "" ? Bake.options.build_config : defaultConfigName
|
356
|
+
configs = @loadedConfigs[Bake.options.main_project_name]
|
357
|
+
foundValidConfig = false
|
358
|
+
configs.each do |c|
|
359
|
+
config, tmp = getFullProject(Bake.options.main_project_name, configs, c.name, c.name == mainConfigName)
|
360
|
+
next if config.defaultToolchain.nil?
|
361
|
+
Kernel.print "* #{config.name}"
|
362
|
+
Kernel.print " (default)" if config.name == defaultConfigName
|
363
|
+
Kernel.print ": #{config.description.text}" if config.description
|
364
|
+
Kernel.print "\n"
|
365
|
+
foundValidConfig = true
|
366
|
+
end
|
367
|
+
|
368
|
+
Bake.formatter.printWarning("No configuration with a DefaultToolchain found", Bake.options.main_dir+"/Project.meta") unless foundValidConfig
|
369
|
+
ExitHelper.exit(0)
|
370
|
+
end
|
371
|
+
|
372
|
+
def printConfigs(adaptConfigs)
|
373
|
+
@adaptConfigs = adaptConfigs
|
374
|
+
@loader = Loader.new
|
375
|
+
loadMainMeta # note.in cache only needed configs are stored
|
376
|
+
printConfigNames
|
377
|
+
end
|
378
|
+
|
379
|
+
def load(adaptConfigs)
|
380
|
+
@adaptConfigs = adaptConfigs
|
381
|
+
@loader = Loader.new
|
382
|
+
loadMainMeta
|
383
|
+
printConfigNames if showConfigNames? # if neither config name nor default is set, list the configs with DefaultToolchain
|
384
|
+
checkRoots
|
385
|
+
while dep = @depsPending.shift
|
386
|
+
loadMeta(dep)
|
387
|
+
end
|
388
|
+
|
389
|
+
return @referencedConfigs
|
390
|
+
end
|
391
|
+
|
392
|
+
end
|
393
|
+
end
|
data/lib/bake/options/options.rb
CHANGED
@@ -148,7 +148,7 @@ module Bake
|
|
148
148
|
|
149
149
|
add_option(["--version" ], lambda { Bake::Usage.version })
|
150
150
|
add_option(["--list", "--show_configs" ], lambda { @showConfigs = true })
|
151
|
-
add_option(["--compilation-db" ], lambda { |x,dummy| @cc2j_filename = (x ? x : "
|
151
|
+
add_option(["--compilation-db" ], lambda { |x,dummy| @cc2j_filename = (x ? x : "compile_commands.json" )})
|
152
152
|
add_option(["--link-2-17", "--link_2_17" ], lambda { @oldLinkOrder = true })
|
153
153
|
add_option(["--build_", ], lambda { @buildDirDelimiter = "_" })
|
154
154
|
|
data/lib/bake/options/usage.rb
CHANGED
@@ -55,7 +55,7 @@ module Bake
|
|
55
55
|
puts " --file-list Writes all sources and headers used by a SINGLE config into '<config output folder>/file-list.txt'."
|
56
56
|
puts " Writes all sources and headers used by ALL configs into '<main config output folder/global-file-list.txt'."
|
57
57
|
puts " --prebuild Does not build configs which are marked as 'prebuild', this feature is used for distributions."
|
58
|
-
puts " --compilation-db [<fn>] Writes compilation information into filename fn in json format, default for fn is
|
58
|
+
puts " --compilation-db [<fn>] Writes compilation information into filename fn in json format, default for fn is compile_commands.json"
|
59
59
|
puts " --create exe|lib|custom Creates a project with exe, lib or custom template"
|
60
60
|
puts " --nb Suppresses the lines \"**** Building x of y: name (config) ****"
|
61
61
|
puts " --crc32 <string> Calulates the CRC32 of string (0x4C11DB7, init 0, final xor 0, input and result not reflected), used for Uid variable calculation"
|
data/lib/blocks/compile.rb
CHANGED
@@ -237,7 +237,12 @@ module Bake
|
|
237
237
|
|
238
238
|
if Bake.options.cc2j_filename
|
239
239
|
cmdJson = cmd.is_a?(Array) ? cmd.join(' ') : cmd
|
240
|
-
|
240
|
+
srcFilePath = source
|
241
|
+
if Bake.options.consoleOutput_fullnames
|
242
|
+
srcFilePath = File.join(@projectDir, srcFilePath)
|
243
|
+
cmdJson[source] = srcFilePath
|
244
|
+
end
|
245
|
+
Blocks::CC2J << { :directory => @projectDir, :command => cmdJson, :file => srcFilePath }
|
241
246
|
end
|
242
247
|
|
243
248
|
if not (cmdLineCheck and BlockBase.isCmdLineEqual?(cmd, cmdLineFile))
|
data/lib/common/version.rb
CHANGED
data/license.txt
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake-toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.44.
|
4
|
+
version: 2.44.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Schaal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rtext
|
@@ -98,42 +98,42 @@ dependencies:
|
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: coveralls
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
description: See documentation for more details
|
@@ -249,23 +249,23 @@ licenses:
|
|
249
249
|
metadata: {}
|
250
250
|
post_install_message:
|
251
251
|
rdoc_options:
|
252
|
-
-
|
252
|
+
- -x
|
253
253
|
- doc
|
254
254
|
require_paths:
|
255
255
|
- lib
|
256
256
|
required_ruby_version: !ruby/object:Gem::Requirement
|
257
257
|
requirements:
|
258
|
-
- -
|
258
|
+
- - '>='
|
259
259
|
- !ruby/object:Gem::Version
|
260
260
|
version: '1.9'
|
261
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
262
|
requirements:
|
263
|
-
- -
|
263
|
+
- - '>='
|
264
264
|
- !ruby/object:Gem::Version
|
265
265
|
version: '0'
|
266
266
|
requirements: []
|
267
267
|
rubyforge_project:
|
268
|
-
rubygems_version: 2.6.
|
268
|
+
rubygems_version: 2.6.7
|
269
269
|
signing_key:
|
270
270
|
specification_version: 4
|
271
271
|
summary: Build tool to compile C/C++ projects fast and easy.
|