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:



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/daedalus.rb', line 670

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.



668
669
670
# File 'lib/daedalus.rb', line 668

def cflags
  @cflags
end

#ldflagsObject

Returns the value of attribute ldflags.



668
669
670
# File 'lib/daedalus.rb', line 668

def ldflags
  @ldflags
end

Instance Method Details

#cleanObject



724
725
726
# File 'lib/daedalus.rb', line 724

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

#consider(compiler, tasks) ⇒ Object



717
718
719
720
721
722
# File 'lib/daedalus.rb', line 717

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



688
689
690
691
692
693
# File 'lib/daedalus.rb', line 688

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



713
714
715
# File 'lib/daedalus.rb', line 713

def libraries
  @static_libraries + @shared_libraries
end

#objectsObject

TODO: Fix this protocol



709
710
711
# File 'lib/daedalus.rb', line 709

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

#pathObject

TODO: change the way files are sorted



696
697
698
# File 'lib/daedalus.rb', line 696

def path
  @base
end

#shared_library(path, &block) ⇒ Object



704
705
706
# File 'lib/daedalus.rb', line 704

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

#static_library(path, &block) ⇒ Object



700
701
702
# File 'lib/daedalus.rb', line 700

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