cxxproject 0.5.76 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Rakefile.rb +116 -116
  2. data/bin/cxx +10 -10
  3. data/lib/cxxproject/buildingblocks/binary_library.rb +39 -39
  4. data/lib/cxxproject/buildingblocks/building_block.rb +251 -234
  5. data/lib/cxxproject/buildingblocks/command_line.rb +79 -86
  6. data/lib/cxxproject/buildingblocks/custom_building_block.rb +39 -39
  7. data/lib/cxxproject/buildingblocks/executable.rb +246 -258
  8. data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +83 -83
  9. data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -20
  10. data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +34 -34
  11. data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +371 -379
  12. data/lib/cxxproject/buildingblocks/makefile.rb +153 -153
  13. data/lib/cxxproject/buildingblocks/module.rb +35 -35
  14. data/lib/cxxproject/buildingblocks/single_source.rb +33 -33
  15. data/lib/cxxproject/buildingblocks/source_library.rb +124 -111
  16. data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -40
  17. data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +41 -41
  18. data/lib/cxxproject/errorparser/error_parser.rb +50 -71
  19. data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +35 -35
  20. data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +35 -35
  21. data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -30
  22. data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +30 -30
  23. data/lib/cxxproject/eval_context.rb +144 -144
  24. data/lib/cxxproject/ext/file.rb +71 -81
  25. data/lib/cxxproject/ext/filelist.rb +6 -6
  26. data/lib/cxxproject/ext/progressbar.rb +20 -0
  27. data/lib/cxxproject/ext/rake.rb +419 -434
  28. data/lib/cxxproject/ext/rake_dirty.rb +30 -30
  29. data/lib/cxxproject/ext/rake_listener.rb +59 -59
  30. data/lib/cxxproject/ext/stdout.rb +44 -44
  31. data/lib/cxxproject/ext/string.rb +9 -9
  32. data/lib/cxxproject/ide_interface.rb +187 -189
  33. data/lib/cxxproject/toolchain/clang.rb +39 -43
  34. data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -99
  35. data/lib/cxxproject/toolchain/diab.rb +1 -1
  36. data/lib/cxxproject/toolchain/gcc.rb +1 -1
  37. data/lib/cxxproject/toolchain/provider.rb +131 -143
  38. data/lib/cxxproject/toolchain/toolchain.rb +38 -38
  39. data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -23
  40. data/lib/cxxproject/torake.rb +259 -218
  41. data/lib/cxxproject/utils/cleanup.rb +20 -24
  42. data/lib/cxxproject/utils/console.rb +6 -6
  43. data/lib/cxxproject/utils/exit_helper.rb +40 -40
  44. data/lib/cxxproject/utils/graphstream.rb +154 -154
  45. data/lib/cxxproject/utils/optional.rb +16 -16
  46. data/lib/cxxproject/utils/printer.rb +50 -50
  47. data/lib/cxxproject/utils/process.rb +52 -58
  48. data/lib/cxxproject/utils/progress.rb +66 -0
  49. data/lib/cxxproject/utils/progress_helper.rb +77 -0
  50. data/lib/cxxproject/utils/rbcurse.rb +284 -0
  51. data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -0
  52. data/lib/cxxproject/utils/rbcurse_progress.rb +71 -0
  53. data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -0
  54. data/lib/cxxproject/utils/stats.rb +60 -60
  55. data/lib/cxxproject/utils/ubigraph.rb +228 -228
  56. data/lib/cxxproject/utils/utils.rb +37 -69
  57. data/lib/cxxproject/version.rb +7 -7
  58. data/lib/cxxproject.rb +23 -19
  59. data/lib/tools/Rakefile.rb.template +10 -10
  60. data/lib/tools/project.rb.template +6 -6
  61. data/lib/tools/project_wizard.rb +66 -66
  62. data/spec/building_block_spec.rb +56 -56
  63. data/spec/cxxproject_2_rake_spec.rb +186 -186
  64. data/spec/file_ext_spec.rb +30 -30
  65. data/spec/ide_interface_spec.rb +41 -41
  66. data/spec/object_dependency_spec.rb +83 -83
  67. data/spec/project_path_spec.rb +71 -71
  68. data/spec/rake_listener_ext_spec.rb +58 -58
  69. data/spec/spec_helper.rb +18 -18
  70. data/spec/string_spec.rb +11 -11
  71. data/spec/testdata/basic/exe12/project.rb +5 -5
  72. data/spec/testdata/basic/lib1/project.rb +5 -5
  73. data/spec/testdata/basic/lib2/project.rb +8 -8
  74. data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -5
  75. data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -19
  76. data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -8
  77. data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -4
  78. data/spec/testdata/onlyOneHeader/project.rb +4 -4
  79. data/spec/toolchain_spec.rb +29 -29
  80. metadata +116 -107
  81. checksums.yaml +0 -7
  82. data/lib/cxxproject/buildingblocks/lint.rb +0 -89
  83. data/lib/cxxproject/errorparser/gcc_lint_error_parser.rb +0 -34
  84. data/lib/cxxproject/errorparser/greenhills_compiler_error_parser.rb +0 -32
  85. data/lib/cxxproject/errorparser/greenhills_linker_error_parser.rb +0 -44
  86. data/lib/cxxproject/errorparser/keil_compiler_error_parser.rb +0 -40
  87. data/lib/cxxproject/errorparser/keil_linker_error_parser.rb +0 -30
  88. data/lib/cxxproject/toolchain/gcc_lint.rb +0 -21
  89. data/lib/cxxproject/toolchain/gcc_param.rb +0 -7
  90. data/lib/cxxproject/toolchain/greenhills.rb +0 -51
  91. data/lib/cxxproject/toolchain/keil.rb +0 -52
  92. data/lib/cxxproject/utils/valgrind.rb +0 -11
