Class: Autoproj::PackageDefinition
- Inherits:
-
Object
- Object
- Autoproj::PackageDefinition
- Defined in:
- lib/autoproj/package_definition.rb
Overview
Autoproj-specific information about a package definition
This stores the information that goes in addition to the autobuild package definitions
Instance Attribute Summary collapse
-
#autobuild ⇒ Autobuild::Package
readonly
The autobuild package definitins.
-
#file ⇒ String
readonly
Path to the file that contains this package’s definition.
-
#package_set ⇒ PackageSet
readonly
The package set that defined this package.
-
#setup ⇒ Object
writeonly
Sets the #setup? flag.
-
#user_blocks ⇒ Array<#call>
readonly
The set of blocks that should be called to prepare the package.
-
#vcs ⇒ VCSDefinition
The version control information associated with this package.
Instance Method Summary collapse
-
#add_setup_block(block) {|pkg| ... } ⇒ Object
Registers a setup block.
- #apply_dependencies_from_manifest ⇒ Object
-
#checked_out? ⇒ Boolean
Whether this package is already checked out.
-
#depends_on(pkg) ⇒ Object
Add another package as a dependency of this one.
-
#initialize(autobuild, package_set, file) ⇒ PackageDefinition
constructor
A new instance of PackageDefinition.
-
#modes ⇒ Array<String>
The modes in which this package will be used.
-
#name ⇒ String
The package name.
-
#setup? ⇒ Boolean
Whether this package is completely setup.
Constructor Details
#initialize(autobuild, package_set, file) ⇒ PackageDefinition
Returns a new instance of PackageDefinition.
34 35 36 37 38 39 40 41 42 |
# File 'lib/autoproj/package_definition.rb', line 34 def initialize(autobuild, package_set, file) @autobuild = autobuild @package_set = package_set @file = file @user_blocks = [] @modes = %w[import build] @setup = false @vcs = VCSDefinition.none end |
Instance Attribute Details
#autobuild ⇒ Autobuild::Package (readonly)
Returns the autobuild package definitins.
8 9 10 |
# File 'lib/autoproj/package_definition.rb', line 8 def autobuild @autobuild end |
#file ⇒ String (readonly)
Returns path to the file that contains this package’s definition.
17 18 19 |
# File 'lib/autoproj/package_definition.rb', line 17 def file @file end |
#package_set ⇒ PackageSet (readonly)
Returns the package set that defined this package.
14 15 16 |
# File 'lib/autoproj/package_definition.rb', line 14 def package_set @package_set end |
#setup=(value) ⇒ Object (writeonly)
Sets the #setup? flag
28 29 30 |
# File 'lib/autoproj/package_definition.rb', line 28 def setup=(value) @setup = value end |
#user_blocks ⇒ Array<#call> (readonly)
Returns the set of blocks that should be called to prepare the package. These are called before any operation has been performed on the package iself.
12 13 14 |
# File 'lib/autoproj/package_definition.rb', line 12 def user_blocks @user_blocks end |
#vcs ⇒ VCSDefinition
Returns the version control information associated with this package.
32 33 34 |
# File 'lib/autoproj/package_definition.rb', line 32 def vcs @vcs end |
Instance Method Details
#add_setup_block(block) {|pkg| ... } ⇒ Object
Registers a setup block
The block will be called when the setup phase is finished, or immediately if it is already finished (i.e. if #setup? returns true)
69 70 71 72 |
# File 'lib/autoproj/package_definition.rb', line 69 def add_setup_block(block) user_blocks << block block.call(autobuild) if setup? end |
#apply_dependencies_from_manifest ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/autoproj/package_definition.rb', line 84 def apply_dependencies_from_manifest manifest = autobuild.description manifest.each_dependency(modes) do |name, is_optional| if is_optional autobuild.optional_dependency name else autobuild.depends_on name end rescue ConfigError => e raise PackageNotFound.new(manifest.path), "manifest #{manifest.path} of #{self.name} from "\ "#{package_set.name} lists '#{name}' as dependency, "\ "but it is neither a normal package nor an osdeps "\ "package. osdeps reports: #{e.}", e.backtrace end end |
#checked_out? ⇒ Boolean
Whether this package is already checked out
75 76 77 |
# File 'lib/autoproj/package_definition.rb', line 75 def checked_out? autobuild.checked_out? end |
#depends_on(pkg) ⇒ Object
Add another package as a dependency of this one
80 81 82 |
# File 'lib/autoproj/package_definition.rb', line 80 def depends_on(pkg) autobuild.depends_on(pkg.autobuild) end |
#modes ⇒ Array<String>
The modes in which this package will be used
Mainly used during dependency resolution to disable unneeded dependencies
50 51 52 53 |
# File 'lib/autoproj/package_definition.rb', line 50 def modes @modes + autobuild.utilities .values.find_all(&:enabled?).map(&:name) end |
#name ⇒ String
The package name
57 58 59 |
# File 'lib/autoproj/package_definition.rb', line 57 def name autobuild.name end |
#setup? ⇒ Boolean
Whether this package is completely setup
If the package is set up, its importer as well as all target directories are properly set, and all #user_blocks have been called.
23 24 25 |
# File 'lib/autoproj/package_definition.rb', line 23 def setup? @setup end |