ebngen 1.0.4 → 1.2.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
- SHA1:
3
- metadata.gz: 42db9e0ecdc53d76e38d21b5e0624bba3abdf679
4
- data.tar.gz: 0418eb5bc561fb53bf655f736c5e7bb96cd9629d
2
+ SHA256:
3
+ metadata.gz: 25e01159723bdfff8f52587f3b3385d4a24e15e2aad84f29fea4260e16ed4eb3
4
+ data.tar.gz: a247b2d81b08ed331ca50b1bbd08d2772327f8f1df27db4f1767356ccb9289d9
5
5
  SHA512:
6
- metadata.gz: dc318a08e1746a13377bec21f7988f554bccbf46ed18a0ee266964ca4ed5dd4c817d5c228dd11a9fdaebbc5d99cb557db28c36b489ec083ab4b346c2f6511cfa
7
- data.tar.gz: c2e9ed506053e9645b685500107a5889601315e53dc173773477eceac58c8566f08da5e84a19e9d7815544c067c79a45702ed432b9d587a4e71973ec8db701ba
6
+ metadata.gz: 7c1893e59e461e110450af451e4930cfe543affb9dd24c090c6ffa02206fcb18a3c874bd11daa84d8369069f7e7896e41d2335ece64af1981fb324115ab7140c
7
+ data.tar.gz: 90b2fe3bbbbe29c6152f64707b8ea5dafdd94b4ba9b0bbaa2fdcd5db2a8889b6a862e259c2aa1478424e2443124f570ec9c7aa14f82df52eb84591a6e6e5f7ea
data/lib/ebngen.rb CHANGED
@@ -1 +1 @@
1
- require_relative 'ebngen\ebngen.rb'
1
+ require_relative 'ebngen/ebngen.rb'
@@ -1,25 +1,25 @@
1
-
2
- module Core
3
-
4
- # perform simple assertion like c <assert.h>
5
- # implementation raise an exception instead go to abort
6
- # two ways how use assert:
7
- # 1) assert(condition, "message")
8
- # 2) assert(condition) do "message" end
9
- # I would prefer use 2.nd way because 1.st way always
10
- # evaluate the message parameter ("like #{failed_var.some_info...}")
11
- # while 2.nd evaluate message only if condition fails
12
- def assert(condition, message=nil)
13
- unless (condition)
14
- if block_given?
15
- message = yield(condition)
16
- end
17
- raise message == nil ? "assertion error" : message
18
- end
19
- end
20
-
21
- module_function :assert
22
-
23
- end
24
-
25
-
1
+
2
+ module Core
3
+
4
+ # perform simple assertion like c <assert.h>
5
+ # implementation raise an exception instead go to abort
6
+ # two ways how use assert:
7
+ # 1) assert(condition, "message")
8
+ # 2) assert(condition) do "message" end
9
+ # I would prefer use 2.nd way because 1.st way always
10
+ # evaluate the message parameter ("like #{failed_var.some_info...}")
11
+ # while 2.nd evaluate message only if condition fails
12
+ def assert(condition, message=nil)
13
+ unless (condition)
14
+ if block_given?
15
+ message = yield(condition)
16
+ end
17
+ raise message == nil ? "assertion error" : message
18
+ end
19
+ end
20
+
21
+ module_function :assert
22
+
23
+ end
24
+
25
+
@@ -1,25 +1,26 @@
1
- module Base
2
- def process(project_data)
3
- project_data.each_key do |key|
4
- methods = instance_methods(false)
5
- if methods.include(key.to_sym)
6
- send(key.to_sym, project_data)
7
- else
8
- puts "#{key} is not processed"
9
- end
10
- end
11
- end
12
-
13
- def create_method(name)
14
- self.class.send(:define_method, name){|project_data|
15
- project_data[name].each_key do |key|
16
- methods = self.class.instance_methods(false)
17
- if methods.include?(key.to_sym)
18
- send(key.to_sym)
19
- else
20
- puts "#{key} is not processed"
21
- end
22
- end
23
- }
24
- end
1
+ module Base
2
+ def process(project_data)
3
+ project_data.each_key do |key|
4
+ methods = instance_methods(false)
5
+ if methods.include(key.to_sym)
6
+ send(key.to_sym, project_data)
7
+ else
8
+ puts "#{key} is not processed"
9
+ end
10
+ end
11
+ end
12
+
13
+ def create_method(name)
14
+ self.class.send(:define_method, name){|project_data|
15
+ project_data[name].each_key do |key|
16
+ methods = self.class.instance_methods(false)
17
+ if methods.include?(key.to_sym)
18
+ puts "process #{key}"
19
+ send(key.to_sym)
20
+ else
21
+ puts "#{key} is not processed"
22
+ end
23
+ end
24
+ }
25
+ end
25
26
  end
