cxxproject 0.5.48 → 0.5.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,29 +1,30 @@
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
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
+ if l != "<Linking>" then
19
+ d.file_name = proj_dir
20
+ d.line_number = 0
21
+ d.message = l
22
+ d.severity = SEVERITY_ERROR
23
+ end
24
+ res << d
25
+ end
26
+ [res, consoleOutput]
27
+ end
28
+
29
+ end
30
+ end
@@ -1,136 +1,144 @@
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
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
+ def get_as_array(hash, s)
46
+ res = hash[s]
47
+ if res.is_a?(Array)
48
+ return res
49
+ end
50
+ return [res]
51
+ end
52
+
53
+ # specify an executable
54
+ # hash supports:
55
+ # * :sources
56
+ # * :includes
57
+ # * :dependencies
58
+ # * :libpath
59
+ # * :output_dir
60
+ def exe(name, hash)
61
+ raise "not a hash" unless hash.is_a?(Hash)
62
+ check_hash hash,[:sources,:includes,:dependencies,:libpath,:output_dir]
63
+ bblock = Executable.new(name)
64
+ bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
65
+ bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes)
66
+ calc_lib_searchpath(hash).each { |sp| bblock.add_lib_element(HasLibraries::SEARCH_PATH, sp) }
67
+ if hash.has_key?(:dependencies)
68
+ bblock.set_dependencies(hash[:dependencies])
69
+ hash[:dependencies].each { |d| bblock.add_lib_element(HasLibraries::DEPENDENCY, d) }
70
+ end
71
+ bblock.set_output_dir(hash[:output_dir]) if hash.has_key?(:output_dir)
72
+ all_blocks << bblock
73
+ end
74
+
75
+ def calc_lib_searchpath(hash)
76
+ if hash.has_key?(:libpath)
77
+ hash[:libpath]
78
+ else
79
+ if Utils::OS.linux? || Utils::OS.mac?
80
+ ["/usr/local/lib","/usr/lib"]
81
+ elsif Utils::OS.windows?
82
+ ["C:/tool/cygwin/lib", "C:/Tool/cygwin/usr/local/lib"]
83
+ end
84
+ end
85
+ end
86
+
87
+ # specify a sourcelib
88
+ # hash supports:
89
+ # * :sources
90
+ # * :includes
91
+ # * :dependencies
92
+ # * :toolchain
93
+ # * :file_dependencies
94
+ # * :output_dir
95
+ def source_lib(name, hash)
96
+ raise "not a hash" unless hash.is_a?(Hash)
97
+ check_hash hash,[:sources, :includes, :dependencies, :toolchain, :file_dependencies, :output_dir]
98
+ raise ":sources need to be defined" unless hash.has_key?(:sources)
99
+ bblock = SourceLibrary.new(name)
100
+ bblock.set_sources(hash[:sources])
101
+ bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes)
102
+ bblock.set_tcs(hash[:toolchain]) if hash.has_key?(:toolchain)
103
+ if hash.has_key?(:dependencies)
104
+ bblock.set_dependencies(hash[:dependencies])
105
+ hash[:dependencies].each { |d| bblock.add_lib_element(HasLibraries::DEPENDENCY, d) }
106
+ end
107
+ bblock.file_dependencies = hash[:file_dependencies] if hash.has_key?(:file_dependencies)
108
+ bblock.set_output_dir(hash[:output_dir]) if hash.has_key?(:output_dir)
109
+ all_blocks << bblock
110
+ end
111
+
112
+ # specify some binary libs
113
+ # returns all binary libs as array
114
+ def bin_libs(*names)
115
+ res = []
116
+ mapped = names.map{|n|n.to_s}
117
+ mapped.each do |name|
118
+ res << BinaryLibrary.new(name)
119
+ end
120
+ mapped
121
+ end
122
+
123
+ def compile(name, hash)
124
+ raise "not a hash" unless hash.is_a?(Hash)
125
+ check_hash hash,[:sources,:includes]
126
+ bblock = SingleSource.new(name)
127
+ bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
128
+ bblock.set_includes(hash[:includes]) if hash.has_key?(:includes)
129
+ all_blocks << bblock
130
+ end
131
+
132
+ def custom(name, hash)
133
+ raise "not a hash" unless hash.is_a?(Hash)
134
+ check_hash hash,[:execute, :dependencies]
135
+ bblock = CustomBuildingBlock.new(name)
136
+ bblock.set_actions(hash[:execute]) if hash.has_key?(:execute)
137
+ if hash.has_key?(:dependencies)
138
+ bblock.set_dependencies(hash[:dependencies])
139
+ end
140
+ all_blocks << bblock
141
+ end
142
+
143
+ end
144
+ end
@@ -1,71 +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
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