cxxproject 0.5.48 → 0.5.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/Rakefile.rb +116 -116
  2. data/bin/cxx +10 -10
  3. data/lib/cxxproject.rb +23 -23
  4. data/lib/cxxproject/buildingblocks/binary_library.rb +39 -39
  5. data/lib/cxxproject/buildingblocks/building_block.rb +251 -239
  6. data/lib/cxxproject/buildingblocks/command_line.rb +79 -79
  7. data/lib/cxxproject/buildingblocks/custom_building_block.rb +39 -41
  8. data/lib/cxxproject/buildingblocks/executable.rb +257 -249
  9. data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +83 -83
  10. data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -20
  11. data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +34 -34
  12. data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +371 -364
  13. data/lib/cxxproject/buildingblocks/makefile.rb +153 -153
  14. data/lib/cxxproject/buildingblocks/module.rb +35 -35
  15. data/lib/cxxproject/buildingblocks/single_source.rb +33 -33
  16. data/lib/cxxproject/buildingblocks/source_library.rb +124 -124
  17. data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -40
  18. data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +41 -33
  19. data/lib/cxxproject/errorparser/error_parser.rb +50 -50
  20. data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +35 -30
  21. data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +35 -29
  22. data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -30
  23. data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +30 -29
  24. data/lib/cxxproject/eval_context.rb +144 -136
  25. data/lib/cxxproject/ext/file.rb +71 -71
  26. data/lib/cxxproject/ext/filelist.rb +6 -6
  27. data/lib/cxxproject/ext/progressbar.rb +20 -20
  28. data/lib/cxxproject/ext/rake.rb +419 -397
  29. data/lib/cxxproject/ext/rake_dirty.rb +30 -30
  30. data/lib/cxxproject/ext/rake_listener.rb +59 -59
  31. data/lib/cxxproject/ext/stdout.rb +44 -44
  32. data/lib/cxxproject/ext/string.rb +9 -9
  33. data/lib/cxxproject/ide_interface.rb +187 -181
  34. data/lib/cxxproject/toolchain/clang.rb +39 -39
  35. data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -99
  36. data/lib/cxxproject/toolchain/diab.rb +3 -1
  37. data/lib/cxxproject/toolchain/gcc.rb +2 -1
  38. data/lib/cxxproject/toolchain/provider.rb +131 -128
  39. data/lib/cxxproject/toolchain/toolchain.rb +38 -38
  40. data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -23
  41. data/lib/cxxproject/torake.rb +218 -216
  42. data/lib/cxxproject/utils/cleanup.rb +20 -20
  43. data/lib/cxxproject/utils/console.rb +6 -6
  44. data/lib/cxxproject/utils/exit_helper.rb +40 -40
  45. data/lib/cxxproject/utils/graphstream.rb +154 -154
  46. data/lib/cxxproject/utils/optional.rb +16 -16
  47. data/lib/cxxproject/utils/printer.rb +50 -50
  48. data/lib/cxxproject/utils/process.rb +52 -52
  49. data/lib/cxxproject/utils/progress.rb +66 -66
  50. data/lib/cxxproject/utils/progress_helper.rb +77 -77
  51. data/lib/cxxproject/utils/rbcurse.rb +284 -284
  52. data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -14
  53. data/lib/cxxproject/utils/rbcurse_progress.rb +71 -71
  54. data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -51
  55. data/lib/cxxproject/utils/stats.rb +60 -60
  56. data/lib/cxxproject/utils/ubigraph.rb +228 -228
  57. data/lib/cxxproject/utils/utils.rb +60 -37
  58. data/lib/cxxproject/utils/valgrind.rb +11 -11
  59. data/lib/cxxproject/version.rb +7 -7
  60. data/lib/tools/Rakefile.rb.template +10 -10
  61. data/lib/tools/project.rb.template +6 -6
  62. data/lib/tools/project_wizard.rb +66 -66
  63. data/spec/building_block_spec.rb +56 -56
  64. data/spec/cxxproject_2_rake_spec.rb +186 -186
  65. data/spec/file_ext_spec.rb +30 -30
  66. data/spec/ide_interface_spec.rb +41 -41
  67. data/spec/object_dependency_spec.rb +83 -83
  68. data/spec/project_path_spec.rb +71 -71
  69. data/spec/rake_listener_ext_spec.rb +58 -58
  70. data/spec/spec_helper.rb +18 -18
  71. data/spec/string_spec.rb +11 -11
  72. data/spec/testdata/basic/exe12/project.rb +5 -5
  73. data/spec/testdata/basic/lib1/project.rb +5 -5
  74. data/spec/testdata/basic/lib2/project.rb +8 -8
  75. data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -5
  76. data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -19
  77. data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -8
  78. data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -4
  79. data/spec/testdata/onlyOneHeader/project.rb +4 -4
  80. data/spec/toolchain_spec.rb +29 -29
  81. metadata +58 -58
