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,90 +1,72 @@
|
|
1
|
-
Feature: PaperHouse::
|
1
|
+
Feature: PaperHouse::RubyExtensionTask
|
2
2
|
|
3
|
-
PaperHouse provides a rake task called `PaperHouse::
|
3
|
+
PaperHouse provides a rake task called `PaperHouse::RubyExtensionTask`
|
4
4
|
to build a C extention library from *.c and *.h files. These source
|
5
5
|
files can be located in multiple subdirectories.
|
6
6
|
|
7
7
|
@linux
|
8
|
-
Scenario: Build a
|
9
|
-
Given the current project directory is "examples/
|
10
|
-
When I
|
8
|
+
Scenario: Build a Ruby extension from one *.c and *.h file
|
9
|
+
Given the current project directory is "examples/ruby_extension"
|
10
|
+
When I run rake "hello"
|
11
11
|
Then the output should match /^gcc/
|
12
12
|
And the output should not match /^llvm-gcc/
|
13
13
|
And a file named "hello.so" should exist
|
14
14
|
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
15
|
-
And the output should contain
|
16
|
-
"""
|
17
|
-
HelloPaperHouse
|
18
|
-
"""
|
15
|
+
And the output should contain "HelloPaperHouse"
|
19
16
|
|
20
17
|
@mac
|
21
|
-
Scenario: Build a
|
22
|
-
Given the current project directory is "examples/
|
23
|
-
When I
|
18
|
+
Scenario: Build a Ruby extension from one *.c and *.h file
|
19
|
+
Given the current project directory is "examples/ruby_extension"
|
20
|
+
When I run rake "hello"
|
24
21
|
Then the output should match /^gcc/
|
25
22
|
And the output should not match /^llvm-gcc/
|
26
23
|
And a file named "hello.bundle" should exist
|
27
24
|
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
28
|
-
And the output should contain
|
29
|
-
"""
|
30
|
-
HelloPaperHouse
|
31
|
-
"""
|
25
|
+
And the output should contain "HelloPaperHouse"
|
32
26
|
|
33
27
|
@linux
|
34
|
-
Scenario: Build a
|
35
|
-
Given the current project directory is "examples/
|
36
|
-
When I
|
28
|
+
Scenario: Build a Ruby extension from one *.c and *.h file using llvm-gcc by specifying 'CC=' option
|
29
|
+
Given the current project directory is "examples/ruby_extension"
|
30
|
+
When I run rake "hello CC=llvm-gcc"
|
37
31
|
Then the output should match /^llvm-gcc/
|
38
32
|
And the output should not match /^gcc/
|
39
33
|
And a file named "hello.so" should exist
|
40
34
|
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
41
|
-
And the output should contain
|
42
|
-
"""
|
43
|
-
HelloPaperHouse
|
44
|
-
"""
|
35
|
+
And the output should contain "HelloPaperHouse"
|
45
36
|
|
46
37
|
@mac
|
47
|
-
Scenario: Build a
|
48
|
-
Given the current project directory is "examples/
|
49
|
-
When I
|
38
|
+
Scenario: Build a Ruby extension from one *.c and *.h file using llvm-gcc by specifying 'CC=' option
|
39
|
+
Given the current project directory is "examples/ruby_extension"
|
40
|
+
When I run rake "hello CC=llvm-gcc"
|
50
41
|
Then the output should match /^llvm-gcc/
|
51
42
|
And the output should not match /^gcc/
|
52
43
|
And a file named "hello.bundle" should exist
|
53
44
|
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
54
|
-
And the output should contain
|
55
|
-
"""
|
56
|
-
HelloPaperHouse
|
57
|
-
"""
|
45
|
+
And the output should contain "HelloPaperHouse"
|
58
46
|
|
59
47
|
@linux
|
60
|
-
Scenario: Build a
|
61
|
-
Given the current project directory is "examples/
|
62
|
-
When I
|
48
|
+
Scenario: Build a Ruby extension from one *.c and *.h file using llvm-gcc
|
49
|
+
Given the current project directory is "examples/ruby_extension"
|
50
|
+
When I run rake "-f Rakefile.llvm hello"
|
63
51
|
Then the output should match /^llvm-gcc/
|
64
52
|
And the output should not match /^gcc/
|
65
53
|
And a file named "hello.so" should exist
|
66
54
|
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
67
|
-
And the output should contain
|
68
|
-
"""
|
69
|
-
HelloPaperHouse
|
70
|
-
"""
|
55
|
+
And the output should contain "HelloPaperHouse"
|
71
56
|
|
72
57
|
@mac
|
73
|
-
Scenario: Build a
|
74
|
-
Given the current project directory is "examples/
|
75
|
-
When I
|
58
|
+
Scenario: Build a Ruby extension from one *.c and *.h file using llvm-gcc
|
59
|
+
Given the current project directory is "examples/ruby_extension"
|
60
|
+
When I run rake "-f Rakefile.llvm hello"
|
76
61
|
Then the output should match /^llvm-gcc/
|
77
62
|
And the output should not match /^gcc/
|
78
63
|
And a file named "hello.bundle" should exist
|
79
64
|
And I successfully run `ruby -I. -rhello -e "p HelloPaperHouse"`
|
80
|
-
And the output should contain
|
81
|
-
"""
|
82
|
-
HelloPaperHouse
|
83
|
-
"""
|
65
|
+
And the output should contain "HelloPaperHouse"
|
84
66
|
|
85
67
|
@linux
|
86
68
|
Scenario: Clean
|
87
|
-
Given the current project directory is "examples/
|
69
|
+
Given the current project directory is "examples/ruby_extension"
|
88
70
|
And I successfully run `rake hello`
|
89
71
|
When I successfully run `rake clean`
|
90
72
|
Then a file named "hello.o" should not exist
|
@@ -93,7 +75,7 @@ Feature: PaperHouse::CExtensionTask
|
|
93
75
|
|
94
76
|
@mac
|
95
77
|
Scenario: Clean
|
96
|
-
Given the current project directory is "examples/
|
78
|
+
Given the current project directory is "examples/ruby_extension"
|
97
79
|
And I successfully run `rake hello`
|
98
80
|
When I successfully run `rake clean`
|
99
81
|
Then a file named "hello.o" should not exist
|
@@ -102,7 +84,7 @@ Feature: PaperHouse::CExtensionTask
|
|
102
84
|
|
103
85
|
@linux
|
104
86
|
Scenario: Clobber
|
105
|
-
Given the current project directory is "examples/
|
87
|
+
Given the current project directory is "examples/ruby_extension"
|
106
88
|
And I successfully run `rake hello`
|
107
89
|
When I successfully run `rake clobber`
|
108
90
|
Then a file named "hello.o" should not exist
|
@@ -111,7 +93,7 @@ Feature: PaperHouse::CExtensionTask
|
|
111
93
|
|
112
94
|
@mac
|
113
95
|
Scenario: Clobber
|
114
|
-
Given the current project directory is "examples/
|
96
|
+
Given the current project directory is "examples/ruby_extension"
|
115
97
|
And I successfully run `rake hello`
|
116
98
|
When I successfully run `rake clobber`
|
117
99
|
Then a file named "hello.o" should not exist
|
@@ -8,172 +8,148 @@ Feature: PaperHouse::SharedLibraryTask
|
|
8
8
|
@linux
|
9
9
|
Scenario: Build a shared library from one *.c and *.h file
|
10
10
|
Given the current project directory is "examples/shared_library"
|
11
|
-
When I
|
12
|
-
Then the
|
11
|
+
When I run rake "hello"
|
12
|
+
Then the stderr should contain:
|
13
13
|
"""
|
14
14
|
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
15
|
-
gcc -H -fPIC -I. -c main.c -o ./main.o
|
16
15
|
gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
17
16
|
ln -s libhello.so.0.1.0 libhello.so
|
18
17
|
ln -s libhello.so.0.1.0 libhello.so.0
|
18
|
+
gcc -H -fPIC -I. -c main.c -o ./main.o
|
19
19
|
gcc -o ./hello ./main.o -L. -lhello
|
20
20
|
"""
|
21
21
|
And a file named "libhello.so.0.1.0" should exist
|
22
22
|
And a file named "hello" should exist
|
23
23
|
And I successfully run `./hello`
|
24
|
-
And the output should contain
|
25
|
-
"""
|
26
|
-
Hello, PaperHouse!
|
27
|
-
"""
|
24
|
+
And the output should contain "Hello, PaperHouse!"
|
28
25
|
|
29
26
|
@mac
|
30
27
|
Scenario: Build a shared library from one *.c and *.h file
|
31
28
|
Given the current project directory is "examples/shared_library"
|
32
|
-
When I
|
33
|
-
Then the
|
29
|
+
When I run rake "hello"
|
30
|
+
Then the stderr should contain:
|
34
31
|
"""
|
35
32
|
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
36
|
-
gcc -H -fPIC -I. -c main.c -o ./main.o
|
37
33
|
gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
38
34
|
ln -s libhello.so.0.1.0 libhello.so
|
39
35
|
ln -s libhello.so.0.1.0 libhello.so.0
|
36
|
+
gcc -H -fPIC -I. -c main.c -o ./main.o
|
40
37
|
gcc -o ./hello ./main.o -L. -lhello
|
41
38
|
"""
|
42
39
|
And a file named "libhello.so.0.1.0" should exist
|
43
40
|
And a file named "hello" should exist
|
44
41
|
And I successfully run `./hello`
|
45
|
-
And the output should contain
|
46
|
-
"""
|
47
|
-
Hello, PaperHouse!
|
48
|
-
"""
|
42
|
+
And the output should contain "Hello, PaperHouse!"
|
49
43
|
|
50
44
|
@linux
|
51
45
|
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc by specifying `CC=` option
|
52
46
|
Given the current project directory is "examples/shared_library"
|
53
|
-
When I
|
54
|
-
Then the
|
47
|
+
When I run rake "hello CC=llvm-gcc"
|
48
|
+
Then the stderr should contain:
|
55
49
|
"""
|
56
50
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
57
|
-
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
58
51
|
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
59
52
|
ln -s libhello.so.0.1.0 libhello.so
|
60
53
|
ln -s libhello.so.0.1.0 libhello.so.0
|
54
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
61
55
|
llvm-gcc -o ./hello ./main.o -L. -lhello
|
62
56
|
"""
|
63
57
|
And a file named "libhello.so.0.1.0" should exist
|
64
58
|
And a file named "hello" should exist
|
65
59
|
And I successfully run `./hello`
|
66
|
-
And the output should contain
|
67
|
-
"""
|
68
|
-
Hello, PaperHouse!
|
69
|
-
"""
|
60
|
+
And the output should contain "Hello, PaperHouse!"
|
70
61
|
|
71
62
|
@mac
|
72
63
|
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc by specifying `CC=` option
|
73
64
|
Given the current project directory is "examples/shared_library"
|
74
|
-
When I
|
75
|
-
Then the
|
65
|
+
When I run rake "hello CC=llvm-gcc"
|
66
|
+
Then the stderr should contain:
|
76
67
|
"""
|
77
68
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
78
|
-
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
79
69
|
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
80
70
|
ln -s libhello.so.0.1.0 libhello.so
|
81
71
|
ln -s libhello.so.0.1.0 libhello.so.0
|
72
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
82
73
|
llvm-gcc -o ./hello ./main.o -L. -lhello
|
83
74
|
"""
|
84
75
|
And a file named "libhello.so.0.1.0" should exist
|
85
76
|
And a file named "hello" should exist
|
86
77
|
And I successfully run `./hello`
|
87
|
-
And the output should contain
|
88
|
-
"""
|
89
|
-
Hello, PaperHouse!
|
90
|
-
"""
|
78
|
+
And the output should contain "Hello, PaperHouse!"
|
91
79
|
|
92
80
|
@linux
|
93
81
|
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc
|
94
82
|
Given the current project directory is "examples/shared_library"
|
95
|
-
When I
|
96
|
-
Then the
|
83
|
+
When I run rake "-f Rakefile.llvm hello"
|
84
|
+
Then the stderr should contain:
|
97
85
|
"""
|
98
86
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
99
|
-
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
100
87
|
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
101
88
|
ln -s libhello.so.0.1.0 libhello.so
|
102
89
|
ln -s libhello.so.0.1.0 libhello.so.0
|
90
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
103
91
|
llvm-gcc -o ./hello ./main.o -L. -lhello
|
104
92
|
"""
|
105
93
|
And a file named "libhello.so.0.1.0" should exist
|
106
94
|
And a file named "hello" should exist
|
107
95
|
And I successfully run `./hello`
|
108
|
-
And the output should contain
|
109
|
-
"""
|
110
|
-
Hello, PaperHouse!
|
111
|
-
"""
|
96
|
+
And the output should contain "Hello, PaperHouse!"
|
112
97
|
|
113
98
|
@mac
|
114
99
|
Scenario: Build a shared library from one *.c and *.h file using llvm-gcc
|
115
100
|
Given the current project directory is "examples/shared_library"
|
116
|
-
When I
|
117
|
-
Then the
|
101
|
+
When I run rake "-f Rakefile.llvm hello"
|
102
|
+
Then the stderr should contain:
|
118
103
|
"""
|
119
104
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
120
|
-
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
121
105
|
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
|
122
106
|
ln -s libhello.so.0.1.0 libhello.so
|
123
107
|
ln -s libhello.so.0.1.0 libhello.so.0
|
108
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
124
109
|
llvm-gcc -o ./hello ./main.o -L. -lhello
|
125
110
|
"""
|
126
111
|
And a file named "libhello.so.0.1.0" should exist
|
127
112
|
And a file named "hello" should exist
|
128
113
|
And I successfully run `./hello`
|
129
|
-
And the output should contain
|
130
|
-
"""
|
131
|
-
Hello, PaperHouse!
|
132
|
-
"""
|
114
|
+
And the output should contain "Hello, PaperHouse!"
|
133
115
|
|
134
116
|
@linux
|
135
117
|
Scenario: Build a shared library from multiple *.c and *.h files in subcirectories
|
136
118
|
Given the current project directory is "examples/shared_library_subdirs"
|
137
|
-
When I
|
119
|
+
When I run rake "hello"
|
138
120
|
Then the output should contain:
|
139
121
|
"""
|
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
122
|
mkdir -p objects
|
123
|
+
gcc -H -Werror -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
143
124
|
gcc -shared -Wl,-soname,libhello.so.0 -o objects/libhello.so.0.1.0 objects/hello.o
|
144
125
|
ln -s objects/libhello.so.0.1.0 libhello.so
|
145
126
|
ln -s objects/libhello.so.0.1.0 libhello.so.0
|
127
|
+
gcc -H -fPIC -Iincludes -Isources -c sources/main.c -o ./main.o
|
146
128
|
gcc -o ./hello ./main.o -L. -lhello
|
147
129
|
"""
|
148
130
|
And a file named "objects/libhello.so.0.1.0" should exist
|
149
131
|
And a file named "hello" should exist
|
150
132
|
And I successfully run `./hello`
|
151
|
-
And the output should contain
|
152
|
-
"""
|
153
|
-
Hello, PaperHouse!
|
154
|
-
"""
|
133
|
+
And the output should contain "Hello, PaperHouse!"
|
155
134
|
|
156
135
|
@mac
|
157
136
|
Scenario: Build a shared library from multiple *.c and *.h files in subcirectories
|
158
137
|
Given the current project directory is "examples/shared_library_subdirs"
|
159
|
-
When I
|
138
|
+
When I run rake "hello"
|
160
139
|
Then the output should contain:
|
161
140
|
"""
|
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
141
|
mkdir -p objects
|
142
|
+
gcc -H -Werror -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
165
143
|
gcc -shared -Wl,-install_name,libhello.so.0 -o objects/libhello.so.0.1.0 objects/hello.o
|
166
144
|
ln -s objects/libhello.so.0.1.0 libhello.so
|
167
145
|
ln -s objects/libhello.so.0.1.0 libhello.so.0
|
146
|
+
gcc -H -fPIC -Iincludes -Isources -c sources/main.c -o ./main.o
|
168
147
|
gcc -o ./hello ./main.o -L. -lhello
|
169
148
|
"""
|
170
149
|
And a file named "objects/libhello.so.0.1.0" should exist
|
171
150
|
And a file named "hello" should exist
|
172
151
|
And I successfully run `./hello`
|
173
|
-
And the output should contain
|
174
|
-
"""
|
175
|
-
Hello, PaperHouse!
|
176
|
-
"""
|
152
|
+
And the output should contain "Hello, PaperHouse!"
|
177
153
|
|
178
154
|
Scenario: Automatically rebuild an executable when dependent library is updated
|
179
155
|
Given the current project directory is "examples/shared_library"
|
@@ -181,10 +157,7 @@ Feature: PaperHouse::SharedLibraryTask
|
|
181
157
|
And I successfully run `sleep 1`
|
182
158
|
And I successfully run `touch libhello.so.0`
|
183
159
|
When I successfully run `rake hello`
|
184
|
-
Then the output should contain
|
185
|
-
"""
|
186
|
-
gcc -o ./hello ./main.o -L. -lhello
|
187
|
-
"""
|
160
|
+
Then the output should contain "gcc -o ./hello ./main.o -L. -lhello"
|
188
161
|
|
189
162
|
Scenario: Clean
|
190
163
|
Given the current project directory is "examples/shared_library"
|
@@ -7,80 +7,68 @@ Feature: PaperHouse::StaticLibraryTask
|
|
7
7
|
|
8
8
|
Scenario: Build a static library from one *.c and *.h file
|
9
9
|
Given the current project directory is "examples/static_library"
|
10
|
-
When I
|
11
|
-
Then the
|
10
|
+
When I run rake "hello"
|
11
|
+
Then the stderr should contain:
|
12
12
|
"""
|
13
13
|
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
14
|
-
gcc -H -fPIC -I. -c main.c -o ./main.o
|
15
14
|
ar -cq ./libhello.a ./hello.o
|
16
15
|
ranlib ./libhello.a
|
16
|
+
gcc -H -fPIC -I. -c main.c -o ./main.o
|
17
17
|
gcc -o ./hello ./main.o -L. -lhello
|
18
18
|
"""
|
19
19
|
And a file named "libhello.a" should exist
|
20
20
|
And a file named "hello" should exist
|
21
21
|
And I successfully run `./hello`
|
22
|
-
And the output should contain
|
23
|
-
"""
|
24
|
-
Hello, PaperHouse!
|
25
|
-
"""
|
22
|
+
And the output should contain "Hello, PaperHouse!"
|
26
23
|
|
27
24
|
Scenario: Build a static library from one *.c and *.h file using llvm-gcc by specifying `CC=` option
|
28
25
|
Given the current project directory is "examples/static_library"
|
29
|
-
When I
|
30
|
-
Then the
|
26
|
+
When I run rake "hello CC=llvm-gcc"
|
27
|
+
Then the stderr should contain:
|
31
28
|
"""
|
32
29
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
33
|
-
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
34
30
|
ar -cq ./libhello.a ./hello.o
|
35
31
|
ranlib ./libhello.a
|
32
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
36
33
|
llvm-gcc -o ./hello ./main.o -L. -lhello
|
37
34
|
"""
|
38
35
|
And a file named "libhello.a" should exist
|
39
36
|
And a file named "hello" should exist
|
40
37
|
And I successfully run `./hello`
|
41
|
-
And the output should contain
|
42
|
-
"""
|
43
|
-
Hello, PaperHouse!
|
44
|
-
"""
|
38
|
+
And the output should contain "Hello, PaperHouse!"
|
45
39
|
|
46
40
|
Scenario: Build a static library from one *.c and *.h file using llvm-gcc
|
47
41
|
Given the current project directory is "examples/static_library"
|
48
|
-
When I
|
49
|
-
Then the
|
42
|
+
When I run rake "-f Rakefile.llvm hello"
|
43
|
+
Then the stderr should contain:
|
50
44
|
"""
|
51
45
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
52
|
-
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
53
46
|
ar -cq ./libhello.a ./hello.o
|
54
47
|
ranlib ./libhello.a
|
48
|
+
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
|
55
49
|
llvm-gcc -o ./hello ./main.o -L. -lhello
|
56
50
|
"""
|
57
51
|
And a file named "libhello.a" should exist
|
58
52
|
And a file named "hello" should exist
|
59
53
|
And I successfully run `./hello`
|
60
|
-
And the output should contain
|
61
|
-
"""
|
62
|
-
Hello, PaperHouse!
|
63
|
-
"""
|
54
|
+
And the output should contain "Hello, PaperHouse!"
|
64
55
|
|
65
56
|
Scenario: Build a static library from multiple *.c and *.h files in subcirectories
|
66
57
|
Given the current project directory is "examples/static_library_subdirs"
|
67
|
-
When I
|
68
|
-
Then the
|
58
|
+
When I run rake "hello"
|
59
|
+
Then the stderr should contain:
|
69
60
|
"""
|
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
61
|
mkdir -p objects
|
62
|
+
gcc -H -Werror -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
73
63
|
ar -cq objects/libhello.a objects/hello.o
|
74
64
|
ranlib objects/libhello.a
|
65
|
+
gcc -H -fPIC -Iincludes -Isources -c sources/main.c -o ./main.o
|
75
66
|
gcc -o ./hello ./main.o -Lobjects -lhello
|
76
67
|
"""
|
77
68
|
And a file named "objects/libhello.a" should exist
|
78
69
|
And a file named "hello" should exist
|
79
70
|
And I successfully run `./hello`
|
80
|
-
And the output should contain
|
81
|
-
"""
|
82
|
-
Hello, PaperHouse!
|
83
|
-
"""
|
71
|
+
And the output should contain "Hello, PaperHouse!"
|
84
72
|
|
85
73
|
Scenario: Automatically rebuild an executable when dependent library is updated
|
86
74
|
Given the current project directory is "examples/static_library"
|
@@ -88,10 +76,7 @@ Feature: PaperHouse::StaticLibraryTask
|
|
88
76
|
And I successfully run `sleep 1`
|
89
77
|
And I successfully run `touch libhello.a`
|
90
78
|
When I successfully run `rake hello`
|
91
|
-
Then the output should contain
|
92
|
-
"""
|
93
|
-
gcc -o ./hello ./main.o -L. -lhello
|
94
|
-
"""
|
79
|
+
Then the output should contain "gcc -o ./hello ./main.o -L. -lhello"
|
95
80
|
|
96
81
|
Scenario: Clean
|
97
82
|
Given the current project directory is "examples/static_library"
|
@@ -1,8 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
Given(/^the current project directory is "(.*?)"$/) do | dir |
|
4
|
+
example_name = File.basename(dir)
|
2
5
|
in_current_dir do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
FileUtils.cp_r File.join('..', '..', dir), '.'
|
7
|
+
Dir.chdir example_name do
|
8
|
+
system 'rake clobber'
|
9
|
+
FileUtils.rm_r 'objects' if FileTest.exists?('objects')
|
10
|
+
end
|
7
11
|
end
|
12
|
+
step %{I cd to "#{example_name}"}
|
13
|
+
end
|
14
|
+
|
15
|
+
When(/^I run rake "(.*?)"$/) do |args|
|
16
|
+
step "I successfully run `rake #{args} -I../../.. -rrake_simplecov_hook`"
|
8
17
|
end
|
data/features/support/env.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
#
|
2
3
|
# Copyright (C) 2013 NEC Corporation
|
3
4
|
#
|
@@ -15,25 +16,21 @@
|
|
15
16
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
17
|
#
|
17
18
|
|
19
|
+
require 'rubygems'
|
18
20
|
|
19
|
-
require
|
20
|
-
|
21
|
-
require "simplecov"
|
21
|
+
require 'simplecov'
|
22
22
|
SimpleCov.start
|
23
23
|
|
24
|
-
require
|
25
|
-
require
|
26
|
-
|
24
|
+
require 'aruba/cucumber'
|
25
|
+
require 'rake'
|
27
26
|
|
28
|
-
ENV[
|
27
|
+
ENV['LD_LIBRARY_PATH'] = '.'
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
require "coveralls"
|
29
|
+
if ENV['TRAVIS']
|
30
|
+
require 'coveralls'
|
33
31
|
Coveralls.wear_merged!
|
34
32
|
end
|
35
33
|
|
36
|
-
|
37
34
|
### Local variables:
|
38
35
|
### mode: Ruby
|
39
36
|
### coding: utf-8-unix
|
data/features/support/hooks.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
AfterConfiguration do |config|
|
4
|
+
FileUtils.rm_f Dir.glob('tmp/.*_id')
|
5
|
+
end
|
6
|
+
|
1
7
|
Before do
|
2
|
-
ENV[
|
3
|
-
ENV[
|
8
|
+
ENV['CC'] = nil
|
9
|
+
ENV['dragonegg_disable_version_check'] = '1'
|
4
10
|
@aruba_timeout_seconds = 5
|
5
11
|
end
|
6
12
|
|
7
|
-
|
8
13
|
After do
|
9
|
-
ENV[
|
10
|
-
ENV[
|
14
|
+
ENV['CC'] = nil
|
15
|
+
ENV['dragonegg_disable_version_check'] = nil
|
11
16
|
Rake::Task.clear
|
12
17
|
end
|
@@ -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 "paper_house/safe_popen"
|
20
|
-
|
19
|
+
require 'paper_house/safe_popen'
|
21
20
|
|
22
21
|
module PaperHouse
|
23
22
|
#
|
@@ -26,68 +25,64 @@ module PaperHouse
|
|
26
25
|
class AutoDepends
|
27
26
|
attr_reader :data
|
28
27
|
|
29
|
-
|
30
|
-
def initialize c_file, o_file, cc, cc_options
|
28
|
+
def initialize(c_file, o_file, cc, cc_options)
|
31
29
|
@cc = cc
|
32
|
-
@command = "#{
|
30
|
+
@command = "#{@cc} -H #{cc_options} -c #{c_file} -o #{o_file}"
|
33
31
|
@data = []
|
32
|
+
@out = STDERR
|
34
33
|
end
|
35
34
|
|
36
|
-
|
37
35
|
#
|
38
36
|
# Runs dependency detection.
|
39
37
|
#
|
40
38
|
def run
|
41
|
-
puts @command
|
39
|
+
@out.puts @command
|
42
40
|
exit_status = popen_command
|
43
|
-
|
41
|
+
fail "#{@cc} failed" if exit_status != 0
|
44
42
|
end
|
45
43
|
|
46
|
-
|
47
|
-
############################################################################
|
48
44
|
private
|
49
|
-
############################################################################
|
50
|
-
|
51
45
|
|
52
46
|
def popen_command
|
53
|
-
SafePopen.popen(
|
47
|
+
SafePopen.popen(@command) do |stdout, stderr, stdin, |
|
54
48
|
stdin.close
|
55
49
|
parse_cc_h_stderr stderr
|
56
50
|
end.exitstatus
|
57
51
|
end
|
58
52
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
parse_cc_h_stderr_line( each, stderr )
|
53
|
+
def parse_cc_h_stderr(stderr)
|
54
|
+
stderr.each do |each|
|
55
|
+
parse_cc_h_stderr_line(each, stderr)
|
63
56
|
end
|
64
57
|
end
|
65
58
|
|
66
|
-
|
67
|
-
def parse_cc_h_stderr_line line, stderr
|
59
|
+
def parse_cc_h_stderr_line(line, stderr)
|
68
60
|
case line
|
69
61
|
when /^\./
|
70
|
-
|
62
|
+
extract_header_path_from line
|
71
63
|
when /Multiple include guards/
|
72
64
|
filter_out_include_guards_warnings stderr
|
73
65
|
else
|
74
|
-
puts line
|
66
|
+
@out.puts line
|
75
67
|
end
|
76
68
|
end
|
77
69
|
|
70
|
+
def extract_header_path_from(line)
|
71
|
+
@data << line.sub(/^\.+\s+/, '').strip
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
78
75
|
|
79
|
-
def filter_out_include_guards_warnings
|
80
|
-
stderr.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
76
|
+
def filter_out_include_guards_warnings(stderr)
|
77
|
+
stderr.each_line do |each|
|
78
|
+
next unless each =~ /:$/
|
79
|
+
@out.puts each
|
80
|
+
return
|
85
81
|
end
|
86
82
|
end
|
87
83
|
end
|
88
84
|
end
|
89
85
|
|
90
|
-
|
91
86
|
### Local variables:
|
92
87
|
### mode: Ruby
|
93
88
|
### coding: utf-8-unix
|