bake-toolkit 2.65.0 → 2.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fd56c91721f565baebab8ee13b453249a1673565cccd22ddde5787797035562
4
- data.tar.gz: d6013cd8ad4eefe6f6979d2b3a905a30b1737b54398c7d317367bc9a36676e71
3
+ metadata.gz: d2d635c3cc903018e92f111403d9a1450fa76c82cabd5d1159afbfe1269c3b1e
4
+ data.tar.gz: a4ecb9b50ead0faaf4e3a2ac37d3d295886bb8d3e6a221f41da69e74ad805474
5
5
  SHA512:
6
- metadata.gz: 4d360c2a3d60a572580ab81ab31575d330b69aa7001b09a3dd725e88e23c5bb3a7e34564d1933e8c68c680fea831eeec63c829f63e1cd5307079c319ef68ce09
7
- data.tar.gz: 3190bf643083cd2378eec6b3a69077e17fe80c2f8f05080e80903306132c362c52dbea7ab834f5a8815eff1916b8b4689780ab863a9f93dbcce14f6dfd05b7da
6
+ metadata.gz: b5d974d79c37da1ced9fa7ae03273a5aacd27531d2e080259225df1884b646ffc7cd2b0b2658011e80446eba81617eef4072474515ee66d500e7fbbdcb87f81f
7
+ data.tar.gz: 998f741470db5a771b26356519f58bc904a0ac26e838aca5f100e4c2f73ef646fe09aa0ca8f96f5b08c075edc3e6dd699c136462a9cab9f8708d286cf882d5e8
data/Rakefile.rb CHANGED
@@ -1,3 +1,7 @@
1
- require 'rake'
2
-
3
- require './rake_helper/spec.rb'
1
+ gem "coveralls", "=0.8.23"
2
+ gem "simplecov", "=0.16.1"
3
+ gem "rspec", "=3.10.0"
4
+
5
+ require 'rake'
6
+
7
+ require './rake_helper/spec.rb'
data/bin/bakery CHANGED
@@ -136,6 +136,7 @@ module Bake
136
136
  runOk = (ExitHelper.exit_code == 0)
137
137
  rescue Exception => e
138
138
  puts e.message
139
+ puts e.backtrace
139
140
  end
140
141
 
141
142
  if Bake.options.dev_features.detect { |x| x.start_with?("dep-overview=") }