@@ -1,284 +1,284 @@
1
- module Cxxproject
2
- module Utils
3
- define_rbcurse_ui = lambda do
4
- require 'rake'
5
- require 'ncurses'
6
- require 'rbcurse'
7
-
8
- require 'rbcurse/rtable'
9
- require 'rbcurse/table/tablecellrenderer'
10
- require 'rbcurse/rsplitpane'
11
- require 'rbcurse/rtextview'
12
- require 'cxxproject/ext/rake_listener'
13
- require 'cxxproject/utils/rbcurse_progress'
14
- require 'cxxproject/utils/rbcurse_tasktable'
15
-
16
- include RubyCurses
17
-
18
- Rake::TaskManager.record_task_metadata = true
19
-
20
- class RakeGui
21
- def initialize
22
- require 'cxxproject/utils/rbcurse_executable_ext'
23
- Cxxproject::ColorizingFormatter.enabled = false
24
- Rake::Task.output_disabled = true
25
-
26
- $log = Logger.new(File.join("./", "view.log"))
27
- $log.level = Logger::ERROR
28
- @data_stack = []
29
- @path_stack = []
30
- end
31
-
32
- def self.keycode(s)
33
- return s[0].to_i
34
- end
35
-
36
- def create_table
37
- @col_names = ['name', 'desc']
38
- return TaskTable.new(self) do
39
- name 'my table'
40
- title 'my table'
41
- cell_editing_allowed false
42
- end
43
- end
44
-
45
- def reenable_including_prerequisites(task)
46
- task.visit() do |t|
47
- t.reenable
48
- true
49
- end
50
- end
51
-
52
- def invoke(table)
53
- t = table.get_value_at(table.focussed_row, 0)
54
- @progress_helper = ProgressHelper.new
55
- complete_task_name = t.name
56
- args = []
57
- if @progress_helper.is_filter(t.name)
58
- args = [get_string('please input filterpattern', 20, '.*')]
59
- complete_task_name = "#{t.name}[#{args[0]}]"
60
- end
61
- @progress_helper.count_with_filter(complete_task_name)
62
-
63
- @progress.max = @progress_helper.todo
64
- Rake::add_listener(self)
65
- reenable_including_prerequisites(t)
66
- t.invoke(args)
67
- Rake::remove_listener(self)
68
- show_details_for(table.focussed_row)
69
- table.repaint_all(true)
70
- end
71
-
72
- def after_execute(name)
73
- needed_tasks = @progress_helper.needed_tasks
74
- if needed_tasks[name]
75
- task = Rake::Task[name]
76
- @progress.title = task.name
77
- @progress.inc(task.progress_count)
78
- @form.repaint
79
- end
80
- end
81
-
82
- def details(table)
83
- t = table.get_value_at(table.focussed_row, 0)
84
- pre = t.prerequisite_tasks
85
- if pre.size > 0
86
- push_table_data(pre, t.name)
87
- table.set_focus_on 0
88
-
89
- show_details_for(0)
90
- end
91
- end
92
-
93
- def repaint_and_next_char
94
- @form.repaint
95
- @window.wrefresh
96
- return @window.getchar
97
- end
98
-
99
- def process_input_events
100
- ch = repaint_and_next_char
101
- while ch != RakeGui.keycode('q')
102
- $log.error "entered key: #{ch}"
103
- case ch
104
- when RakeGui.keycode('a')
105
- @h_split.set_divider_location(@h_split.divider_location+1)
106
- when RakeGui.keycode('s')
107
- @h_split.set_divider_location(@h_split.divider_location-1)
108
- else
109
- @form.handle_key(ch)
110
- end
111
- ch = repaint_and_next_char
112
- end
113
- end
114
-
115
- def push_table_data(task_data, new_path=nil)
116
- @path_stack.push(new_path) if new_path
117
- set_breadcrumbs
118
-
119
- @data_stack.push(task_data)
120
- set_table_data(task_data)
121
- end
122
- def set_table_data(task_data)
123
- size = size()
124
- new_data = task_data.map{|t|[t, t.comment]}
125
- @table.set_data new_data, @col_names
126
- tcm = @table.table_column_model
127
- first_col_width = task_data.map{|t|t.name.size}.max
128
- tcm.column(0).width(first_col_width)
129
- tcm.column(1).width(size[0]-first_col_width-3)
130
- end
131
- def set_breadcrumbs
132
- crumbs = File.join(@path_stack.map{|i|"(#{i})"}.join('/'))
133
- @breadcrumbs.text = crumbs
134
- @breadcrumbs.repaint_all(true)
135
- end
136
- def pop_data
137
- if @data_stack.size > 1
138
- @path_stack.pop
139
- set_breadcrumbs
140
-
141
- popped = @data_stack.pop
142
- top= @data_stack.last
143
- set_table_data(top)
144
- end
145
- end
146
-
147
- def size
148
- return @window.default_for(:width), @window.default_for(:height)
149
- end
150
-
151
- def show_details_for(row)
152
- buffer = StringIO.new
153
- t = @table.get_value_at(row, 0)
154
- t.visit do |t|
155
- if t.output_string && t.output_string.length > 0
156
- buffer.puts(t.output_string)
157
- end
158
- if t.failure
159
- true
160
- else
161
- false
162
- end
163
- end
164
- @output.set_content(buffer.string)
165
- @output.set_focus_on(0)
166
- @output.repaint_all(true)
167
- end
168
-
169
- def start_editor_for_task(t)
170
- file_name = t.name
171
- return unless File.exists?(file_name)
172
-
173
- start_editor(file_name, 0, 0)
174
- end
175
-
176
- def start_editor(file, line, column)
177
- $log.error "starting editor for #{file}:#{line}"
178
- editor = ENV['EDITOR']
179
- editor = 'vi' unless editor
180
- cmd = "#{editor} +#{line} #{file}"
181
- shell_out(cmd)
182
- end
183
-
184
- def shell_out(cmd)
185
- @window.hide
186
- Ncurses.endwin
187
- system(cmd)
188
- Ncurses.refresh
189
- @window.show
190
- end
191
-
192
- def create_breadcrumbs(size)
193
- @breadcrumbs = Label.new @form do
194
- name 'breadcrumbs'
195
- row 0
196
- col 0
197
- width size[0]
198
- height 1
199
- end
200
- @breadcrumbs.display_length(size[0])
201
- @breadcrumbs.text = ''
202
- end
203
-
204
- def create_splitpane(size)
205
- @h_split = SplitPane.new @form do
206
- name 'mainpane'
207
- row 1
208
- col 0
209
- width size[0]
210
- height size[1]-3
211
- orientation :HORIZONTAL_SPLIT
212
- end
213
- end
214
-
215
- def create_output_view(size)
216
- @output = TextView.new nil
217
- @output.set_content('')
218
- @output.configure do
219
- bind_key(RakeGui.keycode('e')) do |code|
220
- line = selected_item
221
- file_pattern = '(.*?):(\d+):(\d*):? '
222
- error_pattern = Regexp.new("#{file_pattern}(error: .*)")
223
- warning_pattern = Regexp.new("#{file_pattern}(warning: .*)")
224
- md = error_pattern.match(line)
225
- md = warning_pattern.match(line) unless md
226
- if md
227
- file_name = md[1]
228
- line = md[2]
229
- col = md[3]
230
- rake_gui.start_editor(file_name, line, col)
231
- end
232
- end
233
- end
234
- end
235
-
236
- def create_components(size)
237
- create_breadcrumbs(size)
238
- @progress = Progress.new(@form, size)
239
- create_splitpane(size)
240
- @table = create_table
241
- push_table_data(Rake::Task.tasks.select {|t|t.comment})
242
-
243
- create_output_view(size)
244
- end
245
-
246
- def wire_components
247
- @h_split.first_component(@table)
248
- @h_split.second_component(@output)
249
- @h_split.set_resize_weight(0.50)
250
- end
251
-
252
- def run
253
- rake_gui = self
254
- begin
255
- VER::start_ncurses
256
-
257
- @window = VER::Window.root_window
258
- @form = Form.new @window
259
-
260
- create_components(size())
261
- wire_components
262
-
263
- @table.bind(:TABLE_TRAVERSAL_EVENT) do |e|
264
- rake_gui.show_details_for(e.newrow)
265
- end
266
-
267
- process_input_events
268
- rescue => e
269
- puts e
270
- end
271
- @window.destroy if @window
272
- VER::stop_ncurses
273
- end
274
- end
275
-
276
- task :ui do
277
- RakeGui.new.run
278
- end
279
-
280
- end
281
-
282
- optional_package(define_rbcurse_ui, nil)
283
- end
284
- end
1
+ module Cxxproject
2
+ module Utils
3
+ define_rbcurse_ui = lambda do
4
+ require 'rake'
5
+ require 'ncurses'
6
+ require 'rbcurse'
7
+
8
+ require 'rbcurse/rtable'
9
+ require 'rbcurse/table/tablecellrenderer'
10
+ require 'rbcurse/rsplitpane'
11
+ require 'rbcurse/rtextview'
12
+ require 'cxxproject/ext/rake_listener'
13
+ require 'cxxproject/utils/rbcurse_progress'
14
+ require 'cxxproject/utils/rbcurse_tasktable'
15
+
16
+ include RubyCurses
17
+
18
+ Rake::TaskManager.record_task_metadata = true
19
+
20
+ class RakeGui
21
+ def initialize
22
+ require 'cxxproject/utils/rbcurse_executable_ext'
23
+ Cxxproject::ColorizingFormatter.enabled = false
24
+ Rake::Task.output_disabled = true
25
+
26
+ $log = Logger.new(File.join("./", "view.log"))
27
+ $log.level = Logger::ERROR
28
+ @data_stack = []
29
+ @path_stack = []
30
+ end
31
+
32
+ def self.keycode(s)
33
+ return s[0].to_i
34
+ end
35
+
36
+ def create_table
37
+ @col_names = ['name', 'desc']
38
+ return TaskTable.new(self) do
39
+ name 'my table'
40
+ title 'my table'
41
+ cell_editing_allowed false
42
+ end
43
+ end
44
+
45
+ def reenable_including_prerequisites(task)
46
+ task.visit() do |t|
47
+ t.reenable
48
+ true
49
+ end
50
+ end
51
+
52
+ def invoke(table)
53
+ t = table.get_value_at(table.focussed_row, 0)
54
+ @progress_helper = ProgressHelper.new
55
+ complete_task_name = t.name
56
+ args = []
57
+ if @progress_helper.is_filter(t.name)
58
+ args = [get_string('please input filterpattern', 20, '.*')]
59
+ complete_task_name = "#{t.name}[#{args[0]}]"
60
+ end
61
+ @progress_helper.count_with_filter(complete_task_name)
62
+
63
+ @progress.max = @progress_helper.todo
64
+ Rake::add_listener(self)
65
+ reenable_including_prerequisites(t)
66
+ t.invoke(args)
67
+ Rake::remove_listener(self)
68
+ show_details_for(table.focussed_row)
69
+ table.repaint_all(true)
70
+ end
71
+
72
+ def after_execute(name)
73
+ needed_tasks = @progress_helper.needed_tasks
74
+ if needed_tasks[name]
75
+ task = Rake::Task[name]
76
+ @progress.title = task.name
77
+ @progress.inc(task.progress_count)
78
+ @form.repaint
79
+ end
80
+ end
81
+
82
+ def details(table)
83
+ t = table.get_value_at(table.focussed_row, 0)
84
+ pre = t.prerequisite_tasks
85
+ if pre.size > 0
86
+ push_table_data(pre, t.name)
87
+ table.set_focus_on 0
88
+
89
+ show_details_for(0)
90
+ end
91
+ end
92
+
93
+ def repaint_and_next_char
94
+ @form.repaint
95
+ @window.wrefresh
96
+ return @window.getchar
97
+ end
98
+
99
+ def process_input_events
100
+ ch = repaint_and_next_char
101
+ while ch != RakeGui.keycode('q')
102
+ $log.error "entered key: #{ch}"
103
+ case ch
104
+ when RakeGui.keycode('a')
105
+ @h_split.set_divider_location(@h_split.divider_location+1)
106
+ when RakeGui.keycode('s')
107
+ @h_split.set_divider_location(@h_split.divider_location-1)
108
+ else
109
+ @form.handle_key(ch)
110
+ end
111
+ ch = repaint_and_next_char
112
+ end
113
+ end
114
+
115
+ def push_table_data(task_data, new_path=nil)
116
+ @path_stack.push(new_path) if new_path
117
+ set_breadcrumbs
118
+
119
+ @data_stack.push(task_data)
120
+ set_table_data(task_data)
121
+ end
122
+ def set_table_data(task_data)
123
+ size = size()
124
+ new_data = task_data.map{|t|[t, t.comment]}
125
+ @table.set_data new_data, @col_names
126
+ tcm = @table.table_column_model
127
+ first_col_width = task_data.map{|t|t.name.size}.max
128
+ tcm.column(0).width(first_col_width)
129
+ tcm.column(1).width(size[0]-first_col_width-3)
130
+ end
131
+ def set_breadcrumbs
132
+ crumbs = File.join(@path_stack.map{|i|"(#{i})"}.join('/'))
133
+ @breadcrumbs.text = crumbs
134
+ @breadcrumbs.repaint_all(true)
135
+ end
136
+ def pop_data
137
+ if @data_stack.size > 1
138
+ @path_stack.pop
139
+ set_breadcrumbs
140
+
141
+ popped = @data_stack.pop
142
+ top= @data_stack.last
143
+ set_table_data(top)
144
+ end
145
+ end
146
+
147
+ def size
148
+ return @window.default_for(:width), @window.default_for(:height)
149
+ end
150
+
151
+ def show_details_for(row)
152
+ buffer = StringIO.new
153
+ t = @table.get_value_at(row, 0)
154
+ t.visit do |t|
155
+ if t.output_string && t.output_string.length > 0
156
+ buffer.puts(t.output_string)
157
+ end
158
+ if t.failure
159
+ true
160
+ else
161
+ false
162
+ end
163
+ end
164
+ @output.set_content(buffer.string)
165
+ @output.set_focus_on(0)
166
+ @output.repaint_all(true)
167
+ end
168
+
169
+ def start_editor_for_task(t)
170
+ file_name = t.name
171
+ return unless File.exists?(file_name)
172
+
173
+ start_editor(file_name, 0, 0)
174
+ end
175
+
176
+ def start_editor(file, line, column)
177
+ $log.error "starting editor for #{file}:#{line}"
178
+ editor = ENV['EDITOR']
179
+ editor = 'vi' unless editor
180
+ cmd = "#{editor} +#{line} #{file}"
181
+ shell_out(cmd)
182
+ end
183
+
184
+ def shell_out(cmd)
185
+ @window.hide
186
+ Ncurses.endwin
187
+ system(cmd)
188
+ Ncurses.refresh
189
+ @window.show
190
+ end
191
+
192
+ def create_breadcrumbs(size)
193
+ @breadcrumbs = Label.new @form do
194
+ name 'breadcrumbs'
195
+ row 0
196
+ col 0
197
+ width size[0]
198
+ height 1
199
+ end
200
+ @breadcrumbs.display_length(size[0])
201
+ @breadcrumbs.text = ''
202
+ end
203
+
204
+ def create_splitpane(size)
205
+ @h_split = SplitPane.new @form do
206
+ name 'mainpane'
207
+ row 1
208
+ col 0
209
+ width size[0]
210
+ height size[1]-3
211
+ orientation :HORIZONTAL_SPLIT
212
+ end
213
+ end
214
+
215
+ def create_output_view(size)
216
+ @output = TextView.new nil
217
+ @output.set_content('')
218
+ @output.configure do
219
+ bind_key(RakeGui.keycode('e')) do |code|
220
+ line = selected_item
221
+ file_pattern = '(.*?):(\d+):(\d*):? '
222
+ error_pattern = Regexp.new("#{file_pattern}(error: .*)")
223
+ warning_pattern = Regexp.new("#{file_pattern}(warning: .*)")
224
+ md = error_pattern.match(line)
225
+ md = warning_pattern.match(line) unless md
226
+ if md
227
+ file_name = md[1]
228
+ line = md[2]
229
+ col = md[3]
230
+ rake_gui.start_editor(file_name, line, col)
231
+ end
232
+ end
233
+ end
234
+ end
235
+
236
+ def create_components(size)
237
+ create_breadcrumbs(size)
238
+ @progress = Progress.new(@form, size)
239
+ create_splitpane(size)
240
+ @table = create_table
241
+ push_table_data(Rake::Task.tasks.select {|t|t.comment})
242
+
243
+ create_output_view(size)
244
+ end
245
+
246
+ def wire_components
247
+ @h_split.first_component(@table)
248
+ @h_split.second_component(@output)
249
+ @h_split.set_resize_weight(0.50)
250
+ end
251
+
252
+ def run
253
+ rake_gui = self
254
+ begin
255
+ VER::start_ncurses
256
+
257
+ @window = VER::Window.root_window
258
+ @form = Form.new @window
259
+
260
+ create_components(size())
261
+ wire_components
262
+
263
+ @table.bind(:TABLE_TRAVERSAL_EVENT) do |e|
264
+ rake_gui.show_details_for(e.newrow)
265
+ end
266
+
267
+ process_input_events
268
+ rescue => e
269
+ puts e
270
+ end
271
+ @window.destroy if @window
272
+ VER::stop_ncurses
273
+ end
274
+ end
275
+
276
+ task :ui do
277
+ RakeGui.new.run
278
+ end
279
+
280
+ end
281
+
282
+ optional_package(define_rbcurse_ui, nil)
283
+ end
284
+ end