Class: CMAKE::Project
Constant Summary
collapse
- TOOLCHAIN =
'cmake'
Instance Method Summary
collapse
-
#generator(filter, project_data) ⇒ Object
-
#initialize(project_data, generator_variable) ⇒ 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_libraries, #get_output_dir, #get_project_name, #get_src_list, #get_target_list, #get_targets, #get_template, #get_type, #set_hash
Methods included from TXT
#save
Methods included from Base
#create_method, #process
Constructor Details
#initialize(project_data, generator_variable) ⇒ Project
Returns a new instance of Project.
21
22
23
24
25
26
27
28
29
|
# File 'lib/ebngen/adapter/cmake.rb', line 21
def initialize(project_data, generator_variable)
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
31
32
33
34
35
|
# File 'lib/ebngen/adapter/cmake.rb', line 31
def generator(filter, project_data)
create_method(Project::TOOLCHAIN)
send(Project::TOOLCHAIN.to_sym, project_data)
save_project()
end
|
#outdir ⇒ Object
63
64
65
|
# File 'lib/ebngen/adapter/cmake.rb', line 63
def outdir()
puts "#{get_output_dir(Project::TOOLCHAIN, @paths.rootdir_table)}"
end
|
#save_project ⇒ Object
93
94
95
96
|
# File 'lib/ebngen/adapter/cmake.rb', line 93
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/ebngen/adapter/cmake.rb', line 37
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 |src|
if src['rootdir']
full_path = @paths.fullpath(src['rootdir'],src['path'])
else
full_path = @paths.fullpath('default_path',src['path'])
end
ipath = File.join("$ProjDirPath$", @paths.relpath(proj_path, full_path))
@project['sources'].insert(-1, ipath)
end
end
|
#target_as_defines(target, doc) ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/ebngen/adapter/cmake.rb', line 115
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
145
146
147
148
149
150
151
|
# File 'lib/ebngen/adapter/cmake.rb', line 145
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/ebngen/adapter/cmake.rb', line 128
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
111
112
113
|
# File 'lib/ebngen/adapter/cmake.rb', line 111
def target_as_predefines(target, doc)
end
|
#target_binary_file(target, doc) ⇒ Object
282
283
284
285
|
# File 'lib/ebngen/adapter/cmake.rb', line 282
def target_binary_file(target, doc)
ta= target.upcase
@project["target"][ta]["binary_file"] = doc
end
|
#target_cc_defines(target, doc) ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/ebngen/adapter/cmake.rb', line 161
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
191
192
193
194
195
196
197
|
# File 'lib/ebngen/adapter/cmake.rb', line 191
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/ebngen/adapter/cmake.rb', line 174
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
153
154
155
|
# File 'lib/ebngen/adapter/cmake.rb', line 153
def target_cc_predefines(target, doc)
end
|
#target_cc_preincludes(target, doc) ⇒ Object
157
158
159
|
# File 'lib/ebngen/adapter/cmake.rb', line 157
def target_cc_preincludes(target, doc)
end
|
#target_cp_defines(target, doc) ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/ebngen/adapter/cmake.rb', line 98
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
207
208
209
210
211
212
213
214
215
216
217
218
|
# File 'lib/ebngen/adapter/cmake.rb', line 207
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
237
238
239
240
241
242
243
|
# File 'lib/ebngen/adapter/cmake.rb', line 237
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/ebngen/adapter/cmake.rb', line 220
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
199
200
201
|
# File 'lib/ebngen/adapter/cmake.rb', line 199
def target_cxx_predefines(target, doc)
end
|
#target_cxx_preincludes(target, doc) ⇒ Object
203
204
205
|
# File 'lib/ebngen/adapter/cmake.rb', line 203
def target_cxx_preincludes(target, doc)
end
|
#target_ld_flags(target, doc) ⇒ Object
245
246
247
248
249
250
251
|
# File 'lib/ebngen/adapter/cmake.rb', line 245
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
253
254
255
256
257
258
259
260
261
262
263
264
265
|
# File 'lib/ebngen/adapter/cmake.rb', line 253
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
# File 'lib/ebngen/adapter/cmake.rb', line 267
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
287
288
289
|
# File 'lib/ebngen/adapter/cmake.rb', line 287
def target_outdir(target, doc)
end
|
tool_chain_specific attribute for each target Params:
89
90
91
|
# File 'lib/ebngen/adapter/cmake.rb', line 89
def target_tool_chain_specific(target, doc)
end
|
#targets ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/ebngen/adapter/cmake.rb', line 67
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
puts "#{key} is not processed"
end
end
end
end
|
#templates ⇒ Object
55
56
57
|
# File 'lib/ebngen/adapter/cmake.rb', line 55
def templates()
end
|
#type ⇒ Object
59
60
61
|
# File 'lib/ebngen/adapter/cmake.rb', line 59
def type()
@project['type'] = get_type(Project::TOOLCHAIN)
end
|