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:

Attributes

source_tree_excludes[R]

Set of regexp matching paths that should not be considered as source files

This is used to determine whether the source code changed (and therefore whether the package should be rebuilt). Autobuild sets up a default set of common excludes, use this to add custom ones

@return [Array<Regexp>]

Public Class Methods

builddir() click to toggle source
# File lib/autobuild/configurable.rb, line 34
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 47
def builddir=(new)
    if new.nil? || new.empty?
        raise ConfigException, "builddir must be non-nil and non-empty"
    end
    if Pathname.new(new).absolute?
        raise ConfigException, "absolute builddirs are not supported"
    end

    @builddir = new
end
new(spec = Hash.new) click to toggle source
Calls superclass method
# File lib/autobuild/configurable.rb, line 27
def initialize(spec = Hash.new)
    @source_tree_excludes = Array.new
    @builddir = nil
    super
end

Public Instance Methods

build() click to toggle source

Do the build in builddir

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

Returns the absolute builddir

# File lib/autobuild/configurable.rb, line 67
def builddir
    File.expand_path(@builddir || self.class.builddir, srcdir)
end
builddir=(new) click to toggle source
# File lib/autobuild/configurable.rb, line 60
def builddir=(new)
    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 74
def buildstamp
    "#{builddir}/#{STAMPFILE}"
end
configure() { || ... } click to toggle source

Configure the builddir directory before starting make

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

    FileUtils.mkdir_p builddir unless File.directory?(builddir)

    yield if block_given?

    Autobuild.touch_stamp(configurestamp)
end
ensure_dependencies_installed() click to toggle source
# File lib/autobuild/configurable.rb, line 91
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 97
def prepare
    source_tree srcdir do |pkg|
        if builddir != srcdir
            pkg.exclude << Regexp.new("^#{Regexp.quote(builddir)}")
        end
        if doc_dir && (doc_dir != srcdir)
            pkg.exclude << Regexp.new("^#{Regexp.quote(doc_dir)}")
        end
        pkg.exclude.concat(source_tree_excludes)
    end

    super

    stamps = dependencies.map { |pkg| Autobuild::Package[pkg].installstamp }
    file configurestamp => stamps do
        @install_invoked = true
        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
        @install_invoked = true
        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 78
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 85
def prepare_for_rebuild
    super

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