cxxproject 0.4.6 → 0.5.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/Rakefile.rb +101 -54
  2. data/bin/cxx +4 -4
  3. data/lib/cxxproject/buildingblocks/binary_library.rb +32 -9
  4. data/lib/cxxproject/buildingblocks/building_block.rb +220 -74
  5. data/lib/cxxproject/buildingblocks/command_line.rb +70 -21
  6. data/lib/cxxproject/buildingblocks/custom_building_block.rb +33 -9
  7. data/lib/cxxproject/buildingblocks/executable.rb +228 -33
  8. data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +69 -43
  9. data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -0
  10. data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +29 -30
  11. data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +343 -64
  12. data/lib/cxxproject/buildingblocks/makefile.rb +142 -24
  13. data/lib/cxxproject/buildingblocks/module.rb +27 -6
  14. data/lib/cxxproject/buildingblocks/single_source.rb +26 -4
  15. data/lib/cxxproject/buildingblocks/source_library.rb +113 -20
  16. data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -0
  17. data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +33 -0
  18. data/lib/cxxproject/errorparser/error_parser.rb +50 -0
  19. data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +30 -0
  20. data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +29 -0
  21. data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -0
  22. data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +29 -0
  23. data/lib/cxxproject/eval_context.rb +136 -0
  24. data/lib/cxxproject/ext/file.rb +71 -0
  25. data/lib/cxxproject/ext/filelist.rb +6 -0
  26. data/lib/cxxproject/ext/progressbar.rb +20 -0
  27. data/lib/cxxproject/ext/rake.rb +397 -0
  28. data/lib/cxxproject/{extensions/rake_listener_ext.rb → ext/rake_listener.rb} +18 -12
  29. data/lib/cxxproject/ext/stdout.rb +44 -0
  30. data/lib/cxxproject/ide_interface.rb +181 -0
  31. data/lib/cxxproject/toolchain/clang.rb +39 -0
  32. data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -0
  33. data/lib/cxxproject/toolchain/diab.rb +36 -33
  34. data/lib/cxxproject/toolchain/gcc.rb +16 -8
  35. data/lib/cxxproject/toolchain/provider.rb +112 -2
  36. data/lib/cxxproject/toolchain/ti.rb +50 -0
  37. data/lib/cxxproject/toolchain/toolchain.rb +38 -0
  38. data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -0
  39. data/lib/cxxproject/torake.rb +181 -123
  40. data/lib/cxxproject/utils/cleanup.rb +20 -0
  41. data/lib/cxxproject/utils/console.rb +6 -0
  42. data/lib/cxxproject/utils/exit_helper.rb +40 -0
  43. data/lib/cxxproject/utils/graphstream.rb +154 -0
  44. data/lib/cxxproject/utils/optional.rb +16 -0
  45. data/lib/cxxproject/utils/printer.rb +50 -0
  46. data/lib/cxxproject/utils/process.rb +53 -0
  47. data/lib/cxxproject/utils/progress.rb +66 -0
  48. data/lib/cxxproject/utils/progress_helper.rb +77 -0
  49. data/lib/cxxproject/utils/rbcurse.rb +284 -0
  50. data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -0
  51. data/lib/cxxproject/utils/rbcurse_progress.rb +71 -0
  52. data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -0
  53. data/lib/cxxproject/utils/stats.rb +60 -0
  54. data/lib/cxxproject/utils/ubigraph.rb +179 -188
  55. data/lib/cxxproject/utils/utils.rb +29 -25
  56. data/lib/cxxproject/version.rb +7 -0
  57. data/lib/cxxproject.rb +13 -7
  58. data/lib/tools/project_wizard.rb +66 -0
  59. data/spec/building_block_spec.rb +50 -6
  60. data/spec/{build_dependencies_spec.rb → cxxproject_2_rake_spec.rb} +82 -65
  61. data/spec/file_ext_spec.rb +30 -0
  62. data/spec/ide_interface_spec.rb +41 -0
  63. data/spec/object_dependency_spec.rb +83 -0
  64. data/spec/project_path_spec.rb +14 -16
  65. data/spec/rake_listener_ext_spec.rb +38 -5
  66. data/spec/spec_helper.rb +18 -0
  67. data/spec/testdata/basic/lib2/project.rb +1 -1
  68. data/spec/testdata/multiple_levels/libs/lib2/project.rb +1 -1
  69. data/spec/toolchain_spec.rb +29 -0
  70. metadata +91 -58
  71. data/lib/cxxproject/extensions/file_ext.rb +0 -47
  72. data/lib/cxxproject/extensions/rake_ext.rb +0 -158
  73. data/lib/cxxproject/extensions/stdout_ext.rb +0 -35
  74. data/lib/cxxproject/task_maker.rb +0 -418
  75. data/lib/cxxproject/testinstanceeval.rb +0 -65
  76. data/lib/cxxproject/toolchain/base.rb +0 -98
  77. data/lib/cxxproject/torake/compiler.rb +0 -10
  78. data/lib/cxxproject/torake/gcccompiler.rb +0 -7
  79. data/lib/cxxproject/torake/osxcompiler.rb +0 -7
  80. data/lib/cxxproject/utils/dot/building_block_graph_writer.rb +0 -19
  81. data/lib/cxxproject/utils/dot/graph_writer.rb +0 -53
  82. data/lib/cxxproject/utils/dot/task_graph_writer.rb +0 -34
  83. data/lib/tools/projectWizard.rb +0 -44
  84. data/spec/dir_spec.rb +0 -13
  85. /data/lib/cxxproject/{extensions/rake_dirty_ext.rb → ext/rake_dirty.rb} +0 -0
  86. /data/lib/cxxproject/{extensions/string_ext.rb → ext/string.rb} +0 -0
