paper_house 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -0
  5. data/CONTRIBUTING.md +12 -0
  6. data/Gemfile +24 -25
  7. data/Guardfile +1 -7
  8. data/README.md +10 -10
  9. data/Rakefile +54 -65
  10. data/examples/executable/Rakefile +3 -1
  11. data/examples/executable_subdirs/Rakefile +8 -6
  12. data/examples/{c_extension → ruby_extension}/.gitignore +0 -0
  13. data/examples/ruby_extension/Rakefile +5 -0
  14. data/examples/ruby_extension/Rakefile.llvm +5 -0
  15. data/examples/{c_extension → ruby_extension}/hello.c +0 -0
  16. data/examples/shared_library/Rakefile +17 -11
  17. data/examples/shared_library/Rakefile.llvm +11 -5
  18. data/examples/shared_library_subdirs/Rakefile +16 -15
  19. data/examples/static_library/Rakefile +6 -5
  20. data/examples/static_library_subdirs/Rakefile +11 -9
  21. data/features/executable_task.feature +15 -27
  22. data/features/{c_extension_task.feature → ruby_extension_task.feature} +30 -48
  23. data/features/shared_library_task.feature +33 -60
  24. data/features/static_library_task.feature +18 -33
  25. data/features/step_definitions/paper_house_steps.rb +13 -4
  26. data/features/support/env.rb +8 -11
  27. data/features/support/hooks.rb +10 -5
  28. data/lib/paper_house/auto_depends.rb +24 -29
  29. data/lib/paper_house/build_task.rb +49 -75
  30. data/lib/paper_house/cc_options.rb +7 -17
  31. data/lib/paper_house/dependency.rb +12 -21
  32. data/lib/paper_house/executable_task.rb +12 -22
  33. data/lib/paper_house/library_task.rb +13 -15
  34. data/lib/paper_house/linker_options.rb +14 -24
  35. data/lib/paper_house/platform.rb +15 -24
  36. data/lib/paper_house/{c_extension_task.rb → ruby_extension_task.rb} +15 -35
  37. data/lib/paper_house/safe_popen.rb +4 -6
  38. data/lib/paper_house/shared_library_task.rb +14 -28
  39. data/lib/paper_house/static_library_task.rb +6 -15
  40. data/lib/paper_house/version.rb +2 -3
  41. data/lib/paper_house.rb +6 -7
  42. data/paper_house.gemspec +17 -19
  43. data/rake_simplecov_hook.rb +24 -0
  44. data/rubocop-todo.yml +6 -0
  45. data/spec/paper_house/executable_task_spec.rb +65 -20
  46. data/spec/paper_house/ruby_extension_task_spec.rb +129 -0
  47. data/spec/paper_house/shared_library_task_spec.rb +124 -49
  48. data/spec/paper_house/static_library_task_spec.rb +81 -27
  49. data/spec/paper_house/version_spec.rb +5 -5
  50. data/spec/spec_helper.rb +8 -13
  51. metadata +17 -15
  52. data/examples/c_extension/Rakefile +0 -3
  53. data/examples/c_extension/Rakefile.llvm +0 -5
  54. data/examples/shared_library/symlinks.rake +0 -7
  55. data/spec/paper_house/c_extension_task_spec.rb +0 -59
  56. 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: 83d636e710a9e46668564e002ac98bbc9f3cd631
4
- data.tar.gz: b2e2476518e7525c286218e44ba056eb794d133b
3
+ metadata.gz: cd32bc848ebfef5fba3838600d62f9f04ed847f0
4
+ data.tar.gz: 7d0c0cb2a9c5ef813d209c659f1b4885bb0cc21b
5
5
  SHA512:
6
- metadata.gz: ef8b24154b40f9e0e97ef8ee5baf2a166eb5e6b2141b29814fa781fae330ac3c31519da6aed8382e337115c72ae3318ecee3a4b24d0dea19c82716f013786773
7
- data.tar.gz: 11c1e1ef0198a2f013f1a7a914ed563332a4a28c945c8a42a1cdaf011295cd82811ecb760acbe286a31c17eeb6f8e3e16e009f922e2c6ebbf0585404dae37049
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
@@ -3,6 +3,7 @@ language: ruby
3
3
  script: "rake travis"
4
4
 
5
5
  rvm:
6
+ - 1.8.7
6
7
  - 1.9.3
7
8
  - 2.0.0
8
9
 
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 "https://rubygems.org"
2
-
1
+ source 'https://rubygems.org'
3
2
 
4
3
  gemspec
5
4
 
6
-
7
5
  group :development do
8
- gem "aruba", "~> 0.5.3"
9
- gem "coveralls", "~> 0.7.0", :require => false
10
- gem "cucumber", "~> 1.3.8"
11
- gem "flay", "~> 2.4.0"
12
- gem "flog", "~> 4.1.2"
13
- gem "fuubar", "~> 1.2.1"
14
- gem "guard", "~> 1.8.3"
15
- gem "guard-bundler", "~> 1.0.0"
16
- gem "guard-cucumber", "~> 1.4.0"
17
- gem "guard-rspec", "~> 3.1.0"
18
- gem "rb-fchange", "~> 0.0.6", :require => false
19
- gem "rb-fsevent", "~> 0.9.3", :require => false
20
- gem "rb-inotify", "~> 0.9.2", :require => false
21
- gem "redcarpet", "~> 2.3.0" if RUBY_VERSION < "1.9.0"
22
- gem "redcarpet", "~> 3.0.0" if RUBY_VERSION >= "1.9.0"
23
- gem "reek", "~> 1.3.3"
24
- gem "relish", "~> 0.7"
25
- gem "rspec", "~> 2.14.1"
26
- gem "rspec-instafail", "~> 0.2.4"
27
- gem "terminal-notifier-guard", "~> 1.5.3"
28
- gem "yard", "~> 0.8.7.2"
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 :bundler do
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
- * [C extension for Ruby](http://rubydoc.info/github/trema/paper-house/PaperHouse/CExtensionTask)
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 | 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 = [ "-Werror", "-Wall", "-Wextra" ]
58
- task.ldflags = "-L/some/path"
59
- task.library_dependencies = "m"
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 "bundler/gem_tasks"
20
- require "coveralls/rake/task"
21
- require "flay"
22
- require "flay_task"
23
- require "flog"
24
- require "rake/tasklib"
25
- require "reek/rake/task"
26
- require "rspec/core"
27
- require "rspec/core/rake_task"
28
- require "yaml"
29
- require "yard"
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 => [ :spec, :cucumber, :quality, "coveralls:push" ]
37
- task :quality => [ :reek, :flog, :flay ]
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
- require "cucumber/rake/task"
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 "paper_house/platform"
43
+ require 'paper_house/platform'
50
44
  if PaperHouse::Platform::MAC
51
- profile << "mac"
45
+ profile << 'mac'
52
46
  else
53
- profile << "linux"
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 = [ "-rubygems" ]
63
- t.reek_opts = "--quiet"
64
- t.source_files = $ruby_source
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( :continue => true )
71
- flog.flog( *$ruby_source )
62
+ flog = Flog.new(:continue => true)
63
+ flog.flog(*ruby_source)
72
64
  threshold = 10
73
65
 
74
- bad_methods = flog.totals.select do | name, score |
75
- ( not ( /##{flog.no_method}$/=~ name ) ) and score > threshold
66
+ bad_methods = flog.totals.select do |name, score|
67
+ !(/##{flog.no_method}$/ =~ name) && score > threshold
76
68
  end
77
- bad_methods.sort do | a, b |
78
- a[ 1 ] <=> b[ 1 ]
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
- raise "#{ bad_methods.size } methods have a flog complexity > #{ threshold }"
73
+ fail "#{bad_methods.size} methods have a flog complexity > #{threshold}"
84
74
  end
85
75
  end
86
76
 
87
-
88
- FlayTask.new do | t |
89
- t.dirs = $ruby_source.collect do | each |
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 = $trace
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 "relish push trema/paper-house"
92
+ sh 'relish push trema/paper-house'
99
93
  end
100
94
 
101
-
102
- YARD::Rake::YardocTask.new do | t |
103
- t.options = [ "--no-private" ]
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( __FILE__ ), ".travis.yml"
101
+ File.join File.dirname(__FILE__), '.travis.yml'
110
102
  end
111
103
 
112
-
113
104
  def rubies
114
- ( [ "1.8.7" ] + YAML.load_file( travis_yml )[ "rvm" ] ).uniq.sort
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 | each |
122
- portability_task_name = "portability:#{ each }"
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#{ each }"
115
+ desc "Run tests against Ruby#{each}"
126
116
  task portability_task_name do
127
- sh "rvm #{ each } exec bundle"
128
- sh "rvm #{ each } exec bundle exec rake"
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,3 +1,5 @@
1
- require "paper_house"
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'paper_house'
2
4
 
3
5
  PaperHouse::ExecutableTask.new :hello
@@ -1,9 +1,11 @@
1
- require "paper_house"
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'paper_house'
2
4
 
3
5
  PaperHouse::ExecutableTask.new :hello do | task |
4
- task.executable_name = "hello"
5
- task.target_directory = "objects"
6
- task.sources = "sources/*.c"
7
- task.includes = "includes"
8
- task.cflags = [ "-Wall", "-Wextra" ]
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
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'paper_house'
4
+
5
+ PaperHouse::RubyExtensionTask.new :hello
@@ -0,0 +1,5 @@
1
+ require "paper_house"
2
+
3
+ PaperHouse::RubyExtensionTask.new :hello do |task|
4
+ task.cc = "llvm-gcc"
5
+ end
File without changes
@@ -1,17 +1,23 @@
1
- require "paper_house"
1
+ # -*- coding: utf-8 -*-
2
2
 
3
- $libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
4
- task.version = "0.1.0"
5
- task.sources = "hello.c"
6
- task.library_dependencies = "m" # not used.
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 => [ :libhello, $libhello.linker_name, $libhello.soname ]
18
+ task :hello => [:libhello, libhello.linker_name, libhello.soname]
11
19
 
12
- PaperHouse::ExecutableTask.new :hello do | task |
13
- task.sources = "main.c"
14
- task.ldflags = "-L."
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
- $libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
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 => [ :libhello, $libhello.linker_name, $libhello.soname ]
19
+ task :hello => [:libhello, libhello.linker_name, libhello.soname]
12
20
 
13
- PaperHouse::ExecutableTask.new :hello do | task |
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
- require "paper_house"
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'paper_house'
2
4
 
3
5
  libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
4
- task.library_name = "hello"
5
- task.version = "0.1.0"
6
- task.target_directory = "objects"
7
- task.sources = "sources/hello.c"
8
- task.includes = "includes"
9
- task.cflags = [ "-Werror", "-Wall", "-Wextra" ]
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 = "sources/main.c"
17
- task.includes = "includes"
18
- task.ldflags = "-L."
17
+ task.sources = 'sources/main.c'
18
+ task.includes = 'includes'
19
+ task.ldflags = '-L.'
19
20
  end
20
21
 
21
- [ libhello.linker_name, libhello.soname ].each do | each |
22
+ [libhello.linker_name, libhello.soname].each do | each |
22
23
  file each do | task |
23
- symlink File.join( "objects", libhello.target_file_name ), task.name
24
+ symlink File.join('objects', libhello.target_file_name), task.name
24
25
  end
25
26
 
26
- CLOBBER.include each if FileTest.exists?( each )
27
+ CLOBBER.include each if FileTest.exists?(each)
27
28
  end
@@ -1,13 +1,14 @@
1
- require "paper_house"
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 = "hello.c"
8
+ task.sources = 'hello.c'
7
9
  end
8
10
 
9
-
10
11
  PaperHouse::ExecutableTask.new :hello do | task |
11
- task.ldflags = "-L."
12
- task.sources = "main.c"
12
+ task.ldflags = '-L.'
13
+ task.sources = 'main.c'
13
14
  end
@@ -1,17 +1,19 @@
1
- require "paper_house"
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 = "hello"
7
- task.target_directory = "objects"
8
- task.sources = "sources/hello.c"
9
- task.includes = "includes"
10
- task.cflags = [ "-Werror", "-Wall", "-Wextra" ]
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 = "sources/main.c"
15
- task.includes = "includes"
16
- task.ldflags = "-Lobjects"
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 successfully run `rake hello`
10
- Then the output should contain:
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 successfully run `rake hello CC=llvm-gcc`
25
- Then the output should contain:
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 successfully run `rake -f Rakefile.llvm hello`
40
- Then the output should contain:
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 successfully run `rake hello`
55
- Then the output should contain:
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"