paper_house 0.4.1 → 0.5.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/CONTRIBUTING.md +12 -0
- data/Gemfile +24 -25
- data/Guardfile +1 -7
- data/README.md +10 -10
- data/Rakefile +54 -65
- data/examples/executable/Rakefile +3 -1
- data/examples/executable_subdirs/Rakefile +8 -6
- data/examples/{c_extension → ruby_extension}/.gitignore +0 -0
- data/examples/ruby_extension/Rakefile +5 -0
- data/examples/ruby_extension/Rakefile.llvm +5 -0
- data/examples/{c_extension → ruby_extension}/hello.c +0 -0
- data/examples/shared_library/Rakefile +17 -11
- data/examples/shared_library/Rakefile.llvm +11 -5
- data/examples/shared_library_subdirs/Rakefile +16 -15
- data/examples/static_library/Rakefile +6 -5
- data/examples/static_library_subdirs/Rakefile +11 -9
- data/features/executable_task.feature +15 -27
- data/features/{c_extension_task.feature → ruby_extension_task.feature} +30 -48
- data/features/shared_library_task.feature +33 -60
- data/features/static_library_task.feature +18 -33
- data/features/step_definitions/paper_house_steps.rb +13 -4
- data/features/support/env.rb +8 -11
- data/features/support/hooks.rb +10 -5
- data/lib/paper_house/auto_depends.rb +24 -29
- data/lib/paper_house/build_task.rb +49 -75
- data/lib/paper_house/cc_options.rb +7 -17
- data/lib/paper_house/dependency.rb +12 -21
- data/lib/paper_house/executable_task.rb +12 -22
- data/lib/paper_house/library_task.rb +13 -15
- data/lib/paper_house/linker_options.rb +14 -24
- data/lib/paper_house/platform.rb +15 -24
- data/lib/paper_house/{c_extension_task.rb → ruby_extension_task.rb} +15 -35
- data/lib/paper_house/safe_popen.rb +4 -6
- data/lib/paper_house/shared_library_task.rb +14 -28
- data/lib/paper_house/static_library_task.rb +6 -15
- data/lib/paper_house/version.rb +2 -3
- data/lib/paper_house.rb +6 -7
- data/paper_house.gemspec +17 -19
- data/rake_simplecov_hook.rb +24 -0
- data/rubocop-todo.yml +6 -0
- data/spec/paper_house/executable_task_spec.rb +65 -20
- data/spec/paper_house/ruby_extension_task_spec.rb +129 -0
- data/spec/paper_house/shared_library_task_spec.rb +124 -49
- data/spec/paper_house/static_library_task_spec.rb +81 -27
- data/spec/paper_house/version_spec.rb +5 -5
- data/spec/spec_helper.rb +8 -13
- metadata +17 -15
- data/examples/c_extension/Rakefile +0 -3
- data/examples/c_extension/Rakefile.llvm +0 -5
- data/examples/shared_library/symlinks.rake +0 -7
- data/spec/paper_house/c_extension_task_spec.rb +0 -59
- data/spec/paper_house/cc_options_spec.rb +0 -59
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,79 +16,58 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
19
|
+
require 'paper_house/library_task'
|
20
|
+
require 'paper_house/linker_options'
|
21
|
+
require 'paper_house/platform'
|
18
22
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
#
|
24
|
+
# Rake for C projects.
|
25
|
+
#
|
24
26
|
module PaperHouse
|
25
27
|
#
|
26
28
|
# Compiles *.c files into a Ruby extension library.
|
27
29
|
#
|
28
|
-
class
|
30
|
+
class RubyExtensionTask < LibraryTask
|
29
31
|
include LinkerOptions
|
30
32
|
include Platform
|
31
33
|
|
32
|
-
|
33
34
|
# Name of target library.
|
34
35
|
attr_writer :library_name
|
35
36
|
|
36
|
-
|
37
37
|
# Name of target library file.
|
38
38
|
def target_file_name
|
39
|
-
library_name + SHARED_EXT
|
39
|
+
library_name.to_s + SHARED_EXT
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
42
|
# List of libraries to link.
|
44
43
|
def library_dependencies
|
45
|
-
|
46
|
-
( [ @library_dependencies ] << "ruby" ).flatten.compact
|
47
|
-
else
|
48
|
-
super
|
49
|
-
end
|
44
|
+
MAC ? ([@library_dependencies] << 'ruby').flatten.compact : super
|
50
45
|
end
|
51
46
|
|
52
|
-
|
53
|
-
############################################################################
|
54
47
|
private
|
55
|
-
############################################################################
|
56
|
-
|
57
48
|
|
58
49
|
def generate_target
|
59
|
-
sh
|
50
|
+
sh(([cc] + cc_options).join(' '))
|
60
51
|
end
|
61
52
|
|
62
|
-
|
63
53
|
def cc_options
|
64
|
-
[
|
54
|
+
[LDSHARED, o_option, objects, ldflags, libdir_option, l_options].flatten
|
65
55
|
end
|
66
56
|
|
67
|
-
|
68
57
|
def o_option
|
69
|
-
"-o #{
|
58
|
+
"-o #{target_path}"
|
70
59
|
end
|
71
60
|
|
72
|
-
|
73
61
|
def libdir_option
|
74
|
-
"-L#{
|
62
|
+
"-L#{RUBY_LIBDIR}"
|
75
63
|
end
|
76
64
|
|
77
|
-
|
78
65
|
def include_directories
|
79
|
-
(
|
66
|
+
(includes + auto_includes + RUBY_INCLUDES).uniq
|
80
67
|
end
|
81
68
|
end
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
# Alias for CExtensionTask
|
86
|
-
#
|
87
|
-
RubyLibraryTask = CExtensionTask
|
88
69
|
end
|
89
70
|
|
90
|
-
|
91
71
|
### Local variables:
|
92
72
|
### mode: Ruby
|
93
73
|
### coding: utf-8-unix
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,9 +16,7 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
18
|
-
|
19
|
-
require "popen4"
|
20
|
-
|
19
|
+
require 'popen4'
|
21
20
|
|
22
21
|
module PaperHouse
|
23
22
|
#
|
@@ -29,11 +28,11 @@ module PaperHouse
|
|
29
28
|
# Starts a new process and pass the subprocess IOs and pid to the
|
30
29
|
# block supplied.
|
31
30
|
#
|
32
|
-
def self.popen
|
31
|
+
def self.popen(command, &block)
|
33
32
|
status = nil
|
34
33
|
begin
|
35
34
|
GC.disable
|
36
|
-
status = POpen4.popen4(
|
35
|
+
status = POpen4.popen4(command, &block)
|
37
36
|
ensure
|
38
37
|
GC.enable
|
39
38
|
end
|
@@ -42,7 +41,6 @@ module PaperHouse
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
|
46
44
|
### Local variables:
|
47
45
|
### mode: Ruby
|
48
46
|
### coding: utf-8-unix
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,11 +16,9 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
18
|
-
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require "paper_house/platform"
|
22
|
-
|
19
|
+
require 'paper_house/library_task'
|
20
|
+
require 'paper_house/linker_options'
|
21
|
+
require 'paper_house/platform'
|
23
22
|
|
24
23
|
module PaperHouse
|
25
24
|
# Compiles *.c files into a shared library.
|
@@ -27,64 +26,51 @@ module PaperHouse
|
|
27
26
|
include LinkerOptions
|
28
27
|
include Platform
|
29
28
|
|
30
|
-
|
31
29
|
# Library version string.
|
32
30
|
attr_accessor :version
|
33
31
|
|
34
|
-
|
35
|
-
def initialize name, version = nil, &block
|
32
|
+
def initialize(name, version = nil, &block)
|
36
33
|
@version = version
|
37
34
|
super name, &block
|
38
35
|
end
|
39
36
|
|
40
|
-
|
41
37
|
# Real name of target library.
|
42
38
|
def target_file_name
|
43
|
-
fail
|
44
|
-
[
|
39
|
+
fail 'version option is a mandatory.' unless @version
|
40
|
+
[linker_name, @version].join '.'
|
45
41
|
end
|
46
|
-
|
47
|
-
|
42
|
+
alias_method :real_name, :target_file_name
|
48
43
|
|
49
44
|
# Name of library used by linkers.
|
50
45
|
def linker_name
|
51
|
-
library_name +
|
46
|
+
library_name + '.so'
|
52
47
|
end
|
53
48
|
|
54
|
-
|
55
49
|
# Soname of target library.
|
56
50
|
def soname
|
57
|
-
File.basename(
|
51
|
+
File.basename(target_file_name).sub(/\.\d+\.\d+\Z/, '')
|
58
52
|
end
|
59
53
|
|
60
|
-
|
61
|
-
############################################################################
|
62
54
|
private
|
63
|
-
############################################################################
|
64
|
-
|
65
55
|
|
66
56
|
def generate_target
|
67
|
-
sh
|
57
|
+
sh(([cc] + cc_options).join(' '))
|
68
58
|
end
|
69
59
|
|
70
|
-
|
71
60
|
def cc_options
|
72
|
-
[
|
61
|
+
['-shared', wl_option, o_option, objects, ldflags, l_options].flatten
|
73
62
|
end
|
74
63
|
|
75
|
-
|
76
64
|
def wl_option
|
77
|
-
"-Wl,#{
|
65
|
+
"-Wl,#{SONAME_OPTION},#{soname}"
|
78
66
|
end
|
79
67
|
|
80
|
-
|
81
68
|
def o_option
|
82
|
-
"-o #{
|
69
|
+
"-o #{target_path}"
|
83
70
|
end
|
84
71
|
end
|
85
72
|
end
|
86
73
|
|
87
|
-
|
88
74
|
### Local variables:
|
89
75
|
### mode: Ruby
|
90
76
|
### coding: utf-8-unix
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,23 +16,17 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
18
|
-
|
19
|
-
require "paper_house/library_task"
|
20
|
-
|
19
|
+
require 'paper_house/library_task'
|
21
20
|
|
22
21
|
module PaperHouse
|
23
22
|
# Compiles *.c files into a static library.
|
24
23
|
class StaticLibraryTask < LibraryTask
|
25
24
|
# Name of target library file.
|
26
25
|
def target_file_name
|
27
|
-
library_name +
|
26
|
+
library_name + '.a'
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
##########################################################################
|
32
29
|
private
|
33
|
-
##########################################################################
|
34
|
-
|
35
30
|
|
36
31
|
def generate_target
|
37
32
|
maybe_rm_target
|
@@ -39,25 +34,21 @@ module PaperHouse
|
|
39
34
|
ranlib
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
37
|
def maybe_rm_target
|
44
38
|
a_file = target_path
|
45
|
-
sh "rm #{
|
39
|
+
sh "rm #{a_file}" if FileTest.exist?(a_file)
|
46
40
|
end
|
47
41
|
|
48
|
-
|
49
42
|
def ar
|
50
|
-
sh "ar -cq #{
|
43
|
+
sh "ar -cq #{target_path} #{objects.to_s}"
|
51
44
|
end
|
52
45
|
|
53
|
-
|
54
46
|
def ranlib
|
55
|
-
sh "ranlib #{
|
47
|
+
sh "ranlib #{target_path}"
|
56
48
|
end
|
57
49
|
end
|
58
50
|
end
|
59
51
|
|
60
|
-
|
61
52
|
### Local variables:
|
62
53
|
### mode: Ruby
|
63
54
|
### coding: utf-8-unix
|
data/lib/paper_house/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,14 +16,12 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
18
|
-
|
19
19
|
# Base module.
|
20
20
|
module PaperHouse
|
21
21
|
# gem version.
|
22
|
-
VERSION =
|
22
|
+
VERSION = '0.5.0'
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
25
|
### Local variables:
|
27
26
|
### mode: Ruby
|
28
27
|
### coding: utf-8
|
data/lib/paper_house.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,13 +16,11 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
18
|
-
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require "paper_house/version"
|
24
|
-
|
19
|
+
require 'paper_house/executable_task'
|
20
|
+
require 'paper_house/ruby_extension_task'
|
21
|
+
require 'paper_house/shared_library_task'
|
22
|
+
require 'paper_house/static_library_task'
|
23
|
+
require 'paper_house/version'
|
25
24
|
|
26
25
|
### Local variables:
|
27
26
|
### mode: Ruby
|
data/paper_house.gemspec
CHANGED
@@ -1,32 +1,30 @@
|
|
1
|
-
lib = File.expand_path(
|
2
|
-
$LOAD_PATH.unshift(
|
3
|
-
require
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'paper_house/version'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
gem.name = "paper_house"
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'paper_house'
|
8
7
|
gem.version = PaperHouse::VERSION
|
9
|
-
gem.summary =
|
10
|
-
gem.description =
|
8
|
+
gem.summary = 'Rake for C projects.'
|
9
|
+
gem.description = 'Rake tasks for compiling C projects.'
|
11
10
|
|
12
|
-
gem.license =
|
11
|
+
gem.license = 'GPL3'
|
13
12
|
|
14
|
-
gem.authors = [
|
15
|
-
gem.email = [
|
16
|
-
gem.homepage =
|
13
|
+
gem.authors = ['Yasuhito Takamiya']
|
14
|
+
gem.email = ['yasuhito@gmail.com']
|
15
|
+
gem.homepage = 'http://github.com/trema/paper-house'
|
17
16
|
|
18
|
-
gem.files = `git ls-files`.split(
|
17
|
+
gem.files = `git ls-files`.split("\n")
|
19
18
|
|
20
|
-
gem.require_paths = [
|
19
|
+
gem.require_paths = ['lib']
|
21
20
|
|
22
|
-
gem.extra_rdoc_files = [
|
23
|
-
gem.test_files = `git ls-files -- {spec,features}/*`.split(
|
21
|
+
gem.extra_rdoc_files = ['README.md']
|
22
|
+
gem.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
24
23
|
|
25
|
-
gem.add_dependency
|
26
|
-
gem.add_dependency
|
24
|
+
gem.add_dependency 'POpen4', '~> 0.1.4'
|
25
|
+
gem.add_dependency 'rake', '~> 10.1.0'
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
28
|
### Local variables:
|
31
29
|
### mode: Ruby
|
32
30
|
### coding: utf-8-unix
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'simplecov'
|
4
|
+
|
5
|
+
def scenario_name
|
6
|
+
File.basename Dir.pwd
|
7
|
+
end
|
8
|
+
|
9
|
+
def id_file
|
10
|
+
File.join Dir.pwd, '..', '..', ".#{scenario_name}_id"
|
11
|
+
end
|
12
|
+
|
13
|
+
def new_scenario_id
|
14
|
+
new_id = 0
|
15
|
+
new_id = IO.read(id_file).chomp.to_i + 1 if File.exists?(id_file)
|
16
|
+
File.open(id_file, 'w') { | file | file.puts new_id }
|
17
|
+
new_id
|
18
|
+
end
|
19
|
+
|
20
|
+
SimpleCov.start do
|
21
|
+
root File.dirname(__FILE__)
|
22
|
+
command_name "#{scenario_name} scenario ##{new_scenario_id}"
|
23
|
+
use_merging true
|
24
|
+
end
|
data/rubocop-todo.yml
ADDED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,32 +16,76 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
19
|
+
require 'paper_house/executable_task'
|
18
20
|
|
19
|
-
|
21
|
+
describe Rake::Task do
|
22
|
+
before { Rake::Task.clear }
|
20
23
|
|
24
|
+
describe '.[]' do
|
25
|
+
subject { Rake::Task[task] }
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
27
|
+
context 'with :test' do
|
28
|
+
let(:task) { :test }
|
29
|
+
|
30
|
+
context 'when ExecutableTask named :test is defined' do
|
31
|
+
before { PaperHouse::ExecutableTask.new :test }
|
32
|
+
|
33
|
+
describe '#invoke' do
|
34
|
+
it do
|
35
|
+
expect do
|
36
|
+
subject.invoke
|
37
|
+
end.to raise_error('Cannot find sources (*.c).')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when ExecutableTask named :test is not defined' do
|
43
|
+
it { expect { subject }.to raise_error }
|
44
|
+
end
|
45
|
+
end
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
49
|
+
#
|
50
|
+
# PaperHouse::ExecutableTask spec.
|
51
|
+
#
|
52
|
+
module PaperHouse
|
53
|
+
describe ExecutableTask, '.new' do
|
54
|
+
context 'with name :test' do
|
55
|
+
subject { ExecutableTask.new :test }
|
56
|
+
|
57
|
+
its(:cc) { should eq 'gcc' }
|
58
|
+
its(:cflags) { should be_empty }
|
59
|
+
its(:executable_name) { should eq 'test' }
|
60
|
+
its(:includes) { should be_empty }
|
61
|
+
its(:ldflags) { should be_empty }
|
62
|
+
its(:library_dependencies) { should be_empty }
|
63
|
+
its(:name) { should eq 'test' }
|
64
|
+
its(:sources) { should eq '*.c' }
|
65
|
+
its(:target_directory) { should eq '.' }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with :test and block' do
|
69
|
+
subject do
|
70
|
+
ExecutableTask.new(:test) do | task |
|
71
|
+
task.executable_name = executable_name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context %{with #executable_name = 'new_name'} do
|
76
|
+
let(:executable_name) { 'new_name' }
|
77
|
+
|
78
|
+
its(:executable_name) { should eq 'new_name' }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with #executable_name = :new_name' do
|
82
|
+
let(:executable_name) { :new_name }
|
83
|
+
|
84
|
+
its(:executable_name) { should eq :new_name }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
44
89
|
|
45
90
|
### Local variables:
|
46
91
|
### mode: Ruby
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 NEC Corporation
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License, version 3, as
|
7
|
+
# published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License along
|
15
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
16
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'paper_house/ruby_extension_task'
|
20
|
+
|
21
|
+
describe Rake::Task do
|
22
|
+
before { Rake::Task.clear }
|
23
|
+
|
24
|
+
describe '.[]' do
|
25
|
+
subject { Rake::Task[task] }
|
26
|
+
|
27
|
+
context 'with :test' do
|
28
|
+
let(:task) { :test }
|
29
|
+
|
30
|
+
context 'when RubyExtensionTask named :test is defined' do
|
31
|
+
before { PaperHouse::RubyExtensionTask.new :test }
|
32
|
+
|
33
|
+
describe '#invoke' do
|
34
|
+
it do
|
35
|
+
expect do
|
36
|
+
subject.invoke
|
37
|
+
end.to raise_error('Cannot find sources (*.c).')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when RubyExtensionTask named :test is not defined' do
|
43
|
+
it { expect { subject }.to raise_error }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# PaperHouse::RubyExtensionTask spec.
|
51
|
+
#
|
52
|
+
module PaperHouse
|
53
|
+
describe RubyExtensionTask, '.new :test' do
|
54
|
+
before { Rake::Task.clear }
|
55
|
+
|
56
|
+
describe '.find_named' do
|
57
|
+
subject { RubyExtensionTask.find_named name }
|
58
|
+
|
59
|
+
context 'with :test' do
|
60
|
+
let(:name) { :test }
|
61
|
+
|
62
|
+
context 'when RubyExtensionTask named :test is defined' do
|
63
|
+
before { RubyExtensionTask.new :test }
|
64
|
+
|
65
|
+
it { expect(subject).to be_a RubyExtensionTask }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when RubyExtensionTask named :test is not defined' do
|
69
|
+
it { expect(subject).to be_nil }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context %{with 'test'} do
|
74
|
+
let(:name) { 'test' }
|
75
|
+
|
76
|
+
context %{when RubyExtensionTask named 'test' is defined} do
|
77
|
+
before { RubyExtensionTask.new :test }
|
78
|
+
|
79
|
+
it { expect(subject).to be_a RubyExtensionTask }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'with :no_such_task' do
|
84
|
+
let(:name) { :no_such_task }
|
85
|
+
|
86
|
+
it { expect(subject).to be_nil }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '.new' do
|
92
|
+
context 'with :test' do
|
93
|
+
subject { RubyExtensionTask.new :test }
|
94
|
+
|
95
|
+
its(:cc) { should eq 'gcc' }
|
96
|
+
its(:cflags) { should be_empty }
|
97
|
+
its(:includes) { should be_empty }
|
98
|
+
its(:name) { should eq 'test' }
|
99
|
+
its(:sources) { should eq '*.c' }
|
100
|
+
its(:target_directory) { should eq '.' }
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'with :test and block' do
|
104
|
+
subject do
|
105
|
+
RubyExtensionTask.new(:test) do | task |
|
106
|
+
task.library_name = library_name
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context %{with #library_name = 'new_name'} do
|
111
|
+
let(:library_name) { 'new_name' }
|
112
|
+
|
113
|
+
its(:library_name) { should eq 'new_name' }
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'with #library_name = :new_name' do
|
117
|
+
let(:library_name) { :new_name }
|
118
|
+
|
119
|
+
its(:library_name) { should eq :new_name }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
### Local variables:
|
126
|
+
### mode: Ruby
|
127
|
+
### coding: utf-8-unix
|
128
|
+
### indent-tabs-mode: nil
|
129
|
+
### End:
|