Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Jul 19, 2013
2 parents 7de0939 + cf32898 commit 11865a2
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 157 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -14,7 +14,6 @@ group :development do
gem "guard-bundler", "~> 1.0.0"
gem "guard-cucumber", "~> 1.4.0"
gem "guard-rspec", "~> 3.0.2"
gem "guard-spork", "~> 1.5.1"
gem "rb-fchange", "~> 0.0.6", :require => false
gem "rb-fsevent", "~> 0.9.3", :require => false
gem "rb-inotify", "~> 0.9.0", :require => false
Expand Down
22 changes: 4 additions & 18 deletions Guardfile
@@ -1,21 +1,12 @@
# More info at https://github.com/guard/guard#readme


guard 'bundler' do
guard :bundler do
watch('Gemfile')
watch(/^.+\.gemspec/)
end


guard 'spork' do
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch(%r{features/support/}) { :cucumber }
end


guard 'rspec', :cli => "--color --drb -r rspec/instafail -f RSpec::Instafail", :rvm => [ "1.8.7", "1.9.3", "2.0.0" ], :all_on_start => false do
guard :rspec, :cli => "--color -r rspec/instafail -f RSpec::Instafail", :all_on_start => false do
watch(%r{^spec/paper-house/.+_spec\.rb$})
watch(%r{^lib/paper-house/(.+)\.rb$}) { |m| "spec/paper-house/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
Expand All @@ -24,14 +15,9 @@ end

require "paper-house/platform"

cli_opts = %w(--format progress --strict --profile)
if PaperHouse::Platform::MAC
cli_opts << "mac"
else
cli_opts << "linux"
end
cli_opts = %w(--format progress --strict --profile) + [ PaperHouse::Platform::MAC ? "mac" : "linux" ]

guard 'cucumber', :cli => cli_opts.join( " " ), :rvm => [ "1.8.7", "1.9.3", "2.0.0" ], :all_on_start => false do
guard :cucumber, :cli => cli_opts.join( " " ), :all_on_start => false do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
Expand Down
1 change: 1 addition & 0 deletions examples/shared_library/Rakefile
Expand Up @@ -3,6 +3,7 @@ require "paper-house"
$libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
task.version = "0.1.0"
task.sources = "hello.c"
task.library_dependencies = "m" # not used.
end


Expand Down
1 change: 1 addition & 0 deletions examples/shared_library/Rakefile.llvm
Expand Up @@ -4,6 +4,7 @@ $libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
task.version = "0.1.0"
task.sources = "hello.c"
task.cc = "llvm-gcc"
task.library_dependencies = "m" # not used.
end


Expand Down
12 changes: 6 additions & 6 deletions features/shared_library_task.feature
Expand Up @@ -13,7 +13,7 @@ Feature: PaperHouse::SharedLibraryTask
"""
gcc -H -fPIC -I. -c hello.c -o ./hello.o
gcc -H -fPIC -I. -c main.c -o ./main.o
gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o
gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
ln -s libhello.so.0.1.0 libhello.so
ln -s libhello.so.0.1.0 libhello.so.0
gcc -o ./hello ./main.o -L. -lhello
Expand All @@ -34,7 +34,7 @@ Feature: PaperHouse::SharedLibraryTask
"""
gcc -H -fPIC -I. -c hello.c -o ./hello.o
gcc -H -fPIC -I. -c main.c -o ./main.o
gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o
gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
ln -s libhello.so.0.1.0 libhello.so
ln -s libhello.so.0.1.0 libhello.so.0
gcc -o ./hello ./main.o -L. -lhello
Expand All @@ -55,7 +55,7 @@ Feature: PaperHouse::SharedLibraryTask
"""
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
ln -s libhello.so.0.1.0 libhello.so
ln -s libhello.so.0.1.0 libhello.so.0
llvm-gcc -o ./hello ./main.o -L. -lhello
Expand All @@ -76,7 +76,7 @@ Feature: PaperHouse::SharedLibraryTask
"""
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
ln -s libhello.so.0.1.0 libhello.so
ln -s libhello.so.0.1.0 libhello.so.0
llvm-gcc -o ./hello ./main.o -L. -lhello
Expand All @@ -97,7 +97,7 @@ Feature: PaperHouse::SharedLibraryTask
"""
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o
llvm-gcc -shared -Wl,-soname,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
ln -s libhello.so.0.1.0 libhello.so
ln -s libhello.so.0.1.0 libhello.so.0
llvm-gcc -o ./hello ./main.o -L. -lhello
Expand All @@ -118,7 +118,7 @@ Feature: PaperHouse::SharedLibraryTask
"""
llvm-gcc -H -fPIC -I. -c hello.c -o ./hello.o
llvm-gcc -H -fPIC -I. -c main.c -o ./main.o
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o
llvm-gcc -shared -Wl,-install_name,libhello.so.0 -o ./libhello.so.0.1.0 ./hello.o -lm
ln -s libhello.so.0.1.0 libhello.so
ln -s libhello.so.0.1.0 libhello.so.0
llvm-gcc -o ./hello ./main.o -L. -lhello
Expand Down
31 changes: 8 additions & 23 deletions features/support/env.rb
Expand Up @@ -17,35 +17,20 @@


require "rubygems"
require "spork"
#uncomment the following line to use spork with the debugger
#require "spork/ext/ruby-debug"

require "simplecov"
SimpleCov.start

Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
require "aruba/cucumber"
require "rake"

if not ENV[ "DRB" ]
require "coveralls"
Coveralls.wear_merged!
end

ENV[ "LD_LIBRARY_PATH" ] = "."
ENV[ "LD_LIBRARY_PATH" ] = "."

require "aruba/cucumber"
require "rake"
end


Spork.each_run do
# This code will be run each time you run your specs.

if ENV[ "DRB" ]
require "coveralls"
Coveralls.wear_merged!
end
if ENV[ "TRAVIS" ]
require "coveralls"
Coveralls.wear_merged!
end


Expand Down
92 changes: 29 additions & 63 deletions lib/paper-house/build-task.rb
Expand Up @@ -18,30 +18,27 @@

require "paper-house/auto-depends"
require "paper-house/dependency"
require "paper-house/cc-options"
require "rake/clean"
require "rake/tasklib"


module PaperHouse
#
# Common base class for *.c compilation tasks.
#
class BuildTask < Rake::TaskLib
# Compile options pass to C compiler.
attr_accessor :cflags
include CcOptions


# Name of task.
attr_accessor :name

# Directory where *.o files are created.
attr_accessor :target_directory

# @!attribute target_directory
# Directory where *.o files are created.
attr_writer :target_directory

def initialize name, &block
init name.to_s
set_defaults
block.call self if block
define
def target_directory
@target_directory ||= "."
end


Expand All @@ -54,24 +51,16 @@ def cc
end


# @!attribute includes
# Glob pattern to match include directories.
attr_writer :includes

def includes
FileList[ [ @includes ] ]
def initialize name, &block
@name = name.to_s
block.call self if block
define
end


# Glob pattern to match source files.
attr_accessor :sources


#
# Relative path to target file.
#
def target_path
File.join @target_directory, target_file_name
File.join target_directory, target_file_name
end


Expand All @@ -82,18 +71,22 @@ def target_path

def define
define_main_task
define_directory_task
define_all_c_compile_tasks
define_maybe_generate_target_task
define_clean_task
define_clobber_task
define_clean_tasks
end


def define_main_task
path = target_path
main_task = task( name => [ @target_directory, path ] )
main_task = task( name => [ target_directory, path ] )
main_task.comment = "Build #{ path }" if not main_task.comment
directory @target_directory
end


def define_directory_task
directory target_directory
end


Expand Down Expand Up @@ -132,6 +125,12 @@ def check_sources_list
end


def define_clean_tasks
define_clean_task
define_clobber_task
end


def define_clean_task
objects.each do | each |
next if not FileTest.exist?( each )
Expand All @@ -154,20 +153,7 @@ def clobber_targets


def objects
sources_list.pathmap File.join( @target_directory, "%n.o" )
end


def init name
@name = name
end


def set_defaults
@sources = "*.c"
@target_directory = "."
@cflags = []
@includes = []
sources_list.pathmap File.join( target_directory, "%n.o" )
end


Expand All @@ -185,27 +171,7 @@ def no_need_to_compile?( o_file, c_file )


def auto_depends_cc_options
( @cflags + [ "-fPIC" ] + cc_i_options ).join " "
end


def cc_i_options
include_directories.pathmap "-I%p"
end


def include_directories
( includes + auto_includes ).uniq
end


def sources_list
FileList.new( @sources )
end


def auto_includes
FileList[ sources_list.pathmap( "%d" ).uniq ]
( cflags + [ "-fPIC" ] + i_options ).join " "
end


Expand Down
17 changes: 9 additions & 8 deletions lib/paper-house/c-extension-task.rb
Expand Up @@ -56,20 +56,21 @@ def library_dependencies


def generate_target
sh "#{ cc } #{ LDSHARED } -o #{ target_path } #{ objects.to_s } #{ cc_linker_options }"
sh ( [ cc ] + cc_options ).join( " " )
end


def cc_linker_options
[
ldflags,
cc_ldflags,
cc_l_options,
].flatten.join " "
def cc_options
[ LDSHARED, o_option, objects, ldflags, libdir_option, l_options ].flatten
end


def cc_ldflags
def o_option
"-o #{ target_path }"
end


def libdir_option
"-L#{ RUBY_LIBDIR }"
end

Expand Down

0 comments on commit 11865a2

Please sign in to comment.