@@ -1,29 +1,29 @@
1
- require 'pathname'
2
- require_relative '_assert'
3
-
4
-
5
- class PathModifier
6
-
7
- attr_reader :rootdir_table
8
-
9
- def initialize(rootdir_table)
10
- @rootdir_table = rootdir_table
11
- end
12
-
13
- def fullpath(rootdir_name, relpath)
14
- Core.assert(@rootdir_table.has_key?(rootdir_name)) do
15
- "rootdir '#{rootdir_name}' is not present in table '@{rootdir_table}'"
16
- end
17
- if (@rootdir_table[ rootdir_name ] && !@rootdir_table[ rootdir_name ].empty?)
18
- relpath = File.join(
19
- @rootdir_table[ rootdir_name ].gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR), relpath.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
20
- )
21
- end
22
- return relpath.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
23
- end
24
-
25
- def relpath(project_full_path, root_dir_path)
26
- return Pathname.new(root_dir_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)).relative_path_from(Pathname.new(project_full_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR))).to_s
27
- end
28
- end
29
-
1
+ require 'pathname'
2
+ require_relative '_assert'
3
+
4
+
5
+ class PathModifier
6
+
7
+ attr_reader :rootdir_table
8
+
9
+ def initialize(rootdir_table)
10
+ @rootdir_table = rootdir_table
11
+ end
12
+
13
+ def fullpath(rootdir_name, relpath)
14
+ Core.assert(@rootdir_table.has_key?(rootdir_name)) do
15
+ "rootdir '#{rootdir_name}' is not present in table '@{rootdir_table}'"
16
+ end
17
+ if (@rootdir_table[ rootdir_name ] && !@rootdir_table[ rootdir_name ].empty?)
18
+ relpath = File.join(
19
+ @rootdir_table[ rootdir_name ].gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR), relpath.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
20
+ )
21
+ end
22
+ return relpath.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
23
+ end
24
+
25
+ def relpath(project_full_path, root_dir_path)
26
+ return Pathname.new(root_dir_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)).relative_path_from(Pathname.new(project_full_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR))).to_s
27
+ end
28
+ end
29
+
@@ -1,49 +1,57 @@
1
- require 'rubygems'
2
- require "yaml"
3
-
4
-
5
- module UNI_Project
6
- def is_toolchain_support(tool_chain)
7
- return @projects_hash.has_key?(tool_chain)
8
- end
9
-
10
- def set_hash(options)
11
- @projects_hash = options
12
- end
13
-
14
- def get_output_dir(toolchain, path_hash)
15
- @projects_hash[toolchain]["outdir"]
16
- end
17
-
18
- def get_src_list(toolchain)
19
- return @projects_hash[toolchain]["source"]
20
- end
21
-
22
- def get_libraries(toolchain)
23
- return @projects_hash[toolchain]["libraries"]
24
- end
25
-
26
- def get_target_list(toolchain)
27
- return @projects_hash[toolchain]["targets"].keys
28
- end
29
-
30
- def get_type(toolchain)
31
- return @projects_hash[toolchain]["type"]
32
- end
33
-
34
- def get_targets(toolchain)
35
- return @projects_hash[toolchain]["targets"]
36
- end
37
-
38
- def get_project_name()
39
- return @projects_hash['document']['project_name']
40
- end
41
-
42
- def get_board()
43
- return @projects_hash['document']['board']
44
- end
45
-
46
- def get_template(toolchain)
47
- return @projects_hash[toolchain]['templates']
48
- end
1
+ require 'rubygems'
2
+ require "yaml"
3
+
4
+
5
+ module UNI_Project
6
+ def is_toolchain_support(tool_chain)
7
+ return @projects_hash.has_key?(tool_chain)
8
+ end
9
+
10
+ def set_hash(options)
11
+ @projects_hash = options
12
+ end
13
+
14
+ def get_output_dir(toolchain, path_hash)
15
+ @projects_hash[toolchain]["outdir"]
16
+ end
17
+
18
+ def get_src_list(toolchain)
19
+ return @projects_hash[toolchain]["source"]
20
+ end
21
+
22
+ def get_libraries(toolchain)
23
+ return @projects_hash[toolchain]["libraries"]
24
+ end
25
+
26
+ def get_target_list(toolchain)
27
+ return @projects_hash[toolchain]["targets"].keys
28
+ end
29
+
30
+ def get_type(toolchain)
31
+ return @projects_hash[toolchain]["type"]
32
+ end
33
+
34
+ def get_targets(toolchain)
35
+ return @projects_hash[toolchain]["targets"]
36
+ end
37
+
38
+ def get_project_name()
39
+ return @projects_hash['document']['project_name']
40
+ end
41
+
42
+ def get_board()
43
+ return @projects_hash['document']['board']
44
+ end
45
+
46
+ def get_template(toolchain)
47
+ return @projects_hash[toolchain]['templates']
48
+ end
49
+
50
+ def get_default_projectset_settings(toolchain)
51
+ return @projects_hash[toolchain]['projectset_settings']
52
+ end
53
+
54
+ def get_default_project_settings(toolchain)
55
+ return @projects_hash[toolchain]['project_settings']
56
+ end
49
57
  end
