cxxproject 0.6.30 → 0.6.31
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -0
- data/lib/cxxproject.rb +3 -3
- data/lib/cxxproject/buildingblocks/building_block.rb +36 -6
- data/lib/cxxproject/buildingblocks/building_blocks.rb +7 -16
- data/lib/cxxproject/buildingblocks/command_line.rb +2 -2
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +81 -63
- data/lib/cxxproject/buildingblocks/linkable.rb +395 -0
- data/lib/cxxproject/buildingblocks/makefile.rb +2 -2
- data/lib/cxxproject/buildingblocks/shared_libs_helper.rb +93 -0
- data/lib/cxxproject/buildingblocks/{source_library.rb → static_library.rb} +35 -22
- data/lib/cxxproject/context.rb +1 -1
- data/lib/cxxproject/ext/rake.rb +51 -29
- data/lib/cxxproject/plugin_context.rb +20 -2
- data/lib/cxxproject/toolchain/provider.rb +38 -13
- data/lib/cxxproject/toolchain/toolchain.rb +3 -0
- data/lib/cxxproject/utils/deprecated.rb +23 -0
- data/lib/cxxproject/utils/utils.rb +10 -4
- data/lib/cxxproject/version.rb +1 -1
- metadata +35 -38
- data/lib/cxxproject/buildingblocks/executable.rb +0 -227
- data/lib/cxxproject/ext/progressbar.rb +0 -20
- data/lib/cxxproject/ext/rake_listener.rb +0 -57
- data/lib/cxxproject/utils/progress.rb +0 -66
- data/lib/cxxproject/utils/progress_helper.rb +0 -77
- data/lib/cxxproject/utils/rbcurse.rb +0 -284
- data/lib/cxxproject/utils/ubigraph.rb +0 -228
@@ -74,7 +74,7 @@ module Cxxproject
|
|
74
74
|
def executeCmd(cmd)
|
75
75
|
Dir.chdir(@project_dir) do
|
76
76
|
check_config_file
|
77
|
-
puts cmd + (RakeFileUtils.verbose ? " (executed in '#{@project_dir}')" : "")
|
77
|
+
puts cmd + ((RakeFileUtils.verbose == true) ? " (executed in '#{@project_dir}')" : "")
|
78
78
|
cmd_result = false
|
79
79
|
begin
|
80
80
|
cmd_result = ProcessHelper.spawnProcess(cmd + " 2>&1")
|
@@ -93,7 +93,7 @@ module Cxxproject
|
|
93
93
|
end
|
94
94
|
Rake.application.idei.set_errors([err_res])
|
95
95
|
end
|
96
|
-
Printer.printError "Error: command \"#{cmd}\" failed" + (RakeFileUtils.verbose ? "" : " (executed in '#{@project_dir}')")
|
96
|
+
Printer.printError "Error: command \"#{cmd}\" failed" + ((RakeFileUtils.verbose == true) ? "" : " (executed in '#{@project_dir}')")
|
97
97
|
raise SystemCommandFailed.new
|
98
98
|
end
|
99
99
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Cxxproject
|
2
|
+
class SharedLibsHelper
|
3
|
+
def symlink_lib_to(link, bb)
|
4
|
+
file = File.basename(bb.executable_name)
|
5
|
+
if file != link
|
6
|
+
cd "#{bb.output_dir}/libs" do
|
7
|
+
symlink(file, link)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class OsxSharedLibs < SharedLibsHelper
|
14
|
+
def calc(linker, bb)
|
15
|
+
flags = ['-install_name', bb.get_output_name(linker)]
|
16
|
+
if bb.compatibility != nil
|
17
|
+
flags << '-compatibility_version'
|
18
|
+
flags << bb.compatibility
|
19
|
+
end
|
20
|
+
if bb.minor != nil
|
21
|
+
flags << '-current_version'
|
22
|
+
flags << bb.minor
|
23
|
+
end
|
24
|
+
flags
|
25
|
+
end
|
26
|
+
|
27
|
+
# For :major=>A, minor=>1.0.1, compatibility=>1.0.0 basic is 'libfoo.A.so'
|
28
|
+
def get_basic_name(linker, bb)
|
29
|
+
prefix = bb.get_output_prefix(linker)
|
30
|
+
name = bb.name
|
31
|
+
dylib = bb.shared_suffix linker
|
32
|
+
return "#{prefix}#{name}#{dylib}"
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Some symbolic links
|
37
|
+
# ln -s foo.dylib foo.A.dylib
|
38
|
+
def post_link_hook(linker, bb)
|
39
|
+
basic_name = get_basic_name(linker, bb)
|
40
|
+
symlink_lib_to(basic_name, bb)
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_version_suffix(linker, bb)
|
44
|
+
bb.major ? ".#{bb.major}" : ''
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class UnixSharedLibs < SharedLibsHelper
|
49
|
+
|
50
|
+
def initialize()
|
51
|
+
end
|
52
|
+
|
53
|
+
# For :major=>1, minor=>2 fullname is '1.2.so'
|
54
|
+
def get_version_suffix(linker, bb)
|
55
|
+
"#{major_suffix bb}#{[bb.major, bb.minor].compact.join('.')}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def major_suffix(bb)
|
59
|
+
bb.major ? ".#{bb.major}" : ''
|
60
|
+
end
|
61
|
+
|
62
|
+
# For :major=>1, minor=>2 soname is 'libfoo.1.so'
|
63
|
+
#def get_major(linker)
|
64
|
+
# prefix = get_output_prefix(linker)
|
65
|
+
# return "#{prefix}#{name}#{major_suffix}#{shared_suffix linker}"
|
66
|
+
#end
|
67
|
+
|
68
|
+
def get_soname(linker, bb)
|
69
|
+
prefix = bb.get_output_prefix(linker)
|
70
|
+
"#{prefix}#{bb.name}#{major_suffix bb}#{bb.shared_suffix linker}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def calc(linker, bb)
|
74
|
+
return ["-Wl,-soname,#{get_soname(linker, bb)}"]
|
75
|
+
end
|
76
|
+
|
77
|
+
# For :major=>1, minor=>2 fullname is 'libfoo.so'
|
78
|
+
def get_basic_name(linker, bb)
|
79
|
+
prefix = bb.get_output_prefix(linker)
|
80
|
+
return "#{prefix}#{bb.name}#{bb.shared_suffix(linker)}"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Some symbolic links
|
84
|
+
# ln -s libfoo.so libfoo.1.2.so
|
85
|
+
# ln -s libfoo.1.so libfoo.1.2.so
|
86
|
+
def post_link_hook(linker, bb)
|
87
|
+
basic_name = get_basic_name(linker, bb)
|
88
|
+
soname = get_soname(linker, bb)
|
89
|
+
symlink_lib_to(basic_name, bb)
|
90
|
+
symlink_lib_to(soname, bb)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -6,7 +6,7 @@ require 'cxxproject/utils/process'
|
|
6
6
|
require 'cxxproject/utils/utils'
|
7
7
|
|
8
8
|
module Cxxproject
|
9
|
-
class
|
9
|
+
class StaticLibrary < BuildingBlock
|
10
10
|
include HasLibraries
|
11
11
|
include HasSources
|
12
12
|
include HasIncludes
|
@@ -28,13 +28,17 @@ module Cxxproject
|
|
28
28
|
super
|
29
29
|
end
|
30
30
|
|
31
|
+
def additional_path_components
|
32
|
+
['libs']
|
33
|
+
end
|
34
|
+
|
31
35
|
def get_archive_name() # relative path
|
32
36
|
return @archive_name if @archive_name
|
33
37
|
parts = [@output_dir]
|
34
38
|
|
35
39
|
if @output_dir_abs
|
36
40
|
parts = [@output_dir_relPath] if @output_dir_relPath
|
37
|
-
parts
|
41
|
+
parts += additional_path_components()
|
38
42
|
end
|
39
43
|
|
40
44
|
parts << "lib#{@name}.a"
|
@@ -54,6 +58,29 @@ module Cxxproject
|
|
54
58
|
@task_name
|
55
59
|
end
|
56
60
|
|
61
|
+
def calc_command_line
|
62
|
+
objs = @objects
|
63
|
+
if @output_dir_abs
|
64
|
+
prefix = File.rel_from_to_project(@project_dir, @output_dir)
|
65
|
+
# objs.map! { |m| m[prefix.length..-1] }
|
66
|
+
end
|
67
|
+
archiver = @tcs[:ARCHIVER]
|
68
|
+
cmd = [archiver[:COMMAND]] # ar
|
69
|
+
cmd += archiver[:ARCHIVE_FLAGS].split(" ")
|
70
|
+
cmd += archiver[:FLAGS]
|
71
|
+
cmd << calc_archive_name # -o debug/x.exe
|
72
|
+
cmd += objs
|
73
|
+
end
|
74
|
+
|
75
|
+
def calc_archive_name
|
76
|
+
aname = get_archive_name
|
77
|
+
# if @output_dir_abs
|
78
|
+
# prefix = File.rel_from_to_project(@project_dir, @output_dir)
|
79
|
+
# aname = aname[prefix.length..-1]
|
80
|
+
# end
|
81
|
+
return aname
|
82
|
+
end
|
83
|
+
|
57
84
|
# task that will link the given object files to a static lib
|
58
85
|
#
|
59
86
|
def convert_to_rake()
|
@@ -61,26 +88,11 @@ module Cxxproject
|
|
61
88
|
archiver = @tcs[:ARCHIVER]
|
62
89
|
|
63
90
|
res = typed_file_task Rake::Task::LIBRARY, get_task_name => object_multitask do
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
if @output_dir_abs
|
69
|
-
dir = @output_dir
|
70
|
-
prefix = File.rel_from_to_project(@project_dir, @output_dir)
|
71
|
-
objs.map! { |m| m[prefix.length..-1] }
|
72
|
-
aname = aname[prefix.length..-1]
|
73
|
-
end
|
74
|
-
|
75
|
-
Dir.chdir(dir) do
|
91
|
+
cmd = calc_command_line
|
92
|
+
aname = calc_archive_name
|
93
|
+
Dir.chdir(@project_dir) do
|
76
94
|
FileUtils.rm(aname) if File.exists?(aname)
|
77
|
-
cmd
|
78
|
-
cmd += archiver[:ARCHIVE_FLAGS].split(" ")
|
79
|
-
cmd += archiver[:FLAGS]
|
80
|
-
cmd << aname # -o debug/x.exe
|
81
|
-
cmd += objs
|
82
|
-
|
83
|
-
cmd.map! {|c| c.include?(' ') ? "\"#{c}\"" : c }
|
95
|
+
# cmd.map! {|c| c.include?(' ') ? "\"#{c}\"" : c }
|
84
96
|
rd, wr = IO.pipe
|
85
97
|
cmd << {
|
86
98
|
:err => wr,
|
@@ -91,11 +103,12 @@ module Cxxproject
|
|
91
103
|
|
92
104
|
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
93
105
|
|
94
|
-
process_result(cmd, consoleOutput,
|
106
|
+
process_result(cmd, consoleOutput, @tcs[:ARCHIVER][:ERROR_PARSER], "Creating #{aname}")
|
95
107
|
|
96
108
|
check_config_file()
|
97
109
|
end
|
98
110
|
end
|
111
|
+
res.tags = tags
|
99
112
|
enhance_with_additional_files(res)
|
100
113
|
add_output_dir_dependency(get_task_name, res, true)
|
101
114
|
|
data/lib/cxxproject/context.rb
CHANGED
@@ -5,7 +5,7 @@ module Cxxproject
|
|
5
5
|
hash.keys.map do |k|
|
6
6
|
error_string = ["error while evaluating \"#{@current_working_dir}/#{@current_project_file}\"",
|
7
7
|
"\"#{k}\" is not a valid specifier!",
|
8
|
-
"
|
8
|
+
"allowed specifiers: #{allowed}"].join($/)
|
9
9
|
raise error_string unless allowed.include?(k)
|
10
10
|
end
|
11
11
|
end
|
data/lib/cxxproject/ext/rake.rb
CHANGED
@@ -17,12 +17,17 @@ end
|
|
17
17
|
module Rake
|
18
18
|
|
19
19
|
class Application
|
20
|
+
attr_writer :raise_exceptions
|
20
21
|
attr_writer :max_parallel_tasks
|
21
22
|
attr_writer :check_unnecessary_includes
|
22
23
|
attr_writer :deriveIncludes
|
23
24
|
attr_writer :preproFlags
|
24
25
|
attr_writer :consoleOutput_fullnames
|
25
26
|
attr_writer :addEmptyLine
|
27
|
+
def raise_exceptions
|
28
|
+
@raise_exceptions ||= false
|
29
|
+
end
|
30
|
+
|
26
31
|
def max_parallel_tasks
|
27
32
|
@max_parallel_tasks ||= 8
|
28
33
|
end
|
@@ -226,11 +231,15 @@ module Rake
|
|
226
231
|
attr_accessor :deps # used to store deps by depfile task for the apply task (no re-read of depsfile)
|
227
232
|
attr_accessor :type
|
228
233
|
attr_accessor :transparent_timestamp
|
229
|
-
attr_accessor :progress_count
|
230
234
|
attr_accessor :output_string
|
231
235
|
attr_accessor :output_after_execute
|
232
236
|
attr_accessor :immediate_output
|
233
237
|
attr_accessor :prerequisites
|
238
|
+
attr_writer :tags
|
239
|
+
def tags
|
240
|
+
@tags = Set.new unless @tags
|
241
|
+
return @tags
|
242
|
+
end
|
234
243
|
|
235
244
|
UNKNOWN = 0x0000 #
|
236
245
|
OBJECT = 0x0001 #
|
@@ -247,6 +256,7 @@ module Rake
|
|
247
256
|
RUN = 0x0800 #
|
248
257
|
CUSTOM = 0x1000 # x
|
249
258
|
COMMANDLINE = 0x2000 # x
|
259
|
+
SHARED_LIBRARY = 0x4000 # x
|
250
260
|
|
251
261
|
STANDARD = 0x371A # x above means included in STANDARD
|
252
262
|
attr_reader :ignore
|
@@ -261,7 +271,6 @@ module Rake
|
|
261
271
|
@type = UNKNOWN
|
262
272
|
@deps = nil
|
263
273
|
@transparent_timestamp = false
|
264
|
-
@progress_count = 0
|
265
274
|
@ignore = false
|
266
275
|
@failure = false
|
267
276
|
@output_after_execute = true
|
@@ -297,21 +306,25 @@ module Rake
|
|
297
306
|
rescue Cxxproject::ExitHelperException
|
298
307
|
raise
|
299
308
|
rescue Exception => e
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
309
|
+
if not application.raise_exceptions
|
310
|
+
if prereq and Rake::Task[n].ignore
|
311
|
+
@prerequisites.delete(n)
|
312
|
+
def self.needed?
|
313
|
+
true
|
314
|
+
end
|
315
|
+
return
|
316
|
+
end
|
317
|
+
Cxxproject::Printer.printError "Error #{name}: #{e.message}"
|
318
|
+
if RakeFileUtils.verbose == true
|
319
|
+
puts e.backtrace
|
320
|
+
end
|
321
|
+
set_failed
|
322
|
+
if e.message.include?('Circular dependency detected')
|
323
|
+
Rake.application.idei.set_abort(true)
|
324
|
+
end
|
325
|
+
else
|
326
|
+
raise e
|
327
|
+
end
|
315
328
|
end
|
316
329
|
|
317
330
|
end
|
@@ -365,18 +378,27 @@ module Rake
|
|
365
378
|
end
|
366
379
|
end
|
367
380
|
|
368
|
-
def handle_error(
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
381
|
+
def handle_error(exception, isSysCmd)
|
382
|
+
if not application.raise_exceptions
|
383
|
+
if not Rake.application.idei.get_abort()
|
384
|
+
if not isSysCmd
|
385
|
+
Cxxproject::Printer.printError "Error for task #{@name}: #{exception.message}"
|
386
|
+
if Rake.application.options.trace
|
387
|
+
exception.backtrace.each do |t|
|
388
|
+
Cxxproject::Printer.printError t
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
begin
|
394
|
+
FileUtils.rm(@name) if File.exists?(@name)
|
395
|
+
rescue Exception => follow_up_exception
|
396
|
+
Cxxproject::Printer.printError "Error: Could not delete #{@name}: #{follow_up_exception.message}"
|
397
|
+
end
|
398
|
+
set_failed
|
399
|
+
else
|
400
|
+
raise exception
|
401
|
+
end
|
380
402
|
end
|
381
403
|
|
382
404
|
def output(name, to_output)
|
@@ -15,10 +15,19 @@ module Cxxproject
|
|
15
15
|
class PluginContext
|
16
16
|
include Context
|
17
17
|
|
18
|
-
def
|
18
|
+
def self.create_no_args_context
|
19
|
+
return PluginContext.new(nil, nil, nil, 0)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create_three_args_context(cxx, building_blocks, log)
|
23
|
+
return PluginContext.new(cxx, building_blocks, log, 3)
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(cxxproject2rake, building_blocks, log, expected_arity)
|
19
27
|
@cxxproject2rake = cxxproject2rake
|
20
28
|
@building_blocks = building_blocks
|
21
29
|
@log = log
|
30
|
+
@expected_arity = expected_arity
|
22
31
|
end
|
23
32
|
|
24
33
|
# method for plugins to get the
|
@@ -26,7 +35,16 @@ module Cxxproject
|
|
26
35
|
# building_blocks
|
27
36
|
# log
|
28
37
|
def cxx_plugin(&blk)
|
29
|
-
blk.
|
38
|
+
if blk.arity != @expected_arity
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
case blk.arity
|
43
|
+
when 0
|
44
|
+
blk.call()
|
45
|
+
when 3
|
46
|
+
blk.call(@cxxproject2rake, @building_blocks, @log)
|
47
|
+
end
|
30
48
|
end
|
31
49
|
|
32
50
|
# specify a toolchain
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cxxproject/toolchain/colorizing_formatter'
|
2
|
+
require 'cxxproject/utils/utils'
|
2
3
|
|
3
4
|
module Cxxproject
|
4
5
|
module Toolchain
|
@@ -6,6 +7,7 @@ module Cxxproject
|
|
6
7
|
class Provider
|
7
8
|
@@settings = {}
|
8
9
|
@@default = {
|
10
|
+
:TARGET_OS => Utils::OS.os(),
|
9
11
|
:COMPILER =>
|
10
12
|
{
|
11
13
|
:CPP => {
|
@@ -65,17 +67,33 @@ module Cxxproject
|
|
65
67
|
:MUST_FLAGS => "",
|
66
68
|
:SCRIPT => "",
|
67
69
|
:USER_LIB_FLAG => "",
|
68
|
-
:
|
70
|
+
:OUTPUT_FLAG => 'output_flag_default',
|
71
|
+
:SHARED_FLAG => 'shared_flag_default',
|
72
|
+
:SONAME_FLAG => 'soname_flag_default',
|
69
73
|
:LIB_FLAG => "",
|
70
74
|
:LIB_PATH_FLAG => "",
|
71
75
|
:LIB_PREFIX_FLAGS => "", # "-Wl,--whole-archive",
|
72
76
|
:LIB_POSTFIX_FLAGS => "", # "-Wl,--no-whole-archive",
|
73
77
|
:FLAGS => [],
|
74
78
|
:MAP_FILE_FLAG => "",
|
75
|
-
:
|
79
|
+
:OUTPUT_PREFIX => {:EXECUTABLE => '', :SHARED_LIBRARY => {:UNIX => 'lib', :OSX => 'lib'} },
|
80
|
+
:OUTPUT_SUFFIX => {
|
81
|
+
:EXECUTABLE => {
|
82
|
+
:UNIX => '.exe',
|
83
|
+
:OSX => '.exe',
|
84
|
+
:WINDOWS => '.exe'
|
85
|
+
},
|
86
|
+
:SHARED_LIBRARY => {
|
87
|
+
:UNIX => '.so',
|
88
|
+
:OSX => '.dylib',
|
89
|
+
:WINDOWS => '.dll'
|
90
|
+
}
|
91
|
+
},
|
76
92
|
:ERROR_PARSER => nil,
|
77
|
-
:START_OF_WHOLE_ARCHIVE => '',
|
78
|
-
:END_OF_WHOLE_ARCHIVE => ''
|
93
|
+
:START_OF_WHOLE_ARCHIVE => {:UNIX => '', :OSX => '', :WINDOWS => ''},
|
94
|
+
:END_OF_WHOLE_ARCHIVE => {:UNIX => '', :OSX => '', :WINDOWS => ''},
|
95
|
+
:ADDITIONAL_COMMANDS => {:OSX => '', :UNIX => ''},
|
96
|
+
:ADDITIONAL_OBJECT_FILE_FLAGS => {:OSX => [], :UNIX => []}
|
79
97
|
},
|
80
98
|
|
81
99
|
:MAKE =>
|
@@ -87,6 +105,10 @@ module Cxxproject
|
|
87
105
|
:CLEAN => "clean"
|
88
106
|
},
|
89
107
|
|
108
|
+
:ENV =>
|
109
|
+
{
|
110
|
+
:LIB_VAR=> {:UNIX => 'LD_LIBRARY_PATH', :OSX => 'DYLD_LIBRARY_PATH', :WINDOWS => 'PATH'},
|
111
|
+
},
|
90
112
|
:CONSOLE_HIGHLIGHTER => ColorizingFormatter.new
|
91
113
|
}
|
92
114
|
|
@@ -121,22 +143,25 @@ module Cxxproject
|
|
121
143
|
@@default
|
122
144
|
end
|
123
145
|
|
124
|
-
def self.
|
146
|
+
def self.modify_linker(based_on, h)
|
125
147
|
chain = @@settings[based_on]
|
126
148
|
raise "unknown toolchain: #{based_on}" unless chain
|
127
|
-
chain[:
|
149
|
+
chain[:LINKER].update(h)
|
128
150
|
chain
|
129
151
|
end
|
130
152
|
|
131
|
-
def self.
|
153
|
+
def self.modify_compiler(based_on, compiler_type, h)
|
154
|
+
chain = @@settings[based_on]
|
155
|
+
raise "unknown toolchain: #{based_on}" unless chain
|
156
|
+
chain[:COMPILER][compiler_type].update(h)
|
157
|
+
chain
|
158
|
+
end
|
132
159
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
ExitHelper.exit(1)
|
137
|
-
end
|
138
|
-
end
|
160
|
+
def self.modify_cpp_compiler(based_on, h)
|
161
|
+
modify_compiler(based_on, :CPP, h)
|
162
|
+
end
|
139
163
|
|
164
|
+
def self.[](name)
|
140
165
|
return @@settings[name] if @@settings.include? name
|
141
166
|
nil
|
142
167
|
end
|