Class: PaperHouse::SharedLibraryTask

Inherits:
LibraryTask show all
Includes:
LinkerOptions, Platform
Defined in:
lib/paper_house/shared_library_task.rb

Overview

Compiles *.c files into a shared library.

Constant Summary

Constants included from Platform

Platform::LDSHARED, Platform::MAC, Platform::RUBY_INCLUDES, Platform::RUBY_LIBDIR, Platform::SHARED_EXT, Platform::SONAME_OPTION

Instance Attribute Summary collapse

Attributes included from LinkerOptions

#ldflags

Attributes inherited from BuildTask

#cc, #name, #target_directory

Attributes included from CcOptions

#cflags, #includes, #sources

Instance Method Summary collapse

Methods included from Platform

name

Methods included from LinkerOptions

#library_dependencies, #library_dependencies=

Methods inherited from LibraryTask

find_by_name, #library_name, #library_name=, #lname

Methods inherited from BuildTask

#target_path

Constructor Details

#initialize(name, version = nil) {|task| ... } ⇒ SharedLibraryTask

Defines a rake task called name that builds a shared library. Note that version number must be set as the version argument or in the block to build the library.

Examples:

PaperHouse::SharedLibraryTask.new :libhello do |task|
  task.version = '0.1.0'
  task.sources = 'hello.c'
  task.library_dependencies = 'm'
end

Yields:

  • (task)


27
28
29
30
# File 'lib/paper_house/shared_library_task.rb', line 27

def initialize(name, version = nil, &block)
  @version = version
  super name, &block
end

Instance Attribute Details

#versionObject

Library version string.



14
15
16
# File 'lib/paper_house/shared_library_task.rb', line 14

def version
  @version
end

Instance Method Details

#linker_nameObject

Name of library used by linkers.



40
41
42
# File 'lib/paper_house/shared_library_task.rb', line 40

def linker_name
  library_name + '.so'
end

#sonameObject

Soname of target library.



45
46
47
# File 'lib/paper_house/shared_library_task.rb', line 45

def soname
  File.basename(target_file_name).sub(/\.\d+\.\d+\Z/, '')
end

#target_file_nameObject Also known as: real_name

Real name of target library.



33
34
35
36
# File 'lib/paper_house/shared_library_task.rb', line 33

def target_file_name
  fail 'version option is a mandatory.' unless @version
  [linker_name, @version].join '.'
end