@@ -1,85 +1,364 @@
1
- module HasSources
1
+ require 'yaml'
2
+ require 'cxxproject/utils/process'
3
+ require 'cxxproject/utils/utils'
4
+ require 'cxxproject/utils/printer'
2
5
 
3
- def sources
4
- @sources ||= []
5
- end
6
- def set_sources(x)
7
- @sources = x
8
- self
9
- end
6
+ module Cxxproject
7
+ module HasSources
10
8
 
11
- def includes
12
- @includes ||= []
13
- end
14
- def set_includes(x)
15
- @includes = x
16
- self
17
- end
9
+ attr_writer :file_dependencies
10
+ attr_reader :incArray
18
11
 
19
- # used when a source file shall have different tcs than the project default
20
- def tcs4source
21
- @tcs4source ||= {}
22
- end
23
- def set_tcs4source(x)
24
- @tcs4source = x
25
- self
26
- end
12
+ def file_dependencies
13
+ @file_dependencies ||= []
14
+ end
27
15
 
28
- def include_string(type)
29
- @include_string[type] ||= ""
30
- end
16
+ def sources
17
+ @sources ||= []
18
+ end
19
+ def set_sources(x)
20
+ @sources = x
21
+ self
22
+ end
23
+
24
+ def deps_in_depFiles
25
+ @deps_in_depFiles ||= Set.new
26
+ end
31
27
 
32
- def define_string(type)
33
- @define_string[type] ||= ""
34
- end
28
+ def source_patterns
29
+ @source_patterns ||= []
30
+ end
31
+ def set_source_patterns(x)
32
+ @source_patterns = x
33
+ self
34
+ end
35
+
36
+ def exclude_sources
37
+ @exclude_sources ||= []
38
+ end
39
+ def set_exclude_sources(x)
40
+ @exclude_sources = x
41
+ self
42
+ end
35
43
 
36
- def calc_compiler_strings()
37
- @include_string = {}
38
- @define_string = {}
44
+ # used when a source file shall have different tcs than the project default
45
+ def tcs4source(source)
46
+ @tcs4source ||= {}
39
47
 
40
- @incArray = []
41
- all_dependencies.each do |e|
42
- d = ALL_BUILDING_BLOCKS[e]
43
- next if not HasSources === d
44
- if d.includes.length == 0
45
- @incArray << File.relFromTo("include", d.project_dir)
48
+ if @tcs4source.include?(source)
49
+ @tcs4source[source]
46
50
  else
47
- d.includes.each { |k| @incArray << File.relFromTo(k, d.project_dir) }
51
+ @tcs
48
52
  end
49
53
  end
50
54
 
