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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd32bc848ebfef5fba3838600d62f9f04ed847f0
|
4
|
+
data.tar.gz: 7d0c0cb2a9c5ef813d209c659f1b4885bb0cc21b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f2b002f1b9348348016771fdeec488408239653d6cca002fa0d149ec122e18aa650046fc9042f7069c3b564f5a39a3d9a62d11e5249f38b375c4b5c761ade88
|
7
|
+
data.tar.gz: d792a1b063b989e139471c2ab718a2afa5ae2239261be1cab9825072ac2770d86d46ec57b8c6105c6fd563d7e3dfc7f30fa13ffa5f72b95dc321c7ab49b677fd
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: rubocop-todo.yml
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
CHANGED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Contributing to PaperHouse
|
2
|
+
|
3
|
+
* Check out the latest develop to make sure the feature hasn't been
|
4
|
+
implemented or the bug hasn't been fixed yet.
|
5
|
+
* Check out the issue tracker to make sure someone already hasn't
|
6
|
+
requested it and/or contributed it.
|
7
|
+
* Fork the project.
|
8
|
+
* Commit and push until you are happy with your contribution.
|
9
|
+
* Make sure to add tests for it. This is important so I don't break it
|
10
|
+
in a future version unintentionally.
|
11
|
+
* Squash your commits.
|
12
|
+
* Create a pull-request.
|
data/Gemfile
CHANGED
@@ -1,34 +1,33 @@
|
|
1
|
-
source
|
2
|
-
|
1
|
+
source 'https://rubygems.org'
|
3
2
|
|
4
3
|
gemspec
|
5
4
|
|
6
|
-
|
7
5
|
group :development do
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem
|
17
|
-
gem
|
18
|
-
gem
|
19
|
-
gem
|
20
|
-
gem
|
21
|
-
gem
|
22
|
-
gem
|
23
|
-
gem
|
24
|
-
gem
|
25
|
-
gem
|
26
|
-
gem
|
27
|
-
gem
|
28
|
-
gem
|
6
|
+
gem 'aruba', '~> 0.5.3'
|
7
|
+
gem 'coveralls', '~> 0.7.0', :require => false
|
8
|
+
gem 'cucumber', '~> 1.3.8'
|
9
|
+
gem 'flay', '~> 2.4.0'
|
10
|
+
gem 'flog', '~> 4.1.2'
|
11
|
+
gem 'fuubar', '~> 1.2.1'
|
12
|
+
gem 'guard', '~> 1.8.3' if RUBY_VERSION < '1.9.0'
|
13
|
+
gem 'guard', '~> 2.0.5' if RUBY_VERSION >= '1.9.0'
|
14
|
+
gem 'guard-cucumber', '~> 1.4.0'
|
15
|
+
gem 'guard-rspec', '~> 3.1.0' if RUBY_VERSION < '1.9.0'
|
16
|
+
gem 'guard-rspec', '~> 4.0.1' if RUBY_VERSION >= '1.9.0'
|
17
|
+
gem 'rb-fchange', '~> 0.0.6', :require => false
|
18
|
+
gem 'rb-fsevent', '~> 0.9.3', :require => false
|
19
|
+
gem 'rb-inotify', '~> 0.9.2', :require => false
|
20
|
+
gem 'redcarpet', '~> 2.3.0' if RUBY_VERSION < '1.9.0'
|
21
|
+
gem 'redcarpet', '~> 3.0.0' if RUBY_VERSION >= '1.9.0'
|
22
|
+
gem 'reek', '~> 1.3.3'
|
23
|
+
gem 'relish', '~> 0.7'
|
24
|
+
gem 'rspec', '~> 2.14.1'
|
25
|
+
gem 'rspec-instafail', '~> 0.2.4'
|
26
|
+
gem 'rubocop', '~> 0.14.1' if RUBY_VERSION >= '1.9.0'
|
27
|
+
gem 'terminal-notifier-guard', '~> 1.5.3'
|
28
|
+
gem 'yard', '~> 0.8.7.2'
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
31
|
### Local variables:
|
33
32
|
### mode: Ruby
|
34
33
|
### coding: utf-8-unix
|
data/Guardfile
CHANGED
@@ -4,13 +4,7 @@ notification :terminal_notifier
|
|
4
4
|
notification :tmux, :display_message => true
|
5
5
|
|
6
6
|
|
7
|
-
guard :
|
8
|
-
watch('Gemfile')
|
9
|
-
watch(/^.+\.gemspec/)
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
guard :rspec, :cli => "--color -r rspec/instafail -f RSpec::Instafail", :all_on_start => false do
|
7
|
+
guard :rspec, :cmd => "rspec --color -r rspec/instafail -f RSpec::Instafail", :all_on_start => false do
|
14
8
|
watch(%r{^spec/paper_house/.+_spec\.rb$})
|
15
9
|
watch(%r{^lib/paper_house/(.+)\.rb$}) { |m| "spec/paper_house/#{m[1]}_spec.rb" }
|
16
10
|
watch('spec/spec_helper.rb') { "spec" }
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Paper House is a ruby gem to easily build C projects using [Rake](https://github
|
|
13
13
|
* [Executable](http://rubydoc.info/github/trema/paper-house/PaperHouse/ExecutableTask)
|
14
14
|
* [Static library](http://rubydoc.info/github/trema/paper-house/PaperHouse/StaticLibraryTask)
|
15
15
|
* [Shared library](http://rubydoc.info/github/trema/paper-house/PaperHouse/SharedLibraryTask)
|
16
|
-
* [
|
16
|
+
* [Ruby extension written in C](http://rubydoc.info/github/trema/paper-house/PaperHouse/RubyExtensionTask)
|
17
17
|
|
18
18
|
|
19
19
|
Features Overview
|
@@ -48,15 +48,15 @@ If you wish to customize the build process more, please set the
|
|
48
48
|
following options defined in `PaperHouse::ExecutableTask`:
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
PaperHouse::ExecutableTask.new :hello do |
|
52
|
-
task.executable_name =
|
53
|
-
task.target_directory =
|
54
|
-
task.cc =
|
55
|
-
task.includes =
|
56
|
-
task.sources =
|
57
|
-
task.cflags =
|
58
|
-
task.ldflags =
|
59
|
-
task.library_dependencies =
|
51
|
+
PaperHouse::ExecutableTask.new :hello do |task|
|
52
|
+
task.executable_name = 'hello_world'
|
53
|
+
task.target_directory = 'objects'
|
54
|
+
task.cc = 'llvm-gcc'
|
55
|
+
task.includes = 'includes'
|
56
|
+
task.sources = 'sources'
|
57
|
+
task.cflags = %w(-Werror -Wall -Wextra)
|
58
|
+
task.ldflags = '-L/some/path'
|
59
|
+
task.library_dependencies = 'm'
|
60
60
|
end
|
61
61
|
```
|
62
62
|
|
data/Rakefile
CHANGED
@@ -15,121 +15,110 @@
|
|
15
15
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
16
|
#
|
17
17
|
|
18
|
-
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
$ruby_source = FileList[ "lib/**/*.rb" ]
|
33
|
-
|
18
|
+
require 'bundler/gem_tasks'
|
19
|
+
require 'coveralls/rake/task'
|
20
|
+
require 'flay'
|
21
|
+
require 'flay_task'
|
22
|
+
require 'flog'
|
23
|
+
require 'rake/tasklib'
|
24
|
+
require 'reek/rake/task'
|
25
|
+
require 'rspec/core'
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
require 'yaml'
|
28
|
+
require 'yard'
|
29
|
+
|
30
|
+
ruby_source = FileList['lib/**/*.rb']
|
34
31
|
|
35
32
|
task :default => :travis
|
36
|
-
task :travis => [
|
37
|
-
task :quality => [
|
38
|
-
|
33
|
+
task :travis => [:spec, :cucumber, :quality, 'coveralls:push']
|
34
|
+
task :quality => [:reek, :flog, :flay]
|
39
35
|
|
40
36
|
Coveralls::RakeTask.new
|
41
37
|
|
42
|
-
|
43
38
|
RSpec::Core::RakeTask.new
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
Cucumber::Rake::Task.new do | t |
|
40
|
+
require 'cucumber/rake/task'
|
41
|
+
Cucumber::Rake::Task.new do |t|
|
48
42
|
profile = %w(--profile)
|
49
|
-
require
|
43
|
+
require 'paper_house/platform'
|
50
44
|
if PaperHouse::Platform::MAC
|
51
|
-
profile <<
|
45
|
+
profile << 'mac'
|
52
46
|
else
|
53
|
-
profile <<
|
47
|
+
profile << 'linux'
|
54
48
|
end
|
55
|
-
t.cucumber_opts = profile.join(
|
49
|
+
t.cucumber_opts = profile.join(' ')
|
56
50
|
end
|
57
51
|
|
58
|
-
|
59
|
-
Reek::Rake::Task.new do | t |
|
52
|
+
Reek::Rake::Task.new do |t|
|
60
53
|
t.fail_on_error = true
|
61
54
|
t.verbose = false
|
62
|
-
t.ruby_opts = [
|
63
|
-
t.reek_opts =
|
64
|
-
t.source_files =
|
55
|
+
t.ruby_opts = ['-rubygems']
|
56
|
+
t.reek_opts = '--quiet'
|
57
|
+
t.source_files = ruby_source
|
65
58
|
end
|
66
59
|
|
67
|
-
|
68
|
-
desc "Analyze for code complexity"
|
60
|
+
desc 'Analyze for code complexity'
|
69
61
|
task :flog do
|
70
|
-
flog = Flog.new(
|
71
|
-
flog.flog(
|
62
|
+
flog = Flog.new(:continue => true)
|
63
|
+
flog.flog(*ruby_source)
|
72
64
|
threshold = 10
|
73
65
|
|
74
|
-
bad_methods = flog.totals.select do |
|
75
|
-
(
|
66
|
+
bad_methods = flog.totals.select do |name, score|
|
67
|
+
!(/##{flog.no_method}$/ =~ name) && score > threshold
|
76
68
|
end
|
77
|
-
bad_methods.sort
|
78
|
-
|
79
|
-
end.reverse.each do | name, score |
|
80
|
-
puts "%8.1f: %s" % [ score, name ]
|
69
|
+
bad_methods.sort { |a, b| a[1] <=> b[1] }.reverse.each do |name, score|
|
70
|
+
puts sprintf('%8.1f: %s', [score, name])
|
81
71
|
end
|
82
72
|
unless bad_methods.empty?
|
83
|
-
|
73
|
+
fail "#{bad_methods.size} methods have a flog complexity > #{threshold}"
|
84
74
|
end
|
85
75
|
end
|
86
76
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
each[ /[^\/]+/ ]
|
77
|
+
FlayTask.new do |t|
|
78
|
+
t.dirs = ruby_source.map do |each|
|
79
|
+
each[/[^\/]+/]
|
91
80
|
end.uniq
|
92
81
|
t.threshold = 0
|
93
|
-
t.verbose =
|
82
|
+
t.verbose = true
|
94
83
|
end
|
95
84
|
|
85
|
+
if RUBY_VERSION >= '1.9.0'
|
86
|
+
task :quality => :rubocop
|
87
|
+
require 'rubocop/rake_task'
|
88
|
+
Rubocop::RakeTask.new
|
89
|
+
end
|
96
90
|
|
97
91
|
task :relish do
|
98
|
-
sh
|
92
|
+
sh 'relish push trema/paper-house'
|
99
93
|
end
|
100
94
|
|
101
|
-
|
102
|
-
|
103
|
-
t.options
|
104
|
-
t.options << "--debug" << "--verbose" if $trace
|
95
|
+
YARD::Rake::YardocTask.new do |t|
|
96
|
+
t.options = ['--no-private']
|
97
|
+
t.options << '--debug' << '--verbose' if Rake.verbose
|
105
98
|
end
|
106
99
|
|
107
|
-
|
108
100
|
def travis_yml
|
109
|
-
File.join File.dirname(
|
101
|
+
File.join File.dirname(__FILE__), '.travis.yml'
|
110
102
|
end
|
111
103
|
|
112
|
-
|
113
104
|
def rubies
|
114
|
-
(
|
105
|
+
(['1.8.7'] + YAML.load_file(travis_yml)['rvm']).uniq.sort
|
115
106
|
end
|
116
107
|
|
117
|
-
|
118
|
-
desc "Run tests against multiple rubies"
|
108
|
+
desc 'Run tests against multiple rubies'
|
119
109
|
task :portability
|
120
110
|
|
121
|
-
rubies.each do |
|
122
|
-
portability_task_name = "portability:#{
|
111
|
+
rubies.each do |each|
|
112
|
+
portability_task_name = "portability:#{each}"
|
123
113
|
task :portability => portability_task_name
|
124
114
|
|
125
|
-
desc "Run tests against Ruby#{
|
115
|
+
desc "Run tests against Ruby#{each}"
|
126
116
|
task portability_task_name do
|
127
|
-
sh "rvm #{
|
128
|
-
sh "rvm #{
|
117
|
+
sh "rvm #{each} exec bundle"
|
118
|
+
sh "rvm #{each} exec bundle exec rake"
|
129
119
|
end
|
130
120
|
end
|
131
121
|
|
132
|
-
|
133
122
|
### Local variables:
|
134
123
|
### mode: Ruby
|
135
124
|
### coding: utf-8-unix
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'paper_house'
|
2
4
|
|
3
5
|
PaperHouse::ExecutableTask.new :hello do | task |
|
4
|
-
task.executable_name =
|
5
|
-
task.target_directory =
|
6
|
-
task.sources =
|
7
|
-
task.includes =
|
8
|
-
task.cflags =
|
6
|
+
task.executable_name = 'hello'
|
7
|
+
task.target_directory = 'objects'
|
8
|
+
task.sources = 'sources/*.c'
|
9
|
+
task.includes = 'includes'
|
10
|
+
task.cflags = %w(-Wall -Wextra)
|
9
11
|
end
|
File without changes
|
File without changes
|
@@ -1,17 +1,23 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
task.
|
3
|
+
require 'paper_house'
|
4
|
+
|
5
|
+
libhello = PaperHouse::SharedLibraryTask.new :libhello do |task|
|
6
|
+
task.version = '0.1.0'
|
7
|
+
task.sources = 'hello.c'
|
8
|
+
task.library_dependencies = 'm' # not used.
|
7
9
|
end
|
8
10
|
|
11
|
+
[libhello.linker_name, libhello.soname].each do |each|
|
12
|
+
file each do |task|
|
13
|
+
symlink libhello.target_file_name, task.name
|
14
|
+
end
|
15
|
+
CLOBBER.include each if FileTest.exists?(each)
|
16
|
+
end
|
9
17
|
|
10
|
-
task :hello => [
|
18
|
+
task :hello => [:libhello, libhello.linker_name, libhello.soname]
|
11
19
|
|
12
|
-
PaperHouse::ExecutableTask.new :hello do |
|
13
|
-
task.sources =
|
14
|
-
task.ldflags =
|
20
|
+
PaperHouse::ExecutableTask.new :hello do |task|
|
21
|
+
task.sources = 'main.c'
|
22
|
+
task.ldflags = '-L.'
|
15
23
|
end
|
16
|
-
|
17
|
-
load "symlinks.rake"
|
@@ -1,19 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require "paper_house"
|
2
4
|
|
3
|
-
|
5
|
+
libhello = PaperHouse::SharedLibraryTask.new :libhello do |task|
|
4
6
|
task.version = "0.1.0"
|
5
7
|
task.sources = "hello.c"
|
6
8
|
task.cc = "llvm-gcc"
|
7
9
|
task.library_dependencies = "m" # not used.
|
8
10
|
end
|
9
11
|
|
12
|
+
[libhello.linker_name, libhello.soname].each do |each|
|
13
|
+
file each do |task|
|
14
|
+
symlink libhello.target_file_name, task.name
|
15
|
+
end
|
16
|
+
CLOBBER.include each if FileTest.exists?(each)
|
17
|
+
end
|
10
18
|
|
11
|
-
task :hello => [
|
19
|
+
task :hello => [:libhello, libhello.linker_name, libhello.soname]
|
12
20
|
|
13
|
-
PaperHouse::ExecutableTask.new :hello do |
|
21
|
+
PaperHouse::ExecutableTask.new :hello do |task|
|
14
22
|
task.sources = "main.c"
|
15
23
|
task.cc = "llvm-gcc"
|
16
24
|
task.ldflags = "-L."
|
17
25
|
end
|
18
|
-
|
19
|
-
load "symlinks.rake"
|
@@ -1,27 +1,28 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'paper_house'
|
2
4
|
|
3
5
|
libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
|
4
|
-
task.library_name =
|
5
|
-
task.version =
|
6
|
-
task.target_directory =
|
7
|
-
task.sources =
|
8
|
-
task.includes =
|
9
|
-
task.cflags =
|
6
|
+
task.library_name = 'hello'
|
7
|
+
task.version = '0.1.0'
|
8
|
+
task.target_directory = 'objects'
|
9
|
+
task.sources = 'sources/hello.c'
|
10
|
+
task.includes = 'includes'
|
11
|
+
task.cflags = %w(-Werror -Wall -Wextra)
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
task :hello => [ :libhello, libhello.linker_name, libhello.soname ]
|
14
|
+
task :hello => [:libhello, libhello.linker_name, libhello.soname]
|
14
15
|
|
15
16
|
PaperHouse::ExecutableTask.new :hello do | task |
|
16
|
-
task.sources =
|
17
|
-
task.includes =
|
18
|
-
task.ldflags =
|
17
|
+
task.sources = 'sources/main.c'
|
18
|
+
task.includes = 'includes'
|
19
|
+
task.ldflags = '-L.'
|
19
20
|
end
|
20
21
|
|
21
|
-
[
|
22
|
+
[libhello.linker_name, libhello.soname].each do | each |
|
22
23
|
file each do | task |
|
23
|
-
symlink File.join(
|
24
|
+
symlink File.join('objects', libhello.target_file_name), task.name
|
24
25
|
end
|
25
26
|
|
26
|
-
CLOBBER.include each if FileTest.exists?(
|
27
|
+
CLOBBER.include each if FileTest.exists?(each)
|
27
28
|
end
|
@@ -1,13 +1,14 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'paper_house'
|
2
4
|
|
3
5
|
task :hello => :libhello
|
4
6
|
|
5
7
|
PaperHouse::StaticLibraryTask.new :libhello do | task |
|
6
|
-
task.sources =
|
8
|
+
task.sources = 'hello.c'
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
11
|
PaperHouse::ExecutableTask.new :hello do | task |
|
11
|
-
task.ldflags =
|
12
|
-
task.sources =
|
12
|
+
task.ldflags = '-L.'
|
13
|
+
task.sources = 'main.c'
|
13
14
|
end
|
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'paper_house'
|
2
4
|
|
3
5
|
task :hello => :libhello
|
4
6
|
|
5
7
|
PaperHouse::StaticLibraryTask.new :libhello do | task |
|
6
|
-
task.library_name =
|
7
|
-
task.target_directory =
|
8
|
-
task.sources =
|
9
|
-
task.includes =
|
10
|
-
task.cflags =
|
8
|
+
task.library_name = 'hello'
|
9
|
+
task.target_directory = 'objects'
|
10
|
+
task.sources = 'sources/hello.c'
|
11
|
+
task.includes = 'includes'
|
12
|
+
task.cflags = %w(-Werror -Wall -Wextra)
|
11
13
|
end
|
12
14
|
|
13
15
|
PaperHouse::ExecutableTask.new :hello do | task |
|
14
|
-
task.sources =
|
15
|
-
task.includes =
|
16
|
-
task.ldflags =
|
16
|
+
task.sources = 'sources/main.c'
|
17
|
+
task.includes = 'includes'
|
18
|
+
task.ldflags = '-Lobjects'
|
17
19
|
end
|
@@ -6,65 +6,53 @@ Feature: PaperHouse::ExecutableTask
|
|
6
6
|
|
7
7
|
Scenario: Build an executable from one *.c file
|
8
8
|
Given the current project directory is "examples/executable"
|
9
|
-
When I
|
10
|
-
Then the
|
9
|
+
When I run rake "hello"
|
10
|
+
Then the stderr should contain:
|
11
11
|
"""
|
12
12
|
gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
13
13
|
gcc -o ./hello ./hello.o
|
14
14
|
"""
|
15
15
|
And a file named "hello" should exist
|
16
16
|
And I successfully run `./hello`
|
17
|
-
And the output should contain
|
18
|
-
"""
|
19
|
-
Hello, PaperHouse!
|
20
|
-
"""
|
17
|
+
And the output should contain "Hello, PaperHouse!"
|
21
18
|
|
22
19
|
Scenario: Build an executable from one *.c file using llvm-gcc by specifying `CC=` option
|
23
20
|
Given the current project directory is "examples/executable"
|
24
|
-
When I
|
25
|
-
Then the
|
21
|
+
When I run rake "hello CC=llvm-gcc"
|
22
|
+
Then the stderr should contain:
|
26
23
|
"""
|
27
24
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
28
25
|
llvm-gcc -o ./hello ./hello.o
|
29
26
|
"""
|
30
27
|
And a file named "hello" should exist
|
31
28
|
And I successfully run `./hello`
|
32
|
-
And the output should contain
|
33
|
-
|
34
|
-
Hello, PaperHouse!
|
35
|
-
"""
|
36
|
-
|
29
|
+
And the output should contain "Hello, PaperHouse!"
|
30
|
+
|
37
31
|
Scenario: Build an executable from one *.c file using llvm-gcc
|
38
32
|
Given the current project directory is "examples/executable"
|
39
|
-
When I
|
40
|
-
Then the
|
33
|
+
When I run rake "-f Rakefile.llvm hello"
|
34
|
+
Then the stderr should contain:
|
41
35
|
"""
|
42
36
|
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
|
43
37
|
llvm-gcc -o ./hello ./hello.o
|
44
38
|
"""
|
45
39
|
And a file named "hello" should exist
|
46
40
|
And I successfully run `./hello`
|
47
|
-
And the output should contain
|
48
|
-
|
49
|
-
Hello, PaperHouse!
|
50
|
-
"""
|
51
|
-
|
41
|
+
And the output should contain "Hello, PaperHouse!"
|
42
|
+
|
52
43
|
Scenario: Build an executable from multiple *.c and *.h files in subdirectories
|
53
44
|
Given the current project directory is "examples/executable_subdirs"
|
54
|
-
When I
|
55
|
-
Then the
|
45
|
+
When I run rake "hello"
|
46
|
+
Then the stderr should contain:
|
56
47
|
"""
|
48
|
+
mkdir -p objects
|
57
49
|
gcc -H -Wall -Wextra -fPIC -Iincludes -Isources -c sources/hello.c -o objects/hello.o
|
58
50
|
gcc -H -Wall -Wextra -fPIC -Iincludes -Isources -c sources/main.c -o objects/main.o
|
59
|
-
mkdir -p objects
|
60
51
|
gcc -o objects/hello objects/hello.o objects/main.o
|
61
52
|
"""
|
62
53
|
And a file named "objects/hello" should exist
|
63
54
|
And I successfully run `./objects/hello`
|
64
|
-
And the output should contain
|
65
|
-
"""
|
66
|
-
Hello, PaperHouse!
|
67
|
-
"""
|
55
|
+
And the output should contain "Hello, PaperHouse!"
|
68
56
|
|
69
57
|
Scenario: Clean
|
70
58
|
Given the current project directory is "examples/executable"
|