@@ -1,156 +1,164 @@
1
- require_relative '../../bake/model/loader'
2
- require_relative '../../bake/config/loader'
3
- require_relative '../../bake/config/checks'
4
-
5
- module Bake
6
-
7
- class AdaptConfig
8
- attr_reader :referencedConfigs
9
-
10
- @@filenames = []
11
-
12
- def self.filenames
13
- @@filenames
14
- end
15
-
16
- def loadProjMeta(filename, filenum)
17
-
18
- Bake::Configs::Checks.symlinkCheck(filename)
19
- Bake::Configs::Checks.sanityFolderName(filename)
20
-
21
- f = @loader.load(filename)
22
-
23
- if f.root_elements.any? { |re| ! Metamodel::Adapt === re }
24
- Bake.formatter.printError("Config file must have only 'Adapt' elements as roots", filename)
25
- ExitHelper.exit(1)
26
- end
27
-
28
- f.root_elements.each do |a|
29
- Bake::Config::checkVer(a.requiredBakeVersion)
30
- end
31
-
32
- configs = []
33
- f.root_elements.each { |re| configs.concat(re.getConfig) }
34
- AdaptConfig::checkSyntax(configs, filename)
35
- configs
36
- end
37
-
38
- def self.checkSyntax(configs, filename, isLocalAdapt = false)
39
- Bake::Configs::Checks::commonMetamodelCheck(configs, filename, true)
40
- configs.each do |c|
41
- if not c.extends.empty?
42
- Bake.formatter.printError("Attribute 'extends' must not be used in adapt config.",c)
43
- ExitHelper.exit(1)
44
- end
45
- if c.name.empty?
46
- Bake.formatter.printError("Configs must be named.",c)
47
- ExitHelper.exit(1)
48
- end
49
- if c.project.empty?
50
- Bake.formatter.printError("The corresponding project must be specified.",c)
51
- ExitHelper.exit(1)
52
- end if !isLocalAdapt
53
- if not ["replace", "remove", "extend", "push_front"].include?c.type
54
- Bake.formatter.printError("Allowed types are 'replace', 'remove', 'extend' and 'push_front'.",c)
55
- ExitHelper.exit(1)
56
- end
57
- if not ["", "yes", "no", "all"].include?c.mergeInc
58
- Bake.formatter.printError("Allowed modes are 'all', 'yes', 'no' and unset.",c)
59
- ExitHelper.exit(1)
60
- end
61
- end
62
- end
63
-
64
- def getPotentialAdaptionProjects()
65
- potentialAdapts = []
66
- Bake.options.roots.each do |root|
67
- r = root.dir
68
- if (r.length == 3 && r.include?(":/"))
69
- r = r + Bake.options.main_project_name # glob would not work otherwise on windows (ruby bug?)
70
- end
71
- Bake.options.adapt.each do |a|
72
- adaptBaseName = File.expand_path(a + "/Adapt.meta")
73
- potentialAdapts << adaptBaseName if File.exists?adaptBaseName
74
- end
75
- potentialAdapts.concat(Root.search_to_depth(r, "Adapt.meta", root.depth))
76
- end
77
-
78
- potentialAdapts.uniq
79
- end
80
-
81
- def chooseProjectFilenames(potentialAdapts)
82
- @@filenames = []
83
- Bake.options.adapt.each do |a|
84
- a.gsub!(/\\/,"/")
85
- found = false
86
-
87
- # from working dir
88
- if File.exist?(a) && File.file?(a)
89
- @@filenames << File.expand_path(a)
90
- found = true
91
- end
92
- next if found
93
-
94
- # from main dir
95
- Dir.chdir Bake.options.main_dir do
96
- if File.exist?(a) && File.file?(a)
97
- @@filenames << (Bake.options.main_dir + "/" + a)
98
- found = true
99
- end
100
- end
101
- next if found
102
-
103
- # from roots
104
- Bake.options.roots.each do |root|
105
- r = root.dir
106
- Dir.chdir r do
107
- if File.exist?(a) && File.file?(a)
108
- @@filenames << (r + "/" + a)
109
- found = true
110
- end
111
- end
112
- break if found
113
- end
114
- next if found
115
-
116
- # old style
117
- adapts = potentialAdapts.find_all { |p| p.include?("/"+a+"/Adapt.meta") or p == a+"/Adapt.meta" }
118
- if adapts.empty?
119
- Bake.formatter.printError("Adaption project #{a} not found")
120
- ExitHelper.exit(1)
121
- else
122
- @@filenames << adapts[0]
123
- if (adapts.length > 1)
124
- Bake.formatter.printWarning("Adaption project #{a} exists more than once")
125
- chosen = " (chosen)"
126
- adapts.each do |f|
127
- Bake.formatter.printWarning(" #{File.dirname(f)}#{chosen}")
128
- chosen = ""
129
- end
130
- end
131
- end
132
- end
133
-
134
- end
135
-
136
- def load()
137
- @@filenames = []
138
- return [] if Bake.options.adapt.empty?
139
-
140
- @loader = Loader.new
141
-
142
- potentialProjects = getPotentialAdaptionProjects()
143
- chooseProjectFilenames(potentialProjects)
144
-
145
- configs = []
146
- @@filenames.each_with_index do |f,i|
147
- configs.concat(loadProjMeta(f, i+1))
148
- end
149
-
150
- return configs
151
- end
152
-
153
-
154
- end
155
-
156
- end
1
+ require_relative '../../bake/model/loader'
2
+ require_relative '../../bake/config/loader'
3
+ require_relative '../../bake/config/checks'
4
+
5
+ module Bake
6
+
7
+ class AdaptConfig
8
+ attr_reader :referencedConfigs
9
+
10
+ @@filenames = []
11
+
12
+ def self.filenames
13
+ @@filenames
14
+ end
15
+
16
+ def loadProjMeta(filename, filenum)
17
+
18
+ Bake::Configs::Checks.symlinkCheck(filename)
19
+ Bake::Configs::Checks.sanityFolderName(filename)
20
+
21
+ f = @loader.load(filename)
22
+
23
+ if f.root_elements.any? { |re| ! Metamodel::Adapt === re }
24
+ Bake.formatter.printError("Config file must have only 'Adapt' elements as roots", filename)
25
+ ExitHelper.exit(1)
26
+ end
27
+
28
+ f.root_elements.each do |a|
29
+ Bake::Config::checkVer(a.requiredBakeVersion)
30
+ end
31
+
32
+ configs = []
33
+ f.root_elements.each { |re| configs.concat(re.getConfig) }
34
+ AdaptConfig::checkSyntax(configs, filename)
35
+ configs
36
+ end
37
+
38
+ def self.checkSyntax(configs, filename, isLocalAdapt = false)
39
+ Bake::Configs::Checks::commonMetamodelCheck(configs, filename, true)
40
+ configs.each do |c|
41
+ if not c.extends.empty?
42
+ Bake.formatter.printError("Attribute 'extends' must not be used in adapt config.",c)
43
+ ExitHelper.exit(1)
44
+ end
45
+ if c.name.empty?
46
+ Bake.formatter.printError("Configs must be named.",c)
47
+ ExitHelper.exit(1)
48
+ end
49
+ if c.project.empty?
50
+ Bake.formatter.printError("The corresponding project must be specified.",c)
51
+ ExitHelper.exit(1)
52
+ end if !isLocalAdapt
53
+ if not ["replace", "remove", "extend", "push_front"].include?c.type
54
+ Bake.formatter.printError("Allowed types are 'replace', 'remove', 'extend' and 'push_front'.",c)
55
+ ExitHelper.exit(1)
56
+ end
57
+ if not ["", "yes", "no", "all"].include?c.mergeInc
58
+ Bake.formatter.printError("Allowed modes are 'all', 'yes', 'no' and unset.",c)
59
+ ExitHelper.exit(1)
60
+ end
61
+ end
62
+ end
63
+
64
+ def getPotentialAdaptionProjects()
65
+ potentialAdapts = []
66
+ Bake.options.roots.each do |root|
67
+ r = root.dir
68
+ if (r.length == 3 && r.include?(":/"))
69
+ r = r + Bake.options.main_project_name # glob would not work otherwise on windows (ruby bug?)
70
+ end
71
+ Bake.options.adapt.each do |a|
72
+ adaptBaseName = File.expand_path(a.gsub(/\(.*\)/,"") + "/Adapt.meta")
73
+ potentialAdapts << adaptBaseName if File.exists?adaptBaseName
74
+ end
75
+ potentialAdapts.concat(Root.search_to_depth(r, "Adapt.meta", root.depth))
76
+ end
77
+
78
+ potentialAdapts.uniq
79
+ end
80
+
81
+ def chooseProjectFilenames(potentialAdapts)
82
+ @@filenames = []
83
+ Bake.options.adapt.each do |aComplete|
84
+ aComplete.gsub!(/\\/,"/")
85
+ a = aComplete.gsub(/\[.*\]/,"")
86
+ projFilter = aComplete.scan(/\[(.*)\]/)
87
+ if projFilter && projFilter.length > 0
88
+ projFilter = projFilter[0][0].split(";").map {|a| a.strip}
89
+ end
90
+
91
+ found = false
92
+
93
+ # from working dir
94
+ if File.exist?(a) && File.file?(a)
95
+ @@filenames << {:file => File.expand_path(a), :projs => projFilter}
96
+ found = true
97
+ end
98
+ next if found
99
+
100
+ # from main dir
101
+ Dir.chdir Bake.options.main_dir do
102
+ if File.exist?(a) && File.file?(a)
103
+ @@filenames << {:file => (Bake.options.main_dir + "/" + a), :projs => projFilter}
104
+ found = true
105
+ end
106
+ end
107
+ next if found
108
+
109
+ # from roots
110
+ Bake.options.roots.each do |root|
111
+ r = root.dir
112
+ Dir.chdir r do
113
+ if File.exist?(a) && File.file?(a)
114
+ @@filenames << {:file => (r + "/" + a), :projs => projFilter}
115
+ found = true
116
+ end
117
+ end
118
+ break if found
119
+ end
120
+ next if found
121
+
122
+ # old style
123
+ adapts = potentialAdapts.find_all { |p| p.include?("/"+a+"/Adapt.meta") or p == a+"/Adapt.meta" }
124
+ if adapts.empty?
125
+ Bake.formatter.printError("Adaption project #{a} not found")
126
+ ExitHelper.exit(1)
127
+ else
128
+ @@filenames << {:file => adapts[0], :projs => projFilter}
129
+ if (adapts.length > 1)
130
+ Bake.formatter.printWarning("Adaption project #{a} exists more than once")
131
+ chosen = " (chosen)"
132
+ adapts.each do |f|
133
+ Bake.formatter.printWarning(" #{File.dirname(f)}#{chosen}")
134
+ chosen = ""
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+ end
141
+
142
+ def load()
143
+ @@filenames = []
144
+ return [] if Bake.options.adapt.empty?
145
+
146
+ @loader = Loader.new
147
+
148
+ potentialProjects = getPotentialAdaptionProjects()
149
+ chooseProjectFilenames(potentialProjects)
150
+
151
+ configs = []
152
+ @@filenames.each_with_index do |f,i|
153
+ loadProjMeta(f[:file], i+1).each do |c|
154
+ configs << {:config => c, :projs => f[:projs]}
155
+ end
156
+ end
157
+
158
+ return configs
159
+ end
160
+
161
+
162
+ end
163
+
164
+ end
data/lib/bake/cache.rb CHANGED
@@ -95,7 +95,8 @@ module Bake
95
95
  end
