bake-toolkit 2.66.0 → 2.70.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa60204c2439429e2b1d8e42d36206941185d1085f5c59390b8e5552f6549893
4
- data.tar.gz: 5cfa793f77484f38e0170995b40b679fbd4367f3ef06c50c86c5cc148aacc9cc
3
+ metadata.gz: 512387067bf3154e79bfe2993a33c20ab4b8527360b89e85105ed74cf9e724df
4
+ data.tar.gz: 017f9892593659a0c6567b51aec681751528f2b5de47ace6ef37d54944399a2d
5
5
  SHA512:
6
- metadata.gz: 6901da13b1b992c9e99af33b82f4dc0841d3d236e376a8a6932ba9d1d40490a98f283d0c6aacc794881703fea09b147f353e24b7c5790329cee56d44c0b9bf97
7
- data.tar.gz: 93edb29bd48e1752ebe1d29e83916309fd291e69701b30e9deadfb9f58dc8507bffdb2da7474fcce7336de9f08275017759092b46528c9db793033e2795f0a9e
6
+ metadata.gz: 676bfebf96efab215d3744dc341ffdd6026df836b9797a4cf5a1d26acd264f2ad55718b99a27e57366b900bf721e8a195e4455d97f5884f94058cd1f5e3e65bc
7
+ data.tar.gz: af6d6ba478071e3c4ad5ffaf009e581bb42f160af73f8c8646a1f24e3ae97bbb661e00a12006fe1d305bab24046ff04b41bb5ce49596dd412829a1575b6acd4a
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
@@ -112,7 +112,7 @@ module Bake
112
112
  p = File.dirname(bp.proj)
113
113
  pRel = File.rel_from_to_project(Dir.pwd, p, false)
114
114
  pRel = "." if pRel.empty?
115
- cmd = (["-m", pRel, "-b", bp.conf] + bp.args.split + passedParams)
115
+ cmd = (["-m", pRel, "-b", bp.conf] + bp.args.split + passedParams + bp.args_end.split)
116
116
  cmdWithNum = "bakery #{currentRun} of #{maxRuns}: bake " + cmd.join(" ")
117
117
  puts "\n#{$stars}"
118
118
  Bake.formatter.printInfo(cmdWithNum)
@@ -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
@@ -89,64 +89,78 @@ module Bake
89
89
  end
90
90
 
91
91
  # check if config has to be manipulated
92
- @adaptConfigs.each do |c|
93
-
94
- projSplitted = c.project.split(";")
95
- confSplitted = c.name.split(";")
96
- projPatterns = projSplitted.map { |p| /\A#{p.gsub("*", "(\\w*)")}\z/ }
97
- confPatterns = confSplitted.map { |p| /\A#{p.gsub("*", "(\\w*)")}\z/ }
98
-
99
- if projPatterns.any? {|p| p.match(config.parent.name) } \
100
- || (projName == Bake.options.main_project_name and projSplitted.any? {|p| p == "__MAIN__"}) \
101
- || projSplitted.any? {|p| p == "__ALL__"}
102
-
103
- if confPatterns.any? {|p| p.match(config.name)} \
104
- || (isMain and confSplitted.any? {|p| p == "__MAIN__"}) \
105
- || confSplitted.any? {|p| p == "__ALL__"}
106
-
107
- adaptHash = c.parent.getHash
108
-
109
- configHash = {
110
- "toolchain" => [@defaultToolchainName],
111
- "os" => [Utils::OS.name],
112
- "mainProject" => [@mainProjectName],
113
- "mainConfig" => [@mainConfigName]
114
- }
115
- config.scopes.each do |s|
116
- configHash[s.name] = [] unless configHash.has_key?(s.name)
117
- configHash[s.name] += s.value.split(";")
118
- end
119
-
120
- if !isMain && @configHashMain
121
- @configHashMain.each do |k,v|
122
- if configHash.has_key?(k)
123
- configHash[k] += v
124
- configHash[k].uniq!
125
- else
126
- 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
127
138
  end
128
139
  end
129
- end
130
-
131
- checkCondition = lambda {|name,value|
132
- return true if adaptHash[name].empty?
133
- if !configHash.has_key?(name)
134
- 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
+ if name == "toolchain" && configHash[name] == [""]
147
+ Bake.formatter.printWarning("Trying to adapt '#{config.name}' with 'toolchain == #{c.parent.toolchain}', but toolchain is not defined yet", c)
148
+ end
149
+ adaptHash[name].any? { |ah| configHash[name].any?{|ch| ah.match(ch)}}
150
+ }
151
+
152
+ adaptCondition = adaptHash.all? {|name,value| checkCondition.call(name, value)}
153
+
154
+ invertLogic = (Bake::Metamodel::Unless === c.parent)
155
+ next if (adaptCondition && invertLogic) || (!adaptCondition && !invertLogic)
156
+
157
+ MergeConfig.new(c, config).merge(c.type.to_sym)
158
+
159
+ if isMain # can be changed after adapt
160
+ @defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
135
161
  end
136
- adaptHash[name].any? { |ah| configHash[name].any?{|ch| ah.match(ch)}}
137
- }
138
-
139
- adaptCondition = adaptHash.all? {|name,value| checkCondition.call(name, value)}
140
-
141
- invertLogic = (Bake::Metamodel::Unless === c.parent)
142
- next if (adaptCondition && invertLogic) || (!adaptCondition && !invertLogic)
143
162
 
144
- MergeConfig.new(c, config).merge(c.type.to_sym)
145
-
146
- if isMain # can be changed after adapt
147
- @defaultToolchainName = config.defaultToolchain.basedOn unless config.defaultToolchain.nil?
148
163
  end
149
-
150
164
  end
151
165
  end
152
166
  end
@@ -243,8 +257,8 @@ module Bake
243
257
  AdaptConfig.checkSyntax(adaptConfigs, filename, true)
244
258
  adaptConfigs.each do |ac|
245
259
  ac.project = proj.name if ac.project == "__THIS__" || ac.project == ""
260
+ @adaptConfigs << {:config => ac, :projs => []}
246
261
  end
247
- @adaptConfigs.concat(adaptConfigs)
248
262
  end
249
263
  end
250
264