51
- [:CPP, :C, :ASM].each do |type|
52
- @include_string[type] = get_include_string(@tcs, type)
53
- @define_string[type] = get_define_string(@tcs, type)
55
+ def set_tcs4source(x)
56
+ @tcs4source = x
57
+ self
54
58
  end
55
- end
56
59
 
57
- def get_include_string(tcs, type)
58
- @incArray.uniq.map!{|k| "#{tcs[:COMPILER][type][:INCLUDE_PATH_FLAG]}#{k}"}.join(" ")
59
- end
60
+ def include_string(type)
61
+ @include_string[type] ||= ""
62
+ end
60
63
 
61
- def get_define_string(tcs, type)
62
- @tcs[:COMPILER][type][:DEFINES].map {|k| "#{tcs[:COMPILER][type][:DEFINE_FLAG]}#{k}"}.join(" ")
63
- end
64
+ def define_string(type)
65
+ @define_string[type] ||= ""
66
+ end
64
67
 
65
- def get_object_file(source)
66
- File.relFromTo(source, @complete_output_dir + (@output_dir_abs ? ("/" + @name) : "") ) + ".o"
67
- end
68
+ def calc_compiler_strings()
69
+ @include_string = {}
70
+ @define_string = {}
68
71
 
69
- def get_dep_file(object)
70
- object + ".d"
71
- end
72
+ @incArray = local_includes.dup
73
+ @incArray.concat(includes)
72
74
 
73
- def get_source_type(source)
74
- ex = File.extname(source)
75
- [:CPP, :C, :ASM].each do |t|
76
- return t if tcs[:COMPILER][t][:SOURCE_FILE_ENDINGS].include?(ex)
75
+ if Rake::application.deriveIncludes
76
+ all_dependencies.each_with_index do |d,i|
77
+ next if not HasIncludes === d
78
+ next if i == 0
79
+ prefix = File.rel_from_to_project(@project_dir,d.project_dir)
80
+ next if not prefix
81
+ @incArray.concat(d.includes.map {|inc| File.add_prefix(prefix,inc)})
82
+ end
83
+ @incArray.uniq!
84
+ end
85
+
86
+ [:CPP, :C, :ASM].each do |type|
87
+ @include_string[type] = get_include_string(@tcs, type)
88
+ @define_string[type] = get_define_string(@tcs, type)
89
+ end
77
90
  end
78
- nil
79
- end
80
91
 
81
- def get_sources_task_name
82
- "Sources of #{name}"
83
- end
92
+ def get_include_string(tcs, type)
93
+ @incArray.map {|k| "#{tcs[:COMPILER][type][:INCLUDE_PATH_FLAG]}#{k}"}
94
+ end
95
+
96
+ def get_define_string(tcs, type)
97
+ tcs[:COMPILER][type][:DEFINES].map {|k| "#{tcs[:COMPILER][type][:DEFINE_FLAG]}#{k}"}
98
+ end
99
+
100
+ def get_object_file(sourceRel)
101
+ parts = [@output_dir]
102
+ if @output_dir_abs
103
+ parts = [@output_dir_relPath] if @output_dir_relPath
104
+ parts << 'objects'
105
+ parts << @name
106
+ end
107
+
108
+ parts << sourceRel.chomp(File.extname(sourceRel))
109
+ File.join(parts) + ".o"
110
+ end
111
+
112
+ def get_dep_file(object)
113
+ object + ".d"
114
+ end
115
+
116
+ def get_source_type(source)
117
+ ex = File.extname(source)
118
+ [:CPP, :C, :ASM].each do |t|
119
+ return t if tcs[:COMPILER][t][:SOURCE_FILE_ENDINGS].include?(ex)
120
+ end
121
+ nil
122
+ end
123
+
124
+ def get_sources_task_name
125
+ "Objects of #{name}"
126
+ end
84
127
 
