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,30 +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
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
@@ -1,30 +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
- 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
+ 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,144 +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
- 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
+
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,81 +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
- # seems both are rel or both are abs in all cases
16
- def self.rel_from_to_project(from,to,endWithSlash = true)
17
- return nil if from.nil? or to.nil?
18
-
19
- toSplitted = to.split('/')
20
- fromSplitted = from.split('/')
21
-
22
- max = [toSplitted.length, fromSplitted.length].min
23
-
24
- return nil if max < 1
25
-
26
- i = 0
27
-
28
- # path letter in windows may be case different
29
- toIsWindowsAbs = false
30
- if toSplitted[0].length > 1 and fromSplitted[0].length > 1
31
- if Cxxproject::Utils.old_ruby?
32
- toIsWindowsAbs = toSplitted[0][1] == 58
33
- i = 1 if toIsWindowsAbs and fromSplitted[0][1] == 58 and toSplitted[0][0].downcase == fromSplitted[0][0].downcase
34
- else
35
- toIsWindowsAbs = toSplitted[0][1] == ':'
36
- i = 1 if toIsWindowsAbs and fromSplitted[0][1] == ':' and toSplitted[0][0].downcase == fromSplitted[0][0].downcase
37
- end
38
- end
39
-
40
- if (toIsWindowsAbs and i==0)
41
- res = to
42
- res += "/" if endWithSlash
43
- return res
44
- end
45
-
46
- while i < max
47
- break if toSplitted[i] != fromSplitted[i]
48
- i += 1
49
- end
50
- j = i
51
-
52
- res = []
53
- while i < fromSplitted.length
54
- res << ".."
55
- i += 1
56
- end
57
-
58
- while j < toSplitted.length
59
- res << toSplitted[j]
60
- j += 1
61
- end
62
-
63
- if res.length == 0
64
- return ""
65
- end
66
-
67
- res = res.join('/')
68
- res += "/" if endWithSlash
69
- res
70
- end
71
-
72
-
73
- def self.add_prefix(prefix, file)
74
- if not prefix or is_absolute?(file)
75
- file
76
- else
77
- prefix + file
78
- end
79
- end
80
-
81
- 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
@@ -1,6 +1,6 @@
1
- module Rake
2
- class FileList
3
- attr_accessor :pending_add
4
- attr_accessor :items
5
- end
6
- end
1
+ module Rake
2
+ class FileList
3
+ attr_accessor :pending_add
4
+ attr_accessor :items
5
+ end
6
+ 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