@@ -1,305 +1,305 @@
1
-
2
- require_relative '_base'
3
- require_relative '_yml_helper'
4
- require_relative '_path_modifier'
5
- require_relative 'cmake/txt'
6
-
7
-
8
- #replace me when yml_merger becomes gem
9
- require 'yml_merger'
10
- require 'nokogiri'
11
- require 'uri'
12
- require 'open-uri'
13
-
14
- module CMAKE
15
- class Project
16
- TOOLCHAIN='cmake'
17
- include Base
18
- include TXT
19
- include UNI_Project
20
-
21
- def initialize(project_data, generator_variable, logger = nil)
22
- @logger = logger
23
- unless (logger)
24
- @logger = Logger.new(STDOUT)
25
- @logger.level = Logger::WARN
26
- end
27
- set_hash(project_data)
28
- @project_name = get_project_name()
29
- @board = get_board()
30
- @paths = PathModifier.new(generator_variable["paths"])
31
- @cmake_project_files = {".txt" => nil, ".bat" => nil, ".sh" => nil}
32
- @project = Hash.new if @project.nil?
33
- @project["document"] = {"project_name" => @project_name, "board" => @board }
34
- end
35
-
36
- def generator(filter, project_data)
37
- return if not is_toolchain_support(Project::TOOLCHAIN)
38
- create_method(Project::TOOLCHAIN)
39
- send(Project::TOOLCHAIN.to_sym, project_data)
40
- save_project()
41
- end
42
-
43
- def source()
44
- #add sources to target
45
- sources = get_src_list(Project::TOOLCHAIN)
46
- o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
47
- proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
48
- @project['sources'] = Array.new
49
- sources.each do |src|
50
- if file['rootdir']
51
- if file.has_key? 'path'
52
- full_path = path_mod.fullpath(file['rootdir'],file['path'])
53
- else
54
- full_path = path_mod.fullpath(file['rootdir'],file['source'])
55
- end
56
- else
57
- if file.has_key? 'path'
58
- full_path = path_mod.fullpath('default_path',file['path'])
59
- else
60
- full_path = path_mod.fullpath('default_path',file['source'])
61
- end
62
- end
63
- ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
64
- @project['sources'].insert(-1, ipath)
65
- end
66
-
67
- end
68
-
69
- def templates()
70
- #load tempaltes
71
- end
72
-
73
- def type()
74
- @project['type'] = get_type(Project::TOOLCHAIN)
75
- end
76
-
77
- def outdir()
78
- @logger.info "#{get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)}"
79
- end
80
-
81
- def targets()
82
- get_targets(Project::TOOLCHAIN).each do |key, value|
83
- return if value.nil?
84
- @project["target"] = Hash.new if @project["target"].nil?
85
- ta = key.upcase
86
- @project["target"][ta] = Hash.new if @project["target"][ta].nil?
87
- #do the target settings
88
- value.each_key do |subkey|
89
- methods = self.class.instance_methods(false)
90
- if methods.include?("target_#{subkey}".to_sym)
91
- send("target_#{subkey}".to_sym, key, value[subkey])
92
- else
93
- @logger.info "#{key} is not processed"
94
- end
95
- end
96
- end
97
- end
98
-
99
- # tool_chain_specific attribute for each target
100
- # Params:
101
- # - target: the name for the target
102
- # - doc: the hash that holds the data
103
- def target_tool_chain_specific(target, doc)
104
- #no specific for cmake
105
- end
106
-
107
- def save_project()
108
- path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
109
- save(File.join(@paths.rootdir_table['output_root'], path, "CMakeLists.txt"), @project)
110
- end
111
-
112
- def target_cp_defines(target, doc)
113
- ta = target.upcase
114
- @project["target"][ta]['cp_defines'] = Array.new
115
- doc.each do |d, v|
116
- if v.nil?
117
- st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d} \""
118
- else
119
- st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d}=#{v} \""
120
- end
121
- @project["target"][ta]['cp_defines'].insert(-1, st_def)
122
- end
123
- end
124
-
125
- def target_as_predefines(target, doc)
126
-
127
- end
128
-
129
- def target_as_defines(target, doc)
130
- ta = target.upcase
131
- @project["target"][ta]['as_defines'] = Array.new
132
- doc.each do | d, v|
133
- if v.nil?
134
- st_def = "SET(CMAKE_ASM_FLAGS_#{ta} \"${CMAKE_ASM_FLAGS_#{ta}} -D#{d} \""
135
- else
136
- st_def = "SET(CMAKE_ASM_FLAGS_#{ta} \"${CMAKE_ASM_FLAGS_#{ta}} -D#{d}=#{v} \""
137
- end
138
- @project["target"][ta]['as_defines'].insert(-1, st_def)
139
- end
140
- end
141
-
142
- def target_as_include(target, doc)
143
- ta = target.upcase
144
- o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
145
- proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
146
- @project["target"][ta]['as_include'] = Array.new
147
- doc.each do |inc|
148
- if inc['rootdir']
149
- full_path = @paths.fullpath(inc['rootdir'],inc['path'])
150
- else
151
- full_path = @paths.fullpath('default_path',inc['path'])
152
- end
153
- ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
154
- inc_str = "include_directories(#{ipath})"
155
- @project["target"][ta]['as_include'].insert(-1, inc_str)
156
- end
157
- end
158
-
159
- def target_as_flags(target, doc)
160
- ta = target.upcase
161
- @project["target"][ta]['as_flags'] = Array.new
162
- doc.each do |flag|
163
- @project["target"][ta]['as_flags'].insert(-1, "SET(CMAKE_ASM_FLAGS_#{ta} \"\$\{CMAKE_ASM_FLAGS_#{ta}\} #{flag}\")")
164
- end
165
- end
166
-
167
- def target_cc_predefines(target, doc)
168
-
169
- end
170
-
171
- def target_cc_preincludes(target, doc)
172
-
173
- end
174
-
175
- def target_cc_defines(target, doc)
176
- ta = target.upcase
177
- @project["target"][ta]['cc_defines'] = Array.new
178
- doc.each do |d, v|
179
- if v.nil?
180
- st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d} \""
181
- else
182
- st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d}=#{v} \""
183
- end
184
- @project["target"][ta]['cc_defines'].insert(-1, st_def)
185
- end
186
- end
187
-
188
- def target_cc_include(target, doc)
189
- ta = target.upcase
190
- o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
191
- proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
192
- @project["target"][ta]['cc_include'] = Array.new
193
- doc.each do |inc|
194
- if inc['rootdir']
195
- full_path = @paths.fullpath(inc['rootdir'],inc['path'])
196
- else
197
- full_path = @paths.fullpath('default_path',inc['path'])
198
- end
199
- ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
200
- inc_str = "include_directories(#{ipath})"
201
- @project["target"][ta]['cc_include'].insert(-1, inc_str)
202
- end
203
- end
204
-
205
- def target_cc_flags(target, doc)
206
- ta = target.upcase
207
- @project["target"][ta]['cc_flags'] = Array.new
208
- doc.each do |flag|
209
- @project["target"][ta]['cc_flags'].insert(-1, "SET(CMAKE_C_FLAGS_#{ta} \"\$\{CMAKE_C_FLAGS_#{ta}\} #{flag}\")")
210
- end
211
- end
212
-
213
- def target_cxx_predefines(target, doc)
214
-
215
- end
216
-
217
- def target_cxx_preincludes(target, doc)
218
-
219
- end
220
-
221
- def target_cxx_defines(target, doc)
222
- ta = target.upcase
223
- @project["target"][ta]['cxx_defines'] = Array.new
224
- doc.each do |d, v|
225
- if v.nil?
226
- st_def = "SET(CMAKE_CXX_FLAGS_#{ta} \"${CMAKE_CXX_FLAGS_#{ta}} -D#{d} \""
227
- else
228
- st_def = "SET(CMAKE_CXX_FLAGS_#{ta} \"${CMAKE_CXX_FLAGS_#{ta}} -D#{d}=#{v} \""
229
- end
230
- @project["target"][ta]['cxx_defines'].insert(-1, st_def)
231
- end
232
- end
233
-
234
- def target_cxx_include(target, doc)
235
- ta = target.upcase
236
- o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
237
- proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
238
- @project["target"][ta]['cxx_include'] = Array.new
239
- doc.each do |inc|
240
- if inc['rootdir']
241
- full_path = @paths.fullpath(inc['rootdir'],inc['path'])
242
- else
243
- full_path = @paths.fullpath('default_path',inc['path'])
244
- end
245
- ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
246
- inc_str = "include_directories(#{ipath})"
247
- @project["target"][ta]['cxx_include'].insert(-1, inc_str)
248
- end
249
- end
250
-
251
- def target_cxx_flags(target, doc)
252
- ta = target.upcase
253
- @project["target"][ta]['cxx_flags'] = Array.new
254
- doc.each do |flag|
255
- @project["target"][ta]['cxx_flags'].insert(-1, "SET(CMAKE_CXX_FLAGS_#{ta} \"\$\{CMAKE_CXX_FLAGS_#{ta}\} #{flag}\")")
256
- end
257
- end
258
-
259
- def target_ld_flags(target, doc)
260
- ta = target.upcase
261
- @project["target"][ta]['ld_flags'] = Array.new
262
- doc.each do |flag|
263
- @project["target"][ta]['ld_flags'].insert(-1, "SET(CMAKE_EXE_LINKER_FLAGS_#{ta} \"\$\{CMAKE_EXE_LINKER_FLAGS_#{ta}\} #{flag}\")")
264
- end
265
- end
266
-
267
- def target_libraries(target, doc)
268
- ta = target.upcase
269
- convert_string = {'DEBUG' => 'debug', 'RELEASE' => 'optimized'}
270
- @project["target"][ta]['libraries'] = Array.new
271
- header = "TARGET_LINK_LIBRARIES(#{project_name}.elf -Wl,--start-group)"
272
- @project["target"][ta]['libraries'].insert(-1, header)
273
- doc.each do |library|
274
- lib = "target_link_libraries(#{project_name}.elf #{convert_string[ta]} #{library})"
275
- @project["target"][ta]['libraries'].insert(-1, lib)
276
- end
277
- footer = "TARGET_LINK_LIBRARIES(#{project_name}.elf -Wl,--end-group)"
278
- @project["target"][ta]['libraries'].insert(-1, footer)
279
- end
280
-
281
- def target_linker_file(target, doc)
282
- ta = target.upcase
283
- o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
284
- proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
285
- @project["target"][ta]['linker_file'] = Array.new
286
- if doc['rootdir']
287
- full_path = @paths.fullpath(doc['rootdir'],doc['path'])
288
- else
289
- full_path = @paths.fullpath('default_path',doc['path'])
290
- end
291
- link = File.join("${ProjDirPath}", @paths.relpath(proj_path, full_path))
292
- linkstr = "set(CMAKE_EXE_LINKER_FLAGS_#{ta} \"${CMAKE_EXE_LINKER_FLAGS_#{ta}} -T#{link} -static\")"
293
- @project["target"][ta]['linker_file'].insert(-1, linkstr)
294
- end
295
-
296
- def target_binary_file(target, doc)
297
- ta= target.upcase
298
- @project["target"][ta]["binary_file"] = doc
299
- end
300
-
301
- def target_outdir(target, doc)
302
-
303
- end
304
- end
1
+
2
+ require_relative '_base'
3
+ require_relative '_yml_helper'
4
+ require_relative '_path_modifier'
5
+ require_relative 'cmake/txt'
6
+
7
+
8
+ #replace me when yml_merger becomes gem
9
+ require 'yml_merger'
10
+ require 'nokogiri'
11
+ require 'uri'
12
+ require 'open-uri'
13
+
14
+ module CMAKE
15
+ class Project
16
+ TOOLCHAIN='cmake'
17
+ include Base
18
+ include TXT
19
+ include UNI_Project
20
+
21
+ def initialize(project_data, generator_variable, logger = nil)
22
+ @logger = logger
23
+ unless (logger)
24
+ @logger = Logger.new(STDOUT)
25
+ @logger.level = Logger::WARN
26
+ end
27
+ set_hash(project_data)
28
+ @project_name = get_project_name()
29
+ @board = get_board()
30
+ @paths = PathModifier.new(generator_variable["paths"])
31
+ @cmake_project_files = {".txt" => nil, ".bat" => nil, ".sh" => nil}
32
+ @project = Hash.new if @project.nil?
33
+ @project["document"] = {"project_name" => @project_name, "board" => @board }
34
+ end
35
+
36
+ def generator(filter, project_data)
37
+ return if not is_toolchain_support(Project::TOOLCHAIN)
38
+ create_method(Project::TOOLCHAIN)
39
+ send(Project::TOOLCHAIN.to_sym, project_data)
40
+ save_project()
41
+ end
42
+
43
+ def source()
44
+ #add sources to target
45
+ sources = get_src_list(Project::TOOLCHAIN)
46
+ o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
47
+ proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
48
+ @project['sources'] = Array.new
49
+ sources.each do |file|
50
+ if file['rootdir']
51
+ if file.has_key? 'path'
52
+ full_path = @paths.fullpath(file['rootdir'],file['path'])
53
+ else
54
+ full_path = @paths.fullpath(file['rootdir'],file['source'])
55
+ end
56
+ else
57
+ if file.has_key? 'path'
58
+ full_path = @paths.fullpath('default_path',file['path'])
59
+ else
60
+ full_path = @paths.fullpath('default_path',file['source'])
61
+ end
62
+ end
63
+ ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
64
+ @project['sources'].insert(-1, ipath)
65
+ end
66
+
67
+ end
68
+
69
+ def templates()
70
+ #load tempaltes
71
+ end
72
+
73
+ def type()
74
+ @project['type'] = get_type(Project::TOOLCHAIN)
75
+ end
76
+
77
+ def outdir()
78
+ @logger.info "#{get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)}"
79
+ end
80
+
81
+ def targets()
82
+ get_targets(Project::TOOLCHAIN).each do |key, value|
83
+ return if value.nil?
84
+ @project["target"] = Hash.new if @project["target"].nil?
85
+ ta = key.upcase
86
+ @project["target"][ta] = Hash.new if @project["target"][ta].nil?
87
+ #do the target settings
88
+ value.each_key do |subkey|
89
+ methods = self.class.instance_methods(false)
90
+ if methods.include?("target_#{subkey}".to_sym)
91
+ send("target_#{subkey}".to_sym, key, value[subkey])
92
+ else
93
+ @logger.info "#{key} is not processed"
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ # tool_chain_specific attribute for each target
100
+ # Params:
101
+ # - target: the name for the target
102
+ # - doc: the hash that holds the data
103
+ def target_tool_chain_specific(target, doc)
104
+ #no specific for cmake
105
+ end
106
+
107
+ def save_project()
108
+ path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
109
+ save(File.join(@paths.rootdir_table['output_root'], path, "CMakeLists.txt"), @project)
110
+ end
111
+
112
+ def target_cp_defines(target, doc)
113
+ ta = target.upcase
114
+ @project["target"][ta]['cp_defines'] = Array.new
115
+ doc.each do |d, v|
116
+ if v.nil?
117
+ st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d} \""
118
+ else
119
+ st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d}=#{v} \""
120
+ end
121
+ @project["target"][ta]['cp_defines'].insert(-1, st_def)
122
+ end
123
+ end
124
+
125
+ def target_as_predefines(target, doc)
126
+
127
+ end
128
+
129
+ def target_as_defines(target, doc)
130
+ ta = target.upcase
131
+ @project["target"][ta]['as_defines'] = Array.new
132
+ doc.each do | d, v|
133
+ if v.nil?
134
+ st_def = "SET(CMAKE_ASM_FLAGS_#{ta} \"${CMAKE_ASM_FLAGS_#{ta}} -D#{d} \""
135
+ else
136
+ st_def = "SET(CMAKE_ASM_FLAGS_#{ta} \"${CMAKE_ASM_FLAGS_#{ta}} -D#{d}=#{v} \""
137
+ end
138
+ @project["target"][ta]['as_defines'].insert(-1, st_def)
139
+ end
140
+ end
141
+
142
+ def target_as_include(target, doc)
143
+ ta = target.upcase
144
+ o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
145
+ proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
146
+ @project["target"][ta]['as_include'] = Array.new
147
+ doc.each do |inc|
148
+ if inc['rootdir']
149
+ full_path = @paths.fullpath(inc['rootdir'],inc['path'])
150
+ else
151
+ full_path = @paths.fullpath('default_path',inc['path'])
152
+ end
153
+ ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
154
+ inc_str = "include_directories(#{ipath})"
155
+ @project["target"][ta]['as_include'].insert(-1, inc_str)
156
+ end
157
+ end
158
+
159
+ def target_as_flags(target, doc)
160
+ ta = target.upcase
161
+ @project["target"][ta]['as_flags'] = Array.new
162
+ doc.each do |flag|
163
+ @project["target"][ta]['as_flags'].insert(-1, "SET(CMAKE_ASM_FLAGS_#{ta} \"\$\{CMAKE_ASM_FLAGS_#{ta}\} #{flag}\")")
164
+ end
165
+ end
166
+
167
+ def target_cc_predefines(target, doc)
168
+
169
+ end
170
+
171
+ def target_cc_preincludes(target, doc)
172
+
173
+ end
174
+
175
+ def target_cc_defines(target, doc)
176
+ ta = target.upcase
177
+ @project["target"][ta]['cc_defines'] = Array.new
178
+ doc.each do |d, v|
179
+ if v.nil?
180
+ st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d} \""
181
+ else
182
+ st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d}=#{v} \""
183
+ end
184
+ @project["target"][ta]['cc_defines'].insert(-1, st_def)
185
+ end
186
+ end
187
+
188
+ def target_cc_include(target, doc)
189
+ ta = target.upcase
190
+ o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
191
+ proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
192
+ @project["target"][ta]['cc_include'] = Array.new
193
+ doc.each do |inc|
194
+ if inc['rootdir']
195
+ full_path = @paths.fullpath(inc['rootdir'],inc['path'])
196
+ else
197
+ full_path = @paths.fullpath('default_path',inc['path'])
198
+ end
199
+ ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
200
+ inc_str = "include_directories(#{ipath})"
201
+ @project["target"][ta]['cc_include'].insert(-1, inc_str)
202
+ end
203
+ end
204
+
205
+ def target_cc_flags(target, doc)
206
+ ta = target.upcase
207
+ @project["target"][ta]['cc_flags'] = Array.new
208
+ doc.each do |flag|
209
+ @project["target"][ta]['cc_flags'].insert(-1, "SET(CMAKE_C_FLAGS_#{ta} \"\$\{CMAKE_C_FLAGS_#{ta}\} #{flag}\")")
210
+ end
211
+ end
212
+
213
+ def target_cxx_predefines(target, doc)
214
+
215
+ end
216
+
217
+ def target_cxx_preincludes(target, doc)
218
+
219
+ end
220
+
221
+ def target_cxx_defines(target, doc)
222
+ ta = target.upcase
223
+ @project["target"][ta]['cxx_defines'] = Array.new
224
+ doc.each do |d, v|
225
+ if v.nil?
226
+ st_def = "SET(CMAKE_CXX_FLAGS_#{ta} \"${CMAKE_CXX_FLAGS_#{ta}} -D#{d} \""
227
+ else
228
+ st_def = "SET(CMAKE_CXX_FLAGS_#{ta} \"${CMAKE_CXX_FLAGS_#{ta}} -D#{d}=#{v} \""
229
+ end
230
+ @project["target"][ta]['cxx_defines'].insert(-1, st_def)
231
+ end
232
+ end
233
+
234
+ def target_cxx_include(target, doc)
235
+ ta = target.upcase
236
+ o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
237
+ proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
238
+ @project["target"][ta]['cxx_include'] = Array.new
239
+ doc.each do |inc|
240
+ if inc['rootdir']
241
+ full_path = @paths.fullpath(inc['rootdir'],inc['path'])
242
+ else
243
+ full_path = @paths.fullpath('default_path',inc['path'])
244
+ end
245
+ ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
246
+ inc_str = "include_directories(#{ipath})"
247
+ @project["target"][ta]['cxx_include'].insert(-1, inc_str)
248
+ end
249
+ end
250
+
251
+ def target_cxx_flags(target, doc)
252
+ ta = target.upcase
253
+ @project["target"][ta]['cxx_flags'] = Array.new
254
+ doc.each do |flag|
255
+ @project["target"][ta]['cxx_flags'].insert(-1, "SET(CMAKE_CXX_FLAGS_#{ta} \"\$\{CMAKE_CXX_FLAGS_#{ta}\} #{flag}\")")
256
+ end
257
+ end
258
+
259
+ def target_ld_flags(target, doc)
260
+ ta = target.upcase
261
+ @project["target"][ta]['ld_flags'] = Array.new
262
+ doc.each do |flag|
263
+ @project["target"][ta]['ld_flags'].insert(-1, "SET(CMAKE_EXE_LINKER_FLAGS_#{ta} \"\$\{CMAKE_EXE_LINKER_FLAGS_#{ta}\} #{flag}\")")
264
+ end
265
+ end
266
+
267
+ def target_libraries(target, doc)
268
+ ta = target.upcase
269
+ convert_string = {'DEBUG' => 'debug', 'RELEASE' => 'optimized'}
270
+ @project["target"][ta]['libraries'] = Array.new
271
+ header = "TARGET_LINK_LIBRARIES(#{@project_name}.elf -Wl,--start-group)"
272
+ @project["target"][ta]['libraries'].insert(-1, header)
273
+ doc.each do |library|
274
+ lib = "target_link_libraries(#{@project_name}.elf #{convert_string[ta]} #{library})"
275
+ @project["target"][ta]['libraries'].insert(-1, lib)
276
+ end
277
+ footer = "TARGET_LINK_LIBRARIES(#{@project_name}.elf -Wl,--end-group)"
278
+ @project["target"][ta]['libraries'].insert(-1, footer)
279
+ end
280
+
281
+ def target_linker_file(target, doc)
282
+ ta = target.upcase
283
+ o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
284
+ proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
285
+ @project["target"][ta]['linker_file'] = Array.new
286
+ if doc['rootdir']
287
+ full_path = @paths.fullpath(doc['rootdir'],doc['path'])
288
+ else
289
+ full_path = @paths.fullpath('default_path',doc['path'])
290
+ end
291
+ link = File.join("${ProjDirPath}", @paths.relpath(proj_path, full_path))
292
+ linkstr = "set(CMAKE_EXE_LINKER_FLAGS_#{ta} \"${CMAKE_EXE_LINKER_FLAGS_#{ta}} -T#{link} -static\")"
293
+ @project["target"][ta]['linker_file'].insert(-1, linkstr)
294
+ end
295
+
296
+ def target_binary_file(target, doc)
297
+ ta= target.upcase
298
+ @project["target"][ta]["binary_file"] = doc
299
+ end
300
+
301
+ def target_outdir(target, doc)
302
+
303
+ end
304
+ end
305
305
  end # end Module IAR