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:



649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
# File 'lib/daedalus.rb', line 649

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.



647
648
649
# File 'lib/daedalus.rb', line 647

def cflags
  @cflags
end

#ldflagsObject

Returns the value of attribute ldflags.



647
648
649
# File 'lib/daedalus.rb', line 647

def ldflags
  @ldflags
end

Instance Method Details

#cleanObject



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

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

#consider(compiler, tasks) ⇒ Object



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

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



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

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

#librariesObject



692
693
694
# File 'lib/daedalus.rb', line 692

def libraries
  @static_libraries + @shared_libraries
end

#objectsObject

TODO: Fix this protocol



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

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

#pathObject

TODO: change the way files are sorted



675
676
677
# File 'lib/daedalus.rb', line 675

def path
  @base
end

#shared_library(path, &block) ⇒ Object



683
684
685
# File 'lib/daedalus.rb', line 683

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

#static_library(path, &block) ⇒ Object



679
680
681
# File 'lib/daedalus.rb', line 679

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