96
96
 
97
97
  if (cache != nil)
98
- cache.adapt_filenames.each do |f|
98
+ cache.adapt_filenames.each do |fHash|
99
+ f = fHash[:file]
99
100
  fileExists = File.exists?(f)
100
101
  puts "Cache: Checking if #{f} exists: #{fileExists}" if Bake.options.debug
101
102
  if !fileExists
@@ -26,8 +26,7 @@ module Bake
26
26
  return configname
27
27
  end
28
28
 
29
- def getFullProjectInternal(configs, configname, isMain) # note: configs is never empty
30
-
29
+ def getFullProjectInternal(configs, configname, isMain, extendStack) # note: configs is never empty
31
30
  configname = resolveConfigName(configs, configname)
32
31
 
33
32
  if isMain
@@ -60,7 +59,11 @@ module Bake
60
59
  if config.extends != ""
61
60
  config.extends.split(",").map {|ex| ex.strip}.reverse.each do |ex|
62
61
  if (ex != "")
63
- parent,parentConfigName = getFullProjectInternal(configs, ex, isMain)
62
+ if extendStack.include?(ex)
63
+ Bake.formatter.printError("Config extends to circular loop: #{(extendStack << ex).join("->")}", configs[0].file_name)
64
+ ExitHelper.exit(1)
65
+ end
66
+ parent,parentConfigName = getFullProjectInternal(configs, ex, isMain, extendStack << ex)
64
67
  MergeConfig.new(config, parent).merge(:merge)
