cxxproject 0.4.6 → 0.5.47
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +101 -54
- data/bin/cxx +4 -4
- data/lib/cxxproject/buildingblocks/binary_library.rb +32 -9
- data/lib/cxxproject/buildingblocks/building_block.rb +220 -74
- data/lib/cxxproject/buildingblocks/command_line.rb +70 -21
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +33 -9
- data/lib/cxxproject/buildingblocks/executable.rb +228 -33
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +69 -43
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -0
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +29 -30
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +343 -64
- data/lib/cxxproject/buildingblocks/makefile.rb +142 -24
- data/lib/cxxproject/buildingblocks/module.rb +27 -6
- data/lib/cxxproject/buildingblocks/single_source.rb +26 -4
- data/lib/cxxproject/buildingblocks/source_library.rb +113 -20
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -0
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +33 -0
- data/lib/cxxproject/errorparser/error_parser.rb +50 -0
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +29 -0
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +29 -0
- data/lib/cxxproject/eval_context.rb +136 -0
- data/lib/cxxproject/ext/file.rb +71 -0
- data/lib/cxxproject/ext/filelist.rb +6 -0
- data/lib/cxxproject/ext/progressbar.rb +20 -0
- data/lib/cxxproject/ext/rake.rb +397 -0
- data/lib/cxxproject/{extensions/rake_listener_ext.rb → ext/rake_listener.rb} +18 -12
- data/lib/cxxproject/ext/stdout.rb +44 -0
- data/lib/cxxproject/ide_interface.rb +181 -0
- data/lib/cxxproject/toolchain/clang.rb +39 -0
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -0
- data/lib/cxxproject/toolchain/diab.rb +36 -33
- data/lib/cxxproject/toolchain/gcc.rb +16 -8
- data/lib/cxxproject/toolchain/provider.rb +112 -2
- data/lib/cxxproject/toolchain/ti.rb +50 -0
- data/lib/cxxproject/toolchain/toolchain.rb +38 -0
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -0
- data/lib/cxxproject/torake.rb +181 -123
- data/lib/cxxproject/utils/cleanup.rb +20 -0
- data/lib/cxxproject/utils/console.rb +6 -0
- data/lib/cxxproject/utils/exit_helper.rb +40 -0
- data/lib/cxxproject/utils/graphstream.rb +154 -0
- data/lib/cxxproject/utils/optional.rb +16 -0
- data/lib/cxxproject/utils/printer.rb +50 -0
- data/lib/cxxproject/utils/process.rb +53 -0
- data/lib/cxxproject/utils/progress.rb +66 -0
- data/lib/cxxproject/utils/progress_helper.rb +77 -0
- data/lib/cxxproject/utils/rbcurse.rb +284 -0
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -0
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -0
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -0
- data/lib/cxxproject/utils/stats.rb +60 -0
- data/lib/cxxproject/utils/ubigraph.rb +179 -188
- data/lib/cxxproject/utils/utils.rb +29 -25
- data/lib/cxxproject/version.rb +7 -0
- data/lib/cxxproject.rb +13 -7
- data/lib/tools/project_wizard.rb +66 -0
- data/spec/building_block_spec.rb +50 -6
- data/spec/{build_dependencies_spec.rb → cxxproject_2_rake_spec.rb} +82 -65
- data/spec/file_ext_spec.rb +30 -0
- data/spec/ide_interface_spec.rb +41 -0
- data/spec/object_dependency_spec.rb +83 -0
- data/spec/project_path_spec.rb +14 -16
- data/spec/rake_listener_ext_spec.rb +38 -5
- data/spec/spec_helper.rb +18 -0
- data/spec/testdata/basic/lib2/project.rb +1 -1
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +1 -1
- data/spec/toolchain_spec.rb +29 -0
- metadata +91 -58
- data/lib/cxxproject/extensions/file_ext.rb +0 -47
- data/lib/cxxproject/extensions/rake_ext.rb +0 -158
- data/lib/cxxproject/extensions/stdout_ext.rb +0 -35
- data/lib/cxxproject/task_maker.rb +0 -418
- data/lib/cxxproject/testinstanceeval.rb +0 -65
- data/lib/cxxproject/toolchain/base.rb +0 -98
- data/lib/cxxproject/torake/compiler.rb +0 -10
- data/lib/cxxproject/torake/gcccompiler.rb +0 -7
- data/lib/cxxproject/torake/osxcompiler.rb +0 -7
- data/lib/cxxproject/utils/dot/building_block_graph_writer.rb +0 -19
- data/lib/cxxproject/utils/dot/graph_writer.rb +0 -53
- data/lib/cxxproject/utils/dot/task_graph_writer.rb +0 -34
- data/lib/tools/projectWizard.rb +0 -44
- data/spec/dir_spec.rb +0 -13
- /data/lib/cxxproject/{extensions/rake_dirty_ext.rb → ext/rake_dirty.rb} +0 -0
- /data/lib/cxxproject/{extensions/string_ext.rb → ext/string.rb} +0 -0
@@ -1,418 +0,0 @@
|
|
1
|
-
require 'cxxproject/buildingblocks/module'
|
2
|
-
require 'cxxproject/buildingblocks/makefile'
|
3
|
-
require 'cxxproject/buildingblocks/executable'
|
4
|
-
require 'cxxproject/buildingblocks/source_library'
|
5
|
-
require 'cxxproject/buildingblocks/single_source'
|
6
|
-
require 'cxxproject/buildingblocks/binary_library'
|
7
|
-
require 'cxxproject/buildingblocks/custom_building_block'
|
8
|
-
require 'cxxproject/buildingblocks/command_line'
|
9
|
-
require 'cxxproject/extensions/rake_ext'
|
10
|
-
require 'cxxproject/extensions/file_ext'
|
11
|
-
require 'cxxproject/utils/dot/graph_writer'
|
12
|
-
|
13
|
-
require 'logger'
|
14
|
-
require 'yaml'
|
15
|
-
require 'tmpdir'
|
16
|
-
|
17
|
-
|
18
|
-
# A class which encapsulates the generation of c/cpp artifacts like object-files, libraries and so on
|
19
|
-
class TaskMaker
|
20
|
-
|
21
|
-
def initialize(logger)
|
22
|
-
@log = logger
|
23
|
-
end
|
24
|
-
|
25
|
-
def set_loglevel(level)
|
26
|
-
@log.level = level
|
27
|
-
end
|
28
|
-
|
29
|
-
def add_file_to_clean_task(name)
|
30
|
-
CLEAN.include(name)
|
31
|
-
end
|
32
|
-
def add_task_to_clean_task(task)
|
33
|
-
Rake.application["clean"].enhance([task])
|
34
|
-
end
|
35
|
-
def already_added_to_clean?(task)
|
36
|
-
Rake.application["clean"].prerequisites.include?task
|
37
|
-
end
|
38
|
-
|
39
|
-
# this is the main api for the task_maker
|
40
|
-
# it will create the tasks that are needed in order to create
|
41
|
-
# one building block
|
42
|
-
#
|
43
|
-
# a building-block can be one of the following:
|
44
|
-
# * a source-library-block (a static lib that will be created)
|
45
|
-
# * an executable-block (which itself might need other libraries)
|
46
|
-
# * a binary-library-block (for which we do not need to do anything since it is already done)
|
47
|
-
# * a custom building block
|
48
|
-
# * a compile-only source file block
|
49
|
-
def create_tasks_for_building_block(bb)
|
50
|
-
@log.debug "create tasks for: #{bb.name}"
|
51
|
-
CLOBBER.include(bb.complete_output_dir)
|
52
|
-
|
53
|
-
bb.calc_transitive_dependencies()
|
54
|
-
|
55
|
-
res = nil
|
56
|
-
if HasSources === bb
|
57
|
-
res = create_tasks_for_buildingblock_with_sources(bb)
|
58
|
-
else
|
59
|
-
if (bb.instance_of?(BinaryLibrary)) then
|
60
|
-
res = create_binary_lib_task(bb)
|
61
|
-
elsif (bb.instance_of?(CustomBuildingBlock)) then
|
62
|
-
# todo...
|
63
|
-
elsif (bb.instance_of?(CommandLine)) then
|
64
|
-
res = create_commandline_task(bb)
|
65
|
-
elsif (bb.instance_of?(Makefile)) then
|
66
|
-
res = create_makefile_task(bb)
|
67
|
-
else
|
68
|
-
raise 'unknown building block'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
init_show_in_graph_flags(bb)
|
73
|
-
add_building_block_deps_as_prerequisites(bb,res)
|
74
|
-
res
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def create_tasks_for_buildingblock_with_sources(bb)
|
80
|
-
res = nil
|
81
|
-
bb.calc_compiler_strings()
|
82
|
-
object_tasks, objects_multitask = create_tasks_for_objects(bb)
|
83
|
-
if (bb.instance_of?(SourceLibrary)) then
|
84
|
-
res = create_source_lib(bb, object_tasks, objects_multitask)
|
85
|
-
elsif (bb.instance_of?(Executable)) then
|
86
|
-
res = create_exe_task(bb, object_tasks, objects_multitask)
|
87
|
-
elsif (bb.instance_of?(SingleSource)) then
|
88
|
-
res = create_single_source_task(bb, objects_multitask)
|
89
|
-
elsif (bb.instance_of?(ModuleBuildingBlock)) then
|
90
|
-
res = task bb.get_task_name
|
91
|
-
res.transparent_timestamp = true
|
92
|
-
end
|
93
|
-
res
|
94
|
-
end
|
95
|
-
|
96
|
-
def create_binary_lib_task(bb)
|
97
|
-
res = task bb.get_task_name
|
98
|
-
def res.needed?
|
99
|
-
return false
|
100
|
-
end
|
101
|
-
res.transparent_timestamp = true
|
102
|
-
res
|
103
|
-
end
|
104
|
-
|
105
|
-
def init_show_in_graph_flags(bb)
|
106
|
-
bb.config_files.each do |cf|
|
107
|
-
# Rake.application[cf].showInGraph = GraphWriter::NO
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# convert building block deps to rake task prerequisites (e.g. exe needs lib)
|
112
|
-
def add_building_block_deps_as_prerequisites(bb,res)
|
113
|
-
bb.dependencies.reverse.each do |d|
|
114
|
-
begin
|
115
|
-
raise "ERROR: tried to add the dependencies of \"#{d}\" to \"#{bb.name}\" but such a building block could not be found!" unless ALL_BUILDING_BLOCKS[d]
|
116
|
-
res.prerequisites.unshift(ALL_BUILDING_BLOCKS[d].get_task_name)
|
117
|
-
rescue Exception => e
|
118
|
-
puts e
|
119
|
-
exit
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def create_single_source_task(bb, objects_multitask)
|
125
|
-
res = nil
|
126
|
-
if objects_multitask
|
127
|
-
res = objects_multitask
|
128
|
-
namespace "compile" do
|
129
|
-
desc "compile sources in #{bb.name}-configuration"
|
130
|
-
task bb.name => objects_multitask
|
131
|
-
end
|
132
|
-
objects_multitask.add_description("compile sources only")
|
133
|
-
end
|
134
|
-
res
|
135
|
-
end
|
136
|
-
|
137
|
-
def create_tasks_for_objects(bb)
|
138
|
-
object_tasks = create_object_file_tasks(bb)
|
139
|
-
objects_multitask = []
|
140
|
-
if object_tasks.length > 0
|
141
|
-
objects_multitask = multitask bb.get_sources_task_name => object_tasks
|
142
|
-
def objects_multitask.needed?
|
143
|
-
return false
|
144
|
-
end
|
145
|
-
objects_multitask.transparent_timestamp = true
|
146
|
-
end
|
147
|
-
[object_tasks,objects_multitask]
|
148
|
-
end
|
149
|
-
|
150
|
-
def convert_depfile(depfile, bb)
|
151
|
-
deps = ""
|
152
|
-
File.open(depfile, "r") do |infile|
|
153
|
-
while (line = infile.gets)
|
154
|
-
deps << line
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
deps = deps.gsub(/\\\n/,'').split()[1..-1]
|
159
|
-
deps.map!{|d| File.expand_path(d)}
|
160
|
-
|
161
|
-
FileUtils.mkpath File.dirname(depfile)
|
162
|
-
File.open(depfile, 'wb') do |f|
|
163
|
-
f.write(deps.to_yaml)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def create_apply_task(depfile,outfileTask,bb)
|
168
|
-
res = task "#{depfile}.apply" do |task|
|
169
|
-
deps = nil
|
170
|
-
begin
|
171
|
-
deps = YAML.load_file(depfile)
|
172
|
-
rescue
|
173
|
-
deps = nil
|
174
|
-
# may happen if depfile was not converted the last time
|
175
|
-
end
|
176
|
-
if (deps)
|
177
|
-
outfileTask.enhance(deps)
|
178
|
-
else
|
179
|
-
def outfileTask.needed?
|
180
|
-
true
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
res.showInGraph = GraphWriter::NO
|
185
|
-
res.transparent_timestamp = true
|
186
|
-
res
|
187
|
-
end
|
188
|
-
|
189
|
-
def create_object_file_tasks(bb)
|
190
|
-
tasks = []
|
191
|
-
|
192
|
-
bb.sources.each do |s|
|
193
|
-
type = bb.get_source_type(s)
|
194
|
-
if type.nil?
|
195
|
-
puts "Warning: no valid source type for #{File.relFromTo(s,bb.project_dir)}, will be ignored!"
|
196
|
-
next
|
197
|
-
end
|
198
|
-
|
199
|
-
source = File.relFromTo(s,bb.project_dir)
|
200
|
-
object = bb.get_object_file(s)
|
201
|
-
depfile = bb.get_dep_file(object)
|
202
|
-
|
203
|
-
if bb.tcs4source().include?s
|
204
|
-
tcs = bb.tcs4source()[s]
|
205
|
-
iString = bb.get_include_string(tcs, type)
|
206
|
-
dString = bb.get_define_string(tcs, type)
|
207
|
-
else
|
208
|
-
tcs = bb.tcs
|
209
|
-
iString = bb.include_string(type)
|
210
|
-
dString = bb.define_string(type)
|
211
|
-
end
|
212
|
-
|
213
|
-
compiler = tcs[:COMPILER][type]
|
214
|
-
depStr = type == :ASM ? "" : (compiler[:DEP_FLAGS] + depfile) # -MMD -MF debug/src/abc.o.d
|
215
|
-
|
216
|
-
cmd = [compiler[:COMMAND], # g++
|
217
|
-
compiler[:COMPILE_FLAGS], # -c
|
218
|
-
depStr,
|
219
|
-
compiler[:FLAGS], # -g3
|
220
|
-
iString, # -I include
|
221
|
-
dString, # -DDEBUG
|
222
|
-
compiler[:OBJECT_FILE_FLAG], # -o
|
223
|
-
object, # debug/src/abc.o
|
224
|
-
source # src/abc.cpp
|
225
|
-
].reject{|e| e == ""}.join(" ")
|
226
|
-
|
227
|
-
add_file_to_clean_task(depfile) if depStr != ""
|
228
|
-
add_file_to_clean_task(object)
|
229
|
-
|
230
|
-
outfileTask = file object => source do
|
231
|
-
puts cmd
|
232
|
-
puts `#{cmd + " 2>&1"}`
|
233
|
-
raise "System command failed" if $?.to_i != 0
|
234
|
-
convert_depfile(depfile, bb) if depStr != ""
|
235
|
-
end
|
236
|
-
outfileTask.showInGraph = GraphWriter::DETAIL
|
237
|
-
outfileTask.enhance(bb.config_files)
|
238
|
-
set_output_dir(object, outfileTask)
|
239
|
-
outfileTask.enhance([create_apply_task(depfile,outfileTask,bb)]) if depStr != ""
|
240
|
-
tasks << outfileTask
|
241
|
-
end
|
242
|
-
tasks
|
243
|
-
end
|
244
|
-
|
245
|
-
def create_commandline_task(bb)
|
246
|
-
res = task bb.get_task_name do
|
247
|
-
cmd = bb.get_command_line
|
248
|
-
puts cmd
|
249
|
-
puts `#{cmd + " 2>&1"}`
|
250
|
-
raise "System command failed" if $?.to_i != 0
|
251
|
-
end
|
252
|
-
res.transparent_timestamp = true
|
253
|
-
res
|
254
|
-
end
|
255
|
-
|
256
|
-
def create_makefile_task(bb)
|
257
|
-
mfile = bb.get_makefile()
|
258
|
-
cmd = [bb.tcs[:MAKE][:COMMAND], # make
|
259
|
-
bb.get_target, # all
|
260
|
-
bb.tcs[:MAKE][:MAKE_FLAGS], # ??
|
261
|
-
bb.tcs[:MAKE][:FLAGS], # -j
|
262
|
-
bb.tcs[:MAKE][:DIR_FLAG], # -C
|
263
|
-
File.dirname(mfile), # x/y
|
264
|
-
bb.tcs[:MAKE][:FILE_FLAG], # -f
|
265
|
-
File.basename(mfile) # x/y/makefile
|
266
|
-
].reject{|e| e == ""}.join(" ")
|
267
|
-
mfileTask = task bb.get_task_name do
|
268
|
-
puts cmd
|
269
|
-
puts `#{cmd + " 2>&1"}`
|
270
|
-
raise "System command failed" if $?.to_i != 0
|
271
|
-
end
|
272
|
-
mfileTask.transparent_timestamp = true
|
273
|
-
mfileTask.enhance(bb.config_files)
|
274
|
-
|
275
|
-
# generate the clean task
|
276
|
-
if not already_added_to_clean?(mfile+"Clean")
|
277
|
-
cmdClean = [bb.tcs[:MAKE][:COMMAND], # make
|
278
|
-
bb.tcs[:MAKE][:CLEAN], # clean
|
279
|
-
bb.tcs[:MAKE][:DIR_FLAG], # -C
|
280
|
-
File.dirname(mfile), # x/y
|
281
|
-
bb.tcs[:MAKE][:FILE_FLAG], # -f
|
282
|
-
File.basename(mfile) # x/y/makefile
|
283
|
-
].reject{|e| e == ""}.join(" ")
|
284
|
-
mfileCleanTask = task mfile+"Clean" do
|
285
|
-
puts cmdClean
|
286
|
-
puts `#{cmdClean + " 2>&1"}`
|
287
|
-
raise "System command failed" if $?.to_i != 0
|
288
|
-
end
|
289
|
-
add_task_to_clean_task(mfileCleanTask)
|
290
|
-
end
|
291
|
-
mfileTask
|
292
|
-
end
|
293
|
-
|
294
|
-
# task that will link the given object files to a static lib
|
295
|
-
#
|
296
|
-
def create_source_lib(bb, objects, object_multitask)
|
297
|
-
archive = bb.get_archive_name()
|
298
|
-
|
299
|
-
cmd = [bb.tcs[:ARCHIVER][:COMMAND], # ar
|
300
|
-
bb.tcs[:ARCHIVER][:ARCHIVE_FLAGS], # -r
|
301
|
-
bb.tcs[:ARCHIVER][:FLAGS], # ??
|
302
|
-
archive, # debug/x.a
|
303
|
-
objects.reject{|e| e == ""}.join(" ") # debug/src/abc.o debug/src/xy.o
|
304
|
-
].reject{|e| e == ""}.join(" ")
|
305
|
-
|
306
|
-
res = file archive => object_multitask do
|
307
|
-
puts cmd
|
308
|
-
puts `#{cmd + " 2>&1"}`
|
309
|
-
raise "System command failed" if $?.to_i != 0
|
310
|
-
end
|
311
|
-
add_file_to_clean_task(archive)
|
312
|
-
res.enhance(bb.config_files)
|
313
|
-
set_output_dir(archive, res)
|
314
|
-
namespace 'lib' do
|
315
|
-
desc archive
|
316
|
-
task bb.name => archive
|
317
|
-
end
|
318
|
-
res
|
319
|
-
end
|
320
|
-
|
321
|
-
# create a task that will link an executable from a set of object files
|
322
|
-
#
|
323
|
-
def create_exe_task(bb, objects, object_multitask)
|
324
|
-
executable = bb.get_executable_name()
|
325
|
-
add_file_to_clean_task(executable)
|
326
|
-
scriptFile = ""
|
327
|
-
script = ""
|
328
|
-
if bb.linker_script
|
329
|
-
scriptFile = File.relFromTo(bb.linker_script, bb.project_dir)
|
330
|
-
script = "#{bb.tcs[:LINKER][:SCRIPT]} #{scriptFile}" # -T xy/xy.dld
|
331
|
-
end
|
332
|
-
|
333
|
-
mapfile = bb.mapfile ? "#{bb.tcs[:LINKER][:MAP_FILE_FLAG]} >#{File.relFromTo(bb.mapfile, bb.complete_output_dir)}" : "" # -Wl,-m6 > xy.map
|
334
|
-
|
335
|
-
# calc linkerLibString (two steps for removing duplicates)
|
336
|
-
lib_searchpaths_array = []
|
337
|
-
libs_to_search_array = []
|
338
|
-
user_libs_array = []
|
339
|
-
libs_with_path_array = []
|
340
|
-
deps = bb.all_dependencies
|
341
|
-
deps.each do |e|
|
342
|
-
d = ALL_BUILDING_BLOCKS[e]
|
343
|
-
next if not HasLibraries === d
|
344
|
-
d.lib_searchpaths.each { |k| lib_searchpaths_array << File.relFromTo(k, d.project_dir) }
|
345
|
-
d.libs_to_search.each { |k| libs_to_search_array << k }
|
346
|
-
d.user_libs.each { |k| user_libs_array << k }
|
347
|
-
d.libs_with_path.each { |k| libs_with_path_array << File.relFromTo(k, d.project_dir) }
|
348
|
-
end
|
349
|
-
strArray = []
|
350
|
-
lib_searchpaths_array.uniq.each { |k| strArray << "#{bb.tcs[:LINKER][:LIB_PATH_FLAG]}#{k}" }
|
351
|
-
libs_to_search_array.uniq.each { |k| strArray << "#{bb.tcs[:LINKER][:LIB_FLAG]}#{k}" }
|
352
|
-
user_libs_array.uniq.each { |k| strArray << "#{bb.tcs[:LINKER][:USER_LIB_FLAG]}#{k}" }
|
353
|
-
libs_with_path_array.uniq.each { |k| strArray << "#{k}" }
|
354
|
-
linkerLibString = strArray.reject{|e| e == ""}.join(" ")
|
355
|
-
|
356
|
-
cmd = [bb.tcs[:LINKER][:COMMAND], # g++
|
357
|
-
bb.tcs[:LINKER][:MUST_FLAGS], # ??
|
358
|
-
bb.tcs[:LINKER][:FLAGS], # --all_load
|
359
|
-
bb.tcs[:LINKER][:EXE_FLAG], # -o
|
360
|
-
executable, # debug/x.o
|
361
|
-
objects.reject{|e| e == ""}.join(" "), # debug/src/abc.o debug/src/xy.o
|
362
|
-
script,
|
363
|
-
mapfile,
|
364
|
-
bb.tcs[:LINKER][:LIB_PREFIX_FLAGS], # "-Wl,--whole-archive "
|
365
|
-
linkerLibString,
|
366
|
-
bb.tcs[:LINKER][:LIB_POSTFIX_FLAGS] # "-Wl,--no-whole-archive "
|
367
|
-
].reject{|e| e == ""}.join(" ")
|
368
|
-
|
369
|
-
create_run_task(executable, bb.config_files, bb.name)
|
370
|
-
|
371
|
-
res = file executable => object_multitask do
|
372
|
-
# TempFile used, because some compilers, e.g. diab, uses ">" for piping to map files:
|
373
|
-
puts cmd
|
374
|
-
puts `#{cmd + " 2>" + get_temp_filename}`
|
375
|
-
puts read_temp_file
|
376
|
-
raise "System command failed" if $?.to_i != 0
|
377
|
-
end
|
378
|
-
res.enhance(bb.config_files)
|
379
|
-
res.enhance([scriptFile]) unless scriptFile==""
|
380
|
-
set_output_dir(executable, res)
|
381
|
-
|
382
|
-
namespace 'exe' do
|
383
|
-
desc executable
|
384
|
-
task bb.name => executable
|
385
|
-
end
|
386
|
-
res
|
387
|
-
end
|
388
|
-
|
389
|
-
def create_run_task(executable, configFiles, name)
|
390
|
-
namespace 'run' do
|
391
|
-
desc "run executable #{executable}"
|
392
|
-
task name => executable do
|
393
|
-
sh "#{executable}"
|
394
|
-
end
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
def set_output_dir(file, taskOfFile)
|
399
|
-
outputdir = File.dirname(file)
|
400
|
-
directory outputdir
|
401
|
-
taskOfFile.enhance([outputdir])
|
402
|
-
end
|
403
|
-
|
404
|
-
def get_temp_filename
|
405
|
-
Dir.tmpdir + "/lake.tmp"
|
406
|
-
end
|
407
|
-
|
408
|
-
def read_temp_file
|
409
|
-
lines = []
|
410
|
-
File.open(get_temp_filename, "r") do |infile|
|
411
|
-
while (line = infile.gets)
|
412
|
-
lines << line
|
413
|
-
end
|
414
|
-
end
|
415
|
-
lines
|
416
|
-
end
|
417
|
-
|
418
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
|
3
|
-
project_string = 'cxx_configuration "debug" do
|
4
|
-
exe "basic",
|
5
|
-
:sources => FileList.new("**/*.cpp"),
|
6
|
-
:dependencies => ["2"]
|
7
|
-
exe "debug",
|
8
|
-
:sources => FileList.new("**/*.cpp"),
|
9
|
-
:dependencies => ["abc"]
|
10
|
-
end'
|
11
|
-
# project_string = 'cxx_configuration "debug" do
|
12
|
-
# [exe ("basic", :sources => FileList.new("**/*.cpp")),
|
13
|
-
# exe ("next",{})]
|
14
|
-
# end'
|
15
|
-
class EvalContext
|
16
|
-
|
17
|
-
attr_accessor :name, :myblock
|
18
|
-
|
19
|
-
def cxx_configuration(name, &block)
|
20
|
-
puts "calling cxx_configuration with name: #{name}"
|
21
|
-
@myblock = block
|
22
|
-
@name = name
|
23
|
-
end
|
24
|
-
|
25
|
-
def eval_project(project_text)
|
26
|
-
instance_eval(project_text)
|
27
|
-
puts "instance_eval with #{project_text}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def configuration(*args, &block)
|
31
|
-
name = args[0]
|
32
|
-
raise "no name given" unless name.is_a?(String) && !name.strip.empty?
|
33
|
-
instance_eval(&block)
|
34
|
-
end
|
35
|
-
|
36
|
-
def check_hash(hash,allowed)
|
37
|
-
puts "hash" + hash.inspect
|
38
|
-
hash.keys.map {|k| raise "#{k} is not a valid specifier!" unless allowed.include?(k) }
|
39
|
-
end
|
40
|
-
|
41
|
-
def exe(name, hash)
|
42
|
-
puts "inside exe"
|
43
|
-
raise "not a hash" unless hash.is_a?(Hash)
|
44
|
-
check_hash hash,[:sources,:includes,:dependencies]
|
45
|
-
puts "sources are: #{hash[:sources]}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def source_lib(name, hash)
|
49
|
-
raise "not a hash" unless hash.is_a?(Hash)
|
50
|
-
check_hash hash,[:sources,:includes,:dependencies]
|
51
|
-
raise ":sources need to be defined" unless hash.has_key?(:sources)
|
52
|
-
puts "sources are: #{hash[:sources]}"
|
53
|
-
end
|
54
|
-
|
55
|
-
def compile(name, hash)
|
56
|
-
raise "not a hash" unless hash.is_a?(Hash)
|
57
|
-
check_hash hash,[:sources,:includes]
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
loadContext = EvalContext.new
|
63
|
-
loadContext.eval_project(project_string)
|
64
|
-
loadContext.myblock.call()
|
65
|
-
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module Cxxproject
|
2
|
-
module Toolchain
|
3
|
-
|
4
|
-
class Provider
|
5
|
-
@@settings = {}
|
6
|
-
@@default = {
|
7
|
-
:COMPILER =>
|
8
|
-
{
|
9
|
-
:CPP => {
|
10
|
-
:COMMAND => "",
|
11
|
-
:DEFINE_FLAG => "",
|
12
|
-
:OBJECT_FILE_FLAG => "",
|
13
|
-
:INCLUDE_PATH_FLAG => "",
|
14
|
-
:COMPILE_FLAGS => "",
|
15
|
-
:DEFINES => [],
|
16
|
-
:FLAGS => "",
|
17
|
-
:SOURCE_FILE_ENDINGS => [".cxx", ".cpp", ".c++", ".cc", ".C"],
|
18
|
-
:DEP_FLAGS => ""
|
19
|
-
},
|
20
|
-
:C => {
|
21
|
-
:COMMAND => "",
|
22
|
-
:DEFINE_FLAG => "",
|
23
|
-
:OBJECT_FILE_FLAG => "",
|
24
|
-
:INCLUDE_PATH_FLAG => "",
|
25
|
-
:COMPILE_FLAGS => "",
|
26
|
-
:DEFINES => [],
|
27
|
-
:FLAGS => "",
|
28
|
-
:SOURCE_FILE_ENDINGS => [".c"],
|
29
|
-
:DEP_FLAGS => ""
|
30
|
-
},
|
31
|
-
:ASM => {
|
32
|
-
:COMMAND => "",
|
33
|
-
:DEFINE_FLAG => "",
|
34
|
-
:OBJECT_FILE_FLAG => "",
|
35
|
-
:INCLUDE_PATH_FLAG => "",
|
36
|
-
:COMPILE_FLAGS => "",
|
37
|
-
:DEFINES => [],
|
38
|
-
:FLAGS => "",
|
39
|
-
:SOURCE_FILE_ENDINGS => [".asm", ".s", ".S"],
|
40
|
-
:DEP_FLAGS => ""
|
41
|
-
}
|
42
|
-
},
|
43
|
-
|
44
|
-
:ARCHIVER =>
|
45
|
-
{
|
46
|
-
:COMMAND => "",
|
47
|
-
:ARCHIVE_FLAGS => "",
|
48
|
-
:FLAGS => ""
|
49
|
-
},
|
50
|
-
|
51
|
-
:LINKER =>
|
52
|
-
{
|
53
|
-
:COMMAND => "",
|
54
|
-
:MUST_FLAGS => "",
|
55
|
-
:SCRIPT => "",
|
56
|
-
:USER_LIB_FLAG => "",
|
57
|
-
:EXE_FLAG => "",
|
58
|
-
:LIB_FLAG => "",
|
59
|
-
:LIB_PATH_FLAG => "",
|
60
|
-
:LIB_PREFIX_FLAGS => "", # "-Wl,--whole-archive",
|
61
|
-
:LIB_POSTFIX_FLAGS => "", # "-Wl,--no-whole-archive",
|
62
|
-
:FLAGS => "",
|
63
|
-
:MAP_FILE_FLAG => "",
|
64
|
-
:OUTPUT_ENDING => ".exe", # or .elf
|
65
|
-
},
|
66
|
-
|
67
|
-
:MAKE =>
|
68
|
-
{
|
69
|
-
:COMMAND => "make",
|
70
|
-
:MAKE_FLAGS => "",
|
71
|
-
:FLAGS => "-j",
|
72
|
-
:FILE_FLAG => "-f",
|
73
|
-
:DIR_FLAG => "-C",
|
74
|
-
:CLEAN => "clean"
|
75
|
-
},
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
def self.add(name, basedOn = nil)
|
80
|
-
chain = Marshal.load(Marshal.dump(basedOn.nil? ? @@default : @@settings[basedOn]))
|
81
|
-
@@settings[name] = chain
|
82
|
-
chain
|
83
|
-
end
|
84
|
-
|
85
|
-
def self.default
|
86
|
-
@@default
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.modify_cpp_compiler(based_on, h)
|
90
|
-
chain = Marshal.load(Marshal.dump(@@settings[based_on]))
|
91
|
-
chain[:COMPILER][:CPP].update(h)
|
92
|
-
chain
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'cxxproject/utils/dot/graph_writer'
|
2
|
-
|
3
|
-
class BuildingBlockGraphWriter < GraphWriter
|
4
|
-
|
5
|
-
private
|
6
|
-
|
7
|
-
def write_node(node)
|
8
|
-
@dotFile.write(" \"#{node.graph_name}\"\n")
|
9
|
-
end
|
10
|
-
|
11
|
-
def write_transition(node, dep)
|
12
|
-
@dotFile.write(" \"#{node.graph_name}\" -> \"#{dep.graph_name}\"\n")
|
13
|
-
end
|
14
|
-
|
15
|
-
def get_deps(node)
|
16
|
-
return node.dependencies.map { |depName| ALL_BUILDING_BLOCKS[depName] }
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
class GraphWriter
|
2
|
-
|
3
|
-
NO = 0
|
4
|
-
DETAIL = 1
|
5
|
-
YES = 2
|
6
|
-
|
7
|
-
def write_graph(filename,startNodes)
|
8
|
-
@filename = filename
|
9
|
-
start_graph
|
10
|
-
@writtenNodes = []
|
11
|
-
startNodes.each { |n| write_step(n) }
|
12
|
-
end_graph
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def write_step(node)
|
18
|
-
return if @writtenNodes.include? node
|
19
|
-
@writtenNodes << node
|
20
|
-
|
21
|
-
write_node(node)
|
22
|
-
|
23
|
-
get_deps(node).each do |dep|
|
24
|
-
write_transition(node, dep)
|
25
|
-
write_step(dep)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def start_graph
|
30
|
-
puts "\nWriting dot-file #{@filename}...\n"
|
31
|
-
@dotFile = File.new(@filename, "w")
|
32
|
-
@dotFile.write("digraph TaskGraph\n");
|
33
|
-
@dotFile.write("{\n");
|
34
|
-
end
|
35
|
-
|
36
|
-
def end_graph
|
37
|
-
@dotFile.write("}\n");
|
38
|
-
@dotFile.close()
|
39
|
-
end
|
40
|
-
|
41
|
-
def write_node(node)
|
42
|
-
raise "Must be implemented by descendants"
|
43
|
-
end
|
44
|
-
|
45
|
-
def write_transition(node, dep)
|
46
|
-
raise "Must be implemented by descendants"
|
47
|
-
end
|
48
|
-
|
49
|
-
def get_deps(node)
|
50
|
-
raise "Must be implemented by descendants"
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|