rake-builder 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/Rakefile +8 -5
  2. data/examples/05_tests/Rakefile +3 -3
  3. data/examples/05_tests/include/units.h +2 -2
  4. data/lib/compiler.rb +25 -30
  5. data/lib/rake/builder.rb +135 -136
  6. data/lib/rake/builder/installer.rb +37 -0
  7. data/lib/rake/{local_config.rb → builder/local_config.rb} +13 -14
  8. data/lib/rake/builder/logger/formatter.rb +7 -1
  9. data/lib/rake/builder/presenters/makefile/builder_presenter.rb +66 -33
  10. data/lib/rake/builder/presenters/makefile_am/builder_presenter.rb +4 -4
  11. data/lib/rake/builder/qt_builder.rb +3 -8
  12. data/lib/rake/builder/task_definers/builder_task_definer.rb +1 -4
  13. data/lib/rake/builder/version.rb +1 -1
  14. data/lib/rake/{microsecond.rb → microsecond_task.rb} +22 -27
  15. data/lib/rake/once_task.rb +2 -7
  16. data/lib/rake/path.rb +1 -6
  17. data/spec/gather_rspec_coverage.rb +2 -0
  18. data/spec/spec_helper.rb +13 -98
  19. data/spec/unit/compiler_spec.rb +129 -0
  20. data/spec/unit/rake/builder/autoconf/version_spec.rb +62 -5
  21. data/spec/unit/rake/builder/configure_ac_spec.rb +53 -0
  22. data/spec/unit/rake/builder/install_spec.rb +101 -0
  23. data/spec/unit/rake/builder/local_config_spec.rb +53 -0
  24. data/spec/unit/rake/builder/logger/formatter_spec.rb +20 -0
  25. data/spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb +163 -0
  26. data/spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb +4 -2
  27. data/spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb +6 -0
  28. data/spec/unit/rake/builder_spec.rb +391 -16
  29. data/spec/unit/rake/microsecond_task_spec.rb +63 -0
  30. metadata +39 -55
  31. data/examples/01_hello_world_cpp/vendor/bundle/gems/coderay-1.0.8/Rakefile +0 -35
  32. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/Rakefile +0 -412
  33. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/fbuffer/fbuffer.h +0 -185
  34. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.c +0 -1427
  35. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.h +0 -149
  36. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.c +0 -2204
  37. data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.h +0 -77
  38. data/examples/01_hello_world_cpp/vendor/bundle/gems/method_source-0.8.1/Rakefile +0 -79
  39. data/examples/01_hello_world_cpp/vendor/bundle/gems/pry-0.9.11.3/Rakefile +0 -136
  40. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/Rakefile +0 -374
  41. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/a.c +0 -6
  42. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/b.c +0 -6
  43. data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/main.c +0 -11
  44. data/examples/01_hello_world_cpp/vendor/bundle/gems/slop-3.4.3/Rakefile +0 -29
  45. data/lib/rake/file_task_alias.rb +0 -24
  46. data/spec/c_project/main.c +0 -12
  47. data/spec/c_project/main.h +0 -6
  48. data/spec/c_project_spec.rb +0 -41
  49. data/spec/cpp_project/main.cpp +0 -12
  50. data/spec/cpp_project/main.h +0 -8
  51. data/spec/cpp_project_spec.rb +0 -203
  52. data/spec/generated_files_spec.rb +0 -65
  53. data/spec/libraries_spec.rb +0 -35
  54. data/spec/local_config_spec.rb +0 -95
  55. data/spec/logger_spec.rb +0 -25
  56. data/spec/microsecond_task_spec.rb +0 -32
  57. data/spec/objective_c_project/main.h +0 -1
  58. data/spec/objective_c_project/main.m +0 -18
  59. data/spec/objective_c_project_spec.rb +0 -72
  60. data/spec/paths_spec.rb +0 -19
  61. data/spec/project_spec.rb +0 -20
  62. data/spec/target_spec.rb +0 -48