@@ -1,234 +1,251 @@
1
- require 'cxxproject/buildingblocks/has_dependencies_mixin'
2
- require 'cxxproject/utils/exit_helper'
3
- require 'cxxproject/ext/rake'
4
- require 'cxxproject/ext/file'
5
- require 'cxxproject/ide_interface'
6
- require 'cxxproject/utils/printer'
7
-
8
- # no deprecated warning for rake >= 0.9.x
9
- include Rake::DSL if defined?(Rake::DSL)
10
- module Cxxproject
11
-
12
- # stores all defined buildingblocks by name (the name should be unique)
13
- ALL_BUILDING_BLOCKS = {}
14
-
15
- trap("INT") do
16
- Rake.application.idei.set_abort(true)
17
- end
18
-
19
- class BuildingBlock
20
- include HasDependencies
21
-
22
- attr_reader :name
23
- attr_reader :config_name
24
- attr_reader :config_files
25
-
26
- attr_reader :project_dir
27
- attr_accessor :output_dir
28
- attr_accessor :output_dir_relPath
29
- attr_accessor :pre_step
30
-
31
- def set_name(x)
32
- @name = x
33
- self
34
- end
35
-
36
- def set_tcs(x)
37
- @tcs = x
38
- self
39
- end
40
-
41
- def has_tcs?
42
- @tcs != nil
43
- end
44
-
45
- def tcs()
46
- raise "Toolchain settings must be set before!" if @tcs.nil?
47
- @tcs
48
- end
49
-
50
- def set_config_files(x)
51
- @config_files = x
52
- @config_date = Time.now
53
- self
54
- end
55
-
56
- def set_project_dir(x)
57
- @project_dir = File.expand_path(x)
58
- self
59
- end
60
-
61
- def set_output_dir(x)
62
- return self if @output_dir
63
-
64
- if not @project_dir
65
- raise "Error: set project dir before output dir!"
66
- end
67
-
68
- if File.is_absolute?(x)
69
- @output_dir = x
70
- @output_dir_relPath = File.rel_from_to_project(@project_dir, x)
71
- else
72
- @output_dir = File.join(@project_dir, x)
73
- @output_dir_relPath = x
74
- end
75
-
76
- self
77
- end
78
-
79
- def initialize(name)
80
- @name = name
81
- @config_name = nil
82
- @config_files = []
83
- @config_date = nil
84
- @project_dir = nil
85
- @tcs = nil
86
- @output_dir = nil
87
- @pre_step = nil
88
- @printedCmdAlternate = false
89
- @lastCommand = nil
90
-
91
- if ALL_BUILDING_BLOCKS.include?(@name) and not self.instance_of?(BinaryLibrary)
92
- raise "building block already exists: #{name}"
93
- else
94
- ALL_BUILDING_BLOCKS[@name] = self
95
- end
96
- end
97
-
98
- def set_config_name(x)
99
- @config_name = x
100
- end
101
-
102
- def complete_init()
103
- if self.respond_to?(:calc_compiler_strings)
104
- calc_compiler_strings
105
- end
106
- end
107
-
108
- def get_task_name()
109
- raise "this method must be implemented by decendants"
110
- end
111
-
112
- ##
113
- # convert all dependencies of a building block to rake task prerequisites (e.g. exe needs lib)
114
- #
115
- def setup_rake_dependencies(task, multitask = nil)
116
- dependencies.reverse_each do |d|
117
- begin
118
- bb = ALL_BUILDING_BLOCKS[d]
119
- raise "Error: tried to add the dependencies of \"#{d}\" to \"#{@name}\" but such a building block could not be found!" unless bb
120
-
121
- if multitask and bb.pre_step
122
- multitask.prerequisites.unshift(bb.get_task_name)
123
- else
124
- task.prerequisites.unshift(bb.get_task_name)
125
- end
126
- rescue ExitHelperException
127
- raise
128
- rescue Exception => e
129
- Printer.printError e.message
130
- ExitHelper.exit(1)
131
- end
132
- end
133
-
134
- task
135
- end
136
-
137
- def add_output_dir_dependency(file, taskOfFile, addDirToCleanTask)
138
- d = File.dirname(file)
139
- directory d
140
- taskOfFile.enhance([d])
141
-
142
- if addDirToCleanTask
143
- CLEAN.include(@output_dir)
144
- end
145
- end
146
-
147
- def printCmd(cmd, alternate, showPath)
148
- @lastCommand = cmd
149
- if showPath or RakeFileUtils.verbose or (alternate.nil? and not Rake::application.options.silent)
150
- @printedCmdAlternate = false
151
- exedIn = ""
152
- exedIn = "\n(executed in '#{@project_dir}')" if (showPath or RakeFileUtils.verbose)
153
- puts "" if Rake::application.addEmptyLine
154
- if cmd.is_a?(Array)
155
- puts cmd.join(' ') + exedIn
156
- else
157
- puts cmd + exedIn
158
- end
159
- else
160
- @printedCmdAlternate = true
161
- puts alternate unless Rake::application.options.silent
162
- end
163
- @lastCommand = cmd
164
- end
165
-
166
-
167
- def process_result(cmd, console_output, error_parser, alternate, success)
168
- hasError = (success == false)
169
- if (cmd != @lastCommand) or (@printedCmdAlternate and hasError)
170
- printCmd(cmd, alternate, hasError && Rake::application.lint == false)
171
- end
172
- errorPrinted = process_console_output(console_output, error_parser)
173
-
174
- if hasError
175
- if not errorPrinted
176
- Printer.printError "Error: system command failed"
177
- res = ErrorDesc.new
178
- res.file_name = @project_dir
179
- res.line_number = 0
180
- res.message = "Unknown error, see log output. Maybe the bake error parser has to be updated..."
181
- res.severity = ErrorParser::SEVERITY_ERROR
182
- Rake.application.idei.set_errors([res])
183
- end
184
- end
185
- if hasError or errorPrinted
186
- raise SystemCommandFailed.new
187
- end
188
- end
189
-
190
- def read_file_or_empty_string(filename)
191
- begin
192
- return File.read(filename)
193
- rescue
194
- return ""
195
- end
196
- end
197
-
198
- def typed_file_task(type, *args, &block)
199
- t = file *args do
200
- block.call
201
- end
202
- t.type = type
203
- return t
204
- end
205
-
206
- def remove_empty_strings_and_join(a, j=' ')
207
- return a.reject{|e|e.to_s.empty?}.join(j)
208
- end
209
-
210
- def catch_output(cmd)
211
- new_command = "#{cmd} 2>&1"
212
- # "/" does not work on windows with backticks, switch the separator on windows:
213
- new_command.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
214
- return `#{new_command}`
215
- end
216
-
217
- def check_config_file()
218
- if @config_date
219
- @config_files.each do |c|
220
- err_msg = nil
221
- if File.exists?(c) and File.mtime(c) > @config_date
222
- @config_date = File.mtime(c)
223
- begin
224
- FileUtils.touch(c)
225
- rescue Exception
226
- end
227
- end
228
- end
229
- end
230
- end
231
-
232
- end
233
-
234
- end
1
+ require 'cxxproject/buildingblocks/has_dependencies_mixin'
2
+ require 'cxxproject/utils/exit_helper'
3
+ require 'cxxproject/ext/rake'
4
+ require 'cxxproject/ext/file'
5
+ require 'cxxproject/ide_interface'
6
+ require 'cxxproject/utils/printer'
7
+
8
+ # no deprecated warning for rake >= 0.9.x
9
+ include Rake::DSL if defined?(Rake::DSL)
10
+ module Cxxproject
11
+
12
+ # stores all defined buildingblocks by name (the name should be unique)
13
+ ALL_BUILDING_BLOCKS = {}
14
+
15
+ trap("INT") do
16
+ Rake.application.idei.set_abort(true)
17
+ end
18
+
19
+ class BuildingBlock
20
+ include HasDependencies
21
+
22
+ attr_reader :name
23
+ attr_reader :config_name
24
+ attr_reader :config_files
25
+
26
+ attr_reader :project_dir
27
+ attr_accessor :output_dir
28
+ attr_accessor :pre_step
29
+ attr_reader :output_dir_abs
30
+
31
+ def set_name(x)
32
+ @name = x
33
+ self
34
+ end
35
+
36
+ def set_tcs(x)
37
+ @tcs = x
38
+ self
39
+ end
40
+
41
+ def has_tcs?
42
+ @tcs != nil
43
+ end
44
+
45
+ def tcs()
46
+ raise "Toolchain settings must be set before!" if @tcs.nil?
47
+ @tcs
48
+ end
49
+
50
+ def set_config_files(x)
51
+ @config_files = x
52
+ @config_date = Time.now
53
+ self
54
+ end
55
+
56
+ def set_project_dir(x)
57
+ @project_dir = File.expand_path(x)
58
+ if @output_dir_abs
59
+ @output_dir_relPath = File.rel_from_to_project(@project_dir, @output_dir)
60
+ end
61
+ self
62
+ end
63
+
64
+ # if output dir is absolute, -L and -l is used for linker ("linux mode")
65
+ def set_output_dir(x)
66
+ return self if @output_dir
67
+
68
+ @output_dir = x
69
+ @output_dir_abs = File.is_absolute?(@output_dir)
70
+ if @project_dir
71
+ @output_dir_relPath = File.rel_from_to_project(@project_dir, @output_dir)
72
+ end
73
+ self
74
+ end
75
+
76
+ def complete_output_dir
77
+ @complete_output_dir ||= calc_complete_output_dir
78
+ end
79
+
80
+ def calc_complete_output_dir
81
+ if @output_dir_abs
82
+ @output_dir
83
+ else
84
+ File.join(@project_dir, @output_dir)
85
+ end
86
+ end
87
+
88
+ def initialize(name)
89
+ @name = name
90
+ @config_name = nil
91
+ @config_files = []
92
+ @config_date = nil
93
+ @project_dir = nil
94
+ @tcs = nil
95
+ @output_dir = nil
96
+ @output_dir_abs = false
97
+ @complete_output_dir = nil
98
+ @pre_step = nil
99
+ @printedCmdAlternate = false
100
+ @lastCommand = nil
101
+
102
+ if ALL_BUILDING_BLOCKS.include?(@name) and not self.instance_of?(BinaryLibrary)
103
+ raise "building block already exists: #{name}"
104
+ else
105
+ ALL_BUILDING_BLOCKS[@name] = self
106
+ end
107
+ end
108
+
109
+ def set_config_name(x)
110
+ @config_name = x
111
+ end
112
+
113
+ def complete_init()
114
+ if self.respond_to?(:calc_compiler_strings)
115
+ calc_compiler_strings
116
+ end
117
+ end
118
+
119
+ def get_task_name()
120
+ raise "this method must be implemented by decendants"
121
+ end
122
+
123
+ ##
124
+ # convert all dependencies of a building block to rake task prerequisites (e.g. exe needs lib)
125
+ #
126
+ def setup_rake_dependencies(task, multitask = nil)
127
+ dependencies.reverse_each do |d|
128
+ begin
129
+ bb = ALL_BUILDING_BLOCKS[d]
130
+ raise "Error: tried to add the dependencies of \"#{d}\" to \"#{@name}\" but such a building block could not be found!" unless bb
131
+
132
+ if multitask and bb.pre_step
133
+ multitask.prerequisites.unshift(bb.get_task_name)
134
+ else
135
+ task.prerequisites.unshift(bb.get_task_name)
136
+ end
137
+ rescue ExitHelperException
138
+ raise
139
+ rescue Exception => e
140
+ Printer.printError e.message
141
+ ExitHelper.exit(1)
142
+ end
143
+ end
144
+
145
+ task
146
+ end
147
+
148
+ def add_output_dir_dependency(file, taskOfFile, addDirToCleanTask)
149
+ d = File.dirname(file)
150
+ directory d
151
+ taskOfFile.enhance([d])
152
+
153
+ if addDirToCleanTask
154
+ CLOBBER.include(complete_output_dir)
155
+ if (@output_dir_abs)
156
+ CLEAN.include(file)
157
+ else
158
+ CLEAN.include(complete_output_dir)
159
+ end
160
+ end
161
+ end
162
+
163
+ def printCmd(cmd, alternate, showPath)
164
+ @lastCommand = cmd
165
+ if showPath or RakeFileUtils.verbose or (alternate.nil? and not Rake::application.options.silent)
166
+ @printedCmdAlternate = false
167
+ exedIn = ""
168
+ exedIn = " (executed in '#{@project_dir}')" if (showPath or RakeFileUtils.verbose)
169
+ puts "" if Rake::application.addEmptyLine
170
+ if cmd.is_a?(Array)
171
+ puts cmd.join(' ') + exedIn
172
+ else
173
+ puts cmd + exedIn
174
+ end
175
+ else
176
+ @printedCmdAlternate = true
177
+ puts alternate unless Rake::application.options.silent
178
+ end
179
+ @lastCommand = cmd
180
+ end
181
+
182
+
183
+ def process_result(cmd, console_output, error_parser, alternate)
184
+ hasError = ($?.success? == false)
185
+ if (cmd != @lastCommand) or (@printedCmdAlternate and hasError)
186
+ printCmd(cmd, alternate, hasError)
187
+ end
188
+ errorPrinted = process_console_output(console_output, error_parser)
189
+
190
+ if hasError
191
+ if not errorPrinted
192
+ Printer.printError "Error: system command failed"
193
+ res = ErrorDesc.new
194
+ res.file_name = @project_dir
195
+ res.line_number = 0
196
+ res.message = "Unknown error, see log output. Maybe the lake error parser has to be updated..."
197
+ res.severity = ErrorParser::SEVERITY_ERROR
198
+ Rake.application.idei.set_errors([res])
199
+ end
200
+ end
201
+ if hasError or errorPrinted
202
+ raise SystemCommandFailed.new
203
+ end
204
+ end
205
+
206
+ def read_file_or_empty_string(filename)
207
+ begin
208
+ return File.read(filename)
209
+ rescue
210
+ return ""
211
+ end
212
+ end
213
+
214
+ def typed_file_task(type, *args, &block)
215
+ t = file *args do
216
+ block.call
217
+ end
218
+ t.type = type
219
+ t.progress_count = 1
220
+ return t
221
+ end
222
+
223
+ def remove_empty_strings_and_join(a, j=' ')
224
+ return a.reject{|e|e.to_s.empty?}.join(j)
225
+ end
226
+
227
+ def catch_output(cmd)
228
+ new_command = "#{cmd} 2>&1"
229
+ # "/" does not work on windows with backticks, switch the separator on windows:
230
+ new_command.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
231
+ return `#{new_command}`
232
+ end
233
+
234
+ def check_config_file()
235
+ if @config_date
236
+ @config_files.each do |c|
237
+ err_msg = nil
238
+ if File.exists?(c) and File.mtime(c) > @config_date
239
+ @config_date = File.mtime(c)
240
+ begin
241
+ FileUtils.touch(c)
242
+ rescue Exception
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
248
+
249
+ end
250
+
251
+ end
@@ -1,86 +1,79 @@
1
- require 'cxxproject/buildingblocks/building_block'
2
- require 'cxxproject/utils/process'
3
-
4
- module Cxxproject
5
-
6
- class CommandLine < BuildingBlock
7
-
8
- def set_command_line(x)
9
- @line = x
10
- self
11
- end
12
-
13
- def get_command_line
14
- @line
15
- end
16
-
17
- def set_defined_in_file(x)
18
- @defined_in_file = x
19
- self
20
- end
21
-
22
- def get_defined_in_file
23
- @defined_in_file
24
- end
25
-
26
- def set_defined_in_line(x)
27
- @defined_in_line = x
28
- self
29
- end
30
-
31
- def get_defined_in_line
32
- @defined_in_line
33
- end
34
-
35
- def initialize(name)
36
- set_command_line(name)
37
- @num = Rake.application.command_line_number
38
- super(get_task_name)
39
- end
40
-
41
- def get_task_name()
42
- "command line (#{@num}): " + get_command_line
43
- end
44
-
45
- def convert_to_rake()
46
- res = task get_task_name do
47
- Dir.chdir(@project_dir) do
48
- check_config_file
49
- cmd = get_command_line
50
- puts cmd + (RakeFileUtils.verbose ? "\n(executed in '#{@project_dir}')" : "")
51
- cmd_result = false
52
- begin
53
- rd, wr = IO.pipe
54
- cmd = [cmd]
55
- cmd << {
56
- :err=>wr,
57
- :out=>wr
58
- }
59
- cmd_result, consoleOutput = ProcessHelper.safeExecute() { sp = spawn(*cmd); ProcessHelper.readOutput(sp, rd, wr) }
60
- puts consoleOutput
61
- rescue
62
- end
63
- if (cmd_result == false)
64
- if Rake.application.idei
65
- err_res = ErrorDesc.new
66
- err_res.file_name = (@defined_in_file ? @defined_in_file : @project_dir)
67
- err_res.line_number = (@defined_in_line ? @defined_in_line : 0)
68
- err_res.severity = ErrorParser::SEVERITY_ERROR
69
- err_res.message = "Command \"#{get_command_line}\" failed"
70
- Rake.application.idei.set_errors([err_res])
71
- end
72
- Printer.printError "Error: command \"#{get_command_line}\" failed" + (RakeFileUtils.verbose ? "" : "\n(executed in '#{@project_dir}')")
73
- raise SystemCommandFailed.new
74
- end
75
- end
76
- end
77
- res.immediate_output = true
78
- res.transparent_timestamp = true
79
- res.type = Rake::Task::COMMANDLINE
80
- setup_rake_dependencies(res)
81
- res
82
- end
83
-
84
-
85
- end
86
- end
1
+ require 'cxxproject/buildingblocks/building_block'
2
+ require 'cxxproject/utils/process'
3
+
4
+ module Cxxproject
5
+
6
+ class CommandLine < BuildingBlock
7
+
8
+ def set_command_line(x)
9
+ @line = x
10
+ self
11
+ end
12
+
13
+ def get_command_line
14
+ @line
15
+ end
16
+
17
+ def set_defined_in_file(x)
18
+ @defined_in_file = x
19
+ self
20
+ end
21
+
22
+ def get_defined_in_file
23
+ @defined_in_file
24
+ end
25
+
26
+ def set_defined_in_line(x)
27
+ @defined_in_line = x
28
+ self
29
+ end
30
+
31
+ def get_defined_in_line
32
+ @defined_in_line
33
+ end
34
+
35
+ def initialize(name)
36
+ set_command_line(name)
37
+ @num = Rake.application.command_line_number
38
+ super(get_task_name)
39
+ end
40
+
41
+ def get_task_name()
42
+ "command line (#{@num}): " + get_command_line
43
+ end
44
+
45
+ def convert_to_rake()
46
+ res = task get_task_name do
47
+ Dir.chdir(@project_dir) do
48
+ check_config_file
49
+ cmd = get_command_line
50
+ puts cmd + (RakeFileUtils.verbose ? " (executed in '#{@project_dir}')" : "")
51
+ cmd_result = false
52
+ begin
53
+ cmd_result = ProcessHelper.spawnProcess(cmd + " 2>&1")
54
+ rescue
55
+ end
56
+ if (cmd_result == false)
57
+ if Rake.application.idei
58
+ err_res = ErrorDesc.new
59
+ err_res.file_name = (@defined_in_file ? @defined_in_file : @project_dir)
60
+ err_res.line_number = (@defined_in_line ? @defined_in_line : 0)
61
+ err_res.severity = ErrorParser::SEVERITY_ERROR
62
+ err_res.message = "Command \"#{get_command_line}\" failed"
63
+ Rake.application.idei.set_errors([err_res])
64
+ end
65
+ Printer.printError "Error: command \"#{get_command_line}\" failed" + (RakeFileUtils.verbose ? "" : " (executed in '#{@project_dir}')")
66
+ raise SystemCommandFailed.new
67
+ end
68
+ end
69
+ end
70
+ res.immediate_output = true
71
+ res.transparent_timestamp = true
72
+ res.type = Rake::Task::COMMANDLINE
73
+ setup_rake_dependencies(res)
74
+ res
75
+ end
76
+
77
+
78
+ end
79
+ end