Module: Autoproj::AutobuildExtensions::Package

Defined in:
lib/autoproj/autobuild_extensions/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#added_tagsObject (readonly)

Tags explicitely added with #add_tag



5
6
7
# File 'lib/autoproj/autobuild_extensions/package.rb', line 5

def added_tags
  @added_tags
end

#descriptionObject

The Autoproj::PackageManifest object that describes this package



17
18
19
# File 'lib/autoproj/autobuild_extensions/package.rb', line 17

def description
  @description
end

#optional_dependenciesObject (readonly)

Returns the value of attribute optional_dependencies.



6
7
8
# File 'lib/autoproj/autobuild_extensions/package.rb', line 6

def optional_dependencies
  @optional_dependencies
end

#os_packagesObject (readonly)

Returns the value of attribute os_packages.



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

def os_packages
  @os_packages
end

#use_package_xml=(value) ⇒ Object (writeonly)



43
44
45
# File 'lib/autoproj/autobuild_extensions/package.rb', line 43

def use_package_xml=(value)
  @use_package_xml = value
end

#wsObject



12
13
14
# File 'lib/autoproj/autobuild_extensions/package.rb', line 12

def ws
    @ws ||= Autoproj.workspace
end

Instance Method Details

#add_tag(tag) ⇒ Object

Add a tag to the package. Use this if you don’t want the tag to be shared with everyone that uses the package (i.e. cannot go in manifest.xml)



57
58
59
# File 'lib/autoproj/autobuild_extensions/package.rb', line 57

def add_tag(tag)
    @added_tags << tag
end

#all_dependencies_with_osdeps(set = Set.new) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/autoproj/autobuild_extensions/package.rb', line 117

def all_dependencies_with_osdeps(set = Set.new)
    original_set = set.dup
    all_dependencies(set)
    set.dup.each do |dep_pkg_name|
        next if original_set.include?(dep_pkg_name)

        if (dep_pkg = ws.manifest.find_autobuild_package(dep_pkg_name))
            set.merge(dep_pkg.os_packages)
        else
            raise ArgumentError,
                  "#{dep_pkg_name}, which is listed as a dependency "\
                  "of #{name}, is not the name of a known package"
        end
    end
    set.merge(os_packages)
    set
end

#autoproj_nameObject

:nodoc:



101
102
103
# File 'lib/autoproj/autobuild_extensions/package.rb', line 101

