Class: Daedalus::LibraryGroup

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

Overview

The purpose of a LibraryGroup is to combine multiple static and shared libraries into a unit. Static libraries are used to statically link a program, while shared libraries may be dynamically loaded by that program or another program.

NOTE: The current protocol for getting a list of static libraries is the #objects method. This should be changed when reworking Daedalus.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, compiler) {|_self| ... } ⇒ LibraryGroup

Returns a new instance of LibraryGroup.

Yields:

  • (_self)

Yield Parameters:



730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# File 'lib/daedalus.rb', line 730

def initialize(base, compiler)
  @base = base
  @static_libraries = []
  @shared_libraries = []
  @compiler = Compiler.new(compiler.cc,
                           compiler.cxx,
                           compiler.ldshared,
                           compiler.ldsharedxx,
                           compiler.log, nil)

  yield self

  compiler.add_library self

  @compiler.cflags.concat cflags if cflags
  @compiler.ldflags.concat ldflags if ldflags
end

Instance Attribute Details

#cflagsObject

Returns the value of attribute cflags.



728
729
730
# File 'lib/daedalus.rb', line 728

def cflags
  @cflags
end

#ldflagsObject

Returns the value of attribute ldflags.



728
729
730
# File 'lib/daedalus.rb', line 728

def ldflags
  @ldflags
end

Instance Method Details

#cleanObject



784
785
786
# File 'lib/daedalus.rb', line 784

def clean
  libraries.each { |l| l.clean }
end

#consider(compiler, tasks) ⇒ Object



777
778
779
780
781
782
# File 'lib/daedalus.rb', line 777

def consider(compiler, tasks)
  # TODO: Note we are using @compiler, not compiler. There should not be a
  # global compiler. There should be a global configuration object that is
  # specialized by specific libraries as needed.
  libraries.each { |l| l.consider @compiler, tasks }
end

#depends_on(file, command) ⇒ Object



748
749
750
751
752
753
# File 'lib/daedalus.rb', line 748

def depends_on(file, command)
  # TODO: HACK, the agony, this should be implicit
  unless File.exist? File.join(@base, file)
    raise "library group #{@base} depends on #{file}, please run #{command}"
  end
end

#librariesObject



773
774
775
# File 'lib/daedalus.rb', line 773

def libraries
  @static_libraries + @shared_libraries
end

#objectsObject

TODO: Fix this protocol



769
770
771
# File 'lib/daedalus.rb', line 769

def objects
  @static_libraries.map { |l| l.path }
end

#pathObject

TODO: change the way files are sorted



756
757
758
# File 'lib/daedalus.rb', line 756

def path
  @base
end

#shared_library(path, &block) ⇒ Object



764
765
766
# File 'lib/daedalus.rb', line 764

def shared_library(path, &block)
  @shared_libraries << SharedLibrary.new(path, @base, @compiler, &block)
end

#static_library(path, &block) ⇒ Object



760
761
762
# File 'lib/daedalus.rb', line 760

def static_library(path, &block)
  @static_libraries << StaticLibrary.new(path, @base, @compiler, &block)
end