module Autoproj

Constants

ENV_FILENAME
GIT_SERVER_ACCESS_METHODS
GIT_SERVER_CONFIG_VARS
Query

Match class for the query system.

This class allows to create a query object based on a textual representation, and then match packages using this query object.

The queries are of the form

FIELD=VALUE:FIELD~VALUE:FIELD=VALUE

The F=V form requires an exact match while F~V allows partial matches. The different matches are combined with AND (i.e. only packages matching all criterias will be returned)

The following fields are allowed:

* autobuild.name: the package name
* autobuild.srcdir: the package source directory
* autobuild.class.name: the package class
* vcs.type: the VCS type (as used in the source.yml files)
* vcs.url: the URL from the VCS. The exact semantic of it depends on the
  VCS type
* package_set.name: the name of the package set that defines the package

Some fields have shortcuts:

* 'name' can be used instead of 'autobuild.name'
* 'class' can be used instead of 'autobuild.class.name'
* 'vcs' can be used instead of 'vcs.url'
* 'package_set' can be used instead of 'package_set.name'
VERSION
YAML_LOAD_ERROR

Attributes

custom_package_handlers[W]
logger[RW]
post_import_blocks[R]
reconfigure[RW]
verbose[RW]

Public Class Methods

add_osdeps_overrides(*args, **kw, &block) click to toggle source
# File lib/autoproj/manifest.rb, line 1247
def self.add_osdeps_overrides(*args, **kw, &block)
    manifest.add_osdeps_overrides(*args, **kw, &block)
end
add_source_handler(name, &handler) click to toggle source

Add a custom source handler named name

Custom source handlers are shortcuts that can be used to represent VCS information. For instance, the {Autoproj.git_server_configuration} helper defines a source handler that allows to easily add new github packages:

Autoproj.git_server_configuration('GITHUB', 'github.com',
   http_url: 'https://github.com',
   default: 'http,ssh')

Defines a ‘github’ custom handler that expands into the full VCS configuration to access github

version_control:
    - tools/orocos.rb:
      github: rock-core/base-types
      branch: test

@yieldparam [String] url the url given to the handler @yieldparam [Hash] the rest of the VCS hash @return [Hash] a VCS hash with the information expanded

# File lib/autoproj/vcs_definition.rb, line 351
def self.add_source_handler(name, &handler)
    @custom_source_handlers[name.to_s] = handler
end
build_dir() click to toggle source

@deprecated use workspace.prefix_dir instead

# File lib/autoproj/system.rb, line 88
def self.build_dir
    Autoproj.warn_deprecated(__method__, "workspace.prefix_dir")
    workspace.prefix_dir
end
bundler_unbundled_system(*args, **options) click to toggle source

Shim for a smooth upgrade path to bundler 2.1+

# File lib/autoproj/base.rb, line 61
def self.bundler_unbundled_system(*args, **options)
    if Bundler.respond_to?(:unbundled_system)
        Bundler.unbundled_system(*args, **options)
    else
        Bundler.clean_system(*args, **options)
    end
end
bundler_with_unbundled_env(&block) click to toggle source

Shim for a smooth upgrade path to bundler 2.1+

# File lib/autoproj/base.rb, line 70
def self.bundler_with_unbundled_env(&block)
    if Bundler.respond_to?(:with_unbundled_env)
        Bundler.with_unbundled_env(&block)
    else
        Bundler.with_clean_env(&block)
    end
end
call_source_handler(vcs, url, options) click to toggle source

Returns the source handlers associated with vcs

Source handlers are added by Autoproj.add_source_handler. The returned value is an object that responds to call(url, options) and return a VCS definition as a hash

# File lib/autoproj/vcs_definition.rb, line 321
def self.call_source_handler(vcs, url, options)
    handler = @custom_source_handlers[vcs.to_s]
    if handler
        handler.call(url, **options)
    else
        raise ArgumentError, "there is no source handler for #{vcs}"
    end
end
change_option(key, value, user_validated = false) click to toggle source

@deprecated use config.set(key, value, user_validated) instead

# File lib/autoproj/options.rb, line 15
def self.change_option(key, value, user_validated = false)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.set(key, value, user_validated)
end
color(*args) click to toggle source
# File lib/autoproj/reporter.rb, line 32
def self.color(*args)
    Autobuild.color(*args)
end
config() click to toggle source
# File lib/autoproj/manifest.rb, line 1243
def self.config
    workspace.config
end
config_dir() click to toggle source

@deprecated use workspace.config_dir instead

# File lib/autoproj/system.rb, line 48
def self.config_dir
    Autoproj.warn "#{__method__} is deprecated, use workspace.config_dir instead"
    caller.each { |l| Autoproj.warn "  #{l}" }
    workspace.config_dir
end
config_file(file) click to toggle source

@deprecated compute the full path with File.join(config_dir, file)

directly instead
# File lib/autoproj/system.rb, line 95
def self.config_file(file)
    Autoproj.warn_deprecated(__method__, "compute the full path with File.join(config_dir, ...) instead")
    File.join(config_dir, file)
end
configuration_option(name, type, options, &validator) click to toggle source

@deprecated use config.declare(name, type, options, &validator) instead

