Class: CMAKE::Project
Constant Summary
collapse
- TOOLCHAIN =
'cmake'
Instance Method Summary
collapse
-
#generator(filter, project_data) ⇒ Object
-
#initialize(project_data, generator_variable, logger = nil) ⇒ Project
constructor
A new instance of Project.
-
#outdir ⇒ Object
-
#save_project ⇒ Object
-
#source ⇒ Object
-
#target_as_defines(target, doc) ⇒ Object
-
#target_as_flags(target, doc) ⇒ Object
-
#target_as_include(target, doc) ⇒ Object
-
#target_as_predefines(target, doc) ⇒ Object
-
#target_binary_file(target, doc) ⇒ Object
-
#target_cc_defines(target, doc) ⇒ Object
-
#target_cc_flags(target, doc) ⇒ Object
-
#target_cc_include(target, doc) ⇒ Object
-
#target_cc_predefines(target, doc) ⇒ Object
-
#target_cc_preincludes(target, doc) ⇒ Object
-
#target_cp_defines(target, doc) ⇒ Object
-
#target_cxx_defines(target, doc) ⇒ Object
-
#target_cxx_flags(target, doc) ⇒ Object
-
#target_cxx_include(target, doc) ⇒ Object
-
#target_cxx_predefines(target, doc) ⇒ Object
-
#target_cxx_preincludes(target, doc) ⇒ Object
-
#target_ld_flags(target, doc) ⇒ Object
-
#target_libraries(target, doc) ⇒ Object
-
#target_linker_file(target, doc) ⇒ Object
-
#target_outdir(target, doc) ⇒ Object
-
#target_tool_chain_specific(target, doc) ⇒ Object
tool_chain_specific attribute for each target Params: - target: the name for the target - doc: the hash that holds the data.
-
#targets ⇒ Object
-
#templates ⇒ Object
-
#type ⇒ Object
#get_board, #get_default_project_settings, #get_default_projectset_settings, #get_libraries, #get_output_dir, #get_project_name, #get_src_list, #get_target_list, #get_targets, #get_template, #get_type, #is_toolchain_support, #set_hash
Methods included from TXT
#save
Methods included from Base
#create_method, #process
Constructor Details
#initialize(project_data, generator_variable, logger = nil) ⇒ Project
Returns a new instance of Project.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ebngen/adapter/cmake.rb', line 21
def initialize(project_data, generator_variable, logger = nil)
@logger = logger
unless (logger)
@logger = Logger.new(STDOUT)
@logger.level = Logger::WARN
end
set_hash(project_data)
@project_name = get_project_name()
@board = get_board()
@paths = PathModifier.new(generator_variable["paths"])
@cmake_project_files = {".txt" => nil, ".bat" => nil, ".sh" => nil}
@project = Hash.new if @project.nil?
@project["document"] = {"project_name" => @project_name, "board" => @board }
end
|
Instance Method Details
#generator(filter, project_data) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/ebngen/adapter/cmake.rb', line 36
def generator(filter, project_data)
return if not is_toolchain_support(Project::TOOLCHAIN)
create_method(Project::TOOLCHAIN)
send(Project::TOOLCHAIN.to_sym, project_data)
save_project()
end
|
#outdir ⇒ Object
77
78
79
|
# File 'lib/ebngen/adapter/cmake.rb', line 77
def outdir()
@logger.info "#{get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)}"
end
|
#save_project ⇒ Object
107
108
109
110
|
# File 'lib/ebngen/adapter/cmake.rb', line 107
def save_project()
path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
save(File.join(@paths.rootdir_table['output_root'], path, "CMakeLists.txt"), @project)
end
|
#source ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/ebngen/adapter/cmake.rb', line 43
def source()
sources = get_src_list(Project::TOOLCHAIN)
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
@project['sources'] = Array.new
sources.each do |file|
if file['rootdir']
if file.has_key? 'path'
full_path = @paths.fullpath(file['rootdir'],file['path'])
else
full_path = @paths.fullpath(file['rootdir'],file['source'])
end
else
if file.has_key? 'path'
full_path = @paths.fullpath('default_path',file['path'])
else
full_path = @paths.fullpath('default_path',file['source'])
end
end
ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
@project['sources'].insert(-1, ipath)
end
end
|
#target_as_defines(target, doc) ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/ebngen/adapter/cmake.rb', line 129
def target_as_defines(target, doc)
ta = target.upcase
@project["target"][ta]['as_defines'] = Array.new
doc.each do | d, v|
if v.nil?
st_def = "SET(CMAKE_ASM_FLAGS_#{ta} \"${CMAKE_ASM_FLAGS_#{ta}} -D#{d} \""
else
st_def = "SET(CMAKE_ASM_FLAGS_#{ta} \"${CMAKE_ASM_FLAGS_#{ta}} -D#{d}=#{v} \""
end
@project["target"][ta]['as_defines'].insert(-1, st_def)
end
end
|
#target_as_flags(target, doc) ⇒ Object
159
160
161
162
163
164
165
|
# File 'lib/ebngen/adapter/cmake.rb', line 159
def target_as_flags(target, doc)
ta = target.upcase
@project["target"][ta]['as_flags'] = Array.new
doc.each do |flag|
@project["target"][ta]['as_flags'].insert(-1, "SET(CMAKE_ASM_FLAGS_#{ta} \"\$\{CMAKE_ASM_FLAGS_#{ta}\} #{flag}\")")
end
end
|
#target_as_include(target, doc) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/ebngen/adapter/cmake.rb', line 142
def target_as_include(target, doc)
ta = target.upcase
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
@project["target"][ta]['as_include'] = Array.new
doc.each do |inc|
if inc['rootdir']
full_path = @paths.fullpath(inc['rootdir'],inc['path'])
else
full_path = @paths.fullpath('default_path',inc['path'])
end
ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
inc_str = "include_directories(#{ipath})"
@project["target"][ta]['as_include'].insert(-1, inc_str)
end
end
|
#target_as_predefines(target, doc) ⇒ Object
125
126
127
|
# File 'lib/ebngen/adapter/cmake.rb', line 125
def target_as_predefines(target, doc)
end
|
#target_binary_file(target, doc) ⇒ Object
296
297
298
299
|
# File 'lib/ebngen/adapter/cmake.rb', line 296
def target_binary_file(target, doc)
ta= target.upcase
@project["target"][ta]["binary_file"] = doc
end
|
#target_cc_defines(target, doc) ⇒ Object
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/ebngen/adapter/cmake.rb', line 175
def target_cc_defines(target, doc)
ta = target.upcase
@project["target"][ta]['cc_defines'] = Array.new
doc.each do |d, v|
if v.nil?
st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d} \""
else
st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d}=#{v} \""
end
@project["target"][ta]['cc_defines'].insert(-1, st_def)
end
end
|
#target_cc_flags(target, doc) ⇒ Object
205
206
207
208
209
210
211
|
# File 'lib/ebngen/adapter/cmake.rb', line 205
def target_cc_flags(target, doc)
ta = target.upcase
@project["target"][ta]['cc_flags'] = Array.new
doc.each do |flag|
@project["target"][ta]['cc_flags'].insert(-1, "SET(CMAKE_C_FLAGS_#{ta} \"\$\{CMAKE_C_FLAGS_#{ta}\} #{flag}\")")
end
end
|
#target_cc_include(target, doc) ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/ebngen/adapter/cmake.rb', line 188
def target_cc_include(target, doc)
ta = target.upcase
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
@project["target"][ta]['cc_include'] = Array.new
doc.each do |inc|
if inc['rootdir']
full_path = @paths.fullpath(inc['rootdir'],inc['path'])
else
full_path = @paths.fullpath('default_path',inc['path'])
end
ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
inc_str = "include_directories(#{ipath})"
@project["target"][ta]['cc_include'].insert(-1, inc_str)
end
end
|
#target_cc_predefines(target, doc) ⇒ Object
167
168
169
|
# File 'lib/ebngen/adapter/cmake.rb', line 167
def target_cc_predefines(target, doc)
end
|
#target_cc_preincludes(target, doc) ⇒ Object
171
172
173
|
# File 'lib/ebngen/adapter/cmake.rb', line 171
def target_cc_preincludes(target, doc)
end
|
#target_cp_defines(target, doc) ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/ebngen/adapter/cmake.rb', line 112
def target_cp_defines(target, doc)
ta = target.upcase
@project["target"][ta]['cp_defines'] = Array.new
doc.each do |d, v|
if v.nil?
st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d} \""
else
st_def = "SET(CMAKE_C_FLAGS_#{ta} \"${CMAKE_C_FLAGS_#{ta}} -D#{d}=#{v} \""
end
@project["target"][ta]['cp_defines'].insert(-1, st_def)
end
end
|
#target_cxx_defines(target, doc) ⇒ Object
221
222
223
224
225
226
227
228
229
230
231
232
|
# File 'lib/ebngen/adapter/cmake.rb', line 221
def target_cxx_defines(target, doc)
ta = target.upcase
@project["target"][ta]['cxx_defines'] = Array.new
doc.each do |d, v|
if v.nil?
st_def = "SET(CMAKE_CXX_FLAGS_#{ta} \"${CMAKE_CXX_FLAGS_#{ta}} -D#{d} \""
else
st_def = "SET(CMAKE_CXX_FLAGS_#{ta} \"${CMAKE_CXX_FLAGS_#{ta}} -D#{d}=#{v} \""
end
@project["target"][ta]['cxx_defines'].insert(-1, st_def)
end
end
|
#target_cxx_flags(target, doc) ⇒ Object
251
252
253
254
255
256
257
|
# File 'lib/ebngen/adapter/cmake.rb', line 251
def target_cxx_flags(target, doc)
ta = target.upcase
@project["target"][ta]['cxx_flags'] = Array.new
doc.each do |flag|
@project["target"][ta]['cxx_flags'].insert(-1, "SET(CMAKE_CXX_FLAGS_#{ta} \"\$\{CMAKE_CXX_FLAGS_#{ta}\} #{flag}\")")
end
end
|
#target_cxx_include(target, doc) ⇒ Object
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
# File 'lib/ebngen/adapter/cmake.rb', line 234
def target_cxx_include(target, doc)
ta = target.upcase
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
@project["target"][ta]['cxx_include'] = Array.new
doc.each do |inc|
if inc['rootdir']
full_path = @paths.fullpath(inc['rootdir'],inc['path'])
else
full_path = @paths.fullpath('default_path',inc['path'])
end
ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
inc_str = "include_directories(#{ipath})"
@project["target"][ta]['cxx_include'].insert(-1, inc_str)
end
end
|
#target_cxx_predefines(target, doc) ⇒ Object
213
214
215
|
# File 'lib/ebngen/adapter/cmake.rb', line 213
def target_cxx_predefines(target, doc)
end
|
#target_cxx_preincludes(target, doc) ⇒ Object
217
218
219
|
# File 'lib/ebngen/adapter/cmake.rb', line 217
def target_cxx_preincludes(target, doc)
end
|
#target_ld_flags(target, doc) ⇒ Object
259
260
261
262
263
264
265
|
# File 'lib/ebngen/adapter/cmake.rb', line 259
def target_ld_flags(target, doc)
ta = target.upcase
@project["target"][ta]['ld_flags'] = Array.new
doc.each do |flag|
@project["target"][ta]['ld_flags'].insert(-1, "SET(CMAKE_EXE_LINKER_FLAGS_#{ta} \"\$\{CMAKE_EXE_LINKER_FLAGS_#{ta}\} #{flag}\")")
end
end
|
#target_libraries(target, doc) ⇒ Object
267
268
269
270
271
272
273
274
275
276
277
278
279
|
# File 'lib/ebngen/adapter/cmake.rb', line 267
def target_libraries(target, doc)
ta = target.upcase
convert_string = {'DEBUG' => 'debug', 'RELEASE' => 'optimized'}
@project["target"][ta]['libraries'] = Array.new
= "TARGET_LINK_LIBRARIES(#{@project_name}.elf -Wl,--start-group)"
@project["target"][ta]['libraries'].insert(-1, )
doc.each do |library|
lib = "target_link_libraries(#{@project_name}.elf #{convert_string[ta]} #{library})"
@project["target"][ta]['libraries'].insert(-1, lib)
end
= "TARGET_LINK_LIBRARIES(#{@project_name}.elf -Wl,--end-group)"
@project["target"][ta]['libraries'].insert(-1, )
end
|
#target_linker_file(target, doc) ⇒ Object
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
# File 'lib/ebngen/adapter/cmake.rb', line 281
def target_linker_file(target, doc)
ta = target.upcase
o_path = get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)
proj_path = File.join(@paths.rootdir_table['output_root'], o_path)
@project["target"][ta]['linker_file'] = Array.new
if doc['rootdir']
full_path = @paths.fullpath(doc['rootdir'],doc['path'])
else
full_path = @paths.fullpath('default_path',doc['path'])
end
link = File.join("${ProjDirPath}", @paths.relpath(proj_path, full_path))
linkstr = "set(CMAKE_EXE_LINKER_FLAGS_#{ta} \"${CMAKE_EXE_LINKER_FLAGS_#{ta}} -T#{link} -static\")"
@project["target"][ta]['linker_file'].insert(-1, linkstr)
end
|
#target_outdir(target, doc) ⇒ Object
301
302
303
|
# File 'lib/ebngen/adapter/cmake.rb', line 301
def target_outdir(target, doc)
end
|
tool_chain_specific attribute for each target Params:
103
104
105
|
# File 'lib/ebngen/adapter/cmake.rb', line 103
def target_tool_chain_specific(target, doc)
end
|
#targets ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/ebngen/adapter/cmake.rb', line 81
def targets()
get_targets(Project::TOOLCHAIN).each do |key, value|
return if value.nil?
@project["target"] = Hash.new if @project["target"].nil?
ta = key.upcase
@project["target"][ta] = Hash.new if @project["target"][ta].nil?
value.each_key do |subkey|
methods = self.class.instance_methods(false)
if methods.include?("target_#{subkey}".to_sym)
send("target_#{subkey}".to_sym, key, value[subkey])
else
@logger.info "#{key} is not processed"
end
end
end
end
|
#templates ⇒ Object
69
70
71
|
# File 'lib/ebngen/adapter/cmake.rb', line 69
def templates()
end
|
#type ⇒ Object
73
74
75
|
# File 'lib/ebngen/adapter/cmake.rb', line 73
def type()
@project['type'] = get_type(Project::TOOLCHAIN)
end
|