cxxproject 0.4.6 → 0.5.47
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +101 -54
- data/bin/cxx +4 -4
- data/lib/cxxproject/buildingblocks/binary_library.rb +32 -9
- data/lib/cxxproject/buildingblocks/building_block.rb +220 -74
- data/lib/cxxproject/buildingblocks/command_line.rb +70 -21
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +33 -9
- data/lib/cxxproject/buildingblocks/executable.rb +228 -33
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +69 -43
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -0
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +29 -30
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +343 -64
- data/lib/cxxproject/buildingblocks/makefile.rb +142 -24
- data/lib/cxxproject/buildingblocks/module.rb +27 -6
- data/lib/cxxproject/buildingblocks/single_source.rb +26 -4
- data/lib/cxxproject/buildingblocks/source_library.rb +113 -20
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -0
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +33 -0
- data/lib/cxxproject/errorparser/error_parser.rb +50 -0
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +29 -0
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +29 -0
- data/lib/cxxproject/eval_context.rb +136 -0
- data/lib/cxxproject/ext/file.rb +71 -0
- data/lib/cxxproject/ext/filelist.rb +6 -0
- data/lib/cxxproject/ext/progressbar.rb +20 -0
- data/lib/cxxproject/ext/rake.rb +397 -0
- data/lib/cxxproject/{extensions/rake_listener_ext.rb → ext/rake_listener.rb} +18 -12
- data/lib/cxxproject/ext/stdout.rb +44 -0
- data/lib/cxxproject/ide_interface.rb +181 -0
- data/lib/cxxproject/toolchain/clang.rb +39 -0
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -0
- data/lib/cxxproject/toolchain/diab.rb +36 -33
- data/lib/cxxproject/toolchain/gcc.rb +16 -8
- data/lib/cxxproject/toolchain/provider.rb +112 -2
- data/lib/cxxproject/toolchain/ti.rb +50 -0
- data/lib/cxxproject/toolchain/toolchain.rb +38 -0
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -0
- data/lib/cxxproject/torake.rb +181 -123
- data/lib/cxxproject/utils/cleanup.rb +20 -0
- data/lib/cxxproject/utils/console.rb +6 -0
- data/lib/cxxproject/utils/exit_helper.rb +40 -0
- data/lib/cxxproject/utils/graphstream.rb +154 -0
- data/lib/cxxproject/utils/optional.rb +16 -0
- data/lib/cxxproject/utils/printer.rb +50 -0
- data/lib/cxxproject/utils/process.rb +53 -0
- data/lib/cxxproject/utils/progress.rb +66 -0
- data/lib/cxxproject/utils/progress_helper.rb +77 -0
- data/lib/cxxproject/utils/rbcurse.rb +284 -0
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -0
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -0
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -0
- data/lib/cxxproject/utils/stats.rb +60 -0
- data/lib/cxxproject/utils/ubigraph.rb +179 -188
- data/lib/cxxproject/utils/utils.rb +29 -25
- data/lib/cxxproject/version.rb +7 -0
- data/lib/cxxproject.rb +13 -7
- data/lib/tools/project_wizard.rb +66 -0
- data/spec/building_block_spec.rb +50 -6
- data/spec/{build_dependencies_spec.rb → cxxproject_2_rake_spec.rb} +82 -65
- data/spec/file_ext_spec.rb +30 -0
- data/spec/ide_interface_spec.rb +41 -0
- data/spec/object_dependency_spec.rb +83 -0
- data/spec/project_path_spec.rb +14 -16
- data/spec/rake_listener_ext_spec.rb +38 -5
- data/spec/spec_helper.rb +18 -0
- data/spec/testdata/basic/lib2/project.rb +1 -1
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +1 -1
- data/spec/toolchain_spec.rb +29 -0
- metadata +91 -58
- data/lib/cxxproject/extensions/file_ext.rb +0 -47
- data/lib/cxxproject/extensions/rake_ext.rb +0 -158
- data/lib/cxxproject/extensions/stdout_ext.rb +0 -35
- data/lib/cxxproject/task_maker.rb +0 -418
- data/lib/cxxproject/testinstanceeval.rb +0 -65
- data/lib/cxxproject/toolchain/base.rb +0 -98
- data/lib/cxxproject/torake/compiler.rb +0 -10
- data/lib/cxxproject/torake/gcccompiler.rb +0 -7
- data/lib/cxxproject/torake/osxcompiler.rb +0 -7
- data/lib/cxxproject/utils/dot/building_block_graph_writer.rb +0 -19
- data/lib/cxxproject/utils/dot/graph_writer.rb +0 -53
- data/lib/cxxproject/utils/dot/task_graph_writer.rb +0 -34
- data/lib/tools/projectWizard.rb +0 -44
- data/spec/dir_spec.rb +0 -13
- /data/lib/cxxproject/{extensions/rake_dirty_ext.rb → ext/rake_dirty.rb} +0 -0
- /data/lib/cxxproject/{extensions/string_ext.rb → ext/string.rb} +0 -0
@@ -1,31 +1,124 @@
|
|
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
|
+
require 'cxxproject/utils/process'
|
6
|
+
require 'cxxproject/utils/utils'
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
module Cxxproject
|
9
|
+
class SourceLibrary < BuildingBlock
|
10
|
+
include HasLibraries
|
11
|
+
include HasSources
|
12
|
+
include HasIncludes
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
14
|
+
def initialize(name)
|
15
|
+
super(name)
|
16
|
+
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def complete_init()
|
19
|
+
if @output_dir_abs
|
20
|
+
add_lib_element(HasLibraries::SEARCH_PATH, File.join(@output_dir, 'libs'), true)
|
21
|
+
add_lib_element(HasLibraries::LIB, @name, true)
|
22
|
+
else
|
23
|
+
add_lib_element(HasLibraries::LIB_WITH_PATH, File.join(@output_dir,"lib#{@name}.a"), true)
|
24
|
+
end
|
25
|
+
super
|
20
26
|
end
|
21
|
-
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
28
|
+
def get_archive_name() # relative path
|
29
|
+
return @archive_name if @archive_name
|
30
|
+
parts = [@output_dir]
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
32
|
+
if @output_dir_abs
|
33
|
+
parts = [@output_dir_relPath] if @output_dir_relPath
|
34
|
+
parts << 'libs'
|
35
|
+
end
|
36
|
+
|
37
|
+
parts << "lib#{@name}.a"
|
38
|
+
|
39
|
+
@archive_name = File.join(parts)
|
40
|
+
@archive_name
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_task_name() # full path
|
44
|
+
return @task_name if @task_name
|
45
|
+
|
46
|
+
parts = [@output_dir]
|
47
|
+
parts << 'libs' if @output_dir_abs
|
48
|
+
parts << "lib#{@name}.a"
|
49
|
+
@task_name = File.join(parts)
|
50
|
+
@task_name = @project_dir + "/" + @task_name unless @output_dir_abs
|
51
|
+
@task_name
|
52
|
+
end
|
53
|
+
|
54
|
+
# task that will link the given object files to a static lib
|
55
|
+
#
|
56
|
+
def convert_to_rake()
|
57
|
+
object_multitask = prepare_tasks_for_objects()
|
58
|
+
archiver = @tcs[:ARCHIVER]
|
59
|
+
|
60
|
+
res = typed_file_task Rake::Task::LIBRARY, get_task_name => object_multitask do
|
61
|
+
dir = @project_dir
|
62
|
+
objs = @objects
|
63
|
+
aname = get_archive_name
|
64
|
+
|
65
|
+
if @output_dir_abs
|
66
|
+
dir = @output_dir
|
67
|
+
prefix = File.rel_from_to_project(@project_dir, @output_dir)
|
68
|
+
objs.map! { |m| m[prefix.length..-1] }
|
69
|
+
aname = aname[prefix.length..-1]
|
70
|
+
end
|
71
|
+
|
72
|
+
Dir.chdir(dir) do
|
73
|
+
FileUtils.rm(aname) if File.exists?(aname)
|
74
|
+
cmd = [archiver[:COMMAND]] # ar
|
75
|
+
cmd += archiver[:ARCHIVE_FLAGS].split(" ")
|
76
|
+
cmd += archiver[:FLAGS].split(" ") # --all_load
|
77
|
+
cmd << aname # -o debug/x.exe
|
78
|
+
cmd += objs
|
79
|
+
|
80
|
+
if Cxxproject::Utils.old_ruby?
|
81
|
+
cmd.map! {|c| ((c.include?" ") ? ("\""+c+"\"") : c )}
|
82
|
+
|
83
|
+
cmdLine = cmd.join(" ")
|
84
|
+
if cmdLine.length > 8000
|
85
|
+
inputName = aname+".tmp"
|
86
|
+
File.open(inputName,"wb") { |f| f.write(cmd[1..-1].join(" ")) }
|
87
|
+
consoleOutput = `#{archiver[:COMMAND] + " @" + inputName}`
|
88
|
+
else
|
89
|
+
consoleOutput = `#{cmd.join(" ")} 2>&1`
|
90
|
+
end
|
91
|
+
else
|
92
|
+
rd, wr = IO.pipe
|
93
|
+
cmd << {
|
94
|
+
:err=>wr,
|
95
|
+
:out=>wr
|
96
|
+
}
|
97
|
+
sp = spawn(*cmd)
|
98
|
+
cmd.pop
|
99
|
+
|
100
|
+
consoleOutput = ProcessHelper.readOutput(sp, rd, wr)
|
101
|
+
end
|
102
|
+
|
103
|
+
process_result(cmd, consoleOutput, archiver[:ERROR_PARSER], "Creating #{aname}")
|
104
|
+
|
105
|
+
check_config_file()
|
106
|
+
end
|
107
|
+
end
|
108
|
+
enhance_with_additional_files(res)
|
109
|
+
add_output_dir_dependency(get_task_name, res, true)
|
30
110
|
|
111
|
+
add_grouping_tasks(get_task_name)
|
112
|
+
|
113
|
+
setup_rake_dependencies(res, object_multitask)
|
114
|
+
return res
|
115
|
+
end
|
116
|
+
|
117
|
+
def add_grouping_tasks(archive)
|
118
|
+
namespace 'lib' do
|
119
|
+
desc archive
|
120
|
+
task @name => archive
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
31
124
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'cxxproject/errorparser/error_parser'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class DiabCompilerErrorParser < ErrorParser
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@error_expression_start = /\"(.+)\", line ([0-9]+): (catastrophic |fatal )*([A-Za-z]+) (.+)/
|
8
|
+
@error_expression_end = /^[ \t]*\^/ # well, it may end without "^"... in this case the error will last the next one starts or console text ends
|
9
|
+
end
|
10
|
+
|
11
|
+
def scan_lines(consoleOutput, proj_dir)
|
12
|
+
res = []
|
13
|
+
error_severity = 255
|
14
|
+
consoleOutputFullnames = ""
|
15
|
+
consoleOutput.each_line do |l|
|
16
|
+
d = ErrorDesc.new
|
17
|
+
lstripped = l.rstrip
|
18
|
+
scan_res = lstripped.scan(@error_expression_start)
|
19
|
+
if scan_res.length == 0
|
20
|
+
d.severity = error_severity
|
21
|
+
d.message = lstripped
|
22
|
+
if lstripped.scan(@error_expression_end).length > 0
|
23
|
+
error_severity = 255
|
24
|
+
end
|
25
|
+
else
|
26
|
+
d.file_name = File.expand_path(scan_res[0][0])
|
27
|
+
d.line_number = scan_res[0][1].to_i
|
28
|
+
d.message = scan_res[0][4]
|
29
|
+
d.severity = get_severity(scan_res[0][3])
|
30
|
+
error_severity = d.severity
|
31
|
+
l.gsub!(scan_res[0][0],d.file_name)
|
32
|
+
end
|
33
|
+
res << d
|
34
|
+
consoleOutputFullnames << l
|
35
|
+
end
|
36
|
+
[res, consoleOutputFullnames]
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'cxxproject/errorparser/error_parser'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class DiabLinkerErrorParser < ErrorParser
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@error_expression = /dld: ([A-Za-z]+): (.+)/
|
8
|
+
end
|
9
|
+
|
10
|
+
def scan_lines(consoleOutput, proj_dir)
|
11
|
+
res = []
|
12
|
+
error_severity = 255
|
13
|
+
consoleOutput.each_line do |l|
|
14
|
+
l.rstrip!
|
15
|
+
d = ErrorDesc.new
|
16
|
+
scan_res = l.scan(@error_expression)
|
17
|
+
if scan_res.length == 0 # msg will end with the beginning of the next message
|
18
|
+
d.severity = error_severity
|
19
|
+
d.message = l
|
20
|
+
else
|
21
|
+
d.file_name = proj_dir
|
22
|
+
d.line_number = 0
|
23
|
+
d.message = scan_res[0][1]
|
24
|
+
d.severity = get_severity(scan_res[0][0])
|
25
|
+
error_severity = d.severity
|
26
|
+
end
|
27
|
+
res << d
|
28
|
+
end
|
29
|
+
[res, consoleOutput]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Cxxproject
|
2
|
+
|
3
|
+
class ErrorDesc
|
4
|
+
def initialize
|
5
|
+
@severity = 255
|
6
|
+
end
|
7
|
+
attr_accessor :severity
|
8
|
+
attr_accessor :line_number
|
9
|
+
attr_accessor :message
|
10
|
+
attr_accessor :file_name
|
11
|
+
end
|
12
|
+
|
13
|
+
class ErrorParser
|
14
|
+
|
15
|
+
SEVERITY_INFO = 0
|
16
|
+
SEVERITY_WARNING = 1
|
17
|
+
SEVERITY_ERROR = 2
|
18
|
+
SEVERITY_OK = 255
|
19
|
+
|
20
|
+
def scan(consoleOutput, proj_dir)
|
21
|
+
raise "Use specialized classes only"
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_severity(str)
|
25
|
+
if str == "info" || str == "note"
|
26
|
+
SEVERITY_INFO
|
27
|
+
elsif str == "warning"
|
28
|
+
SEVERITY_WARNING
|
29
|
+
elsif str == "error"
|
30
|
+
SEVERITY_ERROR
|
31
|
+
else
|
32
|
+
raise "Unknown severity: #{str}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# scan the output from the console line by line and return a list of ErrorDesc objects.
|
37
|
+
# for none-error/warning lines the description object will indicate that as severity 255
|
38
|
+
# for single line errors/warnings: description will contain severity, line-number, message and file-name
|
39
|
+
#
|
40
|
+
# for multi-line errors/warnings:
|
41
|
+
# one description object for each line, first one will contain all single line error information,
|
42
|
+
# all following desc.objects will just repeat the severity and include the message
|
43
|
+
#
|
44
|
+
def scan_lines(consoleOutput, proj_dir)
|
45
|
+
raise "Use specialized classes only"
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'cxxproject/errorparser/error_parser'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class GCCCompilerErrorParser < ErrorParser
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@error_expression = /([^:]+):([0-9]+)[:0-9]* (catastrophic |fatal )*([A-Za-z]+): (.+)/
|
8
|
+
end
|
9
|
+
|
10
|
+
def scan_lines(consoleOutput, proj_dir)
|
11
|
+
res = []
|
12
|
+
consoleOutputFullnames = ""
|
13
|
+
consoleOutput.each_line do |l|
|
14
|
+
d = ErrorDesc.new
|
15
|
+
scan_res = l.gsub(/\r\n?/, "").scan(@error_expression)
|
16
|
+
if scan_res.length > 0
|
17
|
+
d.file_name = File.expand_path(scan_res[0][0])
|
18
|
+
d.line_number = scan_res[0][1].to_i
|
19
|
+
d.message = scan_res[0][4]
|
20
|
+
d.severity = get_severity(scan_res[0][3])
|
21
|
+
l.gsub!(scan_res[0][0],d.file_name)
|
22
|
+
end
|
23
|
+
res << d
|
24
|
+
consoleOutputFullnames << l
|
25
|
+
end
|
26
|
+
[res, consoleOutputFullnames]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cxxproject/errorparser/error_parser'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class GCCLinkerErrorParser < ErrorParser
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
# todo: is every line an error?
|
8
|
+
# todo: some linker errors look like simple text, dunno how to parse properly...
|
9
|
+
# @error_expression1 = /(.*:\(\..*\)): (.*)/ # e.g. /c/Tool/Temp/ccAlar4R.o:x.cpp:(.text+0x17): undefined reference to `_a'
|
10
|
+
# @error_expression2 = /(.*):([0-9]+): (.*)/ # e.g. /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld:roodi.yml.a:1: syntax error
|
11
|
+
end
|
12
|
+
|
13
|
+
def scan_lines(consoleOutput, proj_dir)
|
14
|
+
res = []
|
15
|
+
consoleOutput.each_line do |l|
|
16
|
+
l.rstrip!
|
17
|
+
d = ErrorDesc.new
|
18
|
+
d.file_name = proj_dir
|
19
|
+
d.line_number = 0
|
20
|
+
d.message = l
|
21
|
+
d.severity = SEVERITY_ERROR
|
22
|
+
res << d
|
23
|
+
end
|
24
|
+
[res, consoleOutput]
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'cxxproject/errorparser/error_parser'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class TICompilerErrorParser < ErrorParser
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@error_expression = /\"([^,^\"]+)\", line ([0-9]+)[:0-9]* (catastrophic |fatal )*([A-Za-z]+): (.+)/
|
8
|
+
end
|
9
|
+
|
10
|
+
def scan_lines(consoleOutput, proj_dir)
|
11
|
+
res = []
|
12
|
+
consoleOutputFullnames = ""
|
13
|
+
consoleOutput.each_line do |l|
|
14
|
+
d = ErrorDesc.new
|
15
|
+
scan_res = l.gsub(/\r\n?/, "").scan(@error_expression)
|
16
|
+
if scan_res.length > 0
|
17
|
+
d.file_name = File.expand_path(scan_res[0][0])
|
18
|
+
d.line_number = scan_res[0][1].to_i
|
19
|
+
d.message = scan_res[0][4]
|
20
|
+
d.severity = get_severity(scan_res[0][3])
|
21
|
+
l.gsub!(scan_res[0][0],d.file_name)
|
22
|
+
end
|
23
|
+
res << d
|
24
|
+
consoleOutputFullnames << l
|
25
|
+
end
|
26
|
+
[res, consoleOutputFullnames]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cxxproject/errorparser/error_parser'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
class TILinkerErrorParser < ErrorParser
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
# todo: is every line an error?
|
8
|
+
# todo: some linker errors look like simple text, dunno how to parse properly...
|
9
|
+
# @error_expression1 = /(.*:\(\..*\)): (.*)/ # e.g. /c/Tool/Temp/ccAlar4R.o:x.cpp:(.text+0x17): undefined reference to `_a'
|
10
|
+
# @error_expression2 = /(.*):([0-9]+): (.*)/ # e.g. /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld:roodi.yml.a:1: syntax error
|
11
|
+
end
|
12
|
+
|
13
|
+
def scan_lines(consoleOutput, proj_dir)
|
14
|
+
res = []
|
15
|
+
consoleOutput.each_line do |l|
|
16
|
+
l.rstrip!
|
17
|
+
d = ErrorDesc.new
|
18
|
+
d.file_name = proj_dir
|
19
|
+
d.line_number = 0
|
20
|
+
d.message = l
|
21
|
+
d.severity = SEVERITY_ERROR
|
22
|
+
res << d
|
23
|
+
end
|
24
|
+
[res, consoleOutput]
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
|
2
|
+
module Cxxproject
|
3
|
+
class BinaryLibs
|
4
|
+
class << self
|
5
|
+
def [](*libs)
|
6
|
+
libraries = Array.new
|
7
|
+
libs.each do |x|
|
8
|
+
libraries << BinaryLibrary.new(x)
|
9
|
+
end
|
10
|
+
libraries
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class EvalContext
|
16
|
+
|
17
|
+
attr_accessor :myblock, :all_blocks
|
18
|
+
|
19
|
+
# must be called to add building blocks
|
20
|
+
def cxx_configuration(&block)
|
21
|
+
@myblock = block
|
22
|
+
@all_blocks = []
|
23
|
+
end
|
24
|
+
|
25
|
+
def eval_project(project_text, project_file, pwd)
|
26
|
+
@current_project_file = project_file
|
27
|
+
@current_working_dir = pwd
|
28
|
+
instance_eval(project_text)
|
29
|
+
end
|
30
|
+
|
31
|
+
def configuration(*args, &block)
|
32
|
+
name = args[0]
|
33
|
+
raise "no name given" unless name.is_a?(String) && !name.strip.empty?
|
34
|
+
instance_eval(&block)
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_hash(hash,allowed)
|
38
|
+
hash.keys.map do |k|
|
39
|
+
error_string = ["error while evaluating \"#{@current_working_dir}/#{@current_project_file}\"",
|
40
|
+
"\"#{k}\" is not a valid specifier!"].join($/)
|
41
|
+
raise error_string unless allowed.include?(k)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# specify an executable
|
46
|
+
# hash supports:
|
47
|
+
# * :sources
|
48
|
+
# * :includes
|
49
|
+
# * :dependencies
|
50
|
+
# * :libpath
|
51
|
+
# * :output_dir
|
52
|
+
def exe(name, hash)
|
53
|
+
raise "not a hash" unless hash.is_a?(Hash)
|
54
|
+
check_hash hash,[:sources,:includes,:dependencies,:libpath,:output_dir]
|
55
|
+
bblock = Executable.new(name)
|
56
|
+
bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
|
57
|
+
bblock.set_includes(hash[:includes]) if hash.has_key?(:includes)
|
58
|
+
calc_lib_searchpath(hash).each { |sp| bblock.add_lib_element(HasLibraries::SEARCH_PATH, sp) }
|
59
|
+
if hash.has_key?(:dependencies)
|
60
|
+
bblock.set_dependencies(hash[:dependencies])
|
61
|
+
hash[:dependencies].each { |d| bblock.add_lib_element(HasLibraries::DEPENDENCY, d) }
|
62
|
+
end
|
63
|
+
bblock.set_output_dir(hash[:output_dir]) if hash.has_key?(:output_dir)
|
64
|
+
all_blocks << bblock
|
65
|
+
end
|
66
|
+
|
67
|
+
def calc_lib_searchpath(hash)
|
68
|
+
if hash.has_key?(:libpath)
|
69
|
+
hash[:libpath]
|
70
|
+
else
|
71
|
+
if Utils::OS.linux? || Utils::OS.mac?
|
72
|
+
["/usr/local/lib","/usr/lib"]
|
73
|
+
elsif Utils::OS.windows?
|
74
|
+
["C:/tool/cygwin/lib", "C:/Tool/cygwin/usr/local/lib"]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# specify a sourcelib
|
80
|
+
# hash supports:
|
81
|
+
# * :sources
|
82
|
+
# * :includes
|
83
|
+
# * :dependencies
|
84
|
+
# * :toolchain
|
85
|
+
# * :file_dependencies
|
86
|
+
# * :output_dir
|
87
|
+
def source_lib(name, hash)
|
88
|
+
raise "not a hash" unless hash.is_a?(Hash)
|
89
|
+
check_hash hash,[:sources, :includes, :dependencies, :toolchain, :file_dependencies, :output_dir]
|
90
|
+
raise ":sources need to be defined" unless hash.has_key?(:sources)
|
91
|
+
bblock = SourceLibrary.new(name)
|
92
|
+
bblock.set_sources(hash[:sources])
|
93
|
+
bblock.set_includes(hash[:includes]) if hash.has_key?(:includes)
|
94
|
+
bblock.set_tcs(hash[:toolchain]) if hash.has_key?(:toolchain)
|
95
|
+
if hash.has_key?(:dependencies)
|
96
|
+
bblock.set_dependencies(hash[:dependencies])
|
97
|
+
hash[:dependencies].each { |d| bblock.add_lib_element(HasLibraries::DEPENDENCY, d) }
|
98
|
+
end
|
99
|
+
bblock.file_dependencies = hash[:file_dependencies] if hash.has_key?(:file_dependencies)
|
100
|
+
bblock.set_output_dir(hash[:output_dir]) if hash.has_key?(:output_dir)
|
101
|
+
all_blocks << bblock
|
102
|
+
end
|
103
|
+
|
104
|
+
# specify some binary libs
|
105
|
+
# returns all binary libs as array
|
106
|
+
def bin_libs(*names)
|
107
|
+
res = []
|
108
|
+
mapped = names.map{|n|n.to_s}
|
109
|
+
mapped.each do |name|
|
110
|
+
res << BinaryLibrary.new(name)
|
111
|
+
end
|
112
|
+
mapped
|
113
|
+
end
|
114
|
+
|
115
|
+
def compile(name, hash)
|
116
|
+
raise "not a hash" unless hash.is_a?(Hash)
|
117
|
+
check_hash hash,[:sources,:includes]
|
118
|
+
bblock = SingleSource.new(name)
|
119
|
+
bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
|
120
|
+
bblock.set_includes(hash[:includes]) if hash.has_key?(:includes)
|
121
|
+
all_blocks << bblock
|
122
|
+
end
|
123
|
+
|
124
|
+
def custom(name, hash)
|
125
|
+
raise "not a hash" unless hash.is_a?(Hash)
|
126
|
+
check_hash hash,[:execute, :dependencies]
|
127
|
+
bblock = CustomBuildingBlock.new(name)
|
128
|
+
bblock.set_actions(hash[:execute]) if hash.has_key?(:execute)
|
129
|
+
if hash.has_key?(:dependencies)
|
130
|
+
bblock.set_dependencies(hash[:dependencies])
|
131
|
+
end
|
132
|
+
all_blocks << bblock
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'cxxproject/utils/utils'
|
2
|
+
|
3
|
+
class File
|
4
|
+
|
5
|
+
SLASH = '/'
|
6
|
+
|
7
|
+
def self.is_absolute?(filename)
|
8
|
+
if Cxxproject::Utils.old_ruby?
|
9
|
+
filename[0] == 47 or filename[1] == 58 # 47 = /, 58 = :
|
10
|
+
else
|
11
|
+
filename[0] == SLASH or filename[1] == ':'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.rel_from_to_project(from,to,endWithSlash = true)
|
16
|
+
return nil if from.nil? or to.nil?
|
17
|
+
|
18
|
+
toSplitted = to.split('/')
|
19
|
+
fromSplitted = from.split('/')
|
20
|
+
|
21
|
+
max = [toSplitted.length, fromSplitted.length].min
|
22
|
+
|
23
|
+
return nil if max < 1
|
24
|
+
|
25
|
+
i = 0
|
26
|
+
|
27
|
+
# path letter in windows may be case different
|
28
|
+
if toSplitted[0].length > 1 and fromSplitted[0].length > 1
|
29
|
+
if Cxxproject::Utils.old_ruby?
|
30
|
+
i = 1 if toSplitted[0][1] == 58 and fromSplitted[0][1] == 58 and toSplitted[0].swapcase[0] == fromSplitted[0][0]
|
31
|
+
else
|
32
|
+
i = 1 if toSplitted[0][1] == ':' and fromSplitted[0][1] == ':' and toSplitted[0].swapcase[0] == fromSplitted[0][0]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
while i < max
|
37
|
+
break if toSplitted[i] != fromSplitted[i]
|
38
|
+
i += 1
|
39
|
+
end
|
40
|
+
j = i
|
41
|
+
|
42
|
+
res = []
|
43
|
+
while i < fromSplitted.length
|
44
|
+
res << ".."
|
45
|
+
i += 1
|
46
|
+
end
|
47
|
+
|
48
|
+
while j < toSplitted.length
|
49
|
+
res << toSplitted[j]
|
50
|
+
j += 1
|
51
|
+
end
|
52
|
+
|
53
|
+
if res.length == 0
|
54
|
+
return ""
|
55
|
+
end
|
56
|
+
|
57
|
+
res = res.join('/')
|
58
|
+
res += "/" if endWithSlash
|
59
|
+
res
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def self.add_prefix(prefix, file)
|
64
|
+
if not prefix or is_absolute?(file)
|
65
|
+
file
|
66
|
+
else
|
67
|
+
prefix + file
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ::ProgressBar
|
2
|
+
attr_writer :title
|
3
|
+
|
4
|
+
def title_width=(w)
|
5
|
+
@title_width = w
|
6
|
+
@format = "%-#{@title_width}s #{'%3d%%'.red} #{'%s'.green} #{'%s'.blue}"
|
7
|
+
end
|
8
|
+
|
9
|
+
show_original = self.instance_method(:show)
|
10
|
+
define_method(:show) do
|
11
|
+
if @unblocked && !RakeFileUtils.verbose
|
12
|
+
show_original.bind(self).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def unblock
|
17
|
+
@unblocked = true
|
18
|
+
show
|
19
|
+
end
|
20
|
+
end
|