Class: Daedalus::ExternalLibrary
- Inherits:
-
Object
- Object
- Daedalus::ExternalLibrary
- Defined in:
- lib/daedalus.rb
Instance Attribute Summary collapse
-
#cflags ⇒ Object
Returns the value of attribute cflags.
-
#ldflags ⇒ Object
Returns the value of attribute ldflags.
-
#objects ⇒ Object
Returns the value of attribute objects.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #build(ctx) ⇒ Object
- #consider(ctx, tasks) ⇒ Object
- #describe(ctx) ⇒ Object
- #file(f) ⇒ Object
- #have_objects ⇒ Object
-
#initialize(path) ⇒ ExternalLibrary
constructor
A new instance of ExternalLibrary.
- #out_of_date?(ctx) ⇒ Boolean
- #sha1 ⇒ Object
- #to_build(&blk) ⇒ Object
Constructor Details
#initialize(path) ⇒ ExternalLibrary
Returns a new instance of ExternalLibrary.
535 536 537 538 539 540 541 542 543 544 545 |
# File 'lib/daedalus.rb', line 535 def initialize(path) @path = path @cflags = nil @ldflags = nil @objects = nil @build_dir = path @builder = nil @data = nil end |
Instance Attribute Details
#cflags ⇒ Object
Returns the value of attribute cflags.
547 548 549 |
# File 'lib/daedalus.rb', line 547 def cflags @cflags end |
#ldflags ⇒ Object
Returns the value of attribute ldflags.
547 548 549 |
# File 'lib/daedalus.rb', line 547 def ldflags @ldflags end |
#objects ⇒ Object
Returns the value of attribute objects.
547 548 549 |
# File 'lib/daedalus.rb', line 547 def objects @objects end |
#path ⇒ Object
Returns the value of attribute path.
547 548 549 |
# File 'lib/daedalus.rb', line 547 def path @path end |
Instance Method Details
#build(ctx) ⇒ Object
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'lib/daedalus.rb', line 607 def build(ctx) raise "Unable to build" unless @builder ctx.log.inc! ctx.log.show "LB", @build_dir Dir.chdir(@build_dir) do @builder.call(ctx.log) end @data[:sha1] = sha1() File.open(@data_file, "wb") do |f| f << Marshal.dump(@data) end end |
#consider(ctx, tasks) ⇒ Object
603 604 605 |
# File 'lib/daedalus.rb', line 603 def consider(ctx, tasks) tasks.pre << self if out_of_date?(ctx) end |
#describe(ctx) ⇒ Object
625 626 |
# File 'lib/daedalus.rb', line 625 def describe(ctx) end |
#file(f) ⇒ Object
569 570 571 |
# File 'lib/daedalus.rb', line 569 def file(f) File.join(@path, f) end |
#have_objects ⇒ Object
587 588 589 590 591 592 593 594 |
# File 'lib/daedalus.rb', line 587 def have_objects return true unless @objects @objects.each do |o| return false unless File.exist?(o) end return true end |
#out_of_date?(ctx) ⇒ Boolean
596 597 598 599 600 601 |
# File 'lib/daedalus.rb', line 596 def out_of_date?(ctx) return true unless have_objects return false unless @builder return false if @data and @data[:sha1] == sha1 return true end |
#sha1 ⇒ Object
573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/daedalus.rb', line 573 def sha1 sha1 = Digest::SHA1.new Dir["#{@build_dir}/*"].each do |f| sha1.file(f) if File.file?(f) end Dir["#{@build_dir}/**/*"].each do |f| sha1.file(f) if File.file?(f) end sha1.hexdigest end |
#to_build(&blk) ⇒ Object
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/daedalus.rb', line 549 def to_build(&blk) @builder = blk @data_file = "#{@build_dir}.data" if File.exist?(@data_file) begin File.open @data_file, "rb" do |f| @data = Marshal.load(f.read) end rescue STDERR.puts "WARNING: ExternalLibrary#to_build: load '#{@data_file}' failed" @data = {} end else @data = {} end end |