# File lib/autoproj/options.rb, line 33
def self.configuration_option(name, type, options, &validator)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.declare(name, type, options, &validator)
end
configure(option_name) click to toggle source

@deprecated use config.configure(option_name) instead

# File lib/autoproj/options.rb, line 45
def self.configure(option_name)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.configure(option_name)
end
contains_expansion?(string) click to toggle source

True if the given string contains expansions

# File lib/autoproj/variable_expansion.rb, line 82
def self.contains_expansion?(string)
    string.respond_to?(:to_str) && string.to_str =~ /\$/
end
current_file() click to toggle source

@deprecated use Autoproj.workspace.current_file or add a proper Loader

object to your class
# File lib/autoproj/autobuild_extensions/dsl.rb, line 69
def self.current_file
    Autoproj.warn_deprecated(
        __method__,
        "use AUtoproj.workspace.current_file instead"
    )
    Autoproj.workspace.current_file
end
current_package_set() click to toggle source

@deprecated use Autoproj.workspace.current_package_set or add a proper

Loader object to your class
# File lib/autoproj/autobuild_extensions/dsl.rb, line 79
def self.current_package_set
    Autoproj.warn_deprecated(
        __method__,
        "use Autoproj.workspace.current_package_set instead"
    )
    Autoproj.workspace.current_package_set
end
custom_package_handler(&block) click to toggle source

Registers a block that will be called to determine a package handler for the package in full_path.

# File lib/autoproj/autobuild_extensions/dsl.rb, line 41
def self.custom_package_handler(&block)
    custom_package_handlers << block
end
custom_package_handlers() click to toggle source
# File lib/autoproj/autobuild_extensions/dsl.rb, line 26
def custom_package_handlers
    @custom_package_handlers ||= []
end
declared_option?(name) click to toggle source

@deprecated use config.declared?(name, type, options, &validator) instead

# File lib/autoproj/options.rb, line 39
def self.declared_option?(name)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.declared?(name)
end
default_find_base_dir() click to toggle source

The base path from which we search for workspaces

# File lib/autoproj/find_workspace.rb, line 6
def self.default_find_base_dir
    ENV["AUTOPROJ_CURRENT_ROOT"] || Dir.pwd
end
define(package_type, spec, &block) click to toggle source

