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 +4 -4
- data/Rakefile.rb +7 -3
- data/bin/bakery +2 -1
- data/lib/adapt/config/loader.rb +164 -156
- data/lib/bake/cache.rb +2 -1
- data/lib/bake/config/loader.rb +68 -54
- data/lib/bake/libElement.rb +6 -0
- data/lib/bake/mergeConfig.rb +242 -241
- data/lib/bake/model/loader.rb +178 -178
- data/lib/bake/model/metamodel.rb +18 -18
- data/lib/bake/subst.rb +24 -4
- data/lib/bake/util.rb +1 -0
- data/lib/bakery/buildPattern.rb +3 -2
- data/lib/bakery/model/metamodel.rb +6 -0
- data/lib/bakery/toBake.rb +10 -3
- data/lib/blocks/block.rb +6 -0
- data/lib/blocks/commandLine.rb +44 -44
- data/lib/blocks/compile.rb +17 -16
- data/lib/blocks/executable.rb +4 -0
- data/lib/blocks/fileutil.rb +10 -3
- data/lib/blocks/library.rb +4 -0
- data/lib/common/root.rb +1 -0
- data/lib/common/version.rb +17 -21
- data/lib/tocxx.rb +2 -2
- metadata +20 -35
data/lib/bake/libElement.rb
CHANGED
@@ -56,6 +56,9 @@ module Bake
|
|
56
56
|
cb = block.library.compileBlock
|
57
57
|
if (block.prebuild and File.exist?adaptedPath) or
|
58
58
|
(!cb.nil? and !(cb.calcSources(true, true) - cb.source_files_ignored_in_lib).empty?)
|
59
|
+
if Bake.options.consoleOutput_fullnames
|
60
|
+
adaptedPath = File.expand_path(adaptedPath, @projectDir)
|
61
|
+
end
|
59
62
|
@@linker_libs_array << adaptedPath
|
60
63
|
@@source_libraries << adaptedPath
|
61
64
|
end
|
@@ -67,6 +70,9 @@ module Bake
|
|
67
70
|
cb.object_files_ignored_in_lib.each do |ldirect|
|
68
71
|
adaptedPath, prefix = adaptPath(ldirect, block, prefix)
|
69
72
|
if (!block.prebuild or File.exist?adaptedPath)
|
73
|
+
if Bake.options.consoleOutput_fullnames
|
74
|
+
adaptedPath = File.expand_path(adaptedPath, @projectDir)
|
75
|
+
end
|
70
76
|
@@linker_libs_array << adaptedPath
|
71
77
|
@@source_libraries << adaptedPath
|
72
78
|
end
|
data/lib/bake/mergeConfig.rb
CHANGED
@@ -1,242 +1,243 @@
|
|
1
|
-
require_relative '../common/ext/rtext'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
|
5
|
-
class MergeConfig
|
6
|
-
|
7
|
-
def initialize(child, parent)
|
8
|
-
@child = child
|
9
|
-
@parent = parent
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.clone(obj)
|
13
|
-
if obj.is_a?(Metamodel::ModelElement)
|
14
|
-
cloneModelElement(obj)
|
15
|
-
elsif Array === obj
|
16
|
-
obj.map { |o| clone(o) }
|
17
|
-
else
|
18
|
-
obj # no clone, should not happen
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.cloneModelElement(obj)
|
23
|
-
cpy = obj.class.new
|
24
|
-
cpy.file_name = obj.file_name
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
next unless f
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
parentData
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
return true if (
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
if
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
if
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
1
|
+
require_relative '../common/ext/rtext'
|
2
|
+
|
3
|
+
module Bake
|
4
|
+
|
5
|
+
class MergeConfig
|
6
|
+
|
7
|
+
def initialize(child, parent)
|
8
|
+
@child = child
|
9
|
+
@parent = parent
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.clone(obj)
|
13
|
+
if obj.is_a?(Metamodel::ModelElement)
|
14
|
+
cloneModelElement(obj)
|
15
|
+
elsif Array === obj
|
16
|
+
obj.map { |o| clone(o) }
|
17
|
+
else
|
18
|
+
obj # no clone, should not happen
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.cloneModelElement(obj)
|
23
|
+
cpy = obj.class.new
|
24
|
+
cpy.file_name = obj.file_name
|
25
|
+
cpy.org_file_name = obj.file_name
|
26
|
+
obj.class.ecore.eAllStructuralFeatures.each do |f|
|
27
|
+
value = obj.getGeneric(f.name)
|
28
|
+
if f.is_a?(RGen::ECore::EReference) && f.containment
|
29
|
+
if value.is_a?(Array)
|
30
|
+
cpy.setGeneric(f.name, value.collect{|v| clone(v)})
|
31
|
+
elsif !value.nil?
|
32
|
+
cpy.setGeneric(f.name, clone(value))
|
33
|
+
end
|
34
|
+
elsif f.is_a?(RGen::ECore::EAttribute)
|
35
|
+
cpy.setGeneric(f.name, value) if obj.eIsSet(f.name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
cpy
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def replace()
|
43
|
+
if Metamodel::BaseConfig_INTERNAL === @child &&
|
44
|
+
Metamodel::BaseConfig_INTERNAL === @parent
|
45
|
+
if @child.mergeInc != "" && @parent.mergeInc != "no"
|
46
|
+
@parent.mergeInc = @child.mergeInc
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
@child.class.ecore.eAllReferences.each do |f|
|
51
|
+
next unless @parent.class.ecore.eAllReferences.include?f
|
52
|
+
next unless f.containment
|
53
|
+
childData = @child.getGeneric(f.name)
|
54
|
+
if Metamodel::ModelElement === childData
|
55
|
+
@parent.setGeneric(f.name,childData) if !childData.nil?
|
56
|
+
elsif Array === childData
|
57
|
+
if !childData.empty?
|
58
|
+
parentData = @parent.getGeneric(f.name)
|
59
|
+
cclasses = childData.map { |c| c.class }.uniq
|
60
|
+
parentData.delete_if { |p| cclasses.include?p.class }
|
61
|
+
parentData += childData
|
62
|
+
@parent.setGeneric(f.name,parentData)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def hasSubNodes(elem)
|
69
|
+
elem.class.ecore.eAllReferences.each do |f|
|
70
|
+
next unless f.containment
|
71
|
+
elemData = elem.getGeneric(f.name)
|
72
|
+
return true if (Array === elemData && !elemData.empty?)
|
73
|
+
return true if (Metamodel::ModelElement === elemData)
|
74
|
+
end
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
78
|
+
def sameAttr(childData, parentData)
|
79
|
+
childData.class.ecore.eAllAttributes.all? { |a|
|
80
|
+
a.eAnnotations.each do |x| x.details.each do |y|
|
81
|
+
return true if (y.key == :internal and y.value == true)
|
82
|
+
end; end
|
83
|
+
a.name == "line_number" || (not childData.eIsSet(a.name)) || (childData.getGeneric(a.name) == parentData.getGeneric(a.name))
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
def removeChilds(childElem, parentElem)
|
88
|
+
return if childElem.nil? or parentElem.nil?
|
89
|
+
|
90
|
+
if Metamodel::BaseConfig_INTERNAL === childElem &&
|
91
|
+
Metamodel::BaseConfig_INTERNAL === parentElem
|
92
|
+
if childElem.mergeInc == parentElem.mergeInc
|
93
|
+
parentElem.mergeInc = ""
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
childElem.class.ecore.eAllReferences.each do |f|
|
98
|
+
next unless f.containment
|
99
|
+
begin
|
100
|
+
childData = childElem.getGeneric(f.name)
|
101
|
+
parentData = parentElem.getGeneric(f.name)
|
102
|
+
rescue Exception => ex
|
103
|
+
next # how to check fast if f.name is valid?
|
104
|
+
end
|
105
|
+
next if childData.nil? or parentData.nil?
|
106
|
+
if (Array === childData)
|
107
|
+
if !parentData.empty? && !childData.empty?
|
108
|
+
childData.each do |c|
|
109
|
+
cN = hasSubNodes(c)
|
110
|
+
toRemove = []
|
111
|
+
parentData.each do |p|
|
112
|
+
next if p.class != c.class
|
113
|
+
if (not cN)
|
114
|
+
if sameAttr(c, p)
|
115
|
+
toRemove << p
|
116
|
+
end
|
117
|
+
else
|
118
|
+
removeChilds(c, p);
|
119
|
+
end
|
120
|
+
end
|
121
|
+
toRemove.each do |r|
|
122
|
+
parentElem.removeGeneric(f.name, r)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
elsif Metamodel::ModelElement === childData
|
127
|
+
if parentData.class == childData.class && sameAttr(childData, parentData)
|
128
|
+
cN = hasSubNodes(childData)
|
129
|
+
if (not cN)
|
130
|
+
parentElem.setGeneric(f.name, nil)
|
131
|
+
else
|
132
|
+
removeChilds(childData, parentData)
|
133
|
+
end
|
134
|
+
end # otherwise not equal, will not be deleted
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def extendAttributes(childData, parentData)
|
140
|
+
parentData.class.ecore.eAllAttributes.each do |a|
|
141
|
+
childData.setGeneric(a.name, parentData.getGeneric(a.name)) if !childData.eIsSet(a.name) && parentData.eIsSet(a.name)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def extend(child, parent, push_front)
|
146
|
+
if Metamodel::BaseConfig_INTERNAL === child &&
|
147
|
+
Metamodel::BaseConfig_INTERNAL === parent
|
148
|
+
if child.mergeInc != "" && parent.mergeInc != "no"
|
149
|
+
parent.mergeInc = child.mergeInc
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
(parent.class.ecore.eAllReferences & child.class.ecore.eAllReferences).each do |f|
|
154
|
+
next unless f.containment
|
155
|
+
parentData = parent.getGeneric(f.name)
|
156
|
+
next if parentData.nil? or (Array === parentData && parentData.empty?)
|
157
|
+
childData = child.getGeneric(f.name)
|
158
|
+
|
159
|
+
if Array === parentData
|
160
|
+
if f.name == "compiler"
|
161
|
+
extendedParentData = []
|
162
|
+
parentData.each do |p|
|
163
|
+
c = childData.find { |c| p.ctype == c.ctype }
|
164
|
+
if c
|
165
|
+
extendAttributes(c, p)
|
166
|
+
extend(c, p, push_front)
|
167
|
+
extendedParentData << c
|
168
|
+
else
|
169
|
+
extendedParentData << p
|
170
|
+
end
|
171
|
+
end
|
172
|
+
restOfChildData = childData.find_all { |c| parentData.find {|p| p.ctype != c.ctype } }
|
173
|
+
child.setGeneric(f.name, extendedParentData + restOfChildData)
|
174
|
+
else
|
175
|
+
if push_front
|
176
|
+
child.setGeneric(f.name, childData + parentData)
|
177
|
+
else
|
178
|
+
child.setGeneric(f.name, parentData + childData)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
elsif Metamodel::ModelElement === parentData
|
182
|
+
if childData.nil? || childData.class != parentData.class
|
183
|
+
child.setGeneric(f.name, parentData)
|
184
|
+
else
|
185
|
+
extendAttributes(childData, parentData)
|
186
|
+
extend(childData, parentData, push_front)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def copyChildToParent(c, p)
|
193
|
+
(p.class.ecore.eAllReferences & c.class.ecore.eAllReferences).each do |f|
|
194
|
+
next unless f.containment
|
195
|
+
childData = c.getGeneric(f.name)
|
196
|
+
next if childData.nil? || (Array === childData && childData.empty?)
|
197
|
+
p.setGeneric(f.name, childData)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def merge(type)
|
202
|
+
if (@child.strict == true) && !(@child.class == @parent.class)
|
203
|
+
return
|
204
|
+
end
|
205
|
+
|
206
|
+
s = StringIO.new
|
207
|
+
ser = RText::Serializer.new(Language)
|
208
|
+
|
209
|
+
if Bake.options.debug
|
210
|
+
s.puts "\n>>>> child <<<<"
|
211
|
+
ser.serialize(@child, s)
|
212
|
+
s.puts "\n>>>> parent <<<<"
|
213
|
+
ser.serialize(@parent, s)
|
214
|
+
end
|
215
|
+
|
216
|
+
if (type == :remove)
|
217
|
+
removeChilds(@child, @parent)
|
218
|
+
elsif (type == :replace)
|
219
|
+
replace
|
220
|
+
elsif (type == :extend)
|
221
|
+
c = MergeConfig.clone(@child)
|
222
|
+
extend(c, @parent, false)
|
223
|
+
copyChildToParent(c, @parent)
|
224
|
+
elsif (type == :push_front)
|
225
|
+
c = MergeConfig.clone(@child)
|
226
|
+
extend(c, @parent, true)
|
227
|
+
copyChildToParent(c, @parent)
|
228
|
+
elsif (type == :merge)
|
229
|
+
extend(@child, MergeConfig.clone(@parent), false)
|
230
|
+
end
|
231
|
+
|
232
|
+
if Bake.options.debug
|
233
|
+
s.puts "\n>>>> result of #{type.to_s} <<<<"
|
234
|
+
ser.serialize(type == :merge ? @child : @parent, s)
|
235
|
+
puts "#{s.string}"
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|
242
243
|
end
|