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.
634
635
636
637
638
639
640
641
642
643
644
645
|
# File 'lib/daedalus.rb', line 634
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.
632
633
634
|
# File 'lib/daedalus.rb', line 632
def sources
@sources
end
|
Instance Method Details
#clean ⇒ Object
684
685
686
687
688
689
|
# File 'lib/daedalus.rb', line 684
def clean
Dir.chdir @base do
@sources.each { |s| s.clean }
File.delete name if File.exist? name
end
end
|
#consider(compiler, tasks) ⇒ Object
680
681
682
|
# File 'lib/daedalus.rb', line 680
def consider(compiler, tasks)
tasks.pre << self if out_of_date? compiler
end
|
#name ⇒ Object
651
652
653
|
# File 'lib/daedalus.rb', line 651
def name
File.join @directory, library
end
|
#object_files ⇒ Object
665
666
667
|
# File 'lib/daedalus.rb', line 665
def object_files
@sources.map { |s| s.object_path }
end
|
#out_of_date?(compiler) ⇒ Boolean
669
670
671
672
673
674
675
676
677
678
|
# File 'lib/daedalus.rb', line 669
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
647
648
649
|
# File 'lib/daedalus.rb', line 647
def path
File.join @base, @directory, library
end
|
#source_files(*patterns) ⇒ Object
655
656
657
658
659
660
661
662
663
|
# File 'lib/daedalus.rb', line 655
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
|