def autoproj_name # :nodoc:
    srcdir.gsub(/^#{Regexp.quote(ws.root_dir)}\//, "")
end

#depends_on(name) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/autoproj/autobuild_extensions/package.rb', line 105

def depends_on(name)
    name = name.name if name.respond_to?(:name) # probably a Package object

    pkg_autobuild, pkg_os = partition_package(name)
    pkg_autobuild.each do |pkg|
        next if ws.manifest.ignored?(pkg)

        super(pkg)
    end
    @os_packages.merge(pkg_os.to_set)
end

#depends_on_os_package(name) ⇒ Object



135
136
137
# File 'lib/autoproj/autobuild_extensions/package.rb', line 135

def depends_on_os_package(name)
    depends_on(name)
end

#has_tag?(tag) ⇒ Boolean

True if this package is tagged with the given tag string

Returns:

  • (Boolean)


62
63
64
# File 'lib/autoproj/autobuild_extensions/package.rb', line 62

def has_tag?(tag)
    tags.include?(tag.to_s)
end

#initialize(spec = Hash.new) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/autoproj/autobuild_extensions/package.rb', line 19

def initialize(spec = Hash.new)
    super
    @ws = nil
    @os_packages = Set.new
    @added_tags = Set.new
    @optional_dependencies = Set.new
    @description = PackageManifest.new(self, null: true)
    @use_package_xml = false
    @internal_dependencies = []
end

#internal_dependenciesObject



38
39
40
# File 'lib/autoproj/autobuild_extensions/package.rb', line 38

def internal_dependencies
    @internal_dependencies.dup
end

#internal_dependency(osdeps_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds and ‘internal’ dependency to the package ‘Internal’ dependencies are actually autobuild dependencies for a given package type. It is assumed that only osdeps that do not rely on strict package managers will be declared as internal dependencies.

The difference between a regular “os dependency” is that the internal dependency is installed right after the impport phase (before the actual osdeps phase)



156
157
158
# File 'lib/autoproj/autobuild_extensions/package.rb', line 156

def internal_dependency(osdeps_name)
    @internal_dependencies << osdeps_name
end

#optional_dependency(name) ⇒ Object



160
161
162
# File 'lib/autoproj/autobuild_extensions/package.rb', line 160

def optional_dependency(name)
    optional_dependencies << name
end

#partition_optional_dependenciesObject



179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/autoproj/autobuild_extensions/package.rb', line 179

def partition_optional_dependencies
    packages = []
    osdeps = []
    optional_dependencies.each do |name|
        pkg_autobuild, pkg_osdeps = partition_package(name)
        packages.concat(pkg_autobuild)
        osdeps.concat(pkg_osdeps)
    rescue Autoproj::PackageNotFound
        # Simply ignore non-existent optional dependencies
    end
    [packages, osdeps]
end

#partition_package(pkg_name) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/autoproj/autobuild_extensions/package.rb', line 164

def partition_package(pkg_name)
    pkg_autobuild = []
    pkg_osdeps = []
    ws.manifest.resolve_package_name(pkg_name, include_unavailable: true).each do |type, dep_name|
        if type == :osdeps
            pkg_osdeps << dep_name
        elsif type == :package
            pkg_autobuild << dep_name
        else
            raise Autoproj::InternalError, "expected package type to be either :osdeps or :package, got #{type.inspect}"
        end
    end
    [pkg_autobuild, pkg_osdeps]
end

#post_import(&block) ⇒ Object

Ask autoproj to run the given block after this package has been imported



97
98
99
# File 'lib/autoproj/autobuild_extensions/package.rb', line 97

def post_import(&block)
    Autoproj.post_import(self, &block)
end

#remove_dependency(name) ⇒ Object



139
140
141
142
143
# File 'lib/autoproj/autobuild_extensions/package.rb', line 139

def remove_dependency(name)
    dependencies.delete name
    optional_dependencies.delete name
    os_packages.delete name
end

#remove_obsolete_installed_file(*path) ⇒ Object

Asks autoproj to remove the given file in the package’s installation prefix



85
86
87
88
89
90
91
92
93
# File 'lib/autoproj/autobuild_extensions/package.rb', line 85

def remove_obsolete_installed_file(*path)
    post_install do
        path = File.join(prefix, *path)
        if File.exist?(path)
            Autoproj.message "  removing obsolete file #{path}", :bold
            FileUtils.rm_f path
        end
    end
end

#remove_obsolete_installed_orogen_package(name) ⇒ Object

Asks autoproj to remove references to the given obsolete oroGen package



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/autoproj/autobuild_extensions/package.rb', line 68

def remove_obsolete_installed_orogen_package(name)
    post_install do
        path = File.join(prefix, "lib", "pkgconfig")
        Dir.glob(File.join(path, "#{name}-*.pc")) do |pcfile|
            Autoproj.message "  removing obsolete file #{pcfile}", :bold
            FileUtils.rm_f pcfile
        end
        pcfile = File.join(path, "orogen-project-#{name}.pc")
        if File.exist?(pcfile)
            Autoproj.message "  removing obsolete file #{pcfile}", :bold
            FileUtils.rm_f pcfile
        end
    end
end

#tagsObject

The set of tags for this package. This is an union of the tags contained in description and the ones explicitely added with #add_tag



48
49
50
51
52
# File 'lib/autoproj/autobuild_extensions/package.rb', line 48

def tags
    result = @added_tags.dup
    result |= description.tags.to_set if description
    result
end

#use_package_xml?Boolean

Whether we should use a package.xml file present in this package (parsed as ROS’ catkin would) instead of Autoproj’s manifest.xml

Returns:

  • (Boolean)

See Also:



34
35
36
# File 'lib/autoproj/autobuild_extensions/package.rb', line 34

def use_package_xml?
    @use_package_xml
end