Class: Autobuild::Configurable
- Defined in:
- lib/autobuild/configurable.rb
Overview
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:
-
configure
does configure the package. It is ran after all depended-upon packages are installed. -
build
is ran afterconfigure
if the configure stamp and/or the source files have been updated. The #buildstamp stampfile represents when the last build has been done. The build must be done in the #builddir directory. -
install
is ran afterbuild
.
Instance Attribute Summary collapse
-
#source_tree_excludes ⇒ Array<Regexp>
readonly
Set of regexp matching paths that should not be considered as source files.
Attributes inherited from Package
#dependencies, #env, #failures, #importdir, #importer, #logdir, #name, #prefix, #srcdir, #statistics, #update, #updated, #utilities
Class Method Summary collapse
Instance Method Summary collapse
-
#build ⇒ Object
Do the build in builddir.
-
#builddir ⇒ Object
Returns the absolute builddir.
- #builddir=(new) ⇒ Object
-
#buildstamp ⇒ Object
Build stamp This returns the name of the file which marks when the package has been successfully built for the last time.
-
#configure ⇒ Object
Configure the builddir directory before starting make.
- #ensure_dependencies_installed ⇒ Object
-
#initialize(spec = Hash.new) ⇒ Configurable
constructor
A new instance of Configurable.
- #prepare ⇒ Object
- #prepare_for_forced_build ⇒ Object
- #prepare_for_rebuild ⇒ Object
Methods inherited from Package
[], #add_env_op, #add_stat, #all_dependencies, #applied_post_install?, #apply_env, #apply_post_install, #checked_out?, clear, #depends_on, #depends_on?, #disable, #disable_doc, #disable_phases, #disabled?, #doc_dir, #doc_dir=, #doc_disabled, #doc_target_dir, #doc_target_dir=, #doc_task, each, #enable_doc, #env_add, #env_add_path, #env_add_prefix, #env_set, #env_source_after, #error, #failed?, #file, #find_in_path, #fingerprint, #full_env, #generates_doc?, #has_doc?, #import, #import=, #import_invoked?, #imported?, #in_dir, #inspect, #install, #install_doc, #install_invoked?, #installed?, #installstamp, #isolate_errors, #message, #method_missing, #parallel_build_level, #parallel_build_level=, #post_install, #process_formatting_string, #progress, #progress_done, #progress_start, #provides, #resolve_dependency_env, #resolved_env, #respond_to_missing?, #run, #self_fingerprint, #source_tree, #task, #to_s, #update?, #update_environment, #updated?, #utility, #warn, #working_directory
Constructor Details
#initialize(spec = Hash.new) ⇒ Configurable
Returns a new instance of Configurable.
27 28 29 30 31 |
# File 'lib/autobuild/configurable.rb', line 27 def initialize(spec = Hash.new) @source_tree_excludes = Array.new @builddir = nil super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Autobuild::Package
Instance Attribute Details
#source_tree_excludes ⇒ Array<Regexp> (readonly)
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
25 26 27 |
# File 'lib/autobuild/configurable.rb', line 25 def source_tree_excludes @source_tree_excludes end |
Class Method Details
.builddir ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# 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) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# 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 |
Instance Method Details
#build ⇒ Object
Do the build in builddir
148 |
# File 'lib/autobuild/configurable.rb', line 148 def build; end |
#builddir ⇒ Object
Returns the absolute builddir
67 68 69 |
# File 'lib/autobuild/configurable.rb', line 67 def builddir File.(@builddir || self.class.builddir, srcdir) end |
#builddir=(new) ⇒ Object
60 61 62 63 64 |
# 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 ⇒ Object
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
74 75 76 |
# File 'lib/autobuild/configurable.rb', line 74 def buildstamp "#{builddir}/#{STAMPFILE}" end |
#configure ⇒ Object
Configure the builddir directory before starting make
134 135 136 137 138 139 140 141 142 143 144 145 |
# 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 ⇒ Object
91 92 93 94 95 |
# File 'lib/autobuild/configurable.rb', line 91 def ensure_dependencies_installed dependencies.each do |pkg| Rake::Task[Package[pkg].installstamp].invoke end end |
#prepare ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# 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 ⇒ Object
78 79 80 81 82 83 |
# 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 ⇒ Object
85 86 87 88 89 |
# File 'lib/autobuild/configurable.rb', line 85 def prepare_for_rebuild super FileUtils.rm_rf(builddir) if File.exist?(builddir) && builddir != srcdir end |