Class: Autoproj::PackageDefinition

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#autobuildAutobuild::Package (readonly)

Returns the autobuild package definitins.

Returns:

  • (Autobuild::Package)

    the autobuild package definitins



8
9
10
# File 'lib/autoproj/package_definition.rb', line 8

def autobuild
  @autobuild
end

#fileString (readonly)

Returns path to the file that contains this package’s definition.

Returns:

  • (String)

    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_setPackageSet (readonly)

Returns the package set that defined this package.

Returns:

  • (PackageSet)

    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_blocksArray<#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.

Returns:

  • (Array<#call>)

    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

#vcsVCSDefinition

Returns the version control information associated with this package.

Returns:

  • (VCSDefinition)

    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)

Parameters:

  • block (#call)

    the block that should be registered

Yield Parameters:

  • pkg (Autobuild::Package)

    the autobuild package object

See Also:

  • {user_blocks}


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_manifestObject



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.message}", e.backtrace
    end
end

#checked_out?Boolean

Whether this package is already checked out

Returns:

  • (Boolean)


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

#modesArray<String>

The modes in which this package will be used

Mainly used during dependency resolution to disable unneeded dependencies

Returns:

  • (Array<String>)


50
51
52
53
# File 'lib/autoproj/package_definition.rb', line 50

def modes
    @modes + autobuild.utilities
                      .values.find_all(&:enabled?).map(&:name)
end

#nameString

The package name

Returns:

  • (String)


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.

Returns:

  • (Boolean)


23
24
25
# File 'lib/autoproj/package_definition.rb', line 23

def setup?
    @setup
end