ebngen 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,22 @@
1
- require 'pathname'
2
- require "deep_merge"
3
-
4
- class Assembly
5
- def initialize(options)
6
- @internal_hash = options
7
- end
8
- def assembly(project_name, key = "__add__")
9
- @internal_hash[project_name][key].each do |submodule|
10
- @internal_hash[project_name].deep_merge(deep_copy(@internal_hash[submodule]))
11
- end
12
- @internal_hash[project_name].delete(key)
13
- @internal_hash.keys.each do |subkey|
14
- next if subkey == project_name
15
- @internal_hash.delete(subkey)
16
- end
17
- end
18
-
19
- def deep_copy(o)
20
- Marshal.load(Marshal.dump(o))
21
- end
22
- end
1
+ require 'pathname'
2
+ require "deep_merge"
3
+
4
+ class Assembly
5
+ def initialize(options)
6
+ @internal_hash = options
7
+ end
8
+ def assembly(project_name, key = "__add__")
9
+ @internal_hash[project_name][key].each do |submodule|
10
+ @internal_hash[project_name].deep_merge(deep_copy(@internal_hash[submodule]))
11
+ end
12
+ @internal_hash[project_name].delete(key)
13
+ @internal_hash.keys.each do |subkey|
14
+ next if subkey == project_name
15
+ @internal_hash.delete(subkey)
16
+ end
17
+ end
18
+
19
+ def deep_copy(o)
20
+ Marshal.load(Marshal.dump(o))
21
+ end
22
+ end
@@ -1,48 +1,48 @@
1
-
2
- require_relative 'adapter/iar'
3
- require_relative 'adapter/cmake'
4
- require 'logger'
5
-
6
- class Generator
7
- attr_accessor :generator_variable
8
- def initialize(options, logger = nil)
9
- @logger = logger
10
- unless (logger)
11
- @logger = Logger.new(STDOUT)
12
- @logger.level = Logger::INFO
13
- end
14
- @generator_variable = options
15
- if @generator_variable.class != Hash
16
- puts "failure options shall be a hash"
17
- return
18
- end
19
- if @generator_variable.has_key?('all') and @generator_variable.has_key?('paths')
20
- @logger.info "input setting is ok"
21
- else
22
- @logger.info "input settings is wrong"
23
- end
24
- end
25
-
26
- def generate_projects(tool_chain, filter, project_data)
27
- case tool_chain.downcase
28
- when 'iar'
29
- IAR::Project.new(project_data, @generator_variable, @logger).generator(filter, project_data)
30
- when 'mdk'
31
- @logger.info "mdk TBD"
32
- when 'cmake'
33
- CMAKE::Project.new(project_data, @generator_variable, @logger).generator(filter, project_data)
34
- end
35
- end
36
-
37
- def generate_project_set(tool_chain, project_data)
38
- case tool_chain.downcase
39
- when 'iar'
40
- IAR::Project_set.new(project_data, @generator_variable, @logger).generator()
41
- when 'mdk'
42
- @logger.info "mdk TBD"
43
- when 'armgcc'
44
- @logger.info "armgcc TBD"
45
- end
46
- end
47
-
1
+
2
+ require_relative 'adapter/iar'
3
+ require_relative 'adapter/cmake'
4
+ require 'logger'
5
+
6
+ class Generator
7
+ attr_accessor :generator_variable
8
+ def initialize(options, logger = nil)
9
+ @logger = logger
10
+ unless (logger)
11
+ @logger = Logger.new(STDOUT)
12
+ @logger.level = Logger::INFO
13
+ end
14
+ @generator_variable = options
15
+ if @generator_variable.class != Hash
16
+ puts "failure options shall be a hash"
17
+ return
18
+ end
19
+ if @generator_variable.has_key?('all') and @generator_variable.has_key?('paths')
20
+ @logger.info "input setting is ok"
21
+ else
22
+ @logger.info "input settings is wrong"
23
+ end
24
+ end
25
+
26
+ def generate_projects(tool_chain, filter, project_data)
27
+ case tool_chain.downcase
28
+ when 'iar'
29
+ IAR::Project.new(project_data, @generator_variable, @logger).generator(filter, project_data)
30
+ when 'mdk'
31
+ @logger.info "mdk TBD"
32
+ when 'cmake'
33
+ CMAKE::Project.new(project_data, @generator_variable, @logger).generator(filter, project_data)
34
+ end
35
+ end
36
+
37
+ def generate_project_set(tool_chain, project_data)
38
+ case tool_chain.downcase
39
+ when 'iar'
40
+ IAR::Project_set.new(project_data, @generator_variable, @logger).generator()
41
+ when 'mdk'
42
+ @logger.info "mdk TBD"
43
+ when 'cmake'
44
+ @logger.info "cmake TBD"
45
+ end
46
+ end
47
+
48
48
  end
