ebngen 1.0.4 → 1.2.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 +5 -5
- data/lib/ebngen.rb +1 -1
- data/lib/ebngen/adapter/_assert.rb +25 -25
- data/lib/ebngen/adapter/_base.rb +25 -24
- data/lib/ebngen/adapter/_path_modifier.rb +29 -29
- data/lib/ebngen/adapter/_yml_helper.rb +56 -48
- data/lib/ebngen/adapter/cmake.rb +304 -304
- data/lib/ebngen/adapter/cmake/CMakeList.txt +569 -569
- data/lib/ebngen/adapter/cmake/txt.rb +75 -75
- data/lib/ebngen/adapter/iar.rb +459 -459
- data/lib/ebngen/adapter/iar/ewd.rb +5 -5
- data/lib/ebngen/adapter/iar/ewp.rb +269 -269
- data/lib/ebngen/adapter/iar/eww.rb +61 -61
- data/lib/ebngen/adapter/mdk.rb +480 -0
- data/lib/ebngen/adapter/mdk/uvmwp.rb +91 -0
- data/lib/ebngen/adapter/mdk/uvprojx.rb +278 -0
- data/lib/ebngen/assembly.rb +22 -22
- data/lib/ebngen/ebngen.rb +3 -3
- data/lib/ebngen/generate.rb +48 -47
- data/lib/ebngen/settings/target_types.rb +1 -1
- data/lib/ebngen/settings/tool_chains.rb +4 -4
- data/lib/ebngen/translate.rb +249 -249
- data/lib/ebngen/unifmt.rb +290 -290
- metadata +9 -7
@@ -1,62 +1,62 @@
|
|
1
|
-
|
2
|
-
require 'nokogiri'
|
3
|
-
|
4
|
-
|
5
|
-
module EWW
|
6
|
-
|
7
|
-
def add_batch_project_target(xml, batchname, project, target)
|
8
|
-
definition_node = xml.at_xpath("/workspace/batchBuild/batchDefinition[name[text()='#{batchname}']]")
|
9
|
-
unless (definition_node)
|
10
|
-
build_node = xml.at_xpath("/workspace/batchBuild")
|
11
|
-
unless (build_node)
|
12
|
-
workspace_node = xml.at_xpath("/workspace")
|
13
|
-
Core.assert(workspace_node, "no <workspace> present")
|
14
|
-
# <batchBuild>
|
15
|
-
build_node = Nokogiri::XML::Node.new("batchBuild", xml)
|
16
|
-
workspace_node << build_node
|
17
|
-
end
|
18
|
-
# <batchDefinition>
|
19
|
-
definition_node = Nokogiri::XML::Node.new("batchDefinition", xml)
|
20
|
-
build_node << definition_node
|
21
|
-
# <name>
|
22
|
-
name_node = Nokogiri::XML::Node.new("name", xml)
|
23
|
-
name_node.content = batchname
|
24
|
-
definition_node << name_node
|
25
|
-
end
|
26
|
-
# <member>
|
27
|
-
member_node = Nokogiri::XML::Node.new("member", xml)
|
28
|
-
definition_node << member_node
|
29
|
-
# <project>
|
30
|
-
project_node = Nokogiri::XML::Node.new("project", xml)
|
31
|
-
project_node.content = project
|
32
|
-
member_node << project_node
|
33
|
-
# <configuration>
|
34
|
-
configuration_node = Nokogiri::XML::Node.new("configuration", xml)
|
35
|
-
configuration_node.content = target
|
36
|
-
member_node << configuration_node
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
def add_project(xml , project_path)
|
41
|
-
# find <ProjectWorkspace>
|
42
|
-
workspace_node = xml.at_xpath('/workspace')
|
43
|
-
# add <project>
|
44
|
-
project_node = Nokogiri::XML::Node.new("project", xml)
|
45
|
-
workspace_node << project_node
|
46
|
-
# add <PathAndName>
|
47
|
-
path_node = Nokogiri::XML::Node.new("path", xml)
|
48
|
-
path_node.content = project_path
|
49
|
-
project_node << path_node
|
50
|
-
# add project into existing lists
|
51
|
-
#@projects[ project_path ] = project_node
|
52
|
-
end
|
53
|
-
|
54
|
-
def save(xml, path)
|
55
|
-
Core.assert(path.is_a?(String)) do
|
56
|
-
"param is not a string #{path.class.name}"
|
57
|
-
end
|
58
|
-
FileUtils.mkdir_p File.dirname(path) if ! File.exist?(File.dirname(path))
|
59
|
-
File.write(path, xml.to_xml)
|
60
|
-
end
|
61
|
-
|
1
|
+
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
|
5
|
+
module EWW
|
6
|
+
|
7
|
+
def add_batch_project_target(xml, batchname, project, target)
|
8
|
+
definition_node = xml.at_xpath("/workspace/batchBuild/batchDefinition[name[text()='#{batchname}']]")
|
9
|
+
unless (definition_node)
|
10
|
+
build_node = xml.at_xpath("/workspace/batchBuild")
|
11
|
+
unless (build_node)
|
12
|
+
workspace_node = xml.at_xpath("/workspace")
|
13
|
+
Core.assert(workspace_node, "no <workspace> present")
|
14
|
+
# <batchBuild>
|
15
|
+
build_node = Nokogiri::XML::Node.new("batchBuild", xml)
|
16
|
+
workspace_node << build_node
|
17
|
+
end
|
18
|
+
# <batchDefinition>
|
19
|
+
definition_node = Nokogiri::XML::Node.new("batchDefinition", xml)
|
20
|
+
build_node << definition_node
|
21
|
+
# <name>
|
22
|
+
name_node = Nokogiri::XML::Node.new("name", xml)
|
23
|
+
name_node.content = batchname
|
24
|
+
definition_node << name_node
|
25
|
+
end
|
26
|
+
# <member>
|
27
|
+
member_node = Nokogiri::XML::Node.new("member", xml)
|
28
|
+
definition_node << member_node
|
29
|
+
# <project>
|
30
|
+
project_node = Nokogiri::XML::Node.new("project", xml)
|
31
|
+
project_node.content = project
|
32
|
+
member_node << project_node
|
33
|
+
# <configuration>
|
34
|
+
configuration_node = Nokogiri::XML::Node.new("configuration", xml)
|
35
|
+
configuration_node.content = target
|
36
|
+
member_node << configuration_node
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def add_project(xml , project_path)
|
41
|
+
# find <ProjectWorkspace>
|
42
|
+
workspace_node = xml.at_xpath('/workspace')
|
43
|
+
# add <project>
|
44
|
+
project_node = Nokogiri::XML::Node.new("project", xml)
|
45
|
+
workspace_node << project_node
|
46
|
+
# add <PathAndName>
|
47
|
+
path_node = Nokogiri::XML::Node.new("path", xml)
|
48
|
+
path_node.content = project_path
|
49
|
+
project_node << path_node
|
50
|
+
# add project into existing lists
|
51
|
+
#@projects[ project_path ] = project_node
|
52
|
+
end
|
53
|
+
|
54
|
+
def save(xml, path)
|
55
|
+
Core.assert(path.is_a?(String)) do
|
56
|
+
"param is not a string #{path.class.name}"
|
57
|
+
end
|
58
|
+
FileUtils.mkdir_p File.dirname(path) if ! File.exist?(File.dirname(path))
|
59
|
+
File.write(path, xml.to_xml)
|
60
|
+
end
|
61
|
+
|
62
62
|
end
|
@@ -0,0 +1,480 @@
|
|
1
|
+
|
2
|
+
require_relative '_base'
|
3
|
+
require_relative '_yml_helper'
|
4
|
+
require_relative '_path_modifier'
|
5
|
+
require_relative 'mdk/uvmwp'
|
6
|
+
require_relative 'mdk/uvprojx'
|
7
|
+
|
8
|
+
#replace me when yml_merger becomes gem
|
9
|
+
require 'yml_merger'
|
10
|
+
require 'nokogiri'
|
11
|
+
require 'uri'
|
12
|
+
require 'open-uri'
|
13
|
+
#require 'xsd_populator'
|
14
|
+
#require 'xsd_reader'
|
15
|
+
|
16
|
+
module MDK
|
17
|
+
class Project
|
18
|
+
TOOLCHAIN='mdk'
|
19
|
+
include Base
|
20
|
+
include UVPROJX
|
21
|
+
include UNI_Project
|
22
|
+
|
23
|
+
def initialize(project_data, generator_variable, logger = nil)
|
24
|
+
@logger = logger
|
25
|
+
unless (logger)
|
26
|
+
@logger = Logger.new(STDOUT)
|
27
|
+
@logger.level = Logger::WARN
|
28
|
+
end
|
29
|
+
set_hash(project_data)
|
30
|
+
@project_name = get_project_name()
|
31
|
+
@board = get_board()
|
32
|
+
@paths = PathModifier.new(generator_variable["paths"])
|
33
|
+
@mdk_project_files = {"project_projx"=> nil,".yml" => nil, ".uvprojx" => nil}
|
34
|
+
return nil if get_template(Project::TOOLCHAIN).nil?
|
35
|
+
get_template(Project::TOOLCHAIN).each do |template|
|
36
|
+
@logger.info template
|
37
|
+
ext = File.extname(template)
|
38
|
+
if @mdk_project_files.keys.include?(ext)
|
39
|
+
path = @paths.fullpath("default_path",template)
|
40
|
+
#begin
|
41
|
+
case ext
|
42
|
+
when ".uvprojx"
|
43
|
+
#fn = File.basename(path, ".uvprojx")
|
44
|
+
#if fn == "project_projx"
|
45
|
+
doc = Nokogiri::XML(open(path))
|
46
|
+
#string_xml = XsdPopulator.new(:xsd => path).populated_xml
|
47
|
+
#doc = Nokogiri::XML(string_xml)
|
48
|
+
@mdk_project_files["project_projx"] = doc
|
49
|
+
#init_project(doc, get_default_project_settings(Project_set::TOOLCHAIN))
|
50
|
+
#end
|
51
|
+
end
|
52
|
+
#rescue
|
53
|
+
# @logger.info "failed to open #{template}"
|
54
|
+
#end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def generator(filter, project_data)
|
60
|
+
return if not is_toolchain_support(Project::TOOLCHAIN)
|
61
|
+
create_method( Project::TOOLCHAIN)
|
62
|
+
send(Project::TOOLCHAIN.to_sym, project_data)
|
63
|
+
save_project()
|
64
|
+
end
|
65
|
+
|
66
|
+
def source()
|
67
|
+
#add sources to target
|
68
|
+
=begin
|
69
|
+
return if @mdk_project_files['project_projx'].nil?
|
70
|
+
remove_sources(@mdk_project_files['project_projx'])
|
71
|
+
sources = get_src_list(Project::TOOLCHAIN)
|
72
|
+
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
|
73
|
+
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
|
74
|
+
add_sources(@mdk_project_files['project_projx'], sources, @paths, proj_path)
|
75
|
+
=end
|
76
|
+
end
|
77
|
+
|
78
|
+
def templates()
|
79
|
+
#load tempaltes
|
80
|
+
end
|
81
|
+
|
82
|
+
def type()
|
83
|
+
#set project type
|
84
|
+
end
|
85
|
+
|
86
|
+
def document()
|
87
|
+
project_name = get_project_name()
|
88
|
+
end
|
89
|
+
|
90
|
+
def targets()
|
91
|
+
convert_lut = {
|
92
|
+
'cx_flags' => 'cxx_flags',
|
93
|
+
'cc_define' => 'cc_defines',
|
94
|
+
'cx_define' => 'cxx_defines',
|
95
|
+
'as_define' => 'as_defines',
|
96
|
+
'cp_define' => 'cp_defines',
|
97
|
+
'ar_flags' => 'ar_flags'
|
98
|
+
}
|
99
|
+
get_targets(Project::TOOLCHAIN).each do |key, value|
|
100
|
+
next if value.nil?
|
101
|
+
#add target for uvproj
|
102
|
+
t = new_target(key, @mdk_project_files['project_projx'])
|
103
|
+
if t.nil?
|
104
|
+
@logger.info "missing default debug configuration in template"
|
105
|
+
return
|
106
|
+
end
|
107
|
+
#do the target settings
|
108
|
+
value.each_key do |subkey|
|
109
|
+
#for backward compatible
|
110
|
+
temp_op = subkey.gsub('-', '_')
|
111
|
+
if convert_lut.has_key? temp_op
|
112
|
+
target_op = convert_lut[temp_op]
|
113
|
+
else
|
114
|
+
target_op = temp_op
|
115
|
+
end
|
116
|
+
methods = self.class.instance_methods(false)
|
117
|
+
if methods.include?("target_#{target_op}".to_sym)
|
118
|
+
send("target_#{target_op}".to_sym, t, value[subkey])
|
119
|
+
else
|
120
|
+
@logger.info "#{subkey} is not processed try to use the tool-chain specific"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
#for mdk sources are added pre-target
|
124
|
+
remove_sources(t)
|
125
|
+
sources = get_src_list(Project::TOOLCHAIN)
|
126
|
+
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
|
127
|
+
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
|
128
|
+
add_sources(t.at_xpath("Groups"), sources, @paths, proj_path)
|
129
|
+
end
|
130
|
+
remove_targets(@mdk_project_files['project_projx'], get_target_list(Project::TOOLCHAIN))
|
131
|
+
end
|
132
|
+
|
133
|
+
# tool_chain_specific attribute for each target
|
134
|
+
# Params:
|
135
|
+
# - target_node: the xml node of given target
|
136
|
+
# - doc: the hash that holds the data
|
137
|
+
def target_tool_chain_set_spec(target_node, doc)
|
138
|
+
set_specific(target_node, doc)
|
139
|
+
end
|
140
|
+
|
141
|
+
def target_tool_chain_add_spec(target_node, doc)
|
142
|
+
add_specific(target_node, doc)
|
143
|
+
end
|
144
|
+
|
145
|
+
def save_project()
|
146
|
+
path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
|
147
|
+
@logger.info "save as #{File.join(@paths.rootdir_table['output_root'], path, "#{@project_name}_#{@board}.uvprojx")}"
|
148
|
+
save(@mdk_project_files['project_projx'], File.join(@paths.rootdir_table['output_root'], path, "#{@project_name}_#{@board}.uvprojx"))
|
149
|
+
end
|
150
|
+
|
151
|
+
def target_cp_defines(target_node, doc)
|
152
|
+
cpdefines = []
|
153
|
+
doc.each do |key, value|
|
154
|
+
cpdefines.insert(-1, "#{key}=#{value}")
|
155
|
+
end
|
156
|
+
settings = {'Cads' =>
|
157
|
+
{ 'VariousControls' =>
|
158
|
+
{
|
159
|
+
'Define' => cpdefines
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
set_specific(target_node, settings)
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
def target_as_predefines(target_node, doc)
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
def target_as_defines(target_node, doc)
|
172
|
+
asdefines = []
|
173
|
+
doc.each do |key, value|
|
174
|
+
asdefines.insert(-1, "#{key}=#{value}")
|
175
|
+
end
|
176
|
+
settings = {'Aads' =>
|
177
|
+
{ 'VariousControls' =>
|
178
|
+
{
|
179
|
+
'Define' => asdefines
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
set_specific(target_node, settings)
|
184
|
+
end
|
185
|
+
|
186
|
+
def target_as_include(target_node, doc)
|
187
|
+
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
|
188
|
+
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
|
189
|
+
|
190
|
+
inc_array = Array.new
|
191
|
+
doc.each do |item|
|
192
|
+
if item['rootdir']
|
193
|
+
full_path = @paths.fullpath(item['rootdir'],item['path'])
|
194
|
+
else
|
195
|
+
full_path = @paths.fullpath('default_path',item['path'])
|
196
|
+
end
|
197
|
+
inc_array.insert(-1, File.join("$PROJ_DIR$", @paths.relpath(proj_path, full_path)))
|
198
|
+
end
|
199
|
+
settings = {'Aads' =>
|
200
|
+
{ 'VariousControls' =>
|
201
|
+
{
|
202
|
+
'IncludePath' => inc_array
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
add_specific(target_node, settings)
|
207
|
+
end
|
208
|
+
|
209
|
+
def target_as_flags(target_node, doc)
|
210
|
+
flags_array = Array.new
|
211
|
+
doc.each do |item|
|
212
|
+
if item.class == Hash
|
213
|
+
item.each do |key, value|
|
214
|
+
flags_array.insert(-1, "#{key}=#{value}")
|
215
|
+
end
|
216
|
+
else
|
217
|
+
flags_array.insert(-1, item)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
settings = {'Aads' =>
|
221
|
+
{ 'VariousControls' =>
|
222
|
+
{
|
223
|
+
'MiscControls' => flags_array
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
add_specific(target_node, settings)
|
228
|
+
end
|
229
|
+
|
230
|
+
def target_cc_predefines(target_node, doc)
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
def target_cc_preincludes(target_node, doc)
|
235
|
+
end
|
236
|
+
|
237
|
+
def target_cc_defines(target_node, doc)
|
238
|
+
defines_array = Array.new
|
239
|
+
doc.each do |item, item_value|
|
240
|
+
if item_value.nil?
|
241
|
+
defines_array.insert(-1, "#{item}")
|
242
|
+
else
|
243
|
+
defines_array.insert(-1, "#{item}=#{item_value}")
|
244
|
+
end
|
245
|
+
end
|
246
|
+
settings = {'Cads' =>
|
247
|
+
{ 'VariousControls' =>
|
248
|
+
{
|
249
|
+
'Define' => defines_array
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}
|
253
|
+
add_specific(target_node, settings)
|
254
|
+
end
|
255
|
+
|
256
|
+
def target_cc_include(target_node, doc)
|
257
|
+
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
|
258
|
+
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
|
259
|
+
inc_array = Array.new
|
260
|
+
doc.each do |item|
|
261
|
+
if item['rootdir']
|
262
|
+
full_path = @paths.fullpath(item['rootdir'],item['path'])
|
263
|
+
else
|
264
|
+
full_path = @paths.fullpath('default_path',item['path'])
|
265
|
+
end
|
266
|
+
inc_array.insert(-1, File.join("$PROJ_DIR$", @paths.relpath(proj_path, full_path)))
|
267
|
+
end
|
268
|
+
settings = {'Cads' =>
|
269
|
+
{ 'VariousControls' =>
|
270
|
+
{
|
271
|
+
'IncludePath' => inc_array
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
add_specific(target_node, settings)
|
276
|
+
end
|
277
|
+
|
278
|
+
def target_cc_flags(target_node, doc)
|
279
|
+
flags_array = Array.new
|
280
|
+
doc.each do |item|
|
281
|
+
if item.class == Hash
|
282
|
+
item.each do |key, value|
|
283
|
+
flags_array.insert(-1, "#{key}=#{value}")
|
284
|
+
end
|
285
|
+
else
|
286
|
+
flags_array.insert(-1, item)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
settings = {'Cads' =>
|
290
|
+
{ 'VariousControls' =>
|
291
|
+
{
|
292
|
+
'MiscControls' => flags_array
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
add_specific(target_node, settings)
|
297
|
+
end
|
298
|
+
|
299
|
+
def target_cxx_predefines(target_node, doc)
|
300
|
+
target_cc_predefines(target_node, doc)
|
301
|
+
end
|
302
|
+
|
303
|
+
def target_cxx_preincludes(target_node, doc)
|
304
|
+
target_cc_preincludes(target_node, doc)
|
305
|
+
end
|
306
|
+
|
307
|
+
def target_cxx_defines(target_node, doc)
|
308
|
+
target_cc_defines(target_node, doc)
|
309
|
+
end
|
310
|
+
|
311
|
+
def target_cxx_include(target_node, doc)
|
312
|
+
target_cc_include(target_node, doc)
|
313
|
+
end
|
314
|
+
|
315
|
+
def target_cxx_flags(target_node, doc)
|
316
|
+
target_cc_flags(target_node, doc)
|
317
|
+
end
|
318
|
+
|
319
|
+
def target_ld_flags(target_node, doc)
|
320
|
+
flags_array = Array.new
|
321
|
+
doc.each do |item|
|
322
|
+
if item.class == Hash
|
323
|
+
item.each do |key, value|
|
324
|
+
flags_array.insert(-1, "#{key}=#{value}")
|
325
|
+
end
|
326
|
+
else
|
327
|
+
flags_array.insert(-1, item)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
settings = {'LDads' =>
|
331
|
+
{ 'Misc' => flags_array }
|
332
|
+
}
|
333
|
+
add_specific(target_node, settings)
|
334
|
+
end
|
335
|
+
|
336
|
+
def target_libraries(target_node, doc)
|
337
|
+
flags_array = Array.new
|
338
|
+
doc.each do |item|
|
339
|
+
if item.class == Hash
|
340
|
+
item.each do |key, value|
|
341
|
+
flags_array.insert(-1, "#{key}=#{value}")
|
342
|
+
end
|
343
|
+
else
|
344
|
+
flags_array.insert(-1, item)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
settings = {'LDads' =>
|
348
|
+
{ 'Misc' => flags_array }
|
349
|
+
}
|
350
|
+
add_specific(target_node, settings)
|
351
|
+
end
|
352
|
+
|
353
|
+
def target_linker_file(target_node, doc)
|
354
|
+
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
|
355
|
+
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
|
356
|
+
inc_array = Array.new
|
357
|
+
if doc.has_key?("rootdir")
|
358
|
+
full_path = @paths.fullpath(doc['rootdir'],doc['path'])
|
359
|
+
else
|
360
|
+
full_path = @paths.fullpath('default_path',doc['path'])
|
361
|
+
end
|
362
|
+
inc_array.insert(-1, File.join("$PROJ_DIR$", @paths.relpath(proj_path, full_path)))
|
363
|
+
settings = {'LDads' =>
|
364
|
+
{ 'ScatterFile' => inc_array.join(" ") }
|
365
|
+
}
|
366
|
+
add_specific(target_node, settings)
|
367
|
+
end
|
368
|
+
|
369
|
+
def target_outdir(target_node, doc)
|
370
|
+
=begin
|
371
|
+
<option>
|
372
|
+
<name>IlinkOutputFile</name>
|
373
|
+
<state>K70_pit_drivers_test.out</state>
|
374
|
+
</option>
|
375
|
+
=end
|
376
|
+
settings = { 'OutputDirectory' => "#{get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)}"}
|
377
|
+
set_specific(target_node, settings)
|
378
|
+
settings = { 'OutputName' => "#{get_project_name()}"}
|
379
|
+
set_specific(target_node, settings)
|
380
|
+
end
|
381
|
+
|
382
|
+
end
|
383
|
+
|
384
|
+
class Project_set
|
385
|
+
include UVMWP
|
386
|
+
include UNI_Project
|
387
|
+
TOOLCHAIN='mdk'
|
388
|
+
|
389
|
+
# initialize EWW class
|
390
|
+
# PARAMS:
|
391
|
+
# - project_data: specific project data format for a application/library
|
392
|
+
# - generator_variable: all dependency in hash
|
393
|
+
def initialize(project_data, generator_variable, logger = nil)
|
394
|
+
@logger = logger
|
395
|
+
unless (logger)
|
396
|
+
@logger = Logger.new(STDOUT)
|
397
|
+
@logger.level = Logger::WARN
|
398
|
+
end
|
399
|
+
set_hash(project_data)
|
400
|
+
@project_name = get_project_name()
|
401
|
+
@board = get_board()
|
402
|
+
@paths = PathModifier.new(generator_variable["paths"])
|
403
|
+
@all_projects_hash = generator_variable["all"]
|
404
|
+
@mdk_project_files = {"project_mpw" => nil,".xsd" => nil}
|
405
|
+
return nil if get_template(Project_set::TOOLCHAIN).nil?
|
406
|
+
get_template(Project_set::TOOLCHAIN).each do |template|
|
407
|
+
ext = File.extname(template)
|
408
|
+
if @mdk_project_files.keys.include?(ext)
|
409
|
+
path = @paths.fullpath("default_path",template)
|
410
|
+
case ext
|
411
|
+
when ".xsd"
|
412
|
+
fn = File.basename(path, ".xsd")
|
413
|
+
@logger.info "#{fn} processing"
|
414
|
+
if fn == "project_mpw"
|
415
|
+
#doc = Nokogiri::XML(open(path))
|
416
|
+
string_xml = XsdPopulator.new(:xsd => path).populated_xml
|
417
|
+
doc = Nokogiri::XML(string_xml)
|
418
|
+
@mdk_project_files['project_mpw'] = doc
|
419
|
+
init_project_set(doc, get_default_projectset_settings(Project_set::TOOLCHAIN))
|
420
|
+
end
|
421
|
+
else
|
422
|
+
@logger.info "#{ext} not processed"
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
def generator()
|
429
|
+
return if not is_toolchain_support(Project::TOOLCHAIN)
|
430
|
+
add_project_to_set()
|
431
|
+
save_set()
|
432
|
+
end
|
433
|
+
|
434
|
+
|
435
|
+
def add_project_to_set()
|
436
|
+
return if @mdk_project_files.nil?
|
437
|
+
return if @mdk_project_files['project_mpw'].nil?
|
438
|
+
ext = "project_mpw"
|
439
|
+
#add projects
|
440
|
+
file = "#{@project_name}_#{@board}.uvprojx"
|
441
|
+
add_project(@mdk_project_files[ext], file)
|
442
|
+
#add library projects here
|
443
|
+
#get from dependency['libraries'][library_name]
|
444
|
+
ustruct = @all_projects_hash
|
445
|
+
return if get_libraries(Project_set::TOOLCHAIN).nil?
|
446
|
+
get_libraries(Project_set::TOOLCHAIN).each do |lib|
|
447
|
+
if ustruct[lib].nil?
|
448
|
+
@logger.info "#{lib} information is missing in all hash"
|
449
|
+
next
|
450
|
+
end
|
451
|
+
libname = "#{@project_name}"
|
452
|
+
root = @paths.rootdir_table[@ustruct[library][tool_key]['outdir']['root-dir']]
|
453
|
+
lib_path = File.join(root, @ustruct[library][tool_key]['outdir']['path'], libname)
|
454
|
+
if @ustruct[ project_name ][ tool_key ].has_key?('outdir')
|
455
|
+
wspath = File.join(@output_rootdir, @ustruct[ project_name ][ tool_key ][ 'outdir' ] )
|
456
|
+
else
|
457
|
+
wspath = @output_rootdir
|
458
|
+
end
|
459
|
+
path = Pathname.new(lib_path).relative_path_from(Pathname.new(wspath))
|
460
|
+
|
461
|
+
add_project(@mdk_project_files[ext], path)
|
462
|
+
end
|
463
|
+
|
464
|
+
end
|
465
|
+
|
466
|
+
def save_set()
|
467
|
+
path = get_output_dir(Project_set::TOOLCHAIN, @paths.rootdir_table)
|
468
|
+
@logger.info @paths.rootdir_table['output_root']
|
469
|
+
@logger.info path
|
470
|
+
@logger.info "#{@project_name}_#{@board}"
|
471
|
+
if path.class == Hash
|
472
|
+
save(@mdk_project_files['project_mpw'], File.join(@paths.rootdir_table[path['rootdir']], path['path'], "#{@project_name}_#{@board}.uvmpw"))
|
473
|
+
else
|
474
|
+
save(@mdk_project_files['project_mpw'], File.join(@paths.rootdir_table['output_root'], path, "#{@project_name}_#{@board}.uvmpw"))
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
end
|
479
|
+
|
480
|
+
end # end Module MDK
|