class Autobuild::Configurable

Base class for packages that require a configuration + build step.

Child classes must provide a configurestamp file which represents the last configuration step done. This file is updated by a call to configure (see below)

Three new methods are added, which can be reimplemented in child classes:

Public Class Methods

builddir() click to toggle source
# File lib/autobuild/configurable.rb, line 25
def builddir
    if @builddir
        @builddir
    else
        ancestors.each do |klass|
            if result = klass.instance_variable_get(:@builddir)
                return result
            end
        end
        nil
    end
end
builddir=(new) click to toggle source
# File lib/autobuild/configurable.rb, line 38
def builddir=(new)
    raise ConfigException, "absolute builddirs are not supported" if (Pathname.new(new).absolute?)
    raise ConfigException, "builddir must be non-nil and non-empty" if (new.nil? || new.empty?)
    @builddir = new
end

Public Instance Methods

build() click to toggle source

Do the build in builddir

# File lib/autobuild/configurable.rb, line 122
def build
end
builddir() click to toggle source

Returns the absolute builddir

# File lib/autobuild/configurable.rb, line 52
def builddir; File.expand_path(@builddir || self.class.builddir, srcdir) end
builddir=(new) click to toggle source
# File lib/autobuild/configurable.rb, line 46
def builddir=(new)
    raise ConfigException.new(self), "absolute builddirs are not supported" if (Pathname.new(new).absolute?)
    raise ConfigException.new(self), "builddir must be non-empty" if new.empty?
    @builddir = new
end
buildstamp() click to toggle source

Build stamp This returns the name of the file which marks when the package has been successfully built for the last time. The path is absolute

# File lib/autobuild/configurable.rb, line 57
def buildstamp; "#{builddir}/#{STAMPFILE}" end
configure() { || ... } click to toggle source

Configure the builddir directory before starting make

# File lib/autobuild/configurable.rb, line 110
def configure
    if File.exists?(builddir) && !File.directory?(builddir)
        raise ConfigException.new(self, 'configure'), "#{builddir} already exists but is not a directory"
    end
    FileUtils.mkdir_p builddir if !File.directory?(builddir)

    yield

    Autobuild.touch_stamp(configurestamp)
end
ensure_dependencies_installed() click to toggle source
# File lib/autobuild/configurable.rb, line 74
def ensure_dependencies_installed
    dependencies.each do |pkg|
        Rake::Task[Package[pkg].installstamp].invoke
    end
end
prepare() click to toggle source
Calls superclass method
# File lib/autobuild/configurable.rb, line 80
def prepare
    source_tree srcdir do |pkg|
        pkg.exclude << Regexp.new("^#{Regexp.quote(builddir)}")
        pkg.exclude << Regexp.new("^#{Regexp.quote(doc_dir)}") if doc_dir
    end

    super

    stamps = dependencies.map { |pkg| Autobuild::Package[pkg].installstamp }
    file configurestamp => stamps do
        isolate_errors do
            ensure_dependencies_installed
            configure
            progress_done # Safety net for forgotten progress_done calls
        end
    end
    task "#{name}-prepare" => configurestamp

    file buildstamp => [ srcdir, configurestamp ] do
        isolate_errors do
            ensure_dependencies_installed
            build
            progress_done # Safety net for forgotten progress_done calls
        end
    end
    task "#{name}-build" => buildstamp
    file installstamp => buildstamp
end
prepare_for_forced_build() click to toggle source
Calls superclass method
# File lib/autobuild/configurable.rb, line 59
def prepare_for_forced_build
    super

    FileUtils.rm_f buildstamp
    FileUtils.rm_f configurestamp
end
prepare_for_rebuild() click to toggle source
Calls superclass method
# File lib/autobuild/configurable.rb, line 66
def prepare_for_rebuild
    super

    if File.exists?(builddir) && builddir != srcdir
        FileUtils.rm_rf builddir
    end
end