@@ -1,6 +0,0 @@
1
- #include <stdio.h>
2
-
3
- void a()
4
- {
5
- printf ("In function a\n");
6
- }
@@ -1,6 +0,0 @@
1
- #include <stdio.h>
2
-
3
- void b()
4
- {
5
- printf ("In function b\n");
6
- }
@@ -1,11 +0,0 @@
1
- #include <stdio.h>
2
-
3
- extern void a();
4
- extern void b();
5
-
6
- int main ()
7
- {
8
- a();
9
- b();
10
- return 0;
11
- }
@@ -1,29 +0,0 @@
1
- begin
2
- require 'bundler/gem_tasks'
3
- rescue LoadError
4
- end
5
-
6
- require 'rake/testtask'
7
-
8
- Rake::TestTask.new do |t|
9
- t.libs << 'test'
10
- t.test_files = Dir['test/*_test.rb']
11
- end
12
-
13
- # begin
14
- # require 'rdoc/task'
15
-
16
- # # requires sdoc and horo gems
17
- # RDoc::Task.new do |rdoc|
18
- # rdoc.title = 'Slop API Documentation'
19
- # rdoc.rdoc_dir = 'doc'
20
- # rdoc.options << '-f' << 'sdoc'
21
- # rdoc.options << '-T' << 'rails'
22
- # rdoc.options << '-e' << 'UTF-8'
23
- # rdoc.options << '-g'
24
- # rdoc.rdoc_files.include('lib/**/*.rb')
25
- # end
26
- # rescue LoadError
27
- # end
28
-
29
- task :default => :test
@@ -1,24 +0,0 @@
1
- require 'rubygems' if RUBY_VERSION < '1.9'
2
- require 'rake/tasklib'
3
-
4
- module Rake
5
-
6
- # A task whose behaviour depends on a FileTask
7
- class FileTaskAlias < Task
8
-
9
- attr_accessor :target
10
-
11
- def self.define_task( name, target, &block )
12
- alias_task = super( { name => [] }, &block )
13
- alias_task.target = target
14
- alias_task.prerequisites.unshift( target )
15
- alias_task
16
- end
17
-
18
- def needed?
19
- Rake::Task[ @target ].needed?
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,12 +0,0 @@
1
- #include "main.h"
2
-
3
- int main( int argc, char *argv[] ) {
4
- FILE * file = fopen ( "rake-c-testfile.txt", "w" );
5
- if( file == NULL )
6
- return 1;
7
-
8
- fputs( "rake-builder test", file );
9
- fclose( file );
10
-
11
- return 0;
12
- }
@@ -1,6 +0,0 @@
1
- #ifndef __PROJECT_MAIN_H__
2
- #define __PROJECT_MAIN_H__
3
-
4
- #include <stdio.h>
5
-
6
- #endif // ndef __PROJECT_MAIN_H__
@@ -1,41 +0,0 @@
1
- load File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe 'when building a C project' do
4
-
5
- include RakeBuilderHelper
6
-
7
- before( :all ) do
8
- @test_output_file = Rake::Path.expand_with_root( 'rake-c-testfile.txt', RakeBuilderHelper::SPEC_PATH )
9
- end
10
-
11
- before( :each ) do
12
- Rake::Task.clear
13
- @project = c_task( :executable )
14
- @expected_generated = Rake::Path.expand_all_with_root(
15
- [
16
- './main.o',
17
- @project.makedepend_file, @project.target
18
- ],
19
- RakeBuilderHelper::SPEC_PATH
20
- )
21
- `rm -f #{ @test_output_file }`
22
- `rm -f #{ @project.target }`
23
- end
24
-
25
- after( :each ) do
26
- Rake::Task[ 'clean' ].invoke
27
- `rm -f #{ @test_output_file }`
28
- `rm -f '#{ @project.local_config }'`
29
- end
30
-
31
- it "builds the program with 'build'" do
32
- Rake::Task[ 'build' ].invoke
33
- exist?( @project.target ).should be_true
34
- end
35
-
36
- it "runs the program with 'run'" do
37
- Rake::Task[ 'run' ].invoke
38
- exist?( @test_output_file ).should be_true
39
- end
40
-
41
- end
@@ -1,12 +0,0 @@
1
- #include "main.h"
2
-
3
- int main( int argc, char *argv[] ) {
4
- ofstream outfile( "rake-builder-testfile.txt" );
5
-
6
- if( outfile.fail() )
7
- return 1;
8
-
9
- outfile << "rake-builder test";
10
-
11
- return 0;
12
- }
@@ -1,8 +0,0 @@
1
- #ifndef __PROJECT_MAIN_H__
2
- #define __PROJECT_MAIN_H__
3
-
4
- #include <iostream>
5
- #include <fstream>
6
- using namespace std;
7
-
8
- #endif // ndef __PROJECT_MAIN_H__
@@ -1,203 +0,0 @@
1
- load File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe '#source_files' do
4
-
5
- include RakeBuilderHelper
6
-
7
- before( :each ) do
8
- Rake::Path.stub!(:find_files).with(anything, 'h').and_return(['a.h'])
9
- Rake::Path.stub!(:find_files).with(anything, 'cpp').and_return(['a.cpp'])
10
-
11
- Rake::Task.clear
12
- end
13
-
14
- it 'should find files with the .cpp extension' do
15
- Rake::Path.should_receive(:find_files).with(anything, 'cpp').and_return(['a.cpp'])
16
-
17
- cpp_task(:executable)
18
- end
19
-
20
- it 'should allow configuration of source extension' do
21
- Rake::Path.should_receive(:find_files).with(anything, 'cc').and_return(['a.cc'])
22
-
23
- cpp_task(:executable) { |p| p.source_file_extension = 'cc' }
24
- end
25
-
26
- end
27
-
28
- describe 'when building an executable' do
29
-
30
- include RakeBuilderHelper
31
-
32
- before( :all ) do
33
- @test_output_file = Rake::Path.expand_with_root(
34
- 'rake-builder-testfile.txt', RakeBuilderHelper::SPEC_PATH )
35
- @expected_target = Rake::Path.expand_with_root(
36
- RakeBuilderHelper::TARGET[ :executable ],
37
- RakeBuilderHelper::SPEC_PATH )
38
- end
39
-
40
- before( :each ) do
41
- Rake::Task.clear
42
- @project = cpp_task( :executable )
43
- `rm -f #{ @test_output_file }`
44
- `rm -f #{ @project.target }`
45
- end
46
-
47
- after( :each ) do
48
- Rake::Task[ 'clean' ].invoke
49
- `rm -f #{ @test_output_file }`
50
- end
51
-
52
- it 'knows the target' do
53
- @project.target.should == @expected_target
54
- end
55
-
56
- it 'builds the target in the objects directory' do
57
- File.dirname( @project.target ).should == @project.objects_path
58
- end
59
-
60
- it 'knows the project type' do
61
- @project.target_type.should == :executable
62
- end
63
-
64
- it 'creates the correct tasks' do
65
- expected_tasks = expected_tasks( [ @project.target ] )
66
- missing_tasks = expected_tasks - task_names
67
- missing_tasks.should == []
68
- end
69
-
70
- it 'builds the program with \'build\'' do
71
- Rake::Task[ 'build' ].invoke
72
- exist?( @project.target ).should be_true
73
- end
74
-
75
- it 'has a \'run\' task' do
76
- task_names.include?('run'). should be_true
77
- end
78
-
79
- it 'builds the program with \'run\'' do
80
- Rake::Task[ 'run' ].invoke
81
- exist?( @project.target ).should be_true
82
- end
83
-
84
- it 'runs the program with \'run\'' do
85
- Rake::Task[ 'run' ].invoke
86
- exist?( @test_output_file ).should be_true
87
- end
88
-
89
- end
90
-
91
- describe 'when using namespaces' do
92
-
93
- include RakeBuilderHelper
94
-
95
- before( :each ) do
96
- Rake::Task.clear
97
- @project = cpp_task( :executable, 'my_namespace' )
98
- end
99
-
100
- after( :each ) do
101
- Rake::Task[ 'my_namespace:clean' ].invoke
102
- end
103
-
104
- it 'creates the correct tasks' do
105
- expected = expected_tasks( scoped_tasks( [ @project.target ], 'my_namespace' ), 'my_namespace' )
106
- missing_tasks = expected - task_names
107
- missing_tasks.should == []
108
- end
109
-
110
- end
111
-
112
- describe 'when building a static library' do
113
-
114
- include RakeBuilderHelper
115
-
116
- before( :each ) do
117
- Rake::Task.clear
118
- @project = cpp_task( :static_library )
119
- `rm -f #{@project.target}`
120
- end
121
-
122
- after( :each ) do
123
- Rake::Task[ 'clean' ].invoke
124
- end
125
-
126
- it 'knows the target type' do
127
- @project.target_type.should == :static_library
128
- end
129
-
130
- it 'builds the library' do
131
- Rake::Task[ 'build' ].invoke
132
- exist?( @project.target ).should be_true
133
- end
134
-
135
- it 'hasn\'t got a \'run\' task' do
136
- task_names.include?( 'run' ).should be_false
137
- end
138
-
139
- end
140
-
141
- describe 'when building a shared library' do
142
-
143
- include RakeBuilderHelper
144
-
145
- before( :each ) do
146
- Rake::Task.clear
147
- @project = cpp_task( :shared_library ) do |builder|
148
- builder.compilation_options += ['-fPIC']
149
- end
150
- `rm -f #{ @project.target }`
151
- end
152
-
153
- after( :each ) do
154
- Rake::Task[ 'clean' ].invoke
155
- end
156
-
157
- it 'knows the target type' do
158
- @project.target_type.should == :shared_library
159
- end
160
-
161
- it 'builds the library' do
162
- Rake::Task[ 'build' ].invoke
163
- exist?( @project.target ).should be_true
164
- end
165
-
166
- it 'hasn\'t got a \'run\' task' do
167
- task_names.include?( 'run' ).should be_false
168
- end
169
-
170
- end
171
-
172
- describe 'when installing' do
173
-
174
- include RakeBuilderHelper
175
-
176
- INSTALL_DIRECTORY = '/tmp/rake-builder-test-install'
177
-
178
- before( :each ) do
179
- Rake::Task.clear
180
- `mkdir #{ INSTALL_DIRECTORY }`
181
- @project = cpp_task( :executable ) do |builder|
182
- builder.install_path = INSTALL_DIRECTORY
183
- end
184
- @installed_target = File.join( INSTALL_DIRECTORY, File.basename( @project.target ) )
185
- end
186
-
187
- after( :each ) do
188
- `rm -rf #{ INSTALL_DIRECTORY }`
189
- end
190
-
191
- it 'should install the file' do
192
- Rake::Task[ 'install' ].invoke
193
- exist?( @installed_target ).should be_true
194
- end
195
-
196
- it 'should uninstall the file' do
197
- Rake::Task[ 'install' ].invoke
198
- exist?( @installed_target ).should be_true
199
- Rake::Task[ 'uninstall' ].invoke
200
- exist?( @installed_target ).should be_false
201
- end
202
-
203
- end
@@ -1,65 +0,0 @@
1
- load File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- require 'json'
4
-
5
- describe 'when handling generated files' do
6
-
7
- include RakeBuilderHelper
8
-
9
- before( :each ) do
10
- Rake::Task.clear
11
- @project = cpp_task( :executable )
12
- @expected_generated = Rake::Path.expand_all_with_root(
13
- [
14
- 'main.o',
15
- 'rake-builder-testfile.txt',
16
- @project.makedepend_file,
17
- @project.target ],
18
- RakeBuilderHelper::SPEC_PATH )
19
- end
20
-
21
- after( :each ) do
22
- Rake::Task[ 'clean' ].execute
23
- end
24
-
25
- it 'lists generated files, with a method' do
26
- @project.generated_files.should =~ @expected_generated
27
- end
28
-
29
- it 'removes generated files with \'clean\'' do
30
- Rake::Task[ 'run' ].invoke
31
- @expected_generated.each do |f|
32
- exist?( f ).should be_true
33
- end
34
- Rake::Task[ 'clean' ].invoke
35
- @expected_generated.each do |f|
36
- exist?( f ).should be_false
37
- end
38
- end
39
-
40
- end
41
-
42
- describe 'when adding generated files' do
43
-
44
- include RakeBuilderHelper
45
-
46
- before( :each ) do
47
- @file = 'foobar.txt'
48
- @file_with_path = Rake::Path.expand_with_root( @file, RakeBuilderHelper::SPEC_PATH )
49
- end
50
-
51
- it 'includes added files' do
52
- @project = cpp_task( :executable ) do |app|
53
- app.generated_files << @file_with_path
54
- end
55
- @project.generated_files.include?( @file_with_path ).should be_true
56
- end
57
-
58
- it 'expands the paths of added files' do
59
- @project = cpp_task( :executable ) do |app|
60
- app.generated_files << @file
61
- end
62
- @project.generated_files.include?( @file_with_path ).should be_true
63
- end
64
-
65
- end
@@ -1,35 +0,0 @@
1
- load File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe 'when using libraries' do
4
-
5
- include RakeBuilderHelper
6
-
7
- before( :each ) do
8
- Rake::Task.clear
9
- end
10
-
11
- after( :each ) do
12
- Rake::Task[ 'clean' ].execute
13
- end
14
-
15
- it 'builds if libraries are found' do
16
- lambda do
17
- @project = cpp_task( :executable ) do |builder|
18
- builder.library_dependencies = [ 'gcc' ] # As we're using GCC, libgcc.a should always be present
19
- end
20
- Rake::Task[ 'build' ].invoke
21
- end.should_not raise_error
22
- end
23
-
24
- it 'fails to build if libraries are missing' do
25
- @project = cpp_task( :executable ) do |builder|
26
- builder.library_dependencies = [ 'library_that_doesnt_exist' ]
27
- end
28
-
29
- expect do
30
- Rake::Task[ 'build' ].invoke
31
- end. to raise_error( Rake::Builder::BuildFailure )
32
- end
33
-
34
- end
35
-