Class: Daedalus::Library

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

Direct Known Subclasses

SharedLibrary, StaticLibrary

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Library.

Yields:

  • (_self)

Yield Parameters:



553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/daedalus.rb', line 553

def initialize(path, base, compiler)
  @base = base
  @compiler = compiler

  @directory = File.dirname path
  @library = File.basename path
  @sources = []

  yield self if block_given?

  source_files "#{path}.c" if @sources.empty?
end

Instance Attribute Details

#sourcesObject (readonly)

Returns the value of attribute sources.



551
552
553
# File 'lib/daedalus.rb', line 551

def sources
  @sources
end

Instance Method Details

#cleanObject



603
604
605
606
607
608
# File 'lib/daedalus.rb', line 603

def clean
  Dir.chdir @base do
    @sources.each { |s| s.clean }
    File.delete name if File.exist? name
  end
end

#consider(compiler, tasks) ⇒ Object



599
600
601
# File 'lib/daedalus.rb', line 599

def consider(compiler, tasks)
  tasks.pre << self if out_of_date? compiler
end

#nameObject



570
571
572
# File 'lib/daedalus.rb', line 570

def name
  File.join @directory, library
end

#object_filesObject



584
585
586
# File 'lib/daedalus.rb', line 584

def object_files
  @sources.map { |s| s.object_path }
end

#out_of_date?(compiler) ⇒ Boolean

Returns:

  • (Boolean)


588
589
590
591
592
593
594
595
596
597
# File 'lib/daedalus.rb', line 588

def out_of_date?(compiler)
  Dir.chdir @base do
    return true unless File.exist? name
    @sources.each do |s|
      return true unless File.exist? s.object_path
      return true if File.mtime(s.object_path) > File.mtime(name)
    end
    @sources.any? { |s| s.out_of_date? compiler }
  end
end

#pathObject



566
567
568
# File 'lib/daedalus.rb', line 566

def path
  File.join @base, @directory, library
end

#source_files(*patterns) ⇒ Object



574
575
576
577
578
579
580
581
582
# File 'lib/daedalus.rb', line 574

def source_files(*patterns)
  Dir.chdir @base do
    patterns.each do |t|
      Dir[t].each do |f|
        @sources << SourceFile.new(f)
      end
    end
  end
end