rake-builder 0.9.2 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +13 -0
- data/lib/rake/builder/version.rb +2 -2
- data/lib/rake/microsecond_task.rb +2 -4
- data/spec/unit/compiler_spec.rb +10 -17
- data/spec/unit/rake/builder/autoconf/version_spec.rb +44 -56
- data/spec/unit/rake/builder/configure_ac_spec.rb +5 -10
- data/spec/unit/rake/builder/install_spec.rb +67 -56
- data/spec/unit/rake/builder/local_config_spec.rb +23 -34
- data/spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb +22 -19
- data/spec/unit/rake/builder/presenters/makefile_am/builder_collection_presenter_spec.rb +8 -22
- data/spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb +14 -23
- data/spec/unit/rake/builder/task_definers/builder_collection_task_definer_spec.rb +19 -10
- data/spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb +77 -110
- data/spec/unit/rake/builder_spec.rb +76 -89
- data/spec/unit/rake/microsecond_task_spec.rb +35 -26
- data/spec/unit/rake/path_spec.rb +24 -11
- metadata +65 -81
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60c1b4473a51b3dea752db5616d35f75485f24d9
|
4
|
+
data.tar.gz: f5028bf5de9235c3c68a4f0d270160d5e68fad9d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e2c8faae223acb383fba9cc1727f76eb7c7b0bec433cbad9ab0d1caf2c1a117b0c5c6f810b8ff1c8acd1506b97da746bfd58cc2b6ec1e79805b985a143150ac
|
7
|
+
data.tar.gz: 6ffbfbeadee2ba86245542b14e13518dc364183b9cb7b8aa8d4f25d4b15a1daaeba4e22163143964be56902f84c4396033b072570883b36a57e99b94376a1379
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/joeyates/rake-builder.png)][Continuous Integration]
|
2
|
+
|
1
3
|
rake-builder
|
2
4
|
============
|
3
5
|
|
@@ -10,6 +12,7 @@ rake-builder
|
|
10
12
|
[Source code]: http://github.com/joeyates/rake-builder "Source code at GitHub"
|
11
13
|
[Documentation]: http://rdoc.info/projects/joeyates/rake-builder "Documentation at Rubydoc.info"
|
12
14
|
[Rubygem]: http://rubygems.org/gems/rake-builder "Ruby gem at rubygems.org"
|
15
|
+
[Continuous Integration]: http://travis-ci.org/joeyates/rake-builder "Build status by Travis-CI"
|
13
16
|
|
14
17
|
Hello World! Example
|
15
18
|
====================
|
@@ -122,6 +125,16 @@ If you install a static library, your headers will also be installed.
|
|
122
125
|
Ensure that you use file globs, e.g. './include/**/*.h',
|
123
126
|
as these will ensure that your headers are installed in the correct subdirectories.
|
124
127
|
|
128
|
+
Problem Resolution
|
129
|
+
------------------
|
130
|
+
|
131
|
+
If you project does not build, use Rake's `--trace` option to get more
|
132
|
+
information about what's going wrong:
|
133
|
+
|
134
|
+
```shell
|
135
|
+
$ rake --trace
|
136
|
+
```
|
137
|
+
|
125
138
|
Project
|
126
139
|
=======
|
127
140
|
|
data/lib/rake/builder/version.rb
CHANGED
@@ -28,7 +28,7 @@ module Rake
|
|
28
28
|
|
29
29
|
def needed?
|
30
30
|
return true if not File.exist?(self.name)
|
31
|
-
@timestamp
|
31
|
+
@timestamp ||= File.stat(self.name).mtime
|
32
32
|
prerequisites_needed?
|
33
33
|
end
|
34
34
|
|
@@ -52,9 +52,7 @@ module Rake
|
|
52
52
|
|
53
53
|
def needed?
|
54
54
|
return true if not File.directory?(self.path)
|
55
|
-
|
56
|
-
@timestamp = File.stat(self.path).mtime
|
57
|
-
end
|
55
|
+
@timestamp ||= File.stat(self.path).mtime
|
58
56
|
prerequisites_needed?
|
59
57
|
end
|
60
58
|
|
data/spec/unit/compiler_spec.rb
CHANGED
@@ -10,18 +10,11 @@ describe Compiler::Base do
|
|
10
10
|
subject { Compiler::Base.new }
|
11
11
|
|
12
12
|
context '#include_paths' do
|
13
|
-
|
14
|
-
File.stub(:exist?).
|
15
|
-
with('/opt/local/include/foo/bar.h').
|
16
|
-
and_return(false)
|
17
|
-
end
|
13
|
+
let(:exists) { false }
|
18
14
|
|
19
|
-
|
20
|
-
File.
|
21
|
-
with('/opt/local/include/foo/bar.h')
|
22
|
-
and_return(true)
|
23
|
-
|
24
|
-
subject.include_paths(['foo/bar.h'])
|
15
|
+
before do
|
16
|
+
allow(File).to receive(:exist).
|
17
|
+
with('/opt/local/include/foo/bar.h') { exists }
|
25
18
|
end
|
26
19
|
|
27
20
|
it 'throws an error is the headers are not found' do
|
@@ -88,12 +81,12 @@ COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=x86-64'
|
|
88
81
|
EOT
|
89
82
|
end
|
90
83
|
|
91
|
-
before { subject.
|
84
|
+
before { allow(subject).to receive(:`).with(/gcc/) { gcc_output } }
|
92
85
|
|
93
86
|
it 'calls gcc' do
|
94
|
-
subject.should_receive(:`).with(/gcc/).and_return(gcc_output)
|
95
|
-
|
96
87
|
subject.default_include_paths('c++')
|
88
|
+
|
89
|
+
expect(subject).to have_received(:`).with(/gcc/)
|
97
90
|
end
|
98
91
|
|
99
92
|
it 'parses gcc output' do
|
@@ -111,12 +104,12 @@ makedepend: warning: main.cpp (reading main.h, line 4): cannot find include fil
|
|
111
104
|
EOT
|
112
105
|
end
|
113
106
|
|
114
|
-
before { subject.
|
107
|
+
before { allow(subject).to receive(:`).with(/makedepend/) { makedepend_output } }
|
115
108
|
|
116
109
|
it 'calls makedepend' do
|
117
|
-
subject.should_receive(:`).with(/makedepend/).and_return(makedepend_output)
|
118
|
-
|
119
110
|
subject.missing_headers(['/foo'], ['bar.cpp'])
|
111
|
+
|
112
|
+
expect(subject).to have_received(:`).with(/makedepend/)
|
120
113
|
end
|
121
114
|
|
122
115
|
it 'returns missing headers' do
|
@@ -1,116 +1,104 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Rake::Builder::Autoconf::Version do
|
4
|
+
let(:exists) { true }
|
5
|
+
let(:file_content) { '1.2.3' }
|
4
6
|
before do
|
5
|
-
File.
|
6
|
-
File.
|
7
|
+
allow(File).to receive(:exist?).with('VERSION') { exists }
|
8
|
+
allow(File).to receive(:read).with('VERSION') { file_content }
|
7
9
|
end
|
10
|
+
let(:params) { [] }
|
11
|
+
let(:parameter_version) { '4.5.6' }
|
12
|
+
|
13
|
+
subject { described_class.new(*params) }
|
8
14
|
|
9
15
|
context '.new' do
|
10
16
|
context 'with parameter' do
|
11
17
|
it 'fails if the version parameter is not nn.nn.nn' do
|
12
18
|
expect {
|
13
|
-
|
19
|
+
described_class.new('hello')
|
14
20
|
}.to raise_error(RuntimeError, /badly formatted/)
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
18
24
|
context 'without parameter' do
|
19
25
|
it 'succeeds' do
|
20
|
-
|
26
|
+
described_class.new
|
21
27
|
end
|
22
28
|
end
|
23
29
|
|
24
|
-
context '
|
25
|
-
|
26
|
-
File.should_receive(:exist?).
|
27
|
-
with('VERSION').
|
28
|
-
and_return(false)
|
29
|
-
|
30
|
-
Rake::Builder::Autoconf::Version.new
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'loads the file' do
|
34
|
-
File.should_receive(:exist?).
|
35
|
-
with('VERSION').
|
36
|
-
and_return(true)
|
37
|
-
File.should_receive(:read).
|
38
|
-
with('VERSION').
|
39
|
-
and_return('1.2.3')
|
40
|
-
|
41
|
-
Rake::Builder::Autoconf::Version.new
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'fails if the version is badly formed' do
|
45
|
-
File.should_receive(:read).
|
46
|
-
with('VERSION').
|
47
|
-
and_return('bad')
|
30
|
+
context 'if the version is badly formed' do
|
31
|
+
let(:file_content) { 'bad' }
|
48
32
|
|
33
|
+
it 'fails' do
|
49
34
|
expect {
|
50
|
-
|
35
|
+
described_class.new
|
51
36
|
}.to raise_error(RuntimeError, /file.*?version.*?badly formatted/)
|
52
37
|
end
|
53
38
|
end
|
54
39
|
end
|
55
40
|
|
56
41
|
context '#decide' do
|
57
|
-
let(:
|
58
|
-
let(:without_parameter) { Rake::Builder::Autoconf::Version.new }
|
42
|
+
let(:file) { double(File, write: nil) }
|
59
43
|
|
60
|
-
before
|
44
|
+
before do
|
45
|
+
allow(File).to receive(:open).with('VERSION', 'w').and_yield(file)
|
46
|
+
end
|
61
47
|
|
62
|
-
context 'file
|
63
|
-
|
48
|
+
context 'disk file is absent' do
|
49
|
+
let(:exists) { false }
|
64
50
|
|
65
51
|
context 'parameter is nil' do
|
66
52
|
it 'raises an error' do
|
67
53
|
expect {
|
68
|
-
|
54
|
+
subject.decide
|
69
55
|
}.to raise_error(RuntimeError, /Please do one of the following/)
|
70
56
|
end
|
71
57
|
end
|
72
58
|
|
73
59
|
context 'parameter not nil' do
|
60
|
+
let(:params) { [parameter_version] }
|
61
|
+
|
74
62
|
it 'saves the version' do
|
75
|
-
|
63
|
+
subject.decide
|
76
64
|
|
77
|
-
|
65
|
+
expect(file).to have_received(:write).with(parameter_version + "\n")
|
78
66
|
end
|
79
67
|
|
80
68
|
it 'returns the parameter version' do
|
81
|
-
expect(
|
69
|
+
expect(subject.decide).to eq(parameter_version)
|
82
70
|
end
|
83
71
|
end
|
84
72
|
end
|
85
73
|
|
86
|
-
context 'file
|
87
|
-
|
88
|
-
File.stub(:exist? => true)
|
89
|
-
File.stub(:read).with('VERSION').and_return("6.6.6\n")
|
90
|
-
end
|
74
|
+
context 'disk file exists' do
|
75
|
+
let(:exists) { true }
|
91
76
|
|
92
|
-
context '
|
93
|
-
it 'returns the file version' do
|
94
|
-
expect(
|
77
|
+
context 'without parameters' do
|
78
|
+
it 'returns the file version from disk' do
|
79
|
+
expect(subject.decide).to eq(file_content)
|
95
80
|
end
|
96
81
|
end
|
97
82
|
|
98
83
|
context 'parameter not nil' do
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
84
|
+
context 'if the two versions differ'do
|
85
|
+
let(:params) { [parameter_version] }
|
86
|
+
|
87
|
+
it 'fails' do
|
88
|
+
expect {
|
89
|
+
subject.decide
|
90
|
+
}.to raise_error(RuntimeError, /parameter.*?is different to.*?VERSION/)
|
91
|
+
end
|
105
92
|
end
|
106
93
|
|
107
|
-
|
108
|
-
|
94
|
+
context 'if the two versions are the same' do
|
95
|
+
let(:params) { [file_content] }
|
109
96
|
|
110
|
-
|
97
|
+
it 'returns the version' do
|
98
|
+
expect(subject.decide).to eq(file_content)
|
99
|
+
end
|
111
100
|
end
|
112
101
|
end
|
113
102
|
end
|
114
103
|
end
|
115
104
|
end
|
116
|
-
|
@@ -32,21 +32,16 @@ describe Rake::Builder::ConfigureAc do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context '#save' do
|
35
|
-
|
36
|
-
File.should_receive(:open).with('configure.ac', 'w')
|
35
|
+
let(:file) { double(File, write: nil) }
|
37
36
|
|
38
|
-
|
37
|
+
before do
|
38
|
+
allow(File).to receive(:open).with('configure.ac', 'w').and_yield(file)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'saves the content' do
|
42
|
-
file = stub('File')
|
43
|
-
File.stub(:open).with('configure.ac', 'w') do |&block|
|
44
|
-
block.call file
|
45
|
-
end
|
46
|
-
|
47
|
-
file.should_receive(:write).with(/AC_PREREQ\(2\.61\)/)
|
48
|
-
|
49
42
|
subject.save
|
43
|
+
|
44
|
+
expect(file).to have_received(:write).with(/AC_PREREQ\(2\.61\)/)
|
50
45
|
end
|
51
46
|
end
|
52
47
|
end
|
@@ -2,99 +2,110 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Rake::Builder::Installer do
|
4
4
|
let(:destination_path) { '/destination/path' }
|
5
|
-
let(:destination_pathname) { '
|
5
|
+
let(:destination_pathname) { File.join(destination_path, 'install') }
|
6
|
+
let(:destination_path_writable) { true }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(File).to receive(:writable?).with(destination_path) { destination_path_writable }
|
10
|
+
end
|
6
11
|
|
7
12
|
context '#install' do
|
8
13
|
let(:file_to_install) { '/file/to/install' }
|
14
|
+
let(:file_to_install_exists) { true }
|
15
|
+
let(:destination_path_exists) { true }
|
16
|
+
let(:destination_path_directory) { true }
|
17
|
+
let(:destination_pathname_file) { true }
|
18
|
+
let(:destination_pathname_writable) { true }
|
9
19
|
|
10
20
|
before do
|
11
|
-
File.
|
12
|
-
File.
|
13
|
-
File.
|
14
|
-
File.
|
15
|
-
File.
|
16
|
-
|
17
|
-
FileUtils.stub(:copy_file).with(file_to_install, destination_path)
|
21
|
+
allow(File).to receive(:exist?).with(file_to_install) { file_to_install_exists }
|
22
|
+
allow(File).to receive(:exist?).with(destination_path) { destination_path_exists }
|
23
|
+
allow(File).to receive(:directory?).with(destination_path) { destination_path_directory }
|
24
|
+
allow(File).to receive(:file?).with(destination_pathname) { destination_pathname_file }
|
25
|
+
allow(File).to receive(:writable?).with(destination_pathname) { destination_pathname_writable }
|
26
|
+
allow(FileUtils).to receive(:copy_file).with(file_to_install, destination_path)
|
18
27
|
end
|
19
28
|
|
20
|
-
|
21
|
-
|
29
|
+
context 'if the source does not exist' do
|
30
|
+
let(:file_to_install_exists) { false }
|
22
31
|
|
23
|
-
|
32
|
+
it 'fails' do
|
33
|
+
expect {
|
34
|
+
subject.install file_to_install, destination_path
|
35
|
+
}.to raise_error(RuntimeError, /does not exist/)
|
36
|
+
end
|
24
37
|
end
|
25
38
|
|
26
|
-
|
27
|
-
|
39
|
+
context 'if the destination directory does not exist' do
|
40
|
+
let(:destination_path_exists) { false }
|
28
41
|
|
29
|
-
|
30
|
-
|
31
|
-
|
42
|
+
it 'fails' do
|
43
|
+
expect {
|
44
|
+
subject.install file_to_install, destination_path
|
45
|
+
}.to raise_error(RuntimeError, /does not exist/)
|
46
|
+
end
|
32
47
|
end
|
33
48
|
|
34
|
-
|
35
|
-
|
49
|
+
context 'if the destination is not a directory' do
|
50
|
+
let(:destination_path_directory) { false }
|
36
51
|
|
37
|
-
|
38
|
-
|
39
|
-
|
52
|
+
it 'fails' do
|
53
|
+
expect {
|
54
|
+
subject.install file_to_install, destination_path
|
55
|
+
}.to raise_error(RuntimeError, /is not a directory/)
|
56
|
+
end
|
40
57
|
end
|
41
58
|
|
42
|
-
|
43
|
-
|
59
|
+
context 'if it cannot overwrite an existing destination file' do
|
60
|
+
let(:destination_pathname_file) { true }
|
61
|
+
let(:destination_pathname_writable) { false }
|
44
62
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
it 'check it can overwrite an existing destination file' do
|
51
|
-
File.stub(:file?).with(destination_pathname).and_return(true)
|
52
|
-
File.stub(:writable?).with(destination_pathname).and_return(false)
|
53
|
-
|
54
|
-
expect {
|
55
|
-
subject.install file_to_install, destination_path
|
56
|
-
}.to raise_error(RuntimeError, /cannot be overwritten/)
|
63
|
+
it 'fails' do
|
64
|
+
expect {
|
65
|
+
subject.install file_to_install, destination_path
|
66
|
+
}.to raise_error(RuntimeError, /cannot be overwritten/)
|
67
|
+
end
|
57
68
|
end
|
58
69
|
|
59
70
|
it 'copies the file to the destination' do
|
60
|
-
FileUtils.should_receive(:copy_file).with(file_to_install, destination_path)
|
61
|
-
|
62
71
|
subject.install file_to_install, destination_path
|
72
|
+
|
73
|
+
expect(FileUtils).to have_received(:copy_file).with(file_to_install, destination_path)
|
63
74
|
end
|
64
75
|
end
|
65
76
|
|
66
77
|
context '#uninstall' do
|
78
|
+
let(:destination_pathname_exist) { true }
|
79
|
+
|
67
80
|
before do
|
68
|
-
File.
|
69
|
-
File.
|
70
|
-
File.stub(:unlink).with(destination_pathname)
|
81
|
+
allow(File).to receive(:exist?).with(destination_pathname) { destination_pathname_exist }
|
82
|
+
allow(File).to receive(:unlink).with(destination_pathname)
|
71
83
|
end
|
72
84
|
|
73
|
-
|
74
|
-
|
85
|
+
context 'if the file does not exist' do
|
86
|
+
let(:destination_pathname_exist) { false }
|
75
87
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
it 'does nothing if the file does not exist' do
|
80
|
-
File.should_receive(:exist?).with(destination_pathname).and_return(false)
|
81
|
-
File.should_not_receive(:unlink)
|
88
|
+
it 'does nothing' do
|
89
|
+
subject.uninstall destination_pathname
|
82
90
|
|
83
|
-
|
91
|
+
expect(File).to_not have_received(:unlink)
|
92
|
+
end
|
84
93
|
end
|
85
94
|
|
86
|
-
|
87
|
-
|
95
|
+
context 'if the directory is not writable' do
|
96
|
+
let(:destination_path_writable) { false }
|
88
97
|
|
89
|
-
|
90
|
-
|
91
|
-
|
98
|
+
it 'fails' do
|
99
|
+
expect {
|
100
|
+
subject.uninstall destination_pathname
|
101
|
+
}.to raise_error(RuntimeError, /directory.*?writable/)
|
102
|
+
end
|
92
103
|
end
|
93
104
|
|
94
105
|
it 'deletes the file' do
|
95
|
-
File.should_receive(:unlink).with(destination_pathname)
|
96
|
-
|
97
106
|
subject.uninstall destination_pathname
|
107
|
+
|
108
|
+
expect(File).to have_received(:unlink).with(destination_pathname)
|
98
109
|
end
|
99
110
|
end
|
100
111
|
end
|