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.
- data/Rakefile +8 -5
- data/examples/05_tests/Rakefile +3 -3
- data/examples/05_tests/include/units.h +2 -2
- data/lib/compiler.rb +25 -30
- data/lib/rake/builder.rb +135 -136
- data/lib/rake/builder/installer.rb +37 -0
- data/lib/rake/{local_config.rb → builder/local_config.rb} +13 -14
- data/lib/rake/builder/logger/formatter.rb +7 -1
- data/lib/rake/builder/presenters/makefile/builder_presenter.rb +66 -33
- data/lib/rake/builder/presenters/makefile_am/builder_presenter.rb +4 -4
- data/lib/rake/builder/qt_builder.rb +3 -8
- data/lib/rake/builder/task_definers/builder_task_definer.rb +1 -4
- data/lib/rake/builder/version.rb +1 -1
- data/lib/rake/{microsecond.rb → microsecond_task.rb} +22 -27
- data/lib/rake/once_task.rb +2 -7
- data/lib/rake/path.rb +1 -6
- data/spec/gather_rspec_coverage.rb +2 -0
- data/spec/spec_helper.rb +13 -98
- data/spec/unit/compiler_spec.rb +129 -0
- data/spec/unit/rake/builder/autoconf/version_spec.rb +62 -5
- data/spec/unit/rake/builder/configure_ac_spec.rb +53 -0
- data/spec/unit/rake/builder/install_spec.rb +101 -0
- data/spec/unit/rake/builder/local_config_spec.rb +53 -0
- data/spec/unit/rake/builder/logger/formatter_spec.rb +20 -0
- data/spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb +163 -0
- data/spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb +4 -2
- data/spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb +6 -0
- data/spec/unit/rake/builder_spec.rb +391 -16
- data/spec/unit/rake/microsecond_task_spec.rb +63 -0
- metadata +39 -55
- data/examples/01_hello_world_cpp/vendor/bundle/gems/coderay-1.0.8/Rakefile +0 -35
- data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/Rakefile +0 -412
- data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/fbuffer/fbuffer.h +0 -185
- data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.c +0 -1427
- data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/generator/generator.h +0 -149
- data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.c +0 -2204
- data/examples/01_hello_world_cpp/vendor/bundle/gems/json-1.7.6/ext/json/ext/parser/parser.h +0 -77
- data/examples/01_hello_world_cpp/vendor/bundle/gems/method_source-0.8.1/Rakefile +0 -79
- data/examples/01_hello_world_cpp/vendor/bundle/gems/pry-0.9.11.3/Rakefile +0 -136
- data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/Rakefile +0 -374
- data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/a.c +0 -6
- data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/b.c +0 -6
- data/examples/01_hello_world_cpp/vendor/bundle/gems/rake-10.0.3/doc/example/main.c +0 -11
- data/examples/01_hello_world_cpp/vendor/bundle/gems/slop-3.4.3/Rakefile +0 -29
- data/lib/rake/file_task_alias.rb +0 -24
- data/spec/c_project/main.c +0 -12
- data/spec/c_project/main.h +0 -6
- data/spec/c_project_spec.rb +0 -41
- data/spec/cpp_project/main.cpp +0 -12
- data/spec/cpp_project/main.h +0 -8
- data/spec/cpp_project_spec.rb +0 -203
- data/spec/generated_files_spec.rb +0 -65
- data/spec/libraries_spec.rb +0 -35
- data/spec/local_config_spec.rb +0 -95
- data/spec/logger_spec.rb +0 -25
- data/spec/microsecond_task_spec.rb +0 -32
- data/spec/objective_c_project/main.h +0 -1
- data/spec/objective_c_project/main.m +0 -18
- data/spec/objective_c_project_spec.rb +0 -72
- data/spec/paths_spec.rb +0 -19
- data/spec/project_spec.rb +0 -20
- data/spec/target_spec.rb +0 -48
data/spec/local_config_spec.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
load File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
LOCAL_CONFIG_SPEC_PATH = File.expand_path( File.dirname(__FILE__) )
|
4
|
-
|
5
|
-
describe 'local config files' do
|
6
|
-
|
7
|
-
include RakeBuilderHelper
|
8
|
-
|
9
|
-
before( :each ) do
|
10
|
-
@local_config_file = Rake::Path.expand_with_root( '.rake-builder', LOCAL_CONFIG_SPEC_PATH )
|
11
|
-
@expected_path = "/some/special/path"
|
12
|
-
@config = {:rake_builder=>{:config_file=>{:version=>"1.0"}}, :include_paths=>[ @expected_path ]}
|
13
|
-
end
|
14
|
-
|
15
|
-
after( :each ) do
|
16
|
-
`rm -f '#{ @local_config_file }'`
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'works if the\'s no config file' do
|
20
|
-
lambda do
|
21
|
-
@builder = cpp_task( :executable )
|
22
|
-
end.should_not raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'loads config files' do
|
26
|
-
save_config
|
27
|
-
config = Rake::LocalConfig.new( @local_config_file )
|
28
|
-
config.load
|
29
|
-
|
30
|
-
config.include_paths. should include( @expected_path )
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'fails if the file version is incorrect' do
|
34
|
-
@config[ :rake_builder ][ :config_file ].delete( :version )
|
35
|
-
save_config
|
36
|
-
lambda do
|
37
|
-
config = Rake::LocalConfig.new( @local_config_file )
|
38
|
-
config.load
|
39
|
-
end.should raise_error(Rake::Builder::Error, 'Config file version incorrect')
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'dependencies' do
|
43
|
-
|
44
|
-
before( :each ) do
|
45
|
-
Rake::Task.clear
|
46
|
-
@project = cpp_task( :executable )
|
47
|
-
Rake::Task[ 'clean' ].execute
|
48
|
-
`rm -f #{ @project.local_config }`
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when local_config is invoked' do
|
52
|
-
|
53
|
-
it 'should no longer be needed' do
|
54
|
-
exist?( @project.local_config ).should be_false
|
55
|
-
Rake::Task[ @project.local_config ].needed?.should be_true
|
56
|
-
|
57
|
-
Rake::Task[ @project.local_config ].invoke
|
58
|
-
|
59
|
-
exist?( @project.local_config ).should be_true
|
60
|
-
Rake::Task[ @project.local_config ].needed?.should be_false
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when load_local_config is invoked' do
|
66
|
-
|
67
|
-
it 'should no longer be needed' do
|
68
|
-
Rake::Task[ 'load_local_config' ].needed?.should be_true
|
69
|
-
|
70
|
-
Rake::Task[ 'load_local_config' ].invoke
|
71
|
-
|
72
|
-
Rake::Task[ 'load_local_config' ].needed?.should be_false
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'local_config should no longer be needed' do
|
76
|
-
Rake::Task[ @project.local_config ].needed?.should be_true
|
77
|
-
|
78
|
-
Rake::Task[ 'load_local_config' ].invoke
|
79
|
-
|
80
|
-
Rake::Task[ @project.local_config ].needed?.should be_false
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def save_config( config = @config, filename = @local_config_file )
|
90
|
-
File.open( filename, 'w' ) do | file |
|
91
|
-
file.write config.to_yaml
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
data/spec/logger_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
load File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'the logger' do
|
4
|
-
|
5
|
-
it 'can be read' do
|
6
|
-
builder = Rake::Builder.new do |builder|
|
7
|
-
builder.source_search_paths = [ 'cpp_project' ]
|
8
|
-
end
|
9
|
-
builder.logger.should_not be_nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'can be set' do
|
13
|
-
builder = Rake::Builder.new do |builder|
|
14
|
-
builder.source_search_paths = [ 'cpp_project' ]
|
15
|
-
end
|
16
|
-
lambda do
|
17
|
-
builder.logger = Logger.new( STDOUT )
|
18
|
-
end.should_not raise_exception
|
19
|
-
end
|
20
|
-
|
21
|
-
# TODO: check the output
|
22
|
-
# builder.logger.level = Logger::DEBUG
|
23
|
-
|
24
|
-
end
|
25
|
-
|
@@ -1,32 +0,0 @@
|
|
1
|
-
load File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
describe Rake::Microsecond::DirectoryTask do
|
5
|
-
|
6
|
-
include RakeBuilderHelper
|
7
|
-
include FileUtils
|
8
|
-
|
9
|
-
before :all do
|
10
|
-
@path = File.join(File.dirname(__FILE__), 'microsecond_directory')
|
11
|
-
end
|
12
|
-
|
13
|
-
before :each do
|
14
|
-
rm_rf @path, :verbose => false
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should memorize the directory creation time including fractional seconds' do
|
18
|
-
File.directory?( @path ).should be_false
|
19
|
-
|
20
|
-
t = Rake::Microsecond::DirectoryTask.define_task( @path )
|
21
|
-
|
22
|
-
isolating_seconds do
|
23
|
-
sleep 0.01
|
24
|
-
t.invoke
|
25
|
-
end
|
26
|
-
|
27
|
-
File.directory?( @path ).should be_true
|
28
|
-
t.timestamp.usec.should_not == 0
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
#import <Foundation/Foundation.h>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#import "main.h"
|
2
|
-
|
3
|
-
int main(void)
|
4
|
-
{
|
5
|
-
NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ];
|
6
|
-
NSString *text = @"Written by Objective-C";
|
7
|
-
NSString *filename = @"./rake-builder-testfile.txt";
|
8
|
-
NSData *data = [ text dataUsingEncoding: NSASCIIStringEncoding ];
|
9
|
-
NSFileManager *filemanager = [NSFileManager defaultManager];
|
10
|
-
BOOL written = [ filemanager createFileAtPath: filename contents: data attributes: nil ];
|
11
|
-
if( ! written ) {
|
12
|
-
NSLog( @"Failed to write to file" );
|
13
|
-
}
|
14
|
-
|
15
|
-
[ pool release ];
|
16
|
-
|
17
|
-
return 0;
|
18
|
-
}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
load File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
# Only run on OS X
|
4
|
-
if RUBY_PLATFORM['darwin']
|
5
|
-
|
6
|
-
describe 'when building an Objective-C executable' do
|
7
|
-
|
8
|
-
include RakeBuilderHelper
|
9
|
-
|
10
|
-
before( :all ) do
|
11
|
-
@test_output_file = Rake::Path.expand_with_root(
|
12
|
-
'rake-builder-testfile.txt', RakeBuilderHelper::SPEC_PATH )
|
13
|
-
@expected_target = Rake::Path.expand_with_root(
|
14
|
-
RakeBuilderHelper::TARGET[ :executable ],
|
15
|
-
RakeBuilderHelper::SPEC_PATH )
|
16
|
-
end
|
17
|
-
|
18
|
-
before( :each ) do
|
19
|
-
Rake::Task.clear
|
20
|
-
@project = objective_c_task( :executable )
|
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
|
-
end
|
29
|
-
|
30
|
-
it 'knows the target' do
|
31
|
-
@project.target.should == @expected_target
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'builds the target in the objects directory' do
|
35
|
-
File.dirname( @project.target ).should == @project.objects_path
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'knows the project type' do
|
39
|
-
@project.target_type.should == :executable
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'creates the correct tasks' do
|
43
|
-
expected_tasks = expected_tasks( [ @project.target ] )
|
44
|
-
missing_tasks = expected_tasks - task_names
|
45
|
-
missing_tasks.should == []
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'builds the program with \'build\'' do
|
49
|
-
Rake::Task[ 'build' ].invoke
|
50
|
-
exist?( @project.target ).should be_true
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'has a \'run\' task' do
|
54
|
-
Rake::Task[ 'run' ].should_not be_nil
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'builds the program with \'run\'' do
|
58
|
-
Rake::Task[ 'run' ].invoke
|
59
|
-
exist?( @project.target ).should be_true
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'runs the program with \'run\'' do
|
63
|
-
lambda do
|
64
|
-
Rake::Task[ 'run' ].invoke
|
65
|
-
end.should_not raise_exception
|
66
|
-
exist?( @test_output_file ).should be_true
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
data/spec/paths_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
load File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
PATHS_SPEC_PATH = File.expand_path( File.dirname(__FILE__) )
|
4
|
-
|
5
|
-
describe 'when creating tasks' do
|
6
|
-
|
7
|
-
before( :each ) do
|
8
|
-
Rake::Task.clear
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'remembers the Rakefile path' do
|
12
|
-
builder = Rake::Builder.new do |builder|
|
13
|
-
builder.source_search_paths = [ 'cpp_project' ]
|
14
|
-
end
|
15
|
-
builder.rakefile_path.should == PATHS_SPEC_PATH
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
data/spec/project_spec.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rake::Builder do
|
4
|
-
include RakeBuilderHelper
|
5
|
-
|
6
|
-
def builder(type)
|
7
|
-
c_task(type)
|
8
|
-
end
|
9
|
-
|
10
|
-
[
|
11
|
-
[:static_library, true],
|
12
|
-
[:shared_library, true],
|
13
|
-
[:executable, false]
|
14
|
-
].each do |type, is_library|
|
15
|
-
example type do
|
16
|
-
expect(builder(type).is_library?).to eq(is_library)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
data/spec/target_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
load File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'when creating tasks' do
|
4
|
-
|
5
|
-
before( :each ) do
|
6
|
-
Rake::Task.clear
|
7
|
-
end
|
8
|
-
|
9
|
-
after( :each ) do
|
10
|
-
`rm -f spec/.rake-builder.foo`
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'raises an error when the target is an empty string' do
|
14
|
-
lambda do
|
15
|
-
Rake::Builder.new do |builder|
|
16
|
-
builder.target = ''
|
17
|
-
builder.source_search_paths = [ 'cpp_project' ]
|
18
|
-
end
|
19
|
-
end.should raise_error(Rake::Builder::Error, 'The target name cannot be an empty string')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'raises an error when the target is set to nil' do
|
23
|
-
lambda do
|
24
|
-
Rake::Builder.new do |builder|
|
25
|
-
builder.target = nil
|
26
|
-
builder.source_search_paths = [ 'cpp_project' ]
|
27
|
-
end
|
28
|
-
end.should raise_error(Rake::Builder::Error, 'The target name cannot be nil')
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'sets the target to \'a.out\' if it is not set' do
|
32
|
-
builder = Rake::Builder.new do |builder|
|
33
|
-
builder.source_search_paths = [ 'cpp_project' ]
|
34
|
-
end
|
35
|
-
builder.target.should == Rake::Path.expand_with_root( 'a.out', RakeBuilderHelper::SPEC_PATH )
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'raises an error when the supplied target_type is unknown' do
|
39
|
-
lambda do
|
40
|
-
project = Rake::Builder.new do |builder|
|
41
|
-
builder.target = 'my_prog'
|
42
|
-
builder.target_type = :foo
|
43
|
-
builder.source_search_paths = [ 'cpp_project' ]
|
44
|
-
end
|
45
|
-
end.should raise_error
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|