cxxproject 0.5.48 → 0.5.59
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +116 -116
- data/bin/cxx +10 -10
- data/lib/cxxproject.rb +23 -23
- data/lib/cxxproject/buildingblocks/binary_library.rb +39 -39
- data/lib/cxxproject/buildingblocks/building_block.rb +251 -239
- data/lib/cxxproject/buildingblocks/command_line.rb +79 -79
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +39 -41
- data/lib/cxxproject/buildingblocks/executable.rb +257 -249
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +83 -83
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -20
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +34 -34
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +371 -364
- data/lib/cxxproject/buildingblocks/makefile.rb +153 -153
- data/lib/cxxproject/buildingblocks/module.rb +35 -35
- data/lib/cxxproject/buildingblocks/single_source.rb +33 -33
- data/lib/cxxproject/buildingblocks/source_library.rb +124 -124
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -40
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +41 -33
- data/lib/cxxproject/errorparser/error_parser.rb +50 -50
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +35 -30
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +35 -29
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -30
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +30 -29
- data/lib/cxxproject/eval_context.rb +144 -136
- data/lib/cxxproject/ext/file.rb +71 -71
- data/lib/cxxproject/ext/filelist.rb +6 -6
- data/lib/cxxproject/ext/progressbar.rb +20 -20
- data/lib/cxxproject/ext/rake.rb +419 -397
- data/lib/cxxproject/ext/rake_dirty.rb +30 -30
- data/lib/cxxproject/ext/rake_listener.rb +59 -59
- data/lib/cxxproject/ext/stdout.rb +44 -44
- data/lib/cxxproject/ext/string.rb +9 -9
- data/lib/cxxproject/ide_interface.rb +187 -181
- data/lib/cxxproject/toolchain/clang.rb +39 -39
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -99
- data/lib/cxxproject/toolchain/diab.rb +3 -1
- data/lib/cxxproject/toolchain/gcc.rb +2 -1
- data/lib/cxxproject/toolchain/provider.rb +131 -128
- data/lib/cxxproject/toolchain/toolchain.rb +38 -38
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -23
- data/lib/cxxproject/torake.rb +218 -216
- data/lib/cxxproject/utils/cleanup.rb +20 -20
- data/lib/cxxproject/utils/console.rb +6 -6
- data/lib/cxxproject/utils/exit_helper.rb +40 -40
- data/lib/cxxproject/utils/graphstream.rb +154 -154
- data/lib/cxxproject/utils/optional.rb +16 -16
- data/lib/cxxproject/utils/printer.rb +50 -50
- data/lib/cxxproject/utils/process.rb +52 -52
- data/lib/cxxproject/utils/progress.rb +66 -66
- data/lib/cxxproject/utils/progress_helper.rb +77 -77
- data/lib/cxxproject/utils/rbcurse.rb +284 -284
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -14
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -71
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -51
- data/lib/cxxproject/utils/stats.rb +60 -60
- data/lib/cxxproject/utils/ubigraph.rb +228 -228
- data/lib/cxxproject/utils/utils.rb +60 -37
- data/lib/cxxproject/utils/valgrind.rb +11 -11
- data/lib/cxxproject/version.rb +7 -7
- data/lib/tools/Rakefile.rb.template +10 -10
- data/lib/tools/project.rb.template +6 -6
- data/lib/tools/project_wizard.rb +66 -66
- data/spec/building_block_spec.rb +56 -56
- data/spec/cxxproject_2_rake_spec.rb +186 -186
- data/spec/file_ext_spec.rb +30 -30
- data/spec/ide_interface_spec.rb +41 -41
- data/spec/object_dependency_spec.rb +83 -83
- data/spec/project_path_spec.rb +71 -71
- data/spec/rake_listener_ext_spec.rb +58 -58
- data/spec/spec_helper.rb +18 -18
- data/spec/string_spec.rb +11 -11
- data/spec/testdata/basic/exe12/project.rb +5 -5
- data/spec/testdata/basic/lib1/project.rb +5 -5
- data/spec/testdata/basic/lib2/project.rb +8 -8
- data/spec/testdata/multiple_levels/libs/lib1/project.rb +5 -5
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +19 -19
- data/spec/testdata/multiple_levels/mainproject/basic/project.rb +8 -8
- data/spec/testdata/onlyOneHeader/Rakefile.rb +4 -4
- data/spec/testdata/onlyOneHeader/project.rb +4 -4
- data/spec/toolchain_spec.rb +29 -29
- metadata +58 -58
@@ -1,79 +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 ? " (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
|
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
|
@@ -1,41 +1,39 @@
|
|
1
|
-
require 'cxxproject/buildingblocks/building_block'
|
2
|
-
|
3
|
-
# todo...
|
4
|
-
module Cxxproject
|
5
|
-
|
6
|
-
class CustomBuildingBlock < BuildingBlock
|
7
|
-
attr_reader :custom_command, :actions
|
8
|
-
|
9
|
-
def set_custom_command(c)
|
10
|
-
@custom_command = c
|
11
|
-
self
|
12
|
-
end
|
13
|
-
|
14
|
-
def get_task_name()
|
15
|
-
name
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_actions(actions)
|
19
|
-
if actions.kind_of?(Array)
|
20
|
-
@actions = actions
|
21
|
-
else
|
22
|
-
@actions = [actions]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def convert_to_rake()
|
27
|
-
desc get_task_name
|
28
|
-
res = task get_task_name do
|
29
|
-
actions.each do |a|
|
30
|
-
a.call
|
31
|
-
end
|
32
|
-
end
|
33
|
-
res.type = Rake::Task::CUSTOM
|
34
|
-
setup_rake_dependencies(res)
|
35
|
-
res
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
1
|
+
require 'cxxproject/buildingblocks/building_block'
|
2
|
+
|
3
|
+
# todo...
|
4
|
+
module Cxxproject
|
5
|
+
|
6
|
+
class CustomBuildingBlock < BuildingBlock
|
7
|
+
attr_reader :custom_command, :actions
|
8
|
+
|
9
|
+
def set_custom_command(c)
|
10
|
+
@custom_command = c
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_task_name()
|
15
|
+
name
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_actions(actions)
|
19
|
+
if actions.kind_of?(Array)
|
20
|
+
@actions = actions
|
21
|
+
else
|
22
|
+
@actions = [actions]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def convert_to_rake()
|
27
|
+
desc get_task_name
|
28
|
+
res = task get_task_name do
|
29
|
+
actions.each do |a|
|
30
|
+
a.call
|
31
|
+
end
|
32
|
+
end
|
33
|
+
res.type = Rake::Task::CUSTOM
|
34
|
+
setup_rake_dependencies(res)
|
35
|
+
res
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -1,249 +1,257 @@
|
|
1
|
-
require 'cxxproject/buildingblocks/building_block'
|
2
|
-
require 'cxxproject/buildingblocks/has_libraries_mixin'
|
3
|
-
require 'cxxproject/buildingblocks/has_sources_mixin'
|
4
|
-
require 'cxxproject/buildingblocks/has_includes_mixin'
|
5
|
-
require 'cxxproject/utils/process'
|
6
|
-
require 'cxxproject/utils/utils'
|
7
|
-
|
8
|
-
require '
|
9
|
-
|
10
|
-
require '
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
include
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
when HasLibraries::
|
101
|
-
res << "#{linker[:
|
102
|
-
when HasLibraries::
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
tmp
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
cmd
|
136
|
-
cmd
|
137
|
-
cmd
|
138
|
-
cmd
|
139
|
-
cmd <<
|
140
|
-
cmd
|
141
|
-
cmd << linker[:
|
142
|
-
cmd
|
143
|
-
cmd
|
144
|
-
cmd += linker[:
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
cmd
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
def
|
224
|
-
namespace '
|
225
|
-
desc
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
end
|
1
|
+
require 'cxxproject/buildingblocks/building_block'
|
2
|
+
require 'cxxproject/buildingblocks/has_libraries_mixin'
|
3
|
+
require 'cxxproject/buildingblocks/has_sources_mixin'
|
4
|
+
require 'cxxproject/buildingblocks/has_includes_mixin'
|
5
|
+
require 'cxxproject/utils/process'
|
6
|
+
require 'cxxproject/utils/utils'
|
7
|
+
require 'cxxproject/ext/stdout'
|
8
|
+
require 'cxxproject/utils/valgrind'
|
9
|
+
|
10
|
+
require 'tmpdir'
|
11
|
+
require 'set'
|
12
|
+
require 'etc'
|
13
|
+
|
14
|
+
module Cxxproject
|
15
|
+
|
16
|
+
class Executable < BuildingBlock
|
17
|
+
include HasLibraries
|
18
|
+
include HasSources
|
19
|
+
include HasIncludes
|
20
|
+
|
21
|
+
def set_linker_script(x)
|
22
|
+
@linker_script = x
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_mapfile(x)
|
27
|
+
@mapfile = x
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(name)
|
32
|
+
super(name)
|
33
|
+
@linker_script = nil
|
34
|
+
@mapfile = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_executable_name(name) # ensure it's relative
|
38
|
+
@exe_name = name
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_executable_name() # relative path
|
42
|
+
return @exe_name if @exe_name
|
43
|
+
|
44
|
+
parts = [@output_dir]
|
45
|
+
|
46
|
+
if @output_dir_abs
|
47
|
+
parts = [@output_dir_relPath] if @output_dir_relPath
|
48
|
+
end
|
49
|
+
|
50
|
+
parts << "#{@name}#{@tcs[:LINKER][:OUTPUT_ENDING]}"
|
51
|
+
|
52
|
+
@exe_name = File.join(parts)
|
53
|
+
@exe_name
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_task_name() # full path
|
57
|
+
@project_dir + "/" + get_executable_name
|
58
|
+
end
|
59
|
+
|
60
|
+
def collect_unique(array, set)
|
61
|
+
ret = []
|
62
|
+
array.each do |v|
|
63
|
+
if set.add?(v)
|
64
|
+
ret << v
|
65
|
+
end
|
66
|
+
end
|
67
|
+
ret
|
68
|
+
end
|
69
|
+
|
70
|
+
def adaptPath(v, d, prefix)
|
71
|
+
tmp = nil
|
72
|
+
if File.is_absolute?(v)
|
73
|
+
tmp = v
|
74
|
+
else
|
75
|
+
prefix ||= File.rel_from_to_project(@project_dir,d.project_dir)
|
76
|
+
tmp = File.add_prefix(prefix, v)
|
77
|
+
end
|
78
|
+
tmp = "\"" + tmp + "\"" if tmp.include?(" ")
|
79
|
+
[tmp, prefix]
|
80
|
+
end
|
81
|
+
|
82
|
+
def linker_lib_string()
|
83
|
+
@lib_path_set = Set.new
|
84
|
+
@dep_set = Set.new
|
85
|
+
calc_linker_lib_string_recursive(self)
|
86
|
+
end
|
87
|
+
|
88
|
+
def calc_linker_lib_string_recursive(d)
|
89
|
+
res = []
|
90
|
+
|
91
|
+
return res if @dep_set.include?d
|
92
|
+
@dep_set << d
|
93
|
+
|
94
|
+
if HasLibraries === d
|
95
|
+
prefix = nil
|
96
|
+
linker = @tcs[:LINKER]
|
97
|
+
|
98
|
+
d.lib_elements.each do |elem|
|
99
|
+
case elem[0]
|
100
|
+
when HasLibraries::LIB
|
101
|
+
res << "#{linker[:LIB_FLAG]}#{elem[1]}"
|
102
|
+
when HasLibraries::USERLIB
|
103
|
+
res << "#{linker[:USER_LIB_FLAG]}#{elem[1]}"
|
104
|
+
when HasLibraries::LIB_WITH_PATH
|
105
|
+
tmp, prefix = adaptPath(elem[1], d, prefix)
|
106
|
+
res << tmp
|
107
|
+
when HasLibraries::SEARCH_PATH
|
108
|
+
tmp, prefix = adaptPath(elem[1], d, prefix)
|
109
|
+
if not @lib_path_set.include?tmp
|
110
|
+
@lib_path_set << tmp
|
111
|
+
res << "#{linker[:LIB_PATH_FLAG]}#{tmp}"
|
112
|
+
end
|
113
|
+
when HasLibraries::DEPENDENCY
|
114
|
+
if ALL_BUILDING_BLOCKS.include?elem[1]
|
115
|
+
bb = ALL_BUILDING_BLOCKS[elem[1]]
|
116
|
+
res += calc_linker_lib_string_recursive(bb)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
res
|
123
|
+
end
|
124
|
+
|
125
|
+
# create a task that will link an executable from a set of object files
|
126
|
+
#
|
127
|
+
def convert_to_rake()
|
128
|
+
object_multitask = prepare_tasks_for_objects()
|
129
|
+
|
130
|
+
linker = @tcs[:LINKER]
|
131
|
+
|
132
|
+
res = typed_file_task Rake::Task::EXECUTABLE, get_task_name => object_multitask do
|
133
|
+
Dir.chdir(@project_dir) do
|
134
|
+
|
135
|
+
cmd = [linker[:COMMAND]] # g++
|
136
|
+
cmd += linker[:MUST_FLAGS].split(" ")
|
137
|
+
cmd += Cxxproject::Utils::flagSplit(linker[:FLAGS])
|
138
|
+
cmd << linker[:EXE_FLAG]
|
139
|
+
cmd << get_executable_name # -o debug/x.exe
|
140
|
+
cmd += @objects
|
141
|
+
cmd << linker[:SCRIPT] if @linker_script # -T
|
142
|
+
cmd << @linker_script if @linker_script # xy/xy.dld
|
143
|
+
cmd << linker[:MAP_FILE_FLAG] if @mapfile # -Wl,-m6
|
144
|
+
cmd += Cxxproject::Utils::flagSplit(linker[:LIB_PREFIX_FLAGS]) # "-Wl,--whole-archive "
|
145
|
+
cmd += linker_lib_string
|
146
|
+
cmd += Cxxproject::Utils::flagSplit(linker[:LIB_POSTFIX_FLAGS]) # "-Wl,--no-whole-archive "
|
147
|
+
|
148
|
+
mapfileStr = @mapfile ? " >#{@mapfile}" : ""
|
149
|
+
if Cxxproject::Utils.old_ruby?
|
150
|
+
cmd.map! {|c| ((c.include?(" ")) ? ("\""+c+"\"") : c )}
|
151
|
+
|
152
|
+
# TempFile used, because some compilers, e.g. diab, uses ">" for piping to map files:
|
153
|
+
cmdLinePrint = cmd.join(" ")
|
154
|
+
cmdLine = cmdLinePrint + " 2>" + get_temp_filename
|
155
|
+
if cmdLine.length > 8000
|
156
|
+
inputName = get_executable_name+".tmp"
|
157
|
+
File.open(inputName,"wb") { |f| f.write(cmd[1..-1].join(" ")) }
|
158
|
+
inputName = "\""+inputName+"\"" if inputName.include?" "
|
159
|
+
strCmd = "#{linker[:COMMAND] + " @" + inputName + mapfileStr + " 2>" + get_temp_filename}"
|
160
|
+
else
|
161
|
+
strCmd = "#{cmd.join(" ") + mapfileStr + " 2>" + get_temp_filename}"
|
162
|
+
end
|
163
|
+
printCmd(cmdLinePrint, "Linking #{get_executable_name}", false)
|
164
|
+
consoleOutput = `#{strCmd}`
|
165
|
+
consoleOutput.concat(read_file_or_empty_string(get_temp_filename))
|
166
|
+
else
|
167
|
+
rd, wr = IO.pipe
|
168
|
+
cmdLinePrint = cmd
|
169
|
+
printCmd(cmdLinePrint, "Linking #{get_executable_name}", false)
|
170
|
+
cmd << {
|
171
|
+
:out=> @mapfile ? "#{@mapfile}" : wr, # > xy.map
|
172
|
+
:err=>wr
|
173
|
+
}
|
174
|
+
sp = spawn(*cmd)
|
175
|
+
cmd.pop
|
176
|
+
|
177
|
+
# for console print
|
178
|
+
cmd << " >#{@mapfile}" if @mapfile
|
179
|
+
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
180
|
+
end
|
181
|
+
|
182
|
+
process_result(cmdLinePrint, consoleOutput, linker[:ERROR_PARSER], nil)
|
183
|
+
|
184
|
+
check_config_file()
|
185
|
+
end
|
186
|
+
end
|
187
|
+
res.immediate_output = true
|
188
|
+
res.enhance(@config_files)
|
189
|
+
res.enhance([@project_dir + "/" + @linker_script]) if @linker_script
|
190
|
+
|
191
|
+
add_output_dir_dependency(get_task_name, res, true)
|
192
|
+
add_grouping_tasks(get_task_name)
|
193
|
+
setup_rake_dependencies(res, object_multitask)
|
194
|
+
|
195
|
+
# check that all source libs are checked even if they are not a real rake dependency (can happen if "build this project only")
|
196
|
+
begin
|
197
|
+
libChecker = task get_task_name+"LibChecker" do
|
198
|
+
if File.exists?(get_task_name) # otherwise the task will be executed anyway
|
199
|
+
all_dependencies.each do |bb|
|
200
|
+
if bb and SourceLibrary === bb
|
201
|
+
f = bb.get_task_name # = abs path of library
|
202
|
+
if not File.exists?(f) or File.mtime(f) > File.mtime(get_task_name)
|
203
|
+
def res.needed?
|
204
|
+
true
|
205
|
+
end
|
206
|
+
break
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
rescue
|
213
|
+
def res.needed?
|
214
|
+
true
|
215
|
+
end
|
216
|
+
end
|
217
|
+
libChecker.transparent_timestamp = true
|
218
|
+
res.enhance([libChecker])
|
219
|
+
|
220
|
+
return res
|
221
|
+
end
|
222
|
+
|
223
|
+
def add_grouping_tasks(executable)
|
224
|
+
namespace 'exe' do
|
225
|
+
desc executable
|
226
|
+
task @name => executable
|
227
|
+
end
|
228
|
+
create_run_task(executable, @name)
|
229
|
+
end
|
230
|
+
|
231
|
+
def create_run_task(executable, name)
|
232
|
+
namespace 'run' do
|
233
|
+
desc "run executable #{executable}"
|
234
|
+
res = task name => executable do |t|
|
235
|
+
sh executable
|
236
|
+
end
|
237
|
+
res.type = Rake::Task::RUN
|
238
|
+
res
|
239
|
+
end
|
240
|
+
if Valgrind::available?
|
241
|
+
namespace 'valgrind' do
|
242
|
+
desc "run executable #{executable} with valgrind"
|
243
|
+
res = task name => executable do |t|
|
244
|
+
sh "valgrind #{executable}"
|
245
|
+
end
|
246
|
+
res.type = Rake::Task::RUN
|
247
|
+
res
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
def get_temp_filename
|
253
|
+
Dir.tmpdir + "/lake.tmp"
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
end
|