paper_house 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +35 -0
- data/Guardfile +28 -0
- data/README.md +116 -0
- data/Rakefile +139 -0
- data/cucumber.yml +3 -0
- data/examples/c_extension/.gitignore +5 -0
- data/examples/c_extension/Rakefile +3 -0
- data/examples/c_extension/Rakefile.llvm +5 -0
- data/examples/c_extension/hello.c +6 -0
- data/examples/executable/.gitignore +4 -0
- data/examples/executable/Rakefile +3 -0
- data/examples/executable/Rakefile.llvm +5 -0
- data/examples/executable/hello.c +7 -0
- data/examples/executable_subdirs/.gitignore +4 -0
- data/examples/executable_subdirs/Rakefile +9 -0
- data/examples/executable_subdirs/includes/hello.h +1 -0
- data/examples/executable_subdirs/sources/hello.c +6 -0
- data/examples/executable_subdirs/sources/main.c +8 -0
- data/examples/shared_library/.gitignore +8 -0
- data/examples/shared_library/Rakefile +17 -0
- data/examples/shared_library/Rakefile.llvm +19 -0
- data/examples/shared_library/hello.c +6 -0
- data/examples/shared_library/hello.h +1 -0
- data/examples/shared_library/main.c +7 -0
- data/examples/shared_library/symlinks.rake +7 -0
- data/examples/shared_library_subdirs/.gitignore +8 -0
- data/examples/shared_library_subdirs/Rakefile +27 -0
- data/examples/shared_library_subdirs/includes/hello.h +1 -0
- data/examples/shared_library_subdirs/sources/hello.c +6 -0
- data/examples/shared_library_subdirs/sources/main.c +8 -0
- data/examples/static_library/.gitignore +7 -0
- data/examples/static_library/Rakefile +13 -0
- data/examples/static_library/Rakefile.llvm +14 -0
- data/examples/static_library/hello.c +6 -0
- data/examples/static_library/hello.h +1 -0
- data/examples/static_library/main.c +7 -0
- data/examples/static_library_subdirs/.gitignore +7 -0
- data/examples/static_library_subdirs/Rakefile +17 -0
- data/examples/static_library_subdirs/includes/hello.h +1 -0
- data/examples/static_library_subdirs/sources/hello.c +6 -0
- data/examples/static_library_subdirs/sources/main.c +8 -0
- data/features/c_extension_task.feature +119 -0
- data/features/executable_task.feature +83 -0
- data/features/shared_library_task.feature +209 -0
- data/features/static_library_task.feature +116 -0
- data/features/step_definitions/paper_house_steps.rb +8 -0
- data/features/support/env.rb +41 -0
- data/features/support/hooks.rb +12 -0
- data/lib/paper_house/auto_depends.rb +95 -0
- data/lib/paper_house/build_task.rb +188 -0
- data/lib/paper_house/c_extension_task.rb +95 -0
- data/lib/paper_house/cc_options.rb +81 -0
- data/lib/paper_house/dependency.rb +74 -0
- data/lib/paper_house/executable_task.rb +77 -0
- data/lib/paper_house/library_task.rb +64 -0
- data/lib/paper_house/linker_options.rb +89 -0
- data/lib/paper_house/platform.rb +69 -0
- data/lib/paper_house/safe_popen.rb +50 -0
- data/lib/paper_house/shared_library_task.rb +92 -0
- data/lib/paper_house/static_library_task.rb +65 -0
- data/lib/paper_house/version.rb +30 -0
- data/lib/paper_house.rb +30 -0
- data/paper_house.gemspec +34 -0
- data/spec/paper_house/c_extension_task_spec.rb +59 -0
- data/spec/paper_house/cc_options_spec.rb +59 -0
- data/spec/paper_house/executable_task_spec.rb +49 -0
- data/spec/paper_house/shared_library_task_spec.rb +94 -0
- data/spec/paper_house/static_library_task_spec.rb +61 -0
- data/spec/paper_house/version_spec.rb +31 -0
- data/spec/spec_helper.rb +46 -0
- metadata +161 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require "paper_house"
|
2
|
+
|
3
|
+
task :hello => :libhello
|
4
|
+
|
5
|
+
PaperHouse::StaticLibraryTask.new :libhello do | task |
|
6
|
+
task.library_name = "hello"
|
7
|
+
task.target_directory = "objects"
|
8
|
+
task.sources = "sources/hello.c"
|
9
|
+
task.includes = "includes"
|
10
|
+
task.cflags = [ "-Werror", "-Wall", "-Wextra" ]
|
11
|
+
end
|
12
|
+
|
13
|
+
PaperHouse::ExecutableTask.new :hello do | task |
|
14
|
+
task.sources = "sources/main.c"
|
15
|
+
task.includes = "includes"
|
16
|
+
task.ldflags = "-Lobjects"
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
void print_hello();
|
@@ -0,0 +1,119 @@
|
|
1
|
+
Feature: PaperHouse::CExtensionTask
|
2
|
+
|
3
|
+
PaperHouse provides a rake task called `PaperHouse::CExtensionTask`
|
4
|
+
to build a C extention library from *.c and *.h files. These source
|
5
|
+
files can be located in multiple subdirectories.
|
6
|
+
|
7
|
+
@linux
|
8
|
+
Scenario: Build a C extension from one *.c and *.h file
|
9
|
+
Given the current project directory is "examples/c_extension"
|
10
|
+
When I successfully run `rake hello`
|
11
|
+
Then the output should match /^gcc/
|
12
|
+
And the output should not match /^llvm-gcc/
|
13
|
+
And a file named "hello.so" should exist
|
14
|
+
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
15
|
+
And the output should contain:
|
16
|
+
"""
|
17
|
+
HelloPaperHouse
|
18
|
+
"""
|
19
|
+
|
20
|
+
@mac
|
21
|
+
Scenario: Build a C extension from one *.c and *.h file
|
22
|
+
Given the current project directory is "examples/c_extension"
|
23
|
+
When I successfully run `rake hello`
|
24
|
+
Then the output should match /^gcc/
|
25
|
+
And the output should not match /^llvm-gcc/
|
26
|
+
And a file named "hello.bundle" should exist
|
27
|
+
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
28
|
+
And the output should contain:
|
29
|
+
"""
|
30
|
+
HelloPaperHouse
|
31
|
+
"""
|
32
|
+
|
33
|
+
@linux
|
34
|
+
Scenario: Build a C extension from one *.c and *.h file using llvm-gcc by specifying 'CC=' option
|
35
|
+
Given the current project directory is "examples/c_extension"
|
36
|
+
When I successfully run `rake hello CC=llvm-gcc`
|
37
|
+
Then the output should match /^llvm-gcc/
|
38
|
+
And the output should not match /^gcc/
|
39
|
+
And a file named "hello.so" should exist
|
40
|
+
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
41
|
+
And the output should contain:
|
42
|
+
"""
|
43
|
+
HelloPaperHouse
|
44
|
+
"""
|
45
|
+
|
46
|
+
@mac
|
47
|
+
Scenario: Build a C extension from one *.c and *.h file using llvm-gcc by specifying 'CC=' option
|
48
|
+
Given the current project directory is "examples/c_extension"
|
49
|
+
When I successfully run `rake hello CC=llvm-gcc`
|
50
|
+
Then the output should match /^llvm-gcc/
|
51
|
+
And the output should not match /^gcc/
|
52
|
+
And a file named "hello.bundle" should exist
|
53
|
+
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
54
|
+
And the output should contain:
|
55
|
+
"""
|
56
|
+
HelloPaperHouse
|
57
|
+
"""
|
58
|
+
|
59
|
+
@linux
|
60
|
+
Scenario: Build a C extension from one *.c and *.h file using llvm-gcc
|
61
|
+
Given the current project directory is "examples/c_extension"
|
62
|
+
When I successfully run `rake -f Rakefile.llvm hello`
|
63
|
+
Then the output should match /^llvm-gcc/
|
64
|
+
And the output should not match /^gcc/
|
65
|
+
And a file named "hello.so" should exist
|
66
|
+
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
67
|
+
And the output should contain:
|
68
|
+
"""
|
69
|
+
HelloPaperHouse
|
70
|
+
"""
|
71
|
+
|
72
|
+
@mac
|
73
|
+
Scenario: Build a C extension from one *.c and *.h file using llvm-gcc
|
74
|
+
Given the current project directory is "examples/c_extension"
|
75
|
+
When I successfully run `rake -f Rakefile.llvm hello`
|
76
|
+
Then the output should match /^llvm-gcc/
|
77
|
+
And the output should not match /^gcc/
|
78
|
+
And a file named "hello.bundle" should exist
|
79
|
+
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
80
|
+
And the output should contain:
|
81
|
+
"""
|
82
|
+
HelloPaperHouse
|
83
|
+
"""
|
84
|
+
|
85
|
+
@linux
|
86
|
+
Scenario: Clean
|
87
|
+
Given the current project directory is "examples/c_extension"
|
88
|
+
And I successfully run `rake hello`
|
89
|
+
When I successfully run `rake clean`
|
90
|
+
Then a file named "hello.o" should not exist
|
91
|
+
And a file named ".hello.depends" should exist
|
92
|
+
And a file named "hello.so" should exist
|
93
|
+
|
94
|
+
@mac
|
95
|
+
Scenario: Clean
|
96
|
+
Given the current project directory is "examples/c_extension"
|
97
|
+
And I successfully run `rake hello`
|
98
|
+
When I successfully run `rake clean`
|
99
|
+
Then a file named "hello.o" should not exist
|
100
|
+
And a file named ".hello.depends" should exist
|
101
|
+
And a file named "hello.bundle" should exist
|
102
|
+
|
103
|
+
@linux
|
104
|
+
Scenario: Clobber
|
105
|
+
Given the current project directory is "examples/c_extension"
|
106
|
+
And I successfully run `rake hello`
|
107
|
+
When I successfully run `rake clobber`
|
108
|
+
Then a file named "hello.o" should not exist
|
109
|
+
And a file named ".hello.depends" should not exist
|
110
|
+
And a file named "hello.so" should not exist
|
111
|
+
|
112
|
+
@mac
|
113
|
+
Scenario: Clobber
|
114
|
+
Given the current project directory is "examples/c_extension"
|
115
|
+
And I successfully run `rake hello`
|
116
|
+
When I successfully run `rake clobber`
|
117
|
+
Then a file named "hello.o" should not exist
|
118
|
+
And a file named ".hello.depends" should not exist
|
119
|
+
And a file named "hello.bundle" should not exist
|
@@ -0,0 +1,83 @@
|
|
1
|
+
Feature: PaperHouse::ExecutableTask
|
2
|
+
|
3
|
+
PaperHouse provides a rake task called `PaperHouse::ExecutableTask`
|
4
|
+
to build an executable from *.c and *.h files. These source files
|
5
|
+
can be located in multiple subdirectories.
|
6
|
+
|
7
|
+
Scenario: Build an executable from one *.c file
|
8
|
+
Given the current project directory is "examples/executable"
|
9
|
+
When I successfully run `rake hello`
|
10
|
+
Then the output should contain:
|
11
|
+
"""
|
12
|
+
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
13
|
+
gcc -o ./hello ./hello.o
|
14
|
+
"""
|
15
|
+
And a file named "hello" should exist
|
16
|
+
And I successfully run `./hello`
|
17
|
+
And the output should contain:
|
18
|
+
"""
|
19
|
+
Hello, PaperHouse!
|
20
|
+
"""
|
21
|
+
|
22
|
+
Scenario: Build an executable from one *.c file using llvm-gcc by specifying `CC=` option
|
23
|
+
Given the current project directory is "examples/executable"
|
24
|
+
When I successfully run `rake hello CC=llvm-gcc`
|
25
|
+
Then the output should contain:
|
26
|
+
"""
|
27
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
28
|
+
llvm-gcc -o ./hello ./hello.o
|
29
|
+
"""
|
30
|
+
And a file named "hello" should exist
|
31
|
+
And I successfully run `./hello`
|
32
|
+
And the output should contain:
|
33
|
+
"""
|
34
|
+
Hello, PaperHouse!
|
35
|
+
"""
|
36
|
+
|
37
|
+
Scenario: Build an executable from one *.c file using llvm-gcc
|
38
|
+
Given the current project directory is "examples/executable"
|
39
|
+
When I successfully run `rake -f Rakefile.llvm hello`
|
40
|
+
Then the output should contain:
|
41
|
+
"""
|
42
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
43
|
+
llvm-gcc -o ./hello ./hello.o
|
44
|
+
"""
|
45
|
+
And a file named "hello" should exist
|
46
|
+
And I successfully run `./hello`
|
47
|
+
And the output should contain:
|
48
|
+
"""
|
49
|
+
Hello, PaperHouse!
|
50
|
+
"""
|
51
|
+
|
52
|
+
Scenario: Build an executable from multiple *.c and *.h files in subdirectories
|
53
|
+
Given the current project directory is "examples/executable_subdirs"
|
54
|
+
When I successfully run `rake hello`
|
55
|
+
Then the output should contain:
|
56
|
+
"""
|
57
|
+
gcc -H -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
58
|
+
gcc -H -Wall -Wextra -fPIC -Iincludes -Isources -c sources/main.c -o objects/main.o
|
59
|
+
mkdir -p objects
|
60
|
+
gcc -o objects/hello objects/hello.o objects/main.o
|
61
|
+
"""
|
62
|
+
And a file named "objects/hello" should exist
|
63
|
+
And I successfully run `./objects/hello`
|
64
|
+
And the output should contain:
|
65
|
+
"""
|
66
|
+
Hello, PaperHouse!
|
67
|
+
"""
|
68
|
+
|
69
|
+
Scenario: Clean
|
70
|
+
Given the current project directory is "examples/executable"
|
71
|
+
And I successfully run `rake hello`
|
72
|
+
When I successfully run `rake clean`
|
73
|
+
Then a file named "hello.o" should not exist
|
74
|
+
And a file named ".hello.depends" should exist
|
75
|
+
And a file named "hello" should exist
|
76
|
+
|
77
|
+
Scenario: Clobber
|
78
|
+
Given the current project directory is "examples/executable"
|
79
|
+
And I successfully run `rake hello`
|
80
|
+
When I successfully run `rake clobber`
|
81
|
+
Then a file named "hello.o" should not exist
|
82
|
+
And a file named ".hello.depends" should not exist
|
83
|
+
And a file named "hello" should not exist
|
@@ -0,0 +1,209 @@
|
|
1
|
+
Feature: PaperHouse::SharedLibraryTask
|
2
|
+
|
3
|
+
PaperHouse provides a rake task called
|
4
|
+
`PaperHouse::SharedLibraryTask` to build a shared library from *.c
|
5
|
+
and *.h files. These source files can be located in multiple
|
6
|
+
subdirectories.
|
7
|
+
|
8
|
+
@linux
|
9
|
+
Scenario: Build a shared library from one *.c and *.h file
|
10
|
+
Given the current project directory is "examples/shared_library"
|
11
|
+
When I successfully run `rake hello`
|
12
|
+
Then the output should contain:
|
13
|
+
"""
|
14
|
+
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
15
|
+
gcc -H -fPIC -I. -c main.c -o ./main.o
|
16
|
+
gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
17
|
+
ln -s libhello.so.0.1.0 libhello.so
|
18
|
+
ln -s libhello.so.0.1.0 libhello.so.0
|
19
|
+
gcc -o ./hello ./main.o -L. -lhello
|
20
|
+
"""
|
21
|
+
And a file named "libhello.so.0.1.0" should exist
|
22
|
+
And a file named "hello" should exist
|
23
|
+
And I successfully run `./hello`
|
24
|
+
And the output should contain:
|
25
|
+
"""
|
26
|
+
Hello, PaperHouse!
|
27
|
+
"""
|
28
|
+
|
29
|
+
@mac
|
30
|
+
Scenario: Build a shared library from one *.c and *.h file
|
31
|
+
Given the current project directory is "examples/shared_library"
|
32
|
+
When I successfully run `rake hello`
|
33
|
+
Then the output should contain:
|
34
|
+
"""
|
35
|
+
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
36
|
+
gcc -H -fPIC -I. -c main.c -o ./main.o
|
37
|
+
gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
38
|
+
ln -s libhello.so.0.1.0 libhello.so
|
39
|
+
ln -s libhello.so.0.1.0 libhello.so.0
|
40
|
+
gcc -o ./hello ./main.o -L. -lhello
|
41
|
+
"""
|
42
|
+
And a file named "libhello.so.0.1.0" should exist
|
43
|
+
And a file named "hello" should exist
|
44
|
+
And I successfully run `./hello`
|
45
|
+
And the output should contain:
|
46
|
+
"""
|
47
|
+
Hello, PaperHouse!
|
48
|
+
"""
|
49
|
+
|
50
|
+
@linux
|
51
|
+
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc by specifying `CC=` option
|
52
|
+
Given the current project directory is "examples/shared_library"
|
53
|
+
When I successfully run `rake hello CC=llvm-gcc`
|
54
|
+
Then the output should contain:
|
55
|
+
"""
|
56
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
57
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
58
|
+
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
59
|
+
ln -s libhello.so.0.1.0 libhello.so
|
60
|
+
ln -s libhello.so.0.1.0 libhello.so.0
|
61
|
+
llvm-gcc -o ./hello ./main.o -L. -lhello
|
62
|
+
"""
|
63
|
+
And a file named "libhello.so.0.1.0" should exist
|
64
|
+
And a file named "hello" should exist
|
65
|
+
And I successfully run `./hello`
|
66
|
+
And the output should contain:
|
67
|
+
"""
|
68
|
+
Hello, PaperHouse!
|
69
|
+
"""
|
70
|
+
|
71
|
+
@mac
|
72
|
+
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc by specifying `CC=` option
|
73
|
+
Given the current project directory is "examples/shared_library"
|
74
|
+
When I successfully run `rake hello CC=llvm-gcc`
|
75
|
+
Then the output should contain:
|
76
|
+
"""
|
77
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
78
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
79
|
+
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
80
|
+
ln -s libhello.so.0.1.0 libhello.so
|
81
|
+
ln -s libhello.so.0.1.0 libhello.so.0
|
82
|
+
llvm-gcc -o ./hello ./main.o -L. -lhello
|
83
|
+
"""
|
84
|
+
And a file named "libhello.so.0.1.0" should exist
|
85
|
+
And a file named "hello" should exist
|
86
|
+
And I successfully run `./hello`
|
87
|
+
And the output should contain:
|
88
|
+
"""
|
89
|
+
Hello, PaperHouse!
|
90
|
+
"""
|
91
|
+
|
92
|
+
@linux
|
93
|
+
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc
|
94
|
+
Given the current project directory is "examples/shared_library"
|
95
|
+
When I successfully run `rake -f Rakefile.llvm hello`
|
96
|
+
Then the output should contain:
|
97
|
+
"""
|
98
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
99
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
100
|
+
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
101
|
+
ln -s libhello.so.0.1.0 libhello.so
|
102
|
+
ln -s libhello.so.0.1.0 libhello.so.0
|
103
|
+
llvm-gcc -o ./hello ./main.o -L. -lhello
|
104
|
+
"""
|
105
|
+
And a file named "libhello.so.0.1.0" should exist
|
106
|
+
And a file named "hello" should exist
|
107
|
+
And I successfully run `./hello`
|
108
|
+
And the output should contain:
|
109
|
+
"""
|
110
|
+
Hello, PaperHouse!
|
111
|
+
"""
|
112
|
+
|
113
|
+
@mac
|
114
|
+
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc
|
115
|
+
Given the current project directory is "examples/shared_library"
|
116
|
+
When I successfully run `rake -f Rakefile.llvm hello`
|
117
|
+
Then the output should contain:
|
118
|
+
"""
|
119
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
120
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
121
|
+
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
122
|
+
ln -s libhello.so.0.1.0 libhello.so
|
123
|
+
ln -s libhello.so.0.1.0 libhello.so.0
|
124
|
+
llvm-gcc -o ./hello ./main.o -L. -lhello
|
125
|
+
"""
|
126
|
+
And a file named "libhello.so.0.1.0" should exist
|
127
|
+
And a file named "hello" should exist
|
128
|
+
And I successfully run `./hello`
|
129
|
+
And the output should contain:
|
130
|
+
"""
|
131
|
+
Hello, PaperHouse!
|
132
|
+
"""
|
133
|
+
|
134
|
+
@linux
|
135
|
+
Scenario: Build a shared library from multiple *.c and *.h files in subcirectories
|
136
|
+
Given the current project directory is "examples/shared_library_subdirs"
|
137
|
+
When I successfully run `rake hello`
|
138
|
+
Then the output should contain:
|
139
|
+
"""
|
140
|
+
gcc -H -Werror -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
141
|
+
gcc -H -fPIC -Iincludes -Isources -c sources/main.c -o ./main.o
|
142
|
+
mkdir -p objects
|
143
|
+
gcc -shared -Wl,-soname,libhello.so.0 -o objects/libhello.so.0.1.0 objects/hello.o
|
144
|
+
ln -s objects/libhello.so.0.1.0 libhello.so
|
145
|
+
ln -s objects/libhello.so.0.1.0 libhello.so.0
|
146
|
+
gcc -o ./hello ./main.o -L. -lhello
|
147
|
+
"""
|
148
|
+
And a file named "objects/libhello.so.0.1.0" should exist
|
149
|
+
And a file named "hello" should exist
|
150
|
+
And I successfully run `./hello`
|
151
|
+
And the output should contain:
|
152
|
+
"""
|
153
|
+
Hello, PaperHouse!
|
154
|
+
"""
|
155
|
+
|
156
|
+
@mac
|
157
|
+
Scenario: Build a shared library from multiple *.c and *.h files in subcirectories
|
158
|
+
Given the current project directory is "examples/shared_library_subdirs"
|
159
|
+
When I successfully run `rake hello`
|
160
|
+
Then the output should contain:
|
161
|
+
"""
|
162
|
+
gcc -H -Werror -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
163
|
+
gcc -H -fPIC -Iincludes -Isources -c sources/main.c -o ./main.o
|
164
|
+
mkdir -p objects
|
165
|
+
gcc -shared -Wl,-install_name,libhello.so.0 -o objects/libhello.so.0.1.0 objects/hello.o
|
166
|
+
ln -s objects/libhello.so.0.1.0 libhello.so
|
167
|
+
ln -s objects/libhello.so.0.1.0 libhello.so.0
|
168
|
+
gcc -o ./hello ./main.o -L. -lhello
|
169
|
+
"""
|
170
|
+
And a file named "objects/libhello.so.0.1.0" should exist
|
171
|
+
And a file named "hello" should exist
|
172
|
+
And I successfully run `./hello`
|
173
|
+
And the output should contain:
|
174
|
+
"""
|
175
|
+
Hello, PaperHouse!
|
176
|
+
"""
|
177
|
+
|
178
|
+
Scenario: Automatically rebuild an executable when dependent library is updated
|
179
|
+
Given the current project directory is "examples/shared_library"
|
180
|
+
And I successfully run `rake hello`
|
181
|
+
And I successfully run `sleep 1`
|
182
|
+
And I successfully run `touch libhello.so.0`
|
183
|
+
When I successfully run `rake hello`
|
184
|
+
Then the output should contain:
|
185
|
+
"""
|
186
|
+
gcc -o ./hello ./main.o -L. -lhello
|
187
|
+
"""
|
188
|
+
|
189
|
+
Scenario: Clean
|
190
|
+
Given the current project directory is "examples/shared_library"
|
191
|
+
When I successfully run `rake hello`
|
192
|
+
When I successfully run `rake clean`
|
193
|
+
Then a file named "hello.o" should not exist
|
194
|
+
And a file named "main.o" should not exist
|
195
|
+
And a file named ".libhello.depends" should exist
|
196
|
+
And a file named ".hello.depends" should exist
|
197
|
+
And a file named "libhello.so.0.1.0" should exist
|
198
|
+
And a file named "hello" should exist
|
199
|
+
|
200
|
+
Scenario: Clobber
|
201
|
+
Given the current project directory is "examples/shared_library"
|
202
|
+
When I successfully run `rake hello`
|
203
|
+
When I successfully run `rake clobber`
|
204
|
+
Then a file named "hello.o" should not exist
|
205
|
+
And a file named "main.o" should not exist
|
206
|
+
And a file named ".libhello.depends" should not exist
|
207
|
+
And a file named ".hello.depends" should not exist
|
208
|
+
And a file named "libhello.so.0.1.0" should not exist
|
209
|
+
And a file named "hello" should not exist
|
@@ -0,0 +1,116 @@
|
|
1
|
+
Feature: PaperHouse::StaticLibraryTask
|
2
|
+
|
3
|
+
PaperHouse provides a rake task called
|
4
|
+
`PaperHouse::StaticLibraryTask` to build a static library from *.c
|
5
|
+
and *.h files. These source files can be located in multiple
|
6
|
+
subdirectories.
|
7
|
+
|
8
|
+
Scenario: Build a static library from one *.c and *.h file
|
9
|
+
Given the current project directory is "examples/static_library"
|
10
|
+
When I successfully run `rake hello`
|
11
|
+
Then the output should contain:
|
12
|
+
"""
|
13
|
+
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
14
|
+
gcc -H -fPIC -I. -c main.c -o ./main.o
|
15
|
+
ar -cq ./libhello.a ./hello.o
|
16
|
+
ranlib ./libhello.a
|
17
|
+
gcc -o ./hello ./main.o -L. -lhello
|
18
|
+
"""
|
19
|
+
And a file named "libhello.a" should exist
|
20
|
+
And a file named "hello" should exist
|
21
|
+
And I successfully run `./hello`
|
22
|
+
And the output should contain:
|
23
|
+
"""
|
24
|
+
Hello, PaperHouse!
|
25
|
+
"""
|
26
|
+
|
27
|
+
Scenario: Build a static library from one *.c and *.h file using llvm-gcc by specifying `CC=` option
|
28
|
+
Given the current project directory is "examples/static_library"
|
29
|
+
When I successfully run `rake hello CC=llvm-gcc`
|
30
|
+
Then the output should contain:
|
31
|
+
"""
|
32
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
33
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
34
|
+
ar -cq ./libhello.a ./hello.o
|
35
|
+
ranlib ./libhello.a
|
36
|
+
llvm-gcc -o ./hello ./main.o -L. -lhello
|
37
|
+
"""
|
38
|
+
And a file named "libhello.a" should exist
|
39
|
+
And a file named "hello" should exist
|
40
|
+
And I successfully run `./hello`
|
41
|
+
And the output should contain:
|
42
|
+
"""
|
43
|
+
Hello, PaperHouse!
|
44
|
+
"""
|
45
|
+
|
46
|
+
Scenario: Build a static library from one *.c and *.h file using llvm-gcc
|
47
|
+
Given the current project directory is "examples/static_library"
|
48
|
+
When I successfully run `rake -f Rakefile.llvm hello`
|
49
|
+
Then the output should contain:
|
50
|
+
"""
|
51
|
+
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
52
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
53
|
+
ar -cq ./libhello.a ./hello.o
|
54
|
+
ranlib ./libhello.a
|
55
|
+
llvm-gcc -o ./hello ./main.o -L. -lhello
|
56
|
+
"""
|
57
|
+
And a file named "libhello.a" should exist
|
58
|
+
And a file named "hello" should exist
|
59
|
+
And I successfully run `./hello`
|
60
|
+
And the output should contain:
|
61
|
+
"""
|
62
|
+
Hello, PaperHouse!
|
63
|
+
"""
|
64
|
+
|
65
|
+
Scenario: Build a static library from multiple *.c and *.h files in subcirectories
|
66
|
+
Given the current project directory is "examples/static_library_subdirs"
|
67
|
+
When I successfully run `rake hello`
|
68
|
+
Then the output should contain:
|
69
|
+
"""
|
70
|
+
gcc -H -Werror -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
71
|
+
gcc -H -fPIC -Iincludes -Isources -c sources/main.c -o ./main.o
|
72
|
+
mkdir -p objects
|
73
|
+
ar -cq objects/libhello.a objects/hello.o
|
74
|
+
ranlib objects/libhello.a
|
75
|
+
gcc -o ./hello ./main.o -Lobjects -lhello
|
76
|
+
"""
|
77
|
+
And a file named "objects/libhello.a" should exist
|
78
|
+
And a file named "hello" should exist
|
79
|
+
And I successfully run `./hello`
|
80
|
+
And the output should contain:
|
81
|
+
"""
|
82
|
+
Hello, PaperHouse!
|
83
|
+
"""
|
84
|
+
|
85
|
+
Scenario: Automatically rebuild an executable when dependent library is updated
|
86
|
+
Given the current project directory is "examples/static_library"
|
87
|
+
And I successfully run `rake hello`
|
88
|
+
And I successfully run `sleep 1`
|
89
|
+
And I successfully run `touch libhello.a`
|
90
|
+
When I successfully run `rake hello`
|
91
|
+
Then the output should contain:
|
92
|
+
"""
|
93
|
+
gcc -o ./hello ./main.o -L. -lhello
|
94
|
+
"""
|
95
|
+
|
96
|
+
Scenario: Clean
|
97
|
+
Given the current project directory is "examples/static_library"
|
98
|
+
And I successfully run `rake hello`
|
99
|
+
When I successfully run `rake clean`
|
100
|
+
Then a file named "hello.o" should not exist
|
101
|
+
And a file named "main.o" should not exist
|
102
|
+
And a file named ".libhello.depends" should exist
|
103
|
+
And a file named ".hello.depends" should exist
|
104
|
+
And a file named "libhello.a" should exist
|
105
|
+
And a file named "hello" should exist
|
106
|
+
|
107
|
+
Scenario: Clobber
|
108
|
+
Given the current project directory is "examples/static_library"
|
109
|
+
And I successfully run `rake hello`
|
110
|
+
When I successfully run `rake clobber`
|
111
|
+
Then a file named "hello.o" should not exist
|
112
|
+
And a file named "main.o" should not exist
|
113
|
+
And a file named ".libhello.depends" should not exist
|
114
|
+
And a file named ".hello.depends" should not exist
|
115
|
+
And a file named "libhello.a" should not exist
|
116
|
+
And a file named "hello" should not exist
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Given(/^the current project directory is "(.*?)"$/) do | dir |
|
2
|
+
in_current_dir do
|
3
|
+
project_files = Dir.glob( File.join( "..", "..", dir, "*" ) )
|
4
|
+
FileUtils.cp_r project_files, "."
|
5
|
+
system "rake clobber"
|
6
|
+
FileUtils.rm_r "objects" if FileTest.exists?( "objects" )
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 NEC Corporation
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License, version 3, as
|
6
|
+
# published by the Free Software Foundation.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
#
|
17
|
+
|
18
|
+
|
19
|
+
require "rubygems"
|
20
|
+
|
21
|
+
require "simplecov"
|
22
|
+
SimpleCov.start
|
23
|
+
|
24
|
+
require "aruba/cucumber"
|
25
|
+
require "rake"
|
26
|
+
|
27
|
+
|
28
|
+
ENV[ "LD_LIBRARY_PATH" ] = "."
|
29
|
+
|
30
|
+
|
31
|
+
if ENV[ "TRAVIS" ]
|
32
|
+
require "coveralls"
|
33
|
+
Coveralls.wear_merged!
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
### Local variables:
|
38
|
+
### mode: Ruby
|
39
|
+
### coding: utf-8-unix
|
40
|
+
### indent-tabs-mode: nil
|
41
|
+
### End:
|