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