@@ -1,2 +1,2 @@
1
-
1
+
2
2
  $TARGET_TYPES = ["application", "library", "virtual-library"]
@@ -1,5 +1,5 @@
1
-
2
-
3
- $TOOL_CHAINS = ["iar", "mdk", "cmake"]
4
-
1
+
2
+
3
+ $TOOL_CHAINS = ["iar", "mdk", "cmake"]
4
+
5
5
  $CONFIG_TYPES = ["release", "debug"]
@@ -1,249 +1,249 @@
1
- require 'deep_merge'
2
- require 'rubygems'
3
- require 'pathname'
4
- require 'fileutils'
5
- require 'logger'
6
-
7
- module Utils_set
8
- def nodes_exist?(node, subnodes)
9
- return if subnodes.class != 'Array'
10
- subnodes.each do |key|
11
- return false if ! node.has_key?(key)
12
- end
13
- return true
14
- end
15
- end
16
-
17
- class Translator
18
- attr_accessor :data_in, :data_out, :reference_path
19
-
20
- include Utils_set
21
-
22
- def initialize(node, logger = nil)
23
- @logger = logger
24
- unless (logger)
25
- @logger = Logger.new(STDOUT)
26
- @logger.level = Logger::INFO
27
- end
28
- @data_in = deep_copy(node)
29
- @data_in_component = deep_copy(node)
30
- @data_out = Hash.new
31
- merge_by_add(@data_in)
32
- end
33
-
34
- def deep_copy(o)
35
- Marshal.load(Marshal.dump(o))
36
- end
37
-
38
- def deep_add_merge(struct, subnode, addon)
39
- return if Hash != struct.class
40
- if struct[addon]['__add__'].nil?
41
- #we do not want the addon module to change the status
42
- struct[addon]['attribute'] = ""
43
- struct[subnode] = struct[subnode].deep_merge(deep_copy(struct[addon]))
44
- struct[addon]['attribute'] = 'required'
45
- return
46
- end
47
- #if has more addon
48
- if struct[addon]['__add__'].count != 0
49
- struct[addon]['__add__'].each do |submodule|
50
- deep_add_merge(struct, addon, submodule)
51
- end
52
- struct[subnode] = struct[subnode].deep_merge(deep_copy(struct[addon]))
53
- struct[addon]['attribute'] = 'required'
54
- else
55
- struct[addon]['attribute'] = ""
56
- struct[subnode] = struct[subnode].deep_merge(deep_copy(struct[addon]))
57
- struct[addon]['attribute'] = 'required'
58
- end
59
- end
60
-
61
- # perform merge by "__add__" node only applys to application type
62
- def merge_by_add(struct)
63
- #only scan the top level
64
- return if Hash != struct.class
65
- struct.each_key do |subnode|
66
- if struct[subnode]['__add__'] != nil
67
- struct[subnode]['__add__'].each do |addon|
68
- next if struct[addon].class != Hash
69
- begin
70
- next if struct[subnode]['configuration']['section-type'] != "application"
71
- if struct[addon]['configuration']['section-type'] != "component"
72
- @logger.warn "WARNING #{addon} is required as component but has not a component attribute"
73
- end
74
- rescue
75
- @logger.error "error with the merge_by_add with #{subnode} add #{addon}"
76
- end
77
- deep_add_merge(struct, subnode, addon)
78
- end
79
- #struct[subnode].delete('__add__')
80
- end
81
- end
82
- end
83
-
84
- def translate
85
- translate_project()
86
- return [@data_out, @data_in_component, @data_in]
87
- #puts @data_out.to_yaml
88
- end
89
-
90
- def output_path(proj, comp)
91
- if @data_in[proj].has_key?('outdir')
92
- board = @data_in[proj]['configuration']['board']
93
- if @data_out[proj][comp]['type'] == "library"
94
- if comp == 'uv4'
95
- @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, "mdk")
96
- else
97
- @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, comp)
98
- end
99
- else
100
- if comp == "uv4"
101
- @data_out[proj][comp]['outdir'] = File.join(board, @data_in[proj]['outdir'], "mdk")
102
- else
103
- @data_out[proj][comp]['outdir'] = File.join(board, @data_in[proj]['outdir'], comp)
104
- end
105
- end
106
- end
107
- end
108
-
109
- private
110
-
111
- def convert_rules(proj, comp = 'iar')
112
- if @data_in[proj]['configuration']['section-type'] == "virtual-library"
113
- if @data_in[proj].has_key?(comp)
114
- @data_out[proj] = @data_in[proj]
115
- board = @data_in[proj]['configuration']['board']
116
- path = @data_out[proj][comp]['outdir']['path']
117
- return if ! @data_out[proj].has_key?('chip-convert')
118
- @data_out[proj][comp]['outdir']['path'] = path + @data_out[proj]['chip-convert'][board]
119
- return
120
- end
121
- end
122
-
123
- if @data_in[proj]['configuration']['section-type'] == "component"
124
- return
125
- end
126
-
127
- if @data_in[proj]['configuration'].has_key?('meta_components')
128
- @data_out[proj]['meta_components'] = @data_in[proj]['configuration']['meta_components']
129
- end
130
-
131
- if @data_in[proj]['configuration']['tools'].has_key?(comp)
132
- compiler = @data_in[proj]['configuration']['tools'][comp]
133
- @data_out[proj][comp] = Hash.new
134
- @data_out[proj][comp]['targets'] = Hash.new
135
- @data_out[proj][comp]['type'] = @data_in[proj]['configuration']['section-type']
136
-
137
- @data_out[proj][comp]['templates'] = compiler['project-templates']
138
- if compiler.has_key?("group")
139
- @data_out[proj][comp]['group'] = compiler['group']
140
- end
141
- output_path(proj, comp)
142
- compiler['config'].each_key do |target|
143
- next if compiler['load-to'].nil?
144
- next if compiler['load-to'][target].nil?
145
- create_and_deep_merge(@data_out[proj][comp]['targets'], target, compiler['config'][target])
146
- @data_out[proj][comp]['targets'][target]['linker_file'] = Hash.new
147
- @data_out[proj][comp]['targets'][target]['linker_file']['path'] = compiler['load-to'][target]['linker-file']
148
- @data_out[proj][comp]['targets'][target]['linker_file']['rootdir'] = compiler['load-to'][target]['rootdir']
149
- create_and_deep_merge(@data_out[proj][comp]['targets'][target]['binary_file'], target, compiler['binary-file'])
150
- @data_out[proj][comp]['targets'][target]['identifier'] = compiler['load-to'][target]['identifier']
151
- @data_out[proj][comp]['targets'][target]['config'] = compiler['load-to'][target]['config']
152
- @data_out[proj][comp]['targets'][target]['target'] = compiler['load-to'][target]['target']
153
- @data_out[proj][comp]['targets'][target]['libraries'] = Array.new
154
- if ! @data_in[proj]['configuration']['section-depends'].nil?
155
- @data_in[proj]['configuration']['section-depends'].each do |dep|
156
- @data_out[proj][comp]['targets'][target]['libraries'].insert(-1, dep)
157
- end
158
- end
159
- end
160
- #now translate the source
161
- return if ! @data_in[proj].has_key?('modules')
162
-
163
- if @data_in[proj].has_key?('tools')
164
- #process compile depend files here
165
- if @data_in[proj]['tools'].has_key?(comp) and @data_in[proj].has_key?('modules') and @data_in[proj]["configuration"]["section-type"] == "application"
166
- @data_in[proj]['tools'][comp]['files'].each do |file|
167
- puts file
168
- next ! file.has_key?("virtual-dir")
169
- file['virtual_dir'] = file.delete "virtual-dir"
170
- end
171
- create_and_deep_merge(@data_out[proj][comp], 'source', @data_in[proj]['tools'][comp]['files'])
172
- end
173
- end
174
- @data_in[proj]['modules'].each_key do |mod|
175
- if @data_in[proj]['modules'][mod].class == Hash and @data_in[proj]['modules'][mod].has_key?('virtual-dir')
176
- temp = Marshal.load(Marshal.dump(@data_in[proj]['modules'][mod]['files']))
177
- temp.each do |file|
178
- #puts "old virtual-dir is #{mod} #{file['virtual-dir']}"
179
- #puts "current #{@data_in[proj]['modules'][mod]['virtual-dir'].to_s}"
180
- if file['virtual-dir'] == nil
181
- file['virtual-dir'] = @data_in[proj]['modules'][mod]['virtual-dir'].to_s
182
- else
183
- if ! file.has_key?("processed")
184
- #puts proj,mod,file
185
- #puts file['virtual-dir']
186
- #puts @data_in[proj]['modules'][mod]['virtual-dir'].to_s
187
- file['virtual-dir'] = "#{@data_in[proj]['modules'][mod]['virtual-dir']}:#{file['virtual-dir']}"
188
- file['processed'] = "true"
189
- end
190
- end
191
- #puts "new virtual-dir is #{file['virtual-dir']} for #{proj}"
192
- if comp == 'uv4' || comp == 'mdk'
193
- file['virtual-dir'] = file['virtual-dir'].gsub(':','-')
194
- end
195
- file['virtual_dir'] = file.delete "virtual-dir"
196
- end
197
- create_and_deep_merge(@data_out[proj][comp], 'source', temp)
198
-
199
- else
200
- if @data_in[proj]['modules'][mod].class == Hash and @data_in[proj]['modules'][mod].has_key?('files')
201
- @data_in[proj]['modules'][mod]['files'].each do |file|
202
- next ! file.has_key?("virtual-dir")
203
- file['virtual_dir'] = file.delete "virtual-dir"
204
- end
205
- create_and_deep_merge(@data_out[proj][comp], 'source', @data_in[proj]['modules'][mod]['files'])
206
- end
207
- end
208
- end
209
-
210
- if @data_in[proj].has_key?('document')
211
- create_and_deep_merge(@data_out[proj],'document', @data_in[proj]['document'])
212
- end
213
- end
214
- end
215
-
216
- def create_and_deep_merge(a, b, c)
217
- return if c == nil
218
- if c.class == Array
219
- a[b] = Array.new if a[b] == nil
220
- a[b] = a[b] + c.dup
221
- else
222
- a[b] = Hash.new if a[b] == nil
223
- a[b].deep_merge(c)
224
- end
225
- end
226
-
227
- def translate_project
228
- @data_in.each_key do |proj|
229
- next if @data_in[proj].nil?
230
- if @data_in[proj].has_key?('configuration')
231
- next if @data_in[proj]['configuration']['section-type'] == "component"
232
- end
233
- @data_out[proj] = Hash.new
234
- if @data_in[proj].has_key?('section-type')
235
- @data_out[proj]['type'] = @data_in[proj]['section-type']
236
- end
237
- convert_rules(proj,'iar')
238
- #convert_rules(proj,'uv4')
239
- convert_rules(proj,'cmake')
240
- #convert_rules(proj,'armgcc')
241
- #convert_rules(proj,'kds')
242
- #convert_rules(proj,'atl')
243
- #convert_rules(proj,'lpcx')
244
- end
245
- @data_in_component.each_key do |proj|
246
- # puts "#{proj} TBD"
247
- end
248
- end
249
- end
1
+ require 'deep_merge'
2
+ require 'rubygems'
3
+ require 'pathname'
4
+ require 'fileutils'
5
+ require 'logger'
6
+
7
+ module Utils_set
8
+ def nodes_exist?(node, subnodes)
9
+ return if subnodes.class != 'Array'
10
+ subnodes.each do |key|
11
+ return false if ! node.has_key?(key)
12
+ end
13
+ return true
14
+ end
15
+ end
16
+
17
+ class Translator
18
+ attr_accessor :data_in, :data_out, :reference_path
19
+
20
+ include Utils_set
21
+
22
+ def initialize(node, logger = nil)
23
+ @logger = logger
24
+ unless (logger)
25
+ @logger = Logger.new(STDOUT)
26
+ @logger.level = Logger::INFO
27
+ end
28
+ @data_in = deep_copy(node)
29
+ @data_in_component = deep_copy(node)
30
+ @data_out = Hash.new
31
+ merge_by_add(@data_in)
32
+ end
33
+
34
+ def deep_copy(o)
35
+ Marshal.load(Marshal.dump(o))
36
+ end
37
+
38
+ def deep_add_merge(struct, subnode, addon)
39
+ return if Hash != struct.class
40
+ if struct[addon]['__add__'].nil?
41
+ #we do not want the addon module to change the status
42
+ struct[addon]['attribute'] = ""
43
+ struct[subnode] = struct[subnode].deep_merge(deep_copy(struct[addon]))
44
+ struct[addon]['attribute'] = 'required'
45
+ return
46
+ end
47
+ #if has more addon
48
+ if struct[addon]['__add__'].count != 0
49
+ struct[addon]['__add__'].each do |submodule|
50
+ deep_add_merge(struct, addon, submodule)
51
+ end
52
+ struct[subnode] = struct[subnode].deep_merge(deep_copy(struct[addon]))
53
+ struct[addon]['attribute'] = 'required'
54
+ else
55
+ struct[addon]['attribute'] = ""
56
+ struct[subnode] = struct[subnode].deep_merge(deep_copy(struct[addon]))
57
+ struct[addon]['attribute'] = 'required'
58
+ end
59
+ end
60
+
61
+ # perform merge by "__add__" node only applys to application type
62
+ def merge_by_add(struct)
63
+ #only scan the top level
64
+ return if Hash != struct.class
65
+ struct.each_key do |subnode|
66
+ if struct[subnode]['__add__'] != nil
67
+ struct[subnode]['__add__'].each do |addon|
68
+ next if struct[addon].class != Hash
69
+ begin
70
+ next if struct[subnode]['configuration']['section-type'] != "application"
71
+ if struct[addon]['configuration']['section-type'] != "component"
72
+ @logger.warn "WARNING #{addon} is required as component but has not a component attribute"
73
+ end
74
+ rescue
75
+ @logger.error "error with the merge_by_add with #{subnode} add #{addon}"
76
+ end
77
+ deep_add_merge(struct, subnode, addon)
78
+ end
79
+ #struct[subnode].delete('__add__')
80
+ end
81
+ end
82
+ end
83
+
84
+ def translate
85
+ translate_project()
86
+ return [@data_out, @data_in_component, @data_in]
87
+ #puts @data_out.to_yaml
88
+ end
89
+
90
+ def output_path(proj, comp)
91
+ if @data_in[proj].has_key?('outdir')
92
+ board = @data_in[proj]['configuration']['board']
93
+ if @data_out[proj][comp]['type'] == "library"
94
+ if comp == 'uv4'
95
+ @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, "mdk")
96
+ else
97
+ @data_out[proj][comp]['outdir'] = File.join(@data_in[proj]['outdir'], proj, comp)
98
+ end
99
+ else
100
+ if comp == "uv4"
101
+ @data_out[proj][comp]['outdir'] = File.join(board, @data_in[proj]['outdir'], "mdk")
102
+ else
103
+ @data_out[proj][comp]['outdir'] = File.join(board, @data_in[proj]['outdir'], comp)
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ private
110
+
111
+ def convert_rules(proj, comp = 'iar')
112
+ if @data_in[proj]['configuration']['section-type'] == "virtual-library"
113
+ if @data_in[proj].has_key?(comp)
114
+ @data_out[proj] = @data_in[proj]
115
+ board = @data_in[proj]['configuration']['board']
116
+ path = @data_out[proj][comp]['outdir']['path']
117
+ return if ! @data_out[proj].has_key?('chip-convert')
118
+ @data_out[proj][comp]['outdir']['path'] = path + @data_out[proj]['chip-convert'][board]
119
+ return
120
+ end
121
+ end
122
+
123
+ if @data_in[proj]['configuration']['section-type'] == "component"
124
+ return
125
+ end
126
+
127
+ if @data_in[proj]['configuration'].has_key?('meta_components')
128
+ @data_out[proj]['meta_components'] = @data_in[proj]['configuration']['meta_components']
129
+ end
130
+
131
+ if @data_in[proj]['configuration']['tools'].has_key?(comp)
132
+ compiler = @data_in[proj]['configuration']['tools'][comp]
133
+ @data_out[proj][comp] = Hash.new
134
+ @data_out[proj][comp]['targets'] = Hash.new
135
+ @data_out[proj][comp]['type'] = @data_in[proj]['configuration']['section-type']
136
+
137
+ @data_out[proj][comp]['templates'] = compiler['project-templates']
138
+ if compiler.has_key?("group")
139
+ @data_out[proj][comp]['group'] = compiler['group']
140
+ end
141
+ output_path(proj, comp)
142
+ compiler['config'].each_key do |target|
143
+ next if compiler['load-to'].nil?
144
+ next if compiler['load-to'][target].nil?
145
+ create_and_deep_merge(@data_out[proj][comp]['targets'], target, compiler['config'][target])
146
+ @data_out[proj][comp]['targets'][target]['linker_file'] = Hash.new
147
+ @data_out[proj][comp]['targets'][target]['linker_file']['path'] = compiler['load-to'][target]['linker-file']
148
+ @data_out[proj][comp]['targets'][target]['linker_file']['rootdir'] = compiler['load-to'][target]['rootdir']
149
+ create_and_deep_merge(@data_out[proj][comp]['targets'][target]['binary_file'], target, compiler['binary-file'])
150
+ @data_out[proj][comp]['targets'][target]['identifier'] = compiler['load-to'][target]['identifier']
151
+ @data_out[proj][comp]['targets'][target]['config'] = compiler['load-to'][target]['config']
152
+ @data_out[proj][comp]['targets'][target]['target'] = compiler['load-to'][target]['target']
153
+ @data_out[proj][comp]['targets'][target]['libraries'] = Array.new
154
+ if ! @data_in[proj]['configuration']['section-depends'].nil?
155
+ @data_in[proj]['configuration']['section-depends'].each do |dep|
156
+ @data_out[proj][comp]['targets'][target]['libraries'].insert(-1, dep)
157
+ end
158
+ end
159
+ end
160
+ #now translate the source
161
+ return if ! @data_in[proj].has_key?('modules')
162
+
163
+ if @data_in[proj].has_key?('tools')
164
+ #process compile depend files here
165
+ if @data_in[proj]['tools'].has_key?(comp) and @data_in[proj].has_key?('modules') and @data_in[proj]["configuration"]["section-type"] == "application"
166
+ @data_in[proj]['tools'][comp]['files'].each do |file|
167
+ puts file
168
+ next ! file.has_key?("virtual-dir")
169
+ file['virtual_dir'] = file.delete "virtual-dir"
170
+ end
171
+ create_and_deep_merge(@data_out[proj][comp], 'source', @data_in[proj]['tools'][comp]['files'])
172
+ end
173
+ end
174
+ @data_in[proj]['modules'].each_key do |mod|
175
+ if @data_in[proj]['modules'][mod].class == Hash and @data_in[proj]['modules'][mod].has_key?('virtual-dir')
176
+ temp = Marshal.load(Marshal.dump(@data_in[proj]['modules'][mod]['files']))
177
+ temp.each do |file|
178
+ #puts "old virtual-dir is #{mod} #{file['virtual-dir']}"
179
+ #puts "current #{@data_in[proj]['modules'][mod]['virtual-dir'].to_s}"
180
+ if file['virtual-dir'] == nil
181
+ file['virtual-dir'] = @data_in[proj]['modules'][mod]['virtual-dir'].to_s
182
+ else
183
+ if ! file.has_key?("processed")
184
+ #puts proj,mod,file
185
+ #puts file['virtual-dir']
186
+ #puts @data_in[proj]['modules'][mod]['virtual-dir'].to_s
187
+ file['virtual-dir'] = "#{@data_in[proj]['modules'][mod]['virtual-dir']}:#{file['virtual-dir']}"
188
+ file['processed'] = "true"
189
+ end
190
+ end
191
+ #puts "new virtual-dir is #{file['virtual-dir']} for #{proj}"
192
+ if comp == 'uv4' || comp == 'mdk'
193
+ file['virtual-dir'] = file['virtual-dir'].gsub(':','-')
194
+ end
195
+ file['virtual_dir'] = file.delete "virtual-dir"
196
+ end
197
+ create_and_deep_merge(@data_out[proj][comp], 'source', temp)
198
+
199
+ else
200
+ if @data_in[proj]['modules'][mod].class == Hash and @data_in[proj]['modules'][mod].has_key?('files')
201
+ @data_in[proj]['modules'][mod]['files'].each do |file|
202
+ next ! file.has_key?("virtual-dir")
203
+ file['virtual_dir'] = file.delete "virtual-dir"
204
+ end
205
+ create_and_deep_merge(@data_out[proj][comp], 'source', @data_in[proj]['modules'][mod]['files'])
206
+ end
207
+ end
208
+ end
209
+
210
+ if @data_in[proj].has_key?('document')
211
+ create_and_deep_merge(@data_out[proj],'document', @data_in[proj]['document'])
212
+ end
213
+ end
214
+ end
215
+
216
+ def create_and_deep_merge(a, b, c)
217
+ return if c == nil
218
+ if c.class == Array
219
+ a[b] = Array.new if a[b] == nil
220
+ a[b] = a[b] + c.dup
221
+ else
222
+ a[b] = Hash.new if a[b] == nil
223
+ a[b].deep_merge(c)
224
+ end
225
+ end
226
+
227
+ def translate_project
228
+ @data_in.each_key do |proj|
229
+ next if @data_in[proj].nil?
230
+ if @data_in[proj].has_key?('configuration')
231
+ next if @data_in[proj]['configuration']['section-type'] == "component"
232
+ end
233
+ @data_out[proj] = Hash.new
234
+ if @data_in[proj].has_key?('section-type')
235
+ @data_out[proj]['type'] = @data_in[proj]['section-type']
236
+ end
237
+ convert_rules(proj,'iar')
238
+ #convert_rules(proj,'uv4')
239
+ convert_rules(proj,'cmake')
240
+ #convert_rules(proj,'armgcc')
241
+ #convert_rules(proj,'kds')
242
+ #convert_rules(proj,'atl')
243
+ #convert_rules(proj,'lpcx')
244
+ end
245
+ @data_in_component.each_key do |proj|
246
+ # puts "#{proj} TBD"
247
+ end
248
+ end
249
+ end