@deprecated use {Workspace#define_package} directly instead.

Beware that the return value changed from Autobuild::Package to
Autoproj::PackageDefinition
# File lib/autoproj/autobuild_extensions/dsl.rb, line 90
def self.define(package_type, spec, &block)
    Autoproj.warn_deprecated(
        __method__, "use Autoproj.workspace.define_package "\
                    "instead (and beware that the return value changed from "\
                    "Autobuild::Package to Autoproj::PackageDefinition)"
    )
    workspace.define_package(package_type, spec, block, *current_file)
             .autobuild
end
each_custom_package_handler(&block) click to toggle source
# File lib/autoproj/autobuild_extensions/dsl.rb, line 31
def self.each_custom_package_handler(&block)
    return enum_for(__method__) unless block_given?

    custom_package_handlers.each do |handler|
        block.call(handler)
    end
end
each_post_import_block(pkg, &block) click to toggle source

Enumerate the post-import blocks registered for the given package

@param [PackageDefinition] pkg @see post_import

# File lib/autoproj/base.rb, line 34
def self.each_post_import_block(pkg, &block)
    # We use Autobuild packages as keys
    pkg = pkg.autobuild if pkg.respond_to?(:autobuild)

    @post_import_blocks[nil].each(&block)
    @post_import_blocks[pkg]&.each(&block)
end
env() click to toggle source
# File lib/autoproj/workspace.rb, line 947
def self.env
    workspace.env
end
env_add(name, *value) click to toggle source

@deprecated call Autoproj.env.add instead

# File lib/autoproj/environment.rb, line 93
def self.env_add(name, *value)
    env.add(name, *value)
end
env_add_path(name, *value) click to toggle source

@deprecated call Autoproj.env.add_path instead

# File lib/autoproj/environment.rb, line 103
def self.env_add_path(name, *value)
    env.add_path(name, *value)
end
env_inherit(*names) click to toggle source

@deprecated call Autoproj.env.inherit instead

# File lib/autoproj/environment.rb, line 123
def self.env_inherit(*names)
    env.inherit(*names)
end
env_set(name, *value) click to toggle source

@deprecated call Autoproj.env.set instead

# File lib/autoproj/environment.rb, line 88
def self.env_set(name, *value)
    env.set(name, *value)
end
env_set_path(name, *value) click to toggle source

@deprecated call Autoproj.env.set_path instead

# File lib/autoproj/environment.rb, line 98
def self.env_set_path(name, *value)
    env.set_path(name, *value)
end
env_source_after(file, shell: "sh") click to toggle source

@deprecated call Autoproj.env.source_after instead

# File lib/autoproj/environment.rb, line 113
def self.env_source_after(file, shell: "sh")
    env.source_after(file, shell: shell)
end
env_source_before(file, shell: "sh") click to toggle source

@deprecated call Autoproj.env.source_before instead

# File lib/autoproj/environment.rb, line 118
def self.env_source_before(file, shell: "sh")
    env.source_before(file, shell: shell)
end
env_source_file(file, shell: "sh") click to toggle source

@deprecated call Autoproj.env.source_after instead

# File lib/autoproj/environment.rb, line 108
def self.env_source_file(file, shell: "sh")
    env.source_after(file, shell: shell)
end
error(message) click to toggle source

Displays an error message

# File lib/autoproj/reporter.rb, line 37
def self.error(message)
    Autobuild.error(message)
end
expand(value, definitions = Hash.new) click to toggle source

Expand constants within value

The list of constants is given in definitions. It raises ConfigError if some values are not found

# File lib/autoproj/variable_expansion.rb, line 63
def self.expand(value, definitions = Hash.new)
    if value.respond_to?(:to_hash)
        value.dup.each do |name, definition|
            value[name] = expand(definition, definitions)
        end
        value
    elsif value.respond_to?(:to_ary)
        value.map { |val| expand(val, definitions) }
    else
        value = single_expansion(value, definitions)
        if contains_expansion?(value)
            raise ConfigError.new, "some expansions are not defined in #{value.inspect}"
        end

        value
    end
end
export_env_sh(subdir = nil) click to toggle source

@deprecated use Autoproj.env.export_env_sh instead

# File lib/autoproj/environment.rb, line 143
def self.export_env_sh(subdir = nil)
    env.export_env_sh(subdir)
end
filter_out_paths_in_workspace(paths) click to toggle source

Filters in the given list of paths the paths that are within a workspace

# File lib/autoproj/find_workspace.rb, line 74
def self.filter_out_paths_in_workspace(paths)
    known_workspace_dirs = Array.new
    paths.find_all do |p|
        if !File.directory?(p)
            true
        elsif known_workspace_dirs.any? { |ws_root| "#{p}/".start_with?(ws_root) }
            false
        else
            ws_path, ws_config = find_v2_workspace_config(p)
            if ws_path
                known_workspace_dirs << "#{ws_path}/"
                if (ws_dir = ws_config["workspace"])
                    known_workspace_dirs << "#{ws_dir}/"
                end
                false
            else
                true
            end
        end
    end
end
find_in_path(name) click to toggle source

@deprecated use Autobuild.find_in_path instead

Warning: the autobuild method returns nil (instead of raising) if the argument cannot be found

# File lib/autoproj/system.rb, line 65
def self.find_in_path(name)
    Autoproj.warn "#{__method__} is deprecated, use Autobuild.find_in_path instead"
    caller.each { |l| Autoproj.warn "  #{l}" }
    unless (path = Autobuild.find_in_path(name))
        raise ArgumentError, "cannot find #{name} in PATH (#{ENV['PATH']})"
    end

    path
end
find_prefix_dir(base_dir = default_find_base_dir) click to toggle source

Looks for the autoproj prefix that contains a given directory

@return [String,nil]

# File lib/autoproj/find_workspace.rb, line 20
def self.find_prefix_dir(base_dir = default_find_base_dir)
    find_v2_prefix_dir(base_dir)
end
find_topmost_directory_containing(dir, glob_pattern = nil) { |dir| ... } click to toggle source
# File lib/autoproj/autobuild_extensions/dsl.rb, line 115
def self.find_topmost_directory_containing(dir, glob_pattern = nil)
    result = nil
    while dir != "/"
        match = false
        if glob_pattern
            match = true unless Dir.glob(File.join(dir, glob_pattern)).empty?
        end

        match = true if !match && block_given? && yield(dir)

        if !match && result
            return result
        elsif match
            result = dir
        end

        dir = File.dirname(dir)
    end
end
find_v1_workspace_dir(base_dir = default_find_base_dir) click to toggle source

{#find_workspace_dir} for v1 workspaces

Note that for v1 workspaces {#find_prefix_dir} cannot be implemented

# File lib/autoproj/find_workspace.rb, line 109
def self.find_v1_workspace_dir(base_dir = default_find_base_dir)
    path = Pathname.new(base_dir)
    until path.root?
        if path.join("autoproj").exist?
            return path.to_s unless path.join(".autoproj").exist?
        end
        path = path.parent
    end
    nil
end
find_v2_prefix_dir(base_dir = default_find_base_dir) click to toggle source

{#find_prefix_dir} for v2 workspaces

# File lib/autoproj/find_workspace.rb, line 102
def self.find_v2_prefix_dir(base_dir = default_find_base_dir)
    find_v2_root_dir(base_dir, "prefix")
end
find_v2_root_dir(base_dir, config_field_name) click to toggle source

@private

Finds an autoproj “root directory” that contains a given directory. It can either be the root of a workspace or the root of an install directory

@param [String] base_dir the start of the search @param [String] config_field_name the name of a field in the root’s

configuration file, that should be returned instead of the root
itself

@return [String,nil] the root of the workspace directory, or nil if

there's none
# File lib/autoproj/find_workspace.rb, line 56
def self.find_v2_root_dir(base_dir, config_field_name)
    path, config = find_v2_workspace_config(base_dir)
    return unless path

    result = config[config_field_name] || path.to_s
    result = File.expand_path(result, path.to_s)
    return result if result == path.to_s

    resolved = find_v2_root_dir(result, config_field_name)

    if !resolved || (resolved != result)
        raise ArgumentError, "found #{path} as possible workspace root for #{base_dir}, but it contains a configuration file that points to #{result} and #{result} is not an autoproj workspace root"
    end

    resolved
end
find_v2_workspace_config(base_dir) click to toggle source

Find a workspace configuration file in the parent tree of a given directory

@param [String] base_dir the directory to start from @return [(String,Hash),nil] the root path, and the configuration, or nil

if base_dir is not part of a workspace
# File lib/autoproj/find_workspace.rb, line 30
def self.find_v2_workspace_config(base_dir)
    path = Pathname.new(base_dir).expand_path
    until path.root?
        break if path.join(".autoproj", "config.yml").exist?

        path = path.parent
    end

    return if path.root?

    config_path = path.join(".autoproj", "config.yml")
    [path.to_s, (YAML.load(config_path.read) || Hash.new)]
end
find_v2_workspace_dir(base_dir = default_find_base_dir) click to toggle source

{#find_workspace_dir} for v2 workspaces

# File lib/autoproj/find_workspace.rb, line 97
def self.find_v2_workspace_dir(base_dir = default_find_base_dir)
    find_v2_root_dir(base_dir, "workspace")
end
find_workspace_dir(base_dir = default_find_base_dir) click to toggle source

Looks for the autoproj workspace that is related to a given directory

@return [String,nil]

# File lib/autoproj/find_workspace.rb, line 13
def self.find_workspace_dir(base_dir = default_find_base_dir)
    find_v2_workspace_dir(base_dir)
end
flatten_recursive_hash(hash, prefix = "") click to toggle source

Flattens a hash whose keys are strings and values are either plain values, arrays or hashes

The keys in the flattened hash are made hierarchical by appending “.”. Array values are ignored.

@example

h = Hash['test' => 10, 'h' => Hash['value' => '20']]
options_to_flat_hash(h)
# Hash['test' => '10',
#      'h.value' => 20]

@param [{[String,Symbol]=>}] @return [{String=>String}]

# File lib/autoproj/variable_expansion.rb, line 17
def self.flatten_recursive_hash(hash, prefix = "")
    result = Hash.new
    hash.each do |k, v|
        if v.kind_of?(Hash)
            result.merge!(flatten_recursive_hash(v, "#{prefix}#{k}."))
        elsif !v.respond_to?(:to_ary)
            result["#{prefix}#{k}"] = v.to_s
        end
    end
    result
end
git_server_configuration(name, base_url, git_url: "git:// click to toggle source

Adds the relevant options to handle a gitorious server What this does is ask the user how he would like to access the gitorious server. Then, it sets

#{name}_ROOT to be the base URL for pulling
#{name}_PUSH_ROOT to be the corresponding ssh-based URL for pushing

For instance, with

git_server_configuration "GITHUB", "github.com"

One would use the following shortcut in its source.yml:

- my/package:
  github: account/package

which would be expanded to the expected URLs for pull and push.

# File lib/autoproj/git_server_configuration.rb, line 68
def self.git_server_configuration(name, base_url,
    git_url: "git://#{base_url}",
    http_url: "https://git.#{base_url}",
    ssh_url: "git@#{base_url}:",
    default: "http,ssh",
    disabled_methods: [],
    config: Autoproj.config,
    fallback_to_http: nil,
    lazy: false)

    disabled_methods = Array(disabled_methods)

    long_doc = [
        "How should I interact with #{base_url} (#{(GIT_SERVER_ACCESS_METHODS.keys - disabled_methods).sort.join(', ')})",
        "If you give one value, it's going to be the method used for all access",
        "If you give multiple values, comma-separated, the first one will be",
        "used for pulling and the second one for pushing. An optional third value",
        "will be used to pull from private repositories (the same than pushing is",
        "used by default)"
    ]

    config.declare name, "string", default: default, doc: long_doc do |value|
        git_server_validate_config_value(base_url, value, disabled_methods: disabled_methods)
    end

    unless lazy
        pull, push, private_pull = git_server_resolve_master_config(name, config,
                                                                    base_url: base_url,
                                                                    git_url: git_url,
                                                                    http_url: http_url,
                                                                    ssh_url: ssh_url,
                                                                    disabled_methods: disabled_methods)
    end

    Autoproj.add_source_handler name.downcase do |url, private: false, **vcs_options|
        url += ".git" if url !~ /\.git$/
        url = "/#{url}" if url !~ /^\//

        unless GIT_SERVER_CONFIG_VARS.all? { |v| config.has_value_for?("#{name}#{v}") }
            pull, push, private_pull = git_server_resolve_master_config(name, config,
                                                                        base_url: base_url,
                                                                        git_url: git_url,
                                                                        http_url: http_url,
                                                                        ssh_url: ssh_url,
                                                                        disabled_methods: disabled_methods)
        end
        pull_base_url =
            if private
                config.get("#{name}_PRIVATE_ROOT")
            else
                config.get("#{name}_ROOT")
            end
        push_base_url = config.get("#{name}_PUSH_ROOT")
        Hash[type: "git",
             url: "#{pull_base_url}#{url}",
             push_to: "#{push_base_url}#{url}",
             interactive: (private && private_pull == "http"),
             retry_count: 10,
             repository_id: "#{name.downcase}:#{url}"].merge(vcs_options)
    end
end
git_server_resolve_master_config(name, config, base_url:, git_url:, http_url:, ssh_url:, disabled_methods:) click to toggle source

@api private

Helper for {.git_server_configuration}

# File lib/autoproj/git_server_configuration.rb, line 27
def self.git_server_resolve_master_config(name, config, base_url:, git_url:, http_url:, ssh_url:, disabled_methods:)
    access_mode = config.get(name)
    begin
        git_server_validate_config_value(base_url, access_mode, disabled_methods: disabled_methods)
    rescue Autoproj::InputError => e
        Autoproj.warn e.message
        config.reset(name)
        access_mode = config.get(name)
    end
    access_mode = GIT_SERVER_ACCESS_METHODS[access_mode] || access_mode
    pull, push, private_pull = access_mode.split(",")
    private_pull ||= push
    [[pull, "_ROOT"], [push, "_PUSH_ROOT"], [private_pull, "_PRIVATE_ROOT"]].each do |method, var_suffix|
        url = if method == "git" then git_url
              elsif method == "http" then http_url
              elsif method == "ssh" then ssh_url
              end
        config.set("#{name}#{var_suffix}", url)
    end
    [pull, push, private_pull]
end
git_server_validate_config_value(base_url, value, disabled_methods:) click to toggle source

@api private

Helper for {.git_server_configuration}

# File lib/autoproj/git_server_configuration.rb, line 12
def self.git_server_validate_config_value(base_url, value, disabled_methods:)
    values = (GIT_SERVER_ACCESS_METHODS[value] || value).split(",")
    values.each do |access_method|
        if !GIT_SERVER_ACCESS_METHODS.has_key?(access_method)
            raise Autoproj::InputError, "#{access_method} is not a known access method"
        elsif disabled_methods.include?(access_method)
            raise Autoproj::InputError, "#{access_method} is disabled on #{base_url}"
        end
    end
    value
end
gitorious_server_configuration(name, base_url, **options) click to toggle source
# File lib/autoproj/git_server_configuration.rb, line 130
def self.gitorious_server_configuration(name, base_url, **options)
    Autoproj.warn_deprecated "gitorious_server_configuration",
                             "use require 'git_server_configuration' and
        Autoproj.git_server_configuration instead. note that the method call
        interface has not changed, you just have to change the name(s)"
    git_server_configuration(name, base_url, **options)
end
has_config_key?(name) click to toggle source

@deprecated use config.has_value_for?(name)

# File lib/autoproj/options.rb, line 51
def self.has_config_key?(name)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.has_value_for?(name)
end
has_source_handler?(vcs) click to toggle source

Returns true if vcs refers to a source handler name added by add_source_handler

# File lib/autoproj/vcs_definition.rb, line 312
def self.has_source_handler?(vcs)
    @custom_source_handlers.has_key?(vcs.to_s)
end
import_autobuild_file(package_set, path) click to toggle source
# File lib/autoproj/autobuild_extensions/dsl.rb, line 107
def self.import_autobuild_file(package_set, path)
    Autoproj.warn_deprecated(
        __method__,
        "use Autoproj.workspace.import_autobuild_file"
    )
    Autoproj.workspace.import_autobuild_file(package_set, path)
end
in_autoproj_installation?(path) click to toggle source

Returns true if path is part of an autoproj installation

# File lib/autoproj/system.rb, line 13
def self.in_autoproj_installation?(path)
    !!find_workspace_dir(path, "workspace")
end
in_file(file, exception_t = ConfigError) { || ... } click to toggle source

Yields, and if the given block raises a ConfigError with no file assigned, add that file to both the object and the exception message

# File lib/autoproj/base.rb, line 12
def self.in_file(file, exception_t = ConfigError)
    yield
rescue exception_t => e
    if exception_t != ConfigError
        raise ConfigError.new(file), "in #{file}: #{e.message}", e.backtrace
    elsif !e.file
        e.file = file
        raise e, "in #{file}: #{e.message}", e.backtrace
    else
        raise e
    end
end
in_package_set(package_set, path, &block) click to toggle source

@deprecated use Autoproj.workspace.in_package_set or add a proper Loader

object to your class
# File lib/autoproj/autobuild_extensions/dsl.rb, line 59
def self.in_package_set(package_set, path, &block)
    Autoproj.warn_deprecated(
        __method__,
        "use Autoproj.workspace.in_package_set instead"
    )
    Autoproj.workspace.in_package_set(package_set, path, &block)
end
isolate_environment() click to toggle source

@deprecated use Autoproj.env.isolate instead

# File lib/autoproj/environment.rb, line 133
def self.isolate_environment
    env.isolate
end
load(package_set, *path) click to toggle source

@deprecated use workspace.load or add a separate Loader object to your class

# File lib/autoproj/system.rb, line 107
def self.load(package_set, *path)
    Autoproj.warn_deprecated(
        __method__,
        "use workspace.load or add a separate Loader object to your class"
    )
    workspace.load(package_set, *path)
end
load_config() click to toggle source
# File lib/autoproj/options.rb, line 73
def self.load_config
    workspace.load_config
end
load_if_present(package_set, *path) click to toggle source

@deprecated use workspace.load_if_present or add a separate Loader object to your class

# File lib/autoproj/system.rb, line 116
def self.load_if_present(package_set, *path)
    Autoproj.warn_deprecated(
        __method__,
        "use workspace.load_if_present or add a separate Loader object to your class"
    )
    workspace.load_if_present(package_set, *path)
end
loaded_autobuild_files() click to toggle source
# File lib/autoproj/autobuild_extensions/dsl.rb, line 100
def self.loaded_autobuild_files
    Autoproj.warn_deprecated(
        __method__, "use Autoproj.workspace.loaded_autobuild_files"
    )
    Autoproj.workspace.loaded_autobuild_files
end
manifest() click to toggle source
# File lib/autoproj/manifest.rb, line 1227
def self.manifest
    Autoproj.warn_deprecated(
        __method__, "use workspace.manifest instead"
    )

    workspace.manifest
end
message(*args) click to toggle source
# File lib/autoproj/reporter.rb, line 28
def self.message(*args)
    Autobuild.message(*args)
end
not_silent() { || ... } click to toggle source
# File lib/autoproj/reporter.rb, line 20
def self.not_silent
    silent = Autobuild.silent?
    Autobuild.silent = false
    yield
ensure
    Autobuild.silent = silent
end
option_set() click to toggle source

@deprecated use config.validated_values instead

# File lib/autoproj/options.rb, line 21
def self.option_set
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.validated_values
end
osdeps() click to toggle source
# File lib/autoproj/manifest.rb, line 1235
def self.osdeps
    Autoproj.warn_deprecated(
        __method__, "use workspace.os_package_resolver or workspace.os_package_installer instead"
    )

    workspace.os_package_resolver
end
override_option(option_name, value) click to toggle source

@deprecated use config.override instead

# File lib/autoproj/options.rb, line 3
def self.override_option(option_name, value)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.override(option_name, value)
end
overrides_dir() click to toggle source

@deprecated use workspace.overrides_dir instead

# File lib/autoproj/system.rb, line 55
def self.overrides_dir
    Autoproj.warn "#{__method__} is deprecated, use workspace.overrides_dir instead"
    caller.each { |l| Autoproj.warn "  #{l}" }
    workspace.overrides_dir
end
package_handler_for(full_path) click to toggle source

Tries to find a handler automatically for ‘full_path’

# File lib/autoproj/autobuild_extensions/dsl.rb, line 136
def self.package_handler_for(full_path)
    each_custom_package_handler do |handler|
        pair = handler.call(full_path)
        return pair if pair
    end
    pyglob = File.join(File.basename(full_path), "*.py")
    if !Dir.enum_for(:glob, File.join(full_path, "*.orogen")).to_a.empty?
        ["orogen_package", full_path]
    elsif File.file?(File.join(full_path, "Makefile.am"))
        toplevel_dir = find_topmost_directory_containing(full_path) do |dir|
            configure_ac = File.join(dir, "configure.ac")
            configure_in = File.join(dir, "configure.in")
            File.file?(configure_ac) || File.file?(configure_in)
        end
        ["autotools_package", toplevel_dir] if toplevel_dir
    elsif File.file?(File.join(full_path, "configure.ac")) ||
          File.file?(File.join(full_path, "configure.in"))
        ["autotools_package", full_path]
    elsif File.file?(File.join(full_path, "CMakeLists.txt"))
        toplevel_dir = find_topmost_directory_containing(full_path) do |dir|
            cmakelists = File.join(dir, "CMakeLists.txt")
            File.file?(cmakelists) &&
                (File.read(cmakelists) =~ /PROJECT/i)
        end
        toplevel_dir ||= find_topmost_directory_containing(
            full_path, "CMakeLists.txt"
        )

        manifest_xml = File.join(toplevel_dir, "manifest.xml")
        package_xml = File.join(toplevel_dir, "package.xml")
        if File.file?(package_xml) && !File.file?(manifest_xml)
            return "catkin_package", toplevel_dir
        end

        ["cmake_package", toplevel_dir]
    elsif (dir = (find_topmost_directory_containing(full_path, "Rakefile") ||
                  find_topmost_directory_containing(full_path, "lib/*.rb")))

        ["ruby_package", dir]
    elsif (dir = (find_topmost_directory_containing(full_path, "setup.py") ||
                  find_topmost_directory_containing(full_path, pyglob)))
        ["python_package", dir]
    end
end
package_name_from_options(spec) click to toggle source

@api private

Helper method that extracts the package name from a Rake-style package definition (e.g. package_name => package_deps)

# File lib/autoproj/autobuild_extensions/dsl.rb, line 49
def self.package_name_from_options(spec)
    if spec.kind_of?(Hash)
        spec.to_a.first.first.to_str
    else
        spec.to_str
    end
end
post_import(*packages, &block) click to toggle source

Register a block that should be called after a set of package(s) have been imported

@overload post_import(&block) register the block for all packages @overload post_import(*packages, &block)

@param [Array<Autobuild::Package,PackageDefinition>] packages
# File lib/autoproj/base.rb, line 48
def self.post_import(*packages, &block)
    if packages.empty?
        @post_import_blocks[nil] << block
    else
        packages.each do |pkg|
            # We use Autobuild packages as keys
            pkg = pkg.autobuild if pkg.respond_to?(:autobuild)
            @post_import_blocks[pkg] << block
        end
    end
end
prefix() click to toggle source

@deprecated use workspace.prefix_dir instead

# File lib/autoproj/system.rb, line 76
def self.prefix
    Autoproj.warn_deprecated(__method__, "workspace.prefix_dir")
    workspace.prefix_dir
end
prefix=(path) click to toggle source

@deprecated use workspace.prefix_dir= instead

# File lib/autoproj/system.rb, line 82
def self.prefix=(path)
    Autoproj.warn_deprecated(__method__, "workspace.prefix_dir=")
    workspace.prefix_dir = path
end
prepare_environment(env = Autoproj.env, manifest = Autoproj.manifest) click to toggle source

@deprecated call Autoproj.env.prepare directly

# File lib/autoproj/environment.rb, line 138
def self.prepare_environment(env = Autoproj.env, manifest = Autoproj.manifest)
    env.prepare(manifest)
end
reconfigure?() click to toggle source
# File lib/autoproj/options.rb, line 80
def self.reconfigure?
    @reconfigure
end
remotes_dir() click to toggle source

@deprecated use workspace.remotes_dir instead

# File lib/autoproj/system.rb, line 101
def self.remotes_dir
    Autoproj.warn_deprecated(__method__, "use workspace.remotes_dir instead")
    workspace.remotes_dir
end
remove_source_handler(name) click to toggle source

Deregister a source handler defined with {.add_source_handler}

# File lib/autoproj/vcs_definition.rb, line 356
def self.remove_source_handler(name)
    @custom_source_handlers.delete(name)
end
report(root_dir: nil, silent: nil, debug: Autobuild.debug, on_package_success: :report, on_package_failures: Autobuild::Reporting .default_report_on_package_failures) { || ... } click to toggle source
# File lib/autoproj/reporter.rb, line 95
def self.report(root_dir: nil, silent: nil, debug: Autobuild.debug,
    on_package_success: :report,
    on_package_failures: Autobuild::Reporting
        .default_report_on_package_failures)
    reporter = Autoproj::Reporter.new
    Autobuild::Reporting << reporter
    interrupted = nil

    unless silent.nil?
        on_package_success = silent ? :silent : :report
    end
    silent_errors = %I[report_silent exit_silent].include?(on_package_failures)

    package_failures =
        Autobuild::Reporting.report(on_package_failures: :report_silent) do
            reporter.reset_timer
            yield
        rescue Interrupt => e
            interrupted = e
        end

    if package_failures.empty?
        raise interrupted if interrupted

        Autobuild::Reporting.success if on_package_success == :report
        []
    else
        Autobuild::Reporting.report_finish_on_error(
            package_failures,
            on_package_failures: on_package_failures, interrupted_by: interrupted
        )
    end
rescue CLI::CLIException, InvalidWorkspace, ConfigError => e
    if silent_errors
        [e]
    elsif on_package_failures == :raise
        raise e
    elsif on_package_failures == :report
        Autoproj.not_silent do
            Autoproj.error e.message
        end
        [e]
    elsif on_package_failures == :exit
        Autoproj.not_silent do
            Autoproj.error e.message
        end
        exit 1
    end
rescue SystemExit
    raise
ensure
    report_interrupt if !silent_errors && interrupted

    Autobuild::Reporting.remove(reporter) if reporter
end
report_interrupt(io = STDERR) click to toggle source
# File lib/autoproj/reporter.rb, line 46
def self.report_interrupt(io = STDERR)
    io.puts
    io.puts color("Interrupted by user", :red, :bold)
end
reset_option(key) click to toggle source

@deprecated use config.reset instead

# File lib/autoproj/options.rb, line 9
def self.reset_option(key)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.reset(key)
end
resolve_constant_definitions(constants, definitions = Hash.new) click to toggle source

Resolves all possible variable references from constants

I.e. replaces variables by their values, so that no value in constants refers to variables defined in constants

# File lib/autoproj/variable_expansion.rb, line 97
def self.resolve_constant_definitions(constants, definitions = Hash.new)
    definitions = definitions.merge(constants)

    all_resolutions = Hash.new
    resolution_cache = Hash.new
    constants.each do |key, value|
        all_resolutions[key] = resolve_one_constant(key, value, resolution_cache, definitions)
    end
    all_resolutions
end
resolve_one_constant(name, value, result, definitions) click to toggle source
# File lib/autoproj/variable_expansion.rb, line 86
def self.resolve_one_constant(name, value, result, definitions)
    result[name] ||= single_expansion(value, result) do |missing_name|
        result[missing_name] =
            resolve_one_constant(missing_name, definitions[missing_name], result, definitions)
    end
end
root_dir(dir = Dir.pwd) click to toggle source

Returns the root directory of the current autoproj installation.

If the current directory is not in an autoproj installation, raises UserError.

# File lib/autoproj/system.rb, line 33
def self.root_dir(dir = Dir.pwd)
    if @root_dir
        return @root_dir
    elsif !dir
        @root_dir = ni
        return
    end

    path = Autoproj.find_workspace_dir(dir)
    raise UserError, "not in a Autoproj installation" unless path

    path
end
root_dir=(dir) click to toggle source

Forcefully sets the root directory

This is mostly useful during bootstrapping (i.e. when the search would fail)

# File lib/autoproj/system.rb, line 21
def self.root_dir=(dir)
    if @workspace && dir != @workspace.root_dir
        raise WorkspaceAlreadyCreated, "cannot switch global root directory after a workspace object got created"
    end

    @root_dir = dir
end
ruby_executable() click to toggle source

@deprecated use Workspace.config.ruby_executable instead, or

Autoproj.config.ruby_executable if you don't have a workspace context
object
# File lib/autoproj/autobuild_extensions/dsl.rb, line 10
def self.ruby_executable
    config.ruby_executable
end
run_as_root(*args, env: workspace.env) click to toggle source

Run the provided command as root, using sudo to gain root access

# File lib/autoproj/system.rb, line 130
def self.run_as_root(*args, env: workspace.env)
    unless system(Autobuild.tool_in_path("sudo", env: env), *args)
        raise "failed to run #{args.join(' ')} as root"
    end
end
run_as_user(*args) click to toggle source

Run the provided command as user

# File lib/autoproj/system.rb, line 125
def self.run_as_user(*args)
    raise "failed to run #{args.join(' ')}" unless system(*args)
end
save_config() click to toggle source
# File lib/autoproj/options.rb, line 68
def self.save_config
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.save
end
set_initial_env() click to toggle source

@deprecated use Autoproj.env.isolate instead

# File lib/autoproj/environment.rb, line 128
def self.set_initial_env
    isolate_environment
end
shell_helpers=(flag) click to toggle source

@deprecated use config.shell_helpers= instead

# File lib/autoproj/options.rb, line 63
def self.shell_helpers=(flag)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.shell_helpers = flag
end
shell_helpers?() click to toggle source

@deprecated use config.shell_helpers? instead

# File lib/autoproj/options.rb, line 57
def self.shell_helpers?
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.shell_helpers?
end
silent(&block) click to toggle source
# File lib/autoproj/reporter.rb, line 16
def self.silent(&block)
    Autobuild.silent(&block)
end
silent=(value) click to toggle source
# File lib/autoproj/reporter.rb, line 10
def silent=(value)
    Autobuild.silent = value
end
silent?() click to toggle source
# File lib/autoproj/reporter.rb, line 6
def silent?
    Autobuild.silent?
end
single_expansion(data, definitions) { |constant_name| ... } click to toggle source

Does a non-recursive expansion in data of configuration variables ($VAR_NAME) listed in definitions

If the values listed in definitions also contain configuration variables, they do not get expanded

# File lib/autoproj/variable_expansion.rb, line 34
def self.single_expansion(data, definitions)
    return data unless data.respond_to?(:to_str)

    data = data.gsub(/(.|^)\$(\w+)/) do |constant_name|
        prefix = constant_name[0, 1]
        next(constant_name[1..-1]) if prefix == "\\"

        if prefix == "$"
            prefix = ""
            constant_name = constant_name[1..-1]
        else
            constant_name = constant_name[2..-1]
        end

        value = definitions[constant_name]
        if value.nil?
            if !block_given? || !(value = yield(constant_name))
                raise ArgumentError, "cannot find a definition for $#{constant_name}"
            end
        end
        "#{prefix}#{value}"
    end
    data
end
user_config(key) click to toggle source

@deprecated use config.get(key) instead

# File lib/autoproj/options.rb, line 27
def self.user_config(key)
    Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead"
    config.get(key)
end
validate_solib_dependencies(dir, exclude_paths = []) click to toggle source

Look into dir, searching for shared libraries. For each library, display a warning message if this library has undefined symbols.

# File lib/autoproj/system.rb, line 138
def self.validate_solib_dependencies(dir, exclude_paths = [])
    Find.find(File.expand_path(dir)) do |name|
        next unless name =~ /\.so$/
        next if exclude_paths.find { |p| name =~ p }

        output = `ldd -r #{name} 2>&1`
        if output =~ /undefined symbol/
            Autoproj.message("  WARN: #{name} has undefined symbols", :magenta)
        end
    end
end
warn(message, *style) click to toggle source

Displays a warning message

# File lib/autoproj/reporter.rb, line 42
def self.warn(message, *style)
    Autobuild.warn(message, *style)
end
warn_deprecated(method, msg = nil, level = 0) click to toggle source
# File lib/autoproj.rb, line 82
def self.warn_deprecated(method, msg = nil, level = 0)
    if level >= @warn_deprecated_level
        if msg
            Autoproj.warn "#{method} is deprecated, #{msg}"
        else
            Autoproj.warn msg
        end
        caller.each { |l| Autoproj.warn "  #{l}" }
    end
end
warn_deprecated_level() click to toggle source
# File lib/autoproj.rb, line 73
def self.warn_deprecated_level
    @warn_deprecated_level
end
warn_deprecated_level=(level) click to toggle source
# File lib/autoproj.rb, line 77
def self.warn_deprecated_level=(level)
    @warn_deprecated_level = level
end
workspace() click to toggle source
# File lib/autoproj/workspace.rb, line 938
def self.workspace
    @workspace ||= Workspace.new(root_dir)
end
workspace=(ws) click to toggle source
# File lib/autoproj/workspace.rb, line 942
def self.workspace=(ws)
    @workspace = ws
    self.root_dir = ws&.root_dir
end