Class: Daedalus::Library
- Inherits:
-
Object
show all
- Defined in:
- lib/daedalus.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path, base, compiler) {|_self| ... } ⇒ Library
Returns a new instance of Library.
632
633
634
635
636
637
638
639
640
641
642
643
|
# File 'lib/daedalus.rb', line 632
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
#sources ⇒ Object
Returns the value of attribute sources.
630
631
632
|
# File 'lib/daedalus.rb', line 630
def sources
@sources
end
|
Instance Method Details
#clean ⇒ Object
682
683
684
685
686
687
|
# File 'lib/daedalus.rb', line 682
def clean
Dir.chdir @base do
@sources.each { |s| s.clean }
File.delete name if File.exist? name
end
end
|
#consider(compiler, tasks) ⇒ Object
678
679
680
|
# File 'lib/daedalus.rb', line 678
def consider(compiler, tasks)
tasks.pre << self if out_of_date? compiler
end
|
#name ⇒ Object
649
650
651
|
# File 'lib/daedalus.rb', line 649
def name
File.join @directory, library
end
|
#object_files ⇒ Object
663
664
665
|
# File 'lib/daedalus.rb', line 663
def object_files
@sources.map { |s| s.object_path }
end
|
#out_of_date?(compiler) ⇒ Boolean
667
668
669
670
671
672
673
674
675
676
|
# File 'lib/daedalus.rb', line 667
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
|
#path ⇒ Object
645
646
647
|
# File 'lib/daedalus.rb', line 645
def path
File.join @base, @directory, library
end
|
#source_files(*patterns) ⇒ Object
653
654
655
656
657
658
659
660
661
|
# File 'lib/daedalus.rb', line 653
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
|