Class: MxxRu::BinaryLibrary

Inherits:
Object
  • Object
show all
Defined in:
lib/mxx_ru/binary_library.rb

Overview

Class for description of binary library required to be linked with binary target.

Since 1.3.0

On Unix platform static and shared library can be specified to linker with same name. For example to link libA.a or libA.so user must specify ‘-lA’ option. Linker selects appropriate library (static or shared version) by it own rules (on most Linux platform ld first looks for shared version, than for static version; this approach can be overriden by ‘-static’ option for gcc or ‘-Bstatic’ for ld).

In some cases user may wants to explicitly specify kind of library. For example, if ld by default searches shared libraries than user can specify sequence ‘-Bstatic -lA -Bdynamic’ for ld (or ‘-Wl,-Bstatic,-lA,-Bdynamic’ for gcc). This forces linker for looking only static version of library.

In version 1.3.0 Mxx_ru support for explicit static/shared library selection was added. To implement this support required library description was changed. Instead of storing names of required libraries as String they are stored as BinaryLibrary objects.

Constant Summary collapse

STATIC =

Identifier for static library type.

:static
SHARED =

Identifier for shared library type.

:shared
ANY =

Identifier for library which type if unknown yet (not explicitly specified).

:any

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type) ⇒ BinaryLibrary

Returns a new instance of BinaryLibrary.

Raises:



68
69
70
71
72
73
74
# File 'lib/mxx_ru/binary_library.rb', line 68

def initialize( name, type )
  raise InvalidValueEx.new( "Unknown BinaryLibrary type: #{type}" ) unless
      [ STATIC, SHARED, ANY ].member?( type )

  @name = name
  @type = type
end

Instance Attribute Details

#nameObject (readonly)

Name of library.



64
65
66
# File 'lib/mxx_ru/binary_library.rb', line 64

def name
  @name
end

#typeObject (readonly)

Type of library (STATIC/SHARED/ANY).



66
67
68
# File 'lib/mxx_ru/binary_library.rb', line 66

def type
  @type
end

Instance Method Details

#<=>(another) ⇒ Object



88
89
90
91
92
# File 'lib/mxx_ru/binary_library.rb', line 88

def <=>( another )
  r = @name <=> another.name
  r = @type <=> another.type if 0 == r
  r
end

#==(another) ⇒ Object



84
85
86
# File 'lib/mxx_ru/binary_library.rb', line 84

def ==( another )
  self.eql?( another )
end

#eql?(another) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/mxx_ru/binary_library.rb', line 80

def eql?( another )
  @name.eql?( another.name ) and @type.eql?( another.type )
end

#to_sObject



76
77
78
# File 'lib/mxx_ru/binary_library.rb', line 76

def to_s
  @name
end