class Daedalus::ExternalLibrary
Attributes
cflags[RW]
ldflags[RW]
objects[RW]
path[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/daedalus.rb 534 def initialize(path) 535 @path = path 536 537 @cflags = nil 538 @ldflags = nil 539 @objects = nil 540 541 @build_dir = path 542 @builder = nil 543 @data = nil 544 end
Public Instance Methods
build(ctx)
click to toggle source
# File lib/daedalus.rb 606 def build(ctx) 607 raise "Unable to build" unless @builder 608 609 ctx.log.inc! 610 611 ctx.log.show "LB", @build_dir 612 613 Dir.chdir(@build_dir) do 614 @builder.call(ctx.log) 615 end 616 617 @data[:sha1] = sha1() 618 619 File.open(@data_file, "wb") do |f| 620 f << Marshal.dump(@data) 621 end 622 end
consider(ctx, tasks)
click to toggle source
# File lib/daedalus.rb 602 def consider(ctx, tasks) 603 tasks.pre << self if out_of_date?(ctx) 604 end
describe(ctx)
click to toggle source
# File lib/daedalus.rb 624 def describe(ctx) 625 end
file(f)
click to toggle source
# File lib/daedalus.rb 568 def file(f) 569 File.join(@path, f) 570 end
have_objects()
click to toggle source
# File lib/daedalus.rb 586 def have_objects 587 return true unless @objects 588 @objects.each do |o| 589 return false unless File.exist?(o) 590 end 591 592 return true 593 end
out_of_date?(ctx)
click to toggle source
# File lib/daedalus.rb 595 def out_of_date?(ctx) 596 return true unless have_objects 597 return false unless @builder 598 return false if @data and @data[:sha1] == sha1 599 return true 600 end
sha1()
click to toggle source
# File lib/daedalus.rb 572 def sha1 573 sha1 = Digest::SHA1.new 574 575 Dir["#{@build_dir}/*"].each do |f| 576 sha1.file(f) if File.file?(f) 577 end 578 579 Dir["#{@build_dir}/**/*"].each do |f| 580 sha1.file(f) if File.file?(f) 581 end 582 583 sha1.hexdigest 584 end
to_build(&blk)
click to toggle source
# File lib/daedalus.rb 548 def to_build(&blk) 549 @builder = blk 550 551 @data_file = "#{@build_dir}.data" 552 553 if File.exist?(@data_file) 554 begin 555 File.open @data_file, "rb" do |f| 556 @data = Marshal.load(f.read) 557 end 558 rescue 559 STDERR.puts "WARNING: ExternalLibrary#to_build: load '#{@data_file}' failed" 560 @data = {} 561 end 562 else 563 @data = {} 564 end 565 566 end