128
+ def parse_includes(deps)
129
+ #deps look like "test.o: test.cpp test.h" -> remove .o and .cpp from list
130
+ return deps.gsub(/\\\n/,'').split()[2..-1]
131
+ end
132
+
133
+ def convert_depfile(depfile)
134
+ deps_string = read_file_or_empty_string(depfile)
135
+ deps = parse_includes(deps_string)
136
+ if deps.nil?
137
+ return # ok, because next run the source will be recompiled due to invalid depfile
138
+ end
139
+ expanded_deps = deps.map do |d|
140
+ tmp = d.gsub(/[\\]/,'/')
141
+ deps_in_depFiles << tmp
142
+ tmp
143
+ end
144
+
145
+ FileUtils.mkpath File.dirname(depfile)
146
+ File.open(depfile, 'wb') do |f|
147
+ f.write(expanded_deps.to_yaml)
148
+ end
149
+ end
150
+
151
+ def apply_depfile(depfile,outfileTask)
152
+ deps = nil
153
+ begin
154
+ deps = YAML.load_file(depfile)
155
+ deps.each do |d|
156
+ deps_in_depFiles << d
157
+ f = file d
158
+ f.ignore_missing_file
159
+ end
160
+ outfileTask.enhance(deps)
161
+ rescue
162
+ # may happen if depfile was not converted the last time
163
+ def outfileTask.needed?
164
+ true
165
+ end
166
+ end
167
+ end
168
+
169
+ def create_object_file_tasks()
170
+
171
+ sources_to_build = {}
172
+
173
+ exclude_files = Set.new
174
+ exclude_sources.each do |p|
175
+ if p.include?".."
176
+ Printer.printError "Error: Exclude source file pattern '#{p}' must not include '..'"
177
+ return nil
178
+ end
179
+
180
+ Dir.glob(p).each {|f| exclude_files << f}
181
+ end
182
+ files = Set.new # do not build the same file twice
183
+
184
+ sources.each do |f|
185
+ if f.include?".."
186
+ Printer.printError "Error: Source file '#{f}' must not include '..'"
187
+ return nil
188
+ end
189
+
190
+ next if exclude_files.include?(f)
191
+ next if files.include?(f)
192
+ files << f
193
+ sources_to_build[f] = tcs4source(f)
194
+ end
195
+
196
+ source_patterns.each do |p|
197
+ if p.include?".."
198
+ Printer.printError "Error: Source file pattern '#{p}' must not include '..'"
199
+ return nil
200
+ end
201
+
202
+ globRes = Dir.glob(p)
203
+ if (globRes.length == 0)
204
+ Printer.printWarning "Warning: Source file pattern '#{p}' did not match to any file"
205
+ end
206
+ globRes.each do |f|
207
+ next if exclude_files.include?(f)
208
+ next if files.include?(f)
209
+ files << f
210
+ t = tcs4source(f)
211
+ t = tcs4source(p) if t == nil
212
+ sources_to_build[f] = t
213
+ end
214
+ end
215
+
216
+ ordered = sources_to_build.keys.sort()
217
+ dirs = []
218
+ filemap = {}
219
+ ordered.reverse.each do |o|
220
+ d = File.dirname(o)
221
+ if filemap.include?(d)
222
+ filemap[d] << o
223
+ else
224
+ filemap[d] = [o]
225
+ dirs << d
226
+ end
227
+ end
228
+
229
+ obj_tasks = []
230
+ dirs.each do |d|
231
+ filemap[d].reverse.each do |f|
232
+ obj_task = create_object_file_task(f, sources_to_build[f])
233
+ obj_tasks << obj_task unless obj_task.nil?
234
+ end
235
+ end
236
+ obj_tasks
237
+ end
238
+
239
+ def create_object_file_task(sourceRel, the_tcs)
240
+ if File.is_absolute?(sourceRel)
241
+ sourceRel = File.rel_from_to_project(@project_dir, sourceRel, false)
242
+ end
243
+
244
+ type = get_source_type(sourceRel)
245
+ return nil if type.nil?
246
+
247
+ objectRel = get_object_file(sourceRel)
248
+ @objects << objectRel
249
+ object = File.expand_path(objectRel)
250
+ source = File.expand_path(sourceRel)
251
+
252
+ depStr = ""
253
+ dep_file = nil
254
+ if type != :ASM
255
+ dep_file = get_dep_file(objectRel)
256
+ dep_file = "\""+dep_file+"\"" if dep_file.include?" "
257
+ depStr = the_tcs[:COMPILER][type][:DEP_FLAGS]
258
+ end
259
+
260
+ res = typed_file_task Rake::Task::OBJECT, object => source do
261
+ i_array = the_tcs == @tcs ? @include_string[type] : get_include_string(the_tcs, type)
262
+ d_array = the_tcs == @tcs ? @define_string[type] : get_define_string(the_tcs, type)
263
+
264
+ compiler = the_tcs[:COMPILER][type]
265
+ cmd = [compiler[:COMMAND]]
266
+ cmd += compiler[:COMPILE_FLAGS].split(" ")
267
+ if dep_file
268
+ cmd += depStr.split(" ")
269
+ if the_tcs[:COMPILER][type][:DEP_FLAGS_SPACE]
270
+ cmd << dep_file
271
+ else
272
+ cmd[cmd.length-1] << dep_file
273
+ end
274
+ end
275
+ cmd += compiler[:FLAGS].gsub(/\"/,"").split(" ") # double quotes within string do not work on windows...
276
+ cmd += i_array
277
+ cmd += d_array
278
+ cmd += (compiler[:OBJECT_FILE_FLAG] + objectRel).split(" ")
279
+ cmd << sourceRel
280
+
281
+ if Cxxproject::Utils.old_ruby?
282
+ cmd.map! {|c| ((c.include?" ") ? ("\""+c+"\"") : c )}
283
+ cmdLine = cmd.join(" ")
284
+ if cmdLine.length > 8000
285
+ inputName = objectRel+".tmp"
286
+ File.open(inputName,"wb") { |f| f.write(cmd[1..-1].join(" ")) }
287
+ inputName = "\""+inputName+"\"" if inputName.include?" "
288
+ consoleOutput = `#{compiler[:COMMAND] + " @" + inputName}`
289
+ else
290
+ consoleOutput = `#{cmd.join(" ")} 2>&1`
291
+ end
292
+ else
293
+ rd, wr = IO.pipe
294
+ cmd << {
295
+ :err=>wr,
296
+ :out=>wr
297
+ }
298
+ sp = spawn(*cmd)
299
+ cmd.pop
300
+ consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
301
+ end
302
+
303
+ process_result(cmd, consoleOutput, compiler[:ERROR_PARSER], "Compiling #{sourceRel}")
304
+
305
+ convert_depfile(dep_file) if dep_file
306
+
307
+ check_config_file()
308
+ end
309
+ enhance_with_additional_files(res)
310
+ add_output_dir_dependency(object, res, false)
311
+ apply_depfile(dep_file, res) if depStr != ""
312
+ res
313
+ end
314
+
315
+ def enhance_with_additional_files(task)
316
+ task.enhance(file_dependencies)
317
+ task.enhance(@config_files)
318
+ end
319
+
320
+ def process_console_output(console_output, error_parser)
321
+ ret = false
322
+ if not console_output.empty?
323
+ if error_parser
324
+ begin
325
+ error_descs, console_output_full = error_parser.scan_lines(console_output, @project_dir)
326
+
327
+ console_output = console_output_full if Rake::application.consoleOutput_fullnames
328
+
329
+ ret = error_descs.any? { |e| e.severity == ErrorParser::SEVERITY_ERROR }
330
+
331
+ console_output.gsub!(/[\r]/, "")
332
+ highlighter = @tcs[:CONSOLE_HIGHLIGHTER]
333
+ if (highlighter and highlighter.enabled?)
334
+ puts highlighter.format(console_output, error_descs, error_parser)
335
+ else
336
+ puts console_output
337
+ end
338
+
339
+ Rake.application.idei.set_errors(error_descs)
340
+ rescue Exception => e
341
+ Printer.printWarning "Parsing output failed (maybe language not set to English?): " + e.message
342
+ puts "Original output:"
343
+ puts console_output
344
+ end
345
+ end
346
+ end
347
+ ret
348
+ end
349
+
350
+ def prepare_tasks_for_objects
351
+ if (@output_dir_abs)
352
+ CLEAN.include(@output_dir + "/objects/" + @name)
353
+ end
354
+
355
+ @objects = []
356
+ t = multitask get_sources_task_name
357
+ t.type = Rake::Task::SOURCEMULTI
358
+ t.transparent_timestamp = true
359
+ t.set_building_block(self)
360
+ t
361
+ end
362
+
363
+ end
85
364
  end
@@ -1,35 +1,153 @@
1
1
  require 'cxxproject/buildingblocks/building_block'
2
2
  require 'cxxproject/buildingblocks/has_libraries_mixin'
3
+ require 'cxxproject/utils/printer'
4
+ require 'cxxproject/utils/process'
3
5
 
4
- class Makefile < BuildingBlock
5
- include HasLibraries
6
+ module Cxxproject
7
+ class Makefile < BuildingBlock
8
+ include HasLibraries
6
9
 
7
- def set_target(x)
8
- @target = x
9
- self
10
- end
10
+ def set_target(x)
11
+ @target = x
12
+ self
13
+ end
14
+
15
+ def set_flags(x)
16
+ @flags = x
17
+ self
18
+ end
19
+
20
+ def get_flags(x)
21
+ @flags
22
+ end
23
+
11
24
 
12
- def set_makefile(x)
13
- @makefile = x
14
- self
15
- end
25
+ def set_makefile(x)
26
+ @makefile = x
27
+ self
28
+ end
16
29
 
17
- def get_makefile
18
- File.relFromTo(@makefile, @project_dir)
19
- end
30
+ def set_path_to(hash)
31
+ @path_to = hash
32
+ self
33
+ end
20
34
 
21
- def get_target
22
- @target
23
- end
35
+ def get_makefile
36
+ @makefile
37
+ end
24
38
 
25
- def initialize(name)
26
- super(name)
27
- @target = "all"
28
- @makefile = nil
29
- end
39
+ def get_target
40
+ @target
41
+ end
42
+
43
+ def initialize(mfile, mtarget)
44
+ @target = mtarget != "" ? mtarget : "all"
45
+ @makefile = mfile
46
+ @flags = ""
47
+ @path_to = {}
48
+ @num = Rake.application.makefile_number
49
+ super(get_task_name)
50
+ end
30
51
 
31
- def get_task_name()
32
- get_makefile+"_"+get_target
33
- end
52
+ def get_task_name()
53
+ "makefile (#{@num}): " + get_makefile + (get_target ? ("_"+get_target) : "")
54
+ end
34
55
 
56
+ def calc_pathes_to_projects
57
+ vars = []
58
+ @path_to.each do |k,v|
59
+ bb = ALL_BUILDING_BLOCKS[p]
60
+ if bb
61
+ pref = File.rel_from_to_project(@project_dir,bb.project_dir)
62
+ rex = Regexp.new "\\.\\.\\/(.*)#{p}"
63
+ var = pref.scan(rex)[0]
64
+ if var
65
+ vars << "PATH_TO_#{p}=#{var[0]}"
66
+ end
67
+ else
68
+ vars << "PATH_TO_#{k}=#{v}"
69
+ end
70
+ end
71
+ vars.join(" ")
72
+ end
73
+
74
+ def executeCmd(cmd)
75
+ Dir.chdir(@project_dir) do
76
+ check_config_file
77
+ puts cmd + (RakeFileUtils.verbose ? " (executed in '#{@project_dir}')" : "")
78
+ cmd_result = false
79
+ begin
80
+ cmd_result = ProcessHelper.spawnProcess(cmd + " 2>&1")
81
+ rescue
82
+ end
83
+ if (cmd_result == false)
84
+ if Rake.application.idei
85
+ err_res = ErrorDesc.new
86
+ err_res.file_name = @project_dir + "/" + get_makefile()
87
+ err_res.line_number = 1
88
+ err_res.severity = ErrorParser::SEVERITY_ERROR
89
+ if get_target != ""
90
+ err_res.message = "Target \"#{get_target}\" failed"
91
+ else
92
+ err_res.message = "Failed"
93
+ end
94
+ Rake.application.idei.set_errors([err_res])
95
+ end
96
+ Printer.printError "Error: command \"#{cmd}\" failed" + (RakeFileUtils.verbose ? "" : " (executed in '#{@project_dir}')")
97
+ raise SystemCommandFailed.new
98
+ end
99
+ end
100
+ end
101
+
102
+ def convert_to_rake()
103
+ pathes_to_projects = calc_pathes_to_projects
104
+
105
+ mfile = get_makefile()
106
+ make = @tcs[:MAKE]
107
+ cmd = remove_empty_strings_and_join([
108
+ make[:COMMAND], # make
109
+ get_target, # all
110
+ make[:MAKE_FLAGS],
111
+ @flags, # -j
112
+ make[:DIR_FLAG], # -C
113
+ File.dirname(mfile), # x/y
114
+ make[:FILE_FLAG], # -f
115
+ File.basename(mfile), # x/y/makefile
116
+ pathes_to_projects
117
+ ])
118
+
119
+ mfileTask = task get_task_name do
120
+ executeCmd(cmd)
121
+ end
122
+
123
+ mfileTask.immediate_output = true
124
+ mfileTask.transparent_timestamp = true
125
+ mfileTask.type = Rake::Task::MAKE
126
+ mfileTask.enhance(@config_files)
127
+
128
+ create_clean_task(@project_dir+"/"+mfile, pathes_to_projects)
129
+ setup_rake_dependencies(mfileTask)
130
+ mfileTask
131
+ end
132
+
133
+ def create_clean_task(mfile, pathes_to_projects)
134
+ # generate the clean task
135
+ if not Rake.application["clean"].prerequisites.include?(mfile+"Clean")
136
+ cmd = remove_empty_strings_and_join([@tcs[:MAKE][:COMMAND], # make
137
+ @tcs[:MAKE][:CLEAN], # clean
138
+ @tcs[:MAKE][:DIR_FLAG], # -C
139
+ File.dirname(mfile), # x/y
140
+ @tcs[:MAKE][:FILE_FLAG], # -f
141
+ File.basename(mfile), # x/y/makefile
142
+ pathes_to_projects
143
+ ])
144
+ mfileCleanTask = task mfile+"Clean" do
145
+ executeCmd(cmd)
146
+ end
147
+ mfileCleanTask.immediate_output = true
148
+ Rake.application["clean"].enhance([mfileCleanTask])
149
+ end
150
+ end
151
+
152
+ end
35
153
  end
@@ -1,14 +1,35 @@
1
1
  require 'cxxproject/buildingblocks/building_block'
2
2
  require 'cxxproject/buildingblocks/has_libraries_mixin'
3
3
  require 'cxxproject/buildingblocks/has_sources_mixin'
4
+ require 'cxxproject/buildingblocks/has_includes_mixin'
5
+
4
6
 
5
7
  # can be used as wrapper for other tasks
6
- class ModuleBuildingBlock < BuildingBlock
7
- include HasLibraries
8
- include HasSources
8
+ module Cxxproject
9
+ class ModuleBuildingBlock < BuildingBlock
9
10
 
10
- def get_task_name()
11
- name
12
- end
11
+ attr_accessor :contents
12
+ attr_accessor :main_content
13
+ attr_accessor :last_content
14
+
15
+ def initialize(name)
16
+ super
17
+ @contents = []
18
+ @last_content = self
19
+ @main_content = nil
20
+ end
13
21
 
22
+ def get_task_name()
23
+ name
24
+ end
25
+
26
+ def convert_to_rake()
27
+ res = task get_task_name
28
+ res.type = Rake::Task::MODULE
29
+ res.transparent_timestamp = true
30
+
31
+ setup_rake_dependencies(res)
32
+ res
33
+ end
34
+ end
14
35
  end
@@ -1,11 +1,33 @@
1
1
  require 'cxxproject/buildingblocks/building_block'
2
2
  require 'cxxproject/buildingblocks/has_sources_mixin'
3
+ require 'cxxproject/buildingblocks/has_includes_mixin'
3
4
 
4
- class SingleSource < BuildingBlock
5
- include HasSources
5
+ module Cxxproject
6
+ module SingleSourceModule
7
+ def get_task_name()
8
+ get_sources_task_name
9
+ end
6
10
 
7
- def get_task_name()
8
- get_sources_task_name
11
+ def convert_to_rake()
12
+ objects_multitask = prepare_tasks_for_objects()
13
+
14
+ if objects_multitask
15
+ namespace "compile" do
16
+ desc "compile sources in #{@name}-configuration"
17
+ task @name => objects_multitask
18
+ end
19
+ objects_multitask.add_description("compile sources only")
20
+ end
21
+
22
+ setup_rake_dependencies(objects_multitask)
23
+ objects_multitask
24
+ end
9
25
  end
10
26
 
27
+ class SingleSource < BuildingBlock
28
+ include HasSources
29
+ include HasIncludes
30
+
31
+ include SingleSourceModule
32
+ end
11
33
  end