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,30 +1,30 @@
1
- require 'spec_helper'
2
- require 'cxxproject'
3
-
4
- describe File do
5
-
6
- it 'should calc if a pathname is absolute' do
7
- File.is_absolute?('/test').should eq(true)
8
- File.is_absolute?('a:test').should eq(true)
9
- File.is_absolute?('test').should eq(false)
10
- end
11
-
12
- it 'should find a good relative directory for subdirectories' do
13
- File.rel_from_to_project('x/main/a', 'x/main/b').should eq('../b/')
14
- File.rel_from_to_project('x/main/a/b', 'x/main').should eq('../../')
15
- File.rel_from_to_project('x/main', 'x/main/a/b').should eq('a/b/')
16
- File.rel_from_to_project('x/main', 'x/main').should eq('')
17
- File.rel_from_to_project('x/main', nil).should eq(nil)
18
- File.rel_from_to_project(nil, 'x/main').should eq(nil)
19
- File.rel_from_to_project('x/a', 'y/b').should eq("../../y/b/")
20
- File.rel_from_to_project('x/x', 'x/x').should eq('')
21
- end
22
-
23
- it 'add prefix only if file is not absolute' do
24
- File.add_prefix('abc/', '/usr/local').should eq('/usr/local')
25
- File.add_prefix('abc/', 'nix/usr/local').should eq('abc/nix/usr/local')
26
- File.add_prefix('abc/', 'c:/usr/local').should eq('c:/usr/local')
27
- File.add_prefix('abc/', 'c:\\usr/local').should eq('c:\\usr/local')
28
- end
29
-
30
- end
1
+ require 'spec_helper'
2
+ require 'cxxproject'
3
+
4
+ describe File do
5
+
6
+ it 'should calc if a pathname is absolute' do
7
+ File.is_absolute?('/test').should eq(true)
8
+ File.is_absolute?('a:test').should eq(true)
9
+ File.is_absolute?('test').should eq(false)
10
+ end
11
+
12
+ it 'should find a good relative directory for subdirectories' do
13
+ File.rel_from_to_project('x/main/a', 'x/main/b').should eq('../b/')
14
+ File.rel_from_to_project('x/main/a/b', 'x/main').should eq('../../')
15
+ File.rel_from_to_project('x/main', 'x/main/a/b').should eq('a/b/')
16
+ File.rel_from_to_project('x/main', 'x/main').should eq('')
17
+ File.rel_from_to_project('x/main', nil).should eq(nil)
18
+ File.rel_from_to_project(nil, 'x/main').should eq(nil)
19
+ File.rel_from_to_project('x/a', 'y/b').should eq("../../y/b/")
20
+ File.rel_from_to_project('x/x', 'x/x').should eq('')
21
+ end
22
+
23
+ it 'add prefix only if file is not absolute' do
24
+ File.add_prefix('abc/', '/usr/local').should eq('/usr/local')
25
+ File.add_prefix('abc/', 'nix/usr/local').should eq('abc/nix/usr/local')
26
+ File.add_prefix('abc/', 'c:/usr/local').should eq('c:/usr/local')
27
+ File.add_prefix('abc/', 'c:\\usr/local').should eq('c:\\usr/local')
28
+ end
29
+
30
+ end
@@ -1,41 +1,41 @@
1
- require 'spec_helper'
2
- require 'cxxproject/ide_interface'
3
- require 'cxxproject/utils/utils'
4
- require 'cxxproject/errorparser/error_parser'
5
-
6
- def check_long(e, l)
7
- e.next.should eq(l)
8
- e.next.should eq(0)
9
- e.next.should eq(0)
10
- e.next.should eq(0)
11
- end
12
- def check_string(e, s)
13
- s.bytes do |i|
14
- e.next.should eq(i)
15
- end
16
- end
17
-
18
- describe Cxxproject::IDEInterface do
19
-
20
- it 'should create a correct package from an error-array' do
21
- ide = Cxxproject::IDEInterface.new
22
- error = Cxxproject::ErrorDesc.new
23
- error.severity = 2
24
- error.line_number = 10
25
- error.file_name = 'filename'
26
- error.message = 'error'
27
- packet = ide.create_error_packet(error)
28
-
29
- if not Cxxproject::Utils.old_ruby? # in Ruby 1.8.6 there is no bytes methods...
30
- e = packet.bytes
31
- e.next.should eq(1)
32
- check_long(e, 22)
33
- check_long(e, 8)
34
- check_string(e, 'filename')
35
- check_long(e, 10)
36
- e.next.should eq(2)
37
- check_string(e, 'error')
38
- end
39
- end
40
-
41
- end
1
+ require 'spec_helper'
2
+ require 'cxxproject/ide_interface'
3
+ require 'cxxproject/utils/utils'
4
+ require 'cxxproject/errorparser/error_parser'
5
+
6
+ def check_long(e, l)
7
+ e.next.should eq(l)
8
+ e.next.should eq(0)
9
+ e.next.should eq(0)
10
+ e.next.should eq(0)
11
+ end
12
+ def check_string(e, s)
13
+ s.bytes do |i|
14
+ e.next.should eq(i)
15
+ end
16
+ end
17
+
18
+ describe Cxxproject::IDEInterface do
19
+
20
+ it 'should create a correct package from an error-array' do
21
+ ide = Cxxproject::IDEInterface.new
22
+ error = Cxxproject::ErrorDesc.new
23
+ error.severity = 2
24
+ error.line_number = 10
25
+ error.file_name = 'filename'
26
+ error.message = 'error'
27
+ packet = ide.create_error_packet(error)
28
+
29
+ if not Cxxproject::Utils.old_ruby? # in Ruby 1.8.6 there is no bytes methods...
30
+ e = packet.bytes
31
+ e.next.should eq(1)
32
+ check_long(e, 22)
33
+ check_long(e, 8)
34
+ check_string(e, 'filename')
35
+ check_long(e, 10)
36
+ e.next.should eq(2)
37
+ check_string(e, 'error')
38
+ end
39
+ end
40
+
41
+ end
@@ -1,83 +1,83 @@
1
- require 'spec_helper'
2
- require 'cxxproject'
3
- require 'cxxproject/ext/rake_listener.rb'
4
- require 'cxxproject/utils/cleanup'
5
-
6
- describe Rake::Task do
7
-
8
- before(:each) do
9
- Rake::application.options.silent = true
10
- Cxxproject::Utils.cleanup_rake
11
- end
12
- after(:each) do
13
- Cxxproject::Utils.cleanup_rake
14
- end
15
-
16
- it 'should fail if source of object is missing' do
17
- file 'test.cc' => 'compiler'
18
- File.delete('test.cc') if File.exists?('test.cc')
19
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
20
- cxx = CxxProject2Rake.new([], 'build', GCCChain)
21
-
22
- task = Rake::application['lib:testlib']
23
- task.invoke
24
- task.failure.should eq(true)
25
-
26
- FileUtils.rm_rf('build')
27
- end
28
-
29
- it 'should not fail if include-dependency of object is missing' do
30
- File.open('test.cc', 'w') do |io|
31
- io.puts('#include "test.h"')
32
- end
33
-
34
- File.open('test.h', 'w') do |io|
35
- end
36
-
37
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
38
- CxxProject2Rake.new([], 'build', GCCChain)
39
-
40
- task = Rake::application['lib:testlib']
41
- task.invoke
42
- task.failure.should eq(false)
43
-
44
- Cxxproject::Utils.cleanup_rake
45
-
46
- FileUtils.rm_rf('test.h')
47
- File.open('test.cc', 'w') do |io|
48
- end
49
-
50
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
51
- CxxProject2Rake.new([], 'build', GCCChain)
52
-
53
- task = Rake::application['build/libs/libtestlib.a']
54
- task.invoke
55
- task.failure.should eq(false)
56
-
57
- FileUtils.rm_rf('test.cc')
58
- end
59
-
60
- it 'should not fail if generated headerfile is missing' do
61
- file 'test.h' do
62
- sh 'touch test.h'
63
- end
64
-
65
- file 'test.cc' => 'test.h' do |t|
66
- File.open(t.name, 'w') do |io|
67
- io.puts('#include "test.h"')
68
- end
69
- end
70
-
71
- sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
72
- CxxProject2Rake.new([], 'build', GCCChain)
73
-
74
- task = Rake::application['build/libs/libtestlib.a']
75
- task.invoke
76
- task.failure.should eq(false)
77
-
78
- FileUtils.rm_rf('build')
79
- FileUtils.rm_rf('test.cc')
80
- FileUtils.rm_rf('test.h')
81
- end
82
-
83
- end
1
+ require 'spec_helper'
2
+ require 'cxxproject'
3
+ require 'cxxproject/ext/rake_listener.rb'
4
+ require 'cxxproject/utils/cleanup'
5
+
6
+ describe Rake::Task do
7
+
8
+ before(:each) do
9
+ Rake::application.options.silent = true
10
+ Cxxproject::Utils.cleanup_rake
11
+ end
12
+ after(:each) do
13
+ Cxxproject::Utils.cleanup_rake
14
+ end
15
+
16
+ it 'should fail if source of object is missing' do
17
+ file 'test.cc' => 'compiler'
18
+ File.delete('test.cc') if File.exists?('test.cc')
19
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
20
+ cxx = CxxProject2Rake.new([], 'build', GCCChain)
21
+
22
+ task = Rake::application['lib:testlib']
23
+ task.invoke
24
+ task.failure.should eq(true)
25
+
26
+ FileUtils.rm_rf('build')
27
+ end
28
+
29
+ it 'should not fail if include-dependency of object is missing' do
30
+ File.open('test.cc', 'w') do |io|
31
+ io.puts('#include "test.h"')
32
+ end
33
+
34
+ File.open('test.h', 'w') do |io|
35
+ end
36
+
37
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
38
+ CxxProject2Rake.new([], 'build', GCCChain)
39
+
40
+ task = Rake::application['lib:testlib']
41
+ task.invoke
42
+ task.failure.should eq(false)
43
+
44
+ Cxxproject::Utils.cleanup_rake
45
+
46
+ FileUtils.rm_rf('test.h')
47
+ File.open('test.cc', 'w') do |io|
48
+ end
49
+
50
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
51
+ CxxProject2Rake.new([], 'build', GCCChain)
52
+
53
+ task = Rake::application['build/libs/libtestlib.a']
54
+ task.invoke
55
+ task.failure.should eq(false)
56
+
57
+ FileUtils.rm_rf('test.cc')
58
+ end
59
+
60
+ it 'should not fail if generated headerfile is missing' do
61
+ file 'test.h' do
62
+ sh 'touch test.h'
63
+ end
64
+
65
+ file 'test.cc' => 'test.h' do |t|
66
+ File.open(t.name, 'w') do |io|
67
+ io.puts('#include "test.h"')
68
+ end
69
+ end
70
+
71
+ sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
72
+ CxxProject2Rake.new([], 'build', GCCChain)
73
+
74
+ task = Rake::application['build/libs/libtestlib.a']
75
+ task.invoke
76
+ task.failure.should eq(false)
77
+
78
+ FileUtils.rm_rf('build')
79
+ FileUtils.rm_rf('test.cc')
80
+ FileUtils.rm_rf('test.h')
81
+ end
82
+
83
+ end
@@ -1,71 +1,71 @@
1
- require 'spec_helper'
2
- require 'cxxproject'
3
- require 'cxxproject/utils/cleanup'
4
-
5
- RSPECDIR = File.dirname(__FILE__)
6
-
7
- describe CxxProject2Rake do
8
-
9
- def execute_all_tasks(tasks)
10
- tasks.each do |t|
11
- t.invoke
12
- end
13
- end
14
-
15
- def fresh_cxx(outputdir,base)
16
- Cxxproject::Utils.cleanup_rake
17
- project_configs = nil
18
- cd base do # have to be relative to base
19
- project_configs = Dir.glob('**/project.rb')
20
- end
21
- CxxProject2Rake.new(project_configs, outputdir, GCCChain, base)
22
- end
23
-
24
-
25
- # def is_older? fileA, fileB
26
- # File.mtime(fileA) < File.mtime(fileB)
27
- # end
28
-
29
- # def is_newer? fileA, fileB
30
- # File.mtime(fileA) > File.mtime(fileB)
31
- # end
32
-
33
- def test_on_level(base, outputdir)
34
- libOne = "#{outputdir}/libs/lib1.a"
35
- libTwo = "#{outputdir}/libs/lib2.a"
36
- exe = "#{outputdir}/basic.exe"
37
- exe2 = "#{outputdir}/debug.exe"
38
-
39
- rm_r outputdir if File.directory?(outputdir)
40
- tasks = fresh_cxx(outputdir, base).all_tasks
41
- CLOBBER.each { |fn| rm_r fn rescue nil }
42
-
43
- [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_false }
44
-
45
- execute_all_tasks(tasks)
46
-
47
- [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_true }
48
-
49
- # cleanup
50
- rm_r outputdir if File.directory?(outputdir)
51
- Cxxproject::Utils.cleanup_rake
52
- end
53
-
54
- it 'should resolve paths on different levels' do
55
- outputdir = 'output'
56
-
57
- cd("#{RSPECDIR}/testdata/multiple_levels", :verbose => false) do
58
- test_on_level(".", outputdir)
59
- end
60
-
61
- cd("#{RSPECDIR}/testdata/multiple_levels/mainproject", :verbose => false) do
62
- test_on_level("..", outputdir)
63
- end
64
-
65
- cd("#{RSPECDIR}/testdata", :verbose => false) do
66
- test_on_level("multiple_levels/", outputdir)
67
- end
68
- end
69
-
70
- end
71
-
1
+ require 'spec_helper'
2
+ require 'cxxproject'
3
+ require 'cxxproject/utils/cleanup'
4
+
5
+ RSPECDIR = File.dirname(__FILE__)
6
+
7
+ describe CxxProject2Rake do
8
+
9
+ def execute_all_tasks(tasks)
10
+ tasks.each do |t|
11
+ t.invoke
12
+ end
13
+ end
14
+
15
+ def fresh_cxx(outputdir,base)
16
+ Cxxproject::Utils.cleanup_rake
17
+ project_configs = nil
18
+ cd base do # have to be relative to base
19
+ project_configs = Dir.glob('**/project.rb')
20
+ end
21
+ CxxProject2Rake.new(project_configs, outputdir, GCCChain, base)
22
+ end
23
+
24
+
25
+ # def is_older? fileA, fileB
26
+ # File.mtime(fileA) < File.mtime(fileB)
27
+ # end
28
+
29
+ # def is_newer? fileA, fileB
30
+ # File.mtime(fileA) > File.mtime(fileB)
31
+ # end
32
+
33
+ def test_on_level(base, outputdir)
34
+ libOne = "#{outputdir}/libs/lib1.a"
35
+ libTwo = "#{outputdir}/libs/lib2.a"
36
+ exe = "#{outputdir}/basic.exe"
37
+ exe2 = "#{outputdir}/debug.exe"
38
+
39
+ rm_r outputdir if File.directory?(outputdir)
40
+ tasks = fresh_cxx(outputdir, base).all_tasks
41
+ CLOBBER.each { |fn| rm_r fn rescue nil }
42
+
43
+ [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_false }
44
+
45
+ execute_all_tasks(tasks)
46
+
47
+ [libOne,libTwo,exe,exe2].all? {|f| File.exists?(f).should be_true }
48
+
49
+ # cleanup
50
+ rm_r outputdir if File.directory?(outputdir)
51
+ Cxxproject::Utils.cleanup_rake
52
+ end
53
+
54
+ it 'should resolve paths on different levels' do
55
+ outputdir = 'output'
56
+
57
+ cd("#{RSPECDIR}/testdata/multiple_levels", :verbose => false) do
58
+ test_on_level(".", outputdir)
59
+ end
60
+
61
+ cd("#{RSPECDIR}/testdata/multiple_levels/mainproject", :verbose => false) do
62
+ test_on_level("..", outputdir)
63
+ end
64
+
65
+ cd("#{RSPECDIR}/testdata", :verbose => false) do
66
+ test_on_level("multiple_levels/", outputdir)
67
+ end
68
+ end
69
+
70
+ end
71
+