65
68
  end
66
69
  end
@@ -70,15 +73,13 @@ module Bake
70
73
  end
71
74
 
72
75
  def getFullProject(projName, configs, configname, isMain)
73
-
74
-
75
76
  configname = resolveConfigName(configs, configname)
76
77
 
77
78
  if @fullProjects.has_key?(projName + "," + configname)
78
79
  return @fullProjects[projName + "," + configname]
79
80
  end
80
81
 
81
- config, configname = getFullProjectInternal(configs, configname, isMain)
82
+ config, configname = getFullProjectInternal(configs, configname, isMain, [configname])
82
83
 
83
84
  if isMain
84
85
  @defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
@@ -88,64 +89,75 @@ module Bake
88
89
  end
89
90
 
90
91
  # check if config has to be manipulated
91
- @adaptConfigs.each do |c|
92
-
93
- projSplitted = c.project.split(";")
94
- confSplitted = c.name.split(";")
95
- projPatterns = projSplitted.map { |p| /\A#{p.gsub("*", "(\\w*)")}\z/ }
96
- confPatterns = confSplitted.map { |p| /\A#{p.gsub("*", "(\\w*)")}\z/ }
97
-
98
- if projPatterns.any? {|p| p.match(config.parent.name) } \
99
- || (projName == Bake.options.main_project_name and projSplitted.any? {|p| p == "__MAIN__"}) \
100
- || projSplitted.any? {|p| p == "__ALL__"}
101
-
102
- if confPatterns.any? {|p| p.match(config.name)} \
103
- || (isMain and confSplitted.any? {|p| p == "__MAIN__"}) \
104
- || confSplitted.any? {|p| p == "__ALL__"}
105
-
106
- adaptHash = c.parent.getHash
107
-
108
- configHash = {
109
- "toolchain" => [@defaultToolchainName],
110
- "os" => [Utils::OS.name],
111
- "mainProject" => [@mainProjectName],
112
- "mainConfig" => [@mainConfigName]
113
- }
114
- config.scopes.each do |s|
115
- configHash[s.name] = [] unless configHash.has_key?(s.name)
116
- configHash[s.name] += s.value.split(";")
117
- end
118
-
119
- if !isMain
120
- @configHashMain.each do |k,v|
121
- if configHash.has_key?(k)
122
- configHash[k] += v
123
- configHash[k].uniq!
124
- else
125
- configHash[k] = v
92
+ @adaptConfigs.each do |cHash|
93
+
94
+ c = cHash[:config]
95
+
96
+ projSplitted = c.project.split(";")
97
+ confSplitted = c.name.split(";")
98
+ projSplittedCmd = cHash[:projs]
99
+
100
+ projPatterns = projSplitted.map { |p| /\A#{p.gsub("*", "(\\w*)")}\z/ }
101
+ confPatterns = confSplitted.map { |p| /\A#{p.gsub("*", "(\\w*)")}\z/ }
102
+ projPatternsCmd = projSplittedCmd.map { |p| /\A#{p.gsub("*", "(\\w*)")}\z/ } if projSplittedCmd
103
+
104
+ if projSplittedCmd.empty? \
105
+ || projPatternsCmd.any? {|p| p.match(config.parent.name) } \
106
+ || (projName == Bake.options.main_project_name and projSplittedCmd.any? {|p| p == "__MAIN__"}) \
107
+ || projSplittedCmd.any? {|p| p == "__ALL__"}
108
+
109
+ if projPatterns.any? {|p| p.match(config.parent.name) } \
110
+ || (projName == Bake.options.main_project_name and projSplitted.any? {|p| p == "__MAIN__"}) \
111
+ || projSplitted.any? {|p| p == "__ALL__"}
112
+
113
+ if confPatterns.any? {|p| p.match(config.name)} \
114
+ || (isMain and confSplitted.any? {|p| p == "__MAIN__"}) \
115
+ || confSplitted.any? {|p| p == "__ALL__"}
116
+
117
+ adaptHash = c.parent.getHash
118
+
119
+ configHash = {
120
+ "toolchain" => [@defaultToolchainName],
121
+ "os" => [Utils::OS.name],
122
+ "mainProject" => [@mainProjectName],
123
+ "mainConfig" => [@mainConfigName]
124
+ }
125
+ config.scopes.each do |s|
126
+ configHash[s.name] = [] unless configHash.has_key?(s.name)
127
+ configHash[s.name] += s.value.split(";")
128
+ end
129
+
130
+ if !isMain && @configHashMain
131
+ @configHashMain.each do |k,v|
132
+ if configHash.has_key?(k)
133
+ configHash[k] += v
134
+ configHash[k].uniq!
135
+ else
136
+ configHash[k] = v
137
+ end
126
138
  end
127
139
  end
128
- end
129
-
130
- checkCondition = lambda {|name,value|
131
- return true if adaptHash[name].empty?
132
- if !configHash.has_key?(name)
133
- return adaptHash[name].any?{|ah| ah.match("")}
140
+
141
+ checkCondition = lambda {|name,value|
142
+ return true if adaptHash[name].empty?
143
+ if !configHash.has_key?(name)
144
+ return adaptHash[name].any?{|ah| ah.match("")}
145
+ end
146
+ adaptHash[name].any? { |ah| configHash[name].any?{|ch| ah.match(ch)}}
147
+ }
148
+
149
+ adaptCondition = adaptHash.all? {|name,value| checkCondition.call(name, value)}
150
+
151
+ invertLogic = (Bake::Metamodel::Unless === c.parent)
152
+ next if (adaptCondition && invertLogic) || (!adaptCondition && !invertLogic)
153
+
154
+ MergeConfig.new(c, config).merge(c.type.to_sym)
155
+
156
+ if isMain # can be changed after adapt
157
+ @defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
134
158
  end
135
- adaptHash[name].any? { |ah| configHash[name].any?{|ch| ah.match(ch)}}
136
- }
137
-
138
- adaptCondition = adaptHash.all? {|name,value| checkCondition.call(name, value)}
139
159
 
140
- invertLogic = (Bake::Metamodel::Unless === c.parent)
141
- next if (adaptCondition && invertLogic) || (!adaptCondition && !invertLogic)
142
-
143
- MergeConfig.new(c, config).merge(c.type.to_sym)
144
-
145
- if isMain # can be changed after adapt
146
- @defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
147
160
  end
148
-
149
161
  end
150
162
  end
151
163
  end
@@ -237,13 +249,13 @@ module Bake
237
249
  if adaptRoots.length > 0
238
250
  adaptRoots.each do |adapt|
239
251
  Bake::Config::checkVer(adapt.requiredBakeVersion)
240
- adapt.mainProject = @mainProjectName if adapt.mainProject == "__THIS__"
252
+ adapt.mainProject = proj.name if adapt.mainProject == "__THIS__"
241
253
  adaptConfigs = adapt.getConfig
242
254
  AdaptConfig.checkSyntax(adaptConfigs, filename, true)
243
255
  adaptConfigs.each do |ac|
244
256
  ac.project = proj.name if ac.project == "__THIS__" || ac.project == ""
257
+ @adaptConfigs << {:config => ac, :projs => []}
245
258
  end
246
- @adaptConfigs.concat(adaptConfigs)
247
259
  end
248
260
  end
249
261