Module: Autoproj
- Extended by:
- Logger::Forward
- Defined in:
- lib/autoproj.rb,
lib/autoproj/cli.rb,
lib/autoproj/base.rb,
lib/autoproj/test.rb,
lib/autoproj/python.rb,
lib/autoproj/system.rb,
lib/autoproj/cli/doc.rb,
lib/autoproj/cli/log.rb,
lib/autoproj/cli/tag.rb,
lib/autoproj/options.rb,
lib/autoproj/version.rb,
lib/autoproj/cli/base.rb,
lib/autoproj/cli/exec.rb,
lib/autoproj/cli/main.rb,
lib/autoproj/cli/show.rb,
lib/autoproj/cli/test.rb,
lib/autoproj/manifest.rb,
lib/autoproj/reporter.rb,
lib/autoproj/cli/build.rb,
lib/autoproj/cli/cache.rb,
lib/autoproj/cli/clean.rb,
lib/autoproj/cli/envsh.rb,
lib/autoproj/cli/query.rb,
lib/autoproj/cli/reset.rb,
lib/autoproj/cli/watch.rb,
lib/autoproj/cli/which.rb,
lib/autoproj/ops/build.rb,
lib/autoproj/ops/cache.rb,
lib/autoproj/ops/tools.rb,
lib/autoproj/ops/watch.rb,
lib/autoproj/ops/which.rb,
lib/autoproj/workspace.rb,
lib/autoproj/cli/commit.rb,
lib/autoproj/cli/locate.rb,
lib/autoproj/cli/osdeps.rb,
lib/autoproj/cli/status.rb,
lib/autoproj/cli/update.rb,
lib/autoproj/exceptions.rb,
lib/autoproj/ops/import.rb,
lib/autoproj/ops/loader.rb,
lib/autoproj/query_base.rb,
lib/autoproj/cli/patcher.rb,
lib/autoproj/cli/utility.rb,
lib/autoproj/cli/version.rb,
lib/autoproj/environment.rb,
lib/autoproj/metapackage.rb,
lib/autoproj/ops/install.rb,
lib/autoproj/package_set.rb,
lib/autoproj/build_option.rb,
lib/autoproj/cli/main_doc.rb,
lib/autoproj/cli/manifest.rb,
lib/autoproj/cli/versions.rb,
lib/autoproj/ops/snapshot.rb,
lib/autoproj/cli/bootstrap.rb,
lib/autoproj/cli/main_test.rb,
lib/autoproj/configuration.rb,
lib/autoproj/aruba_minitest.rb,
lib/autoproj/find_workspace.rb,
lib/autoproj/ops/cached_env.rb,
lib/autoproj/vcs_definition.rb,
lib/autoproj/zsh_completion.rb,
lib/autoproj/bash_completion.rb,
lib/autoproj/cli/main_global.rb,
lib/autoproj/cli/main_plugin.rb,
lib/autoproj/cli/reconfigure.rb,
lib/autoproj/ops/atomic_write.rb,
lib/autoproj/os_package_query.rb,
lib/autoproj/package_manifest.rb,
lib/autoproj/shell_completion.rb,
lib/autoproj/cli/switch_config.rb,
lib/autoproj/local_package_set.rb,
lib/autoproj/ops/configuration.rb,
lib/autoproj/package_selection.rb,
lib/autoproj/package_definition.rb,
lib/autoproj/variable_expansion.rb,
lib/autoproj/cli/inspection_tool.rb,
lib/autoproj/ops/phase_reporting.rb,
lib/autoproj/os_package_resolver.rb,
lib/autoproj/os_package_installer.rb,
lib/autoproj/ros_condition_parser.rb,
lib/autoproj/ros_package_manifest.rb,
lib/autoproj/source_package_query.rb,
lib/autoproj/installation_manifest.rb,
lib/autoproj/os_repository_resolver.rb,
lib/autoproj/os_repository_installer.rb,
lib/autoproj/repository_managers/apt.rb,
lib/autoproj/autobuild_extensions/dsl.rb,
lib/autoproj/autobuild_extensions/git.rb,
lib/autoproj/autobuild_extensions/svn.rb,
lib/autoproj/git_server_configuration.rb,
lib/autoproj/ops/main_config_switcher.rb,
lib/autoproj/package_managers/manager.rb,
lib/autoproj/autobuild_extensions/python.rb,
lib/autoproj/repository_managers/manager.rb,
lib/autoproj/autobuild_extensions/package.rb,
lib/autoproj/package_managers/gem_manager.rb,
lib/autoproj/package_managers/pip_manager.rb,
lib/autoproj/package_managers/pkg_manager.rb,
lib/autoproj/package_managers/yum_manager.rb,
lib/autoproj/package_managers/port_manager.rb,
lib/autoproj/package_managers/debian_version.rb,
lib/autoproj/package_managers/emerge_manager.rb,
lib/autoproj/package_managers/pacman_manager.rb,
lib/autoproj/package_managers/zypper_manager.rb,
lib/autoproj/package_managers/bundler_manager.rb,
lib/autoproj/package_managers/apt_dpkg_manager.rb,
lib/autoproj/package_managers/homebrew_manager.rb,
lib/autoproj/package_managers/unknown_os_manager.rb,
lib/autoproj/autobuild_extensions/archive_importer.rb,
lib/autoproj/package_managers/shell_script_manager.rb,
lib/autoproj/repository_managers/unknown_os_manager.rb
Defined Under Namespace
Modules: ArubaMinitest, AutobuildExtensions, CLI, CmdLine, Ops, PackageManagers, Python, RepositoryManagers, SelfTest Classes: BashCompletion, BuildOption, ConfigError, Configuration, Environment, ExcludedPackage, ExcludedSelection, ExecutableNotFound, ImportFailed, InputError, InstallationManifest, InternalError, InvalidPackageManifest, InvalidWorkspace, InvalidYAMLFormatting, LocalPackageSet, Manifest, Metapackage, MismatchingWorkspace, MissingOSDep, NotWorkspace, OSPackageInstaller, OSPackageQuery, OSPackageResolver, OSRepositoryInstaller, OSRepositoryResolver, OutdatedWorkspace, PackageDefinition, PackageImportFailed, PackageManifest, PackageNotFound, PackageSelection, PackageSet, PackageUnavailable, QueryBase, Reporter, RosConditionParser, RosPackageManifest, ShellCompletion, SourcePackageQuery, UnregisteredPackage, UnregisteredPackageSet, UserError, VCSDefinition, Workspace, WorkspaceAlreadyCreated, ZshCompletion
Constant Summary collapse
- YAML_LOAD_ERROR =
if defined? Psych::SyntaxError Psych::SyntaxError else ArgumentError end
- VERSION =
"2.17.0"
- ENV_FILENAME =
if Autobuild.windows? then "env.bat" else "env.sh" end
- Query =
For backward compatibility
SourcePackageQuery
- GIT_SERVER_CONFIG_VARS =
%w[_ROOT _PUSH_ROOT _PRIVATE_ROOT]
- GIT_SERVER_ACCESS_METHODS =
Hash[ "git" => "git,ssh", "ssh" => "ssh,ssh", "http" => "http,http"]
Class Attribute Summary collapse
- .custom_package_handlers ⇒ Object
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.post_import_blocks ⇒ Object
readonly
Returns the value of attribute post_import_blocks.
-
.reconfigure ⇒ Object
Returns the value of attribute reconfigure.
-
.verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
- .add_osdeps_overrides(*args, **kw, &block) ⇒ Object
-
.add_source_handler(name) {|url, the| ... } ⇒ Hash
Add a custom source handler named
name
. -
.build_dir ⇒ Object
deprecated
Deprecated.
use workspace.prefix_dir instead
-
.bundler_unbundled_system(*args, **options) ⇒ Object
Shim for a smooth upgrade path to bundler 2.1+.
-
.bundler_with_unbundled_env(&block) ⇒ Object
Shim for a smooth upgrade path to bundler 2.1+.
-
.call_source_handler(vcs, url, options) ⇒ Object
Returns the source handlers associated with
vcs
. -
.change_option(key, value, user_validated = false) ⇒ Object
deprecated
Deprecated.
use config.set(key, value, user_validated) instead
- .color(*args) ⇒ Object
- .config ⇒ Object
-
.config_dir ⇒ Object
deprecated
Deprecated.
use workspace.config_dir instead
-
.config_file(file) ⇒ Object
deprecated
Deprecated.
compute the full path with File.join(config_dir, file) directly instead
-
.configuration_option(name, type, options, &validator) ⇒ Object
deprecated
Deprecated.
use config.declare(name, type, options, &validator) instead
-
.configure(option_name) ⇒ Object
deprecated
Deprecated.
use config.configure(option_name) instead
-
.contains_expansion?(string) ⇒ Boolean
True if the given string contains expansions.
-
.create_symlink(from, to) ⇒ Object
OS-independent creation of symbolic links.
-
.current_file ⇒ Object
deprecated
Deprecated.
use Autoproj.workspace.current_file or add a proper Loader object to your class
-
.current_package_set ⇒ Object
deprecated
Deprecated.
use Autoproj.workspace.current_package_set or add a proper Loader object to your class
-
.custom_package_handler(&block) ⇒ Object
Registers a block that will be called to determine a package handler for the package in full_path.
-
.declared_option?(name) ⇒ Boolean
deprecated
Deprecated.
use config.declared?(name, type, options, &validator) instead
-
.default_find_base_dir ⇒ Object
The base path from which we search for workspaces.
-
.define(package_type, spec, &block) ⇒ Object
deprecated
Deprecated.
use Workspace#define_package directly instead. Beware that the return value changed from Autobuild::Package to Autoproj::PackageDefinition
- .each_custom_package_handler(&block) ⇒ Object
-
.each_post_import_block(pkg, &block) ⇒ Object
Enumerate the post-import blocks registered for the given package.
- .env ⇒ Object
-
.env_add(name, *value) ⇒ Object
deprecated
Deprecated.
call Autoproj.env.add instead
-
.env_add_path(name, *value) ⇒ Object
deprecated
Deprecated.
call Autoproj.env.add_path instead
-
.env_inherit(*names) ⇒ Object
deprecated
Deprecated.
call Autoproj.env.inherit instead
-
.env_set(name, *value) ⇒ Object
deprecated
Deprecated.
call Autoproj.env.set instead
-
.env_set_path(name, *value) ⇒ Object
deprecated
Deprecated.
call Autoproj.env.set_path instead
-
.env_source_after(file, shell: "sh") ⇒ Object
deprecated
Deprecated.
call Autoproj.env.source_after instead
-
.env_source_before(file, shell: "sh") ⇒ Object
deprecated
Deprecated.
call Autoproj.env.source_before instead
-
.env_source_file(file, shell: "sh") ⇒ Object
deprecated
Deprecated.
call Autoproj.env.source_after instead
-
.error(message) ⇒ Object
Displays an error message.
-
.expand(value, definitions = Hash.new) ⇒ Object
Expand constants within
value
. -
.export_env_sh(subdir = nil) ⇒ Object
deprecated
Deprecated.
use Autoproj.env.export_env_sh instead
-
.filter_out_paths_in_workspace(paths) ⇒ Object
Filters in the given list of paths the paths that are within a workspace.
-
.find_in_path(name) ⇒ Object
deprecated
Deprecated.
use Autobuild.find_in_path instead
-
.find_prefix_dir(base_dir = default_find_base_dir) ⇒ String?
Looks for the autoproj prefix that contains a given directory.
- .find_topmost_directory_containing(dir, glob_pattern = nil) ⇒ Object
-
.find_v1_workspace_dir(base_dir = default_find_base_dir) ⇒ Object
#find_workspace_dir for v1 workspaces.
-
.find_v2_prefix_dir(base_dir = default_find_base_dir) ⇒ Object
#find_prefix_dir for v2 workspaces.
-
.find_v2_root_dir(base_dir, config_field_name) ⇒ String?
Finds an autoproj “root directory” that contains a given directory.
-
.find_v2_workspace_config(base_dir) ⇒ (String,Hash)?
Find a workspace configuration file in the parent tree of a given directory.
-
.find_v2_workspace_dir(base_dir = default_find_base_dir) ⇒ Object
#find_workspace_dir for v2 workspaces.
-
.find_workspace_dir(base_dir = default_find_base_dir) ⇒ String?
Looks for the autoproj workspace that is related to a given directory.
-
.flatten_recursive_hash(hash, prefix = "") ⇒ {String=>String}
Flattens a hash whose keys are strings and values are either plain values, arrays or hashes.
-
.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) ⇒ Object
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.
-
.git_server_resolve_master_config(name, config, base_url:, git_url:, http_url:, ssh_url:, disabled_methods:) ⇒ Object
private
Helper for Autoproj.git_server_configuration.
-
.git_server_validate_config_value(base_url, value, disabled_methods:) ⇒ Object
private
Helper for Autoproj.git_server_configuration.
- .gitorious_server_configuration(name, base_url, **options) ⇒ Object
-
.has_config_key?(name) ⇒ Boolean
deprecated
Deprecated.
use config.has_value_for?(name)
-
.has_source_handler?(vcs) ⇒ Boolean
Returns true if
vcs
refers to a source handler name added by #add_source_handler. - .import_autobuild_file(package_set, path) ⇒ Object
-
.in_autoproj_installation?(path) ⇒ Boolean
Returns true if
path
is part of an autoproj installation. -
.in_file(file, exception_t = ConfigError) ⇒ Object
Yields, and if the given block raises a ConfigError with no file assigned, add that file to both the object and the exception message.
-
.in_package_set(package_set, path, &block) ⇒ Object
deprecated
Deprecated.
use Autoproj.workspace.in_package_set or add a proper Loader object to your class
-
.isolate_environment ⇒ Object
deprecated
Deprecated.
use Autoproj.env.isolate instead
-
.load(package_set, *path) ⇒ Object
deprecated
Deprecated.
use workspace.load or add a separate Loader object to your class
- .load_config ⇒ Object
-
.load_if_present(package_set, *path) ⇒ Object
deprecated
Deprecated.
use workspace.load_if_present or add a separate Loader object to your class
- .loaded_autobuild_files ⇒ Object
- .manifest ⇒ Object
- .message(*args) ⇒ Object
- .not_silent ⇒ Object
-
.option_set ⇒ Object
deprecated
Deprecated.
use config.validated_values instead
- .osdeps ⇒ Object
-
.override_option(option_name, value) ⇒ Object
deprecated
Deprecated.
use config.override instead
-
.overrides_dir ⇒ Object
deprecated
Deprecated.
use workspace.overrides_dir instead
-
.package_handler_for(full_path) ⇒ Object
Tries to find a handler automatically for ‘full_path’.
-
.package_name_from_options(spec) ⇒ Object
private
Helper method that extracts the package name from a Rake-style package definition (e.g. package_name => package_deps).
-
.post_import(*packages, &block) ⇒ Object
Register a block that should be called after a set of package(s) have been imported.
-
.prefix ⇒ Object
deprecated
Deprecated.
use workspace.prefix_dir instead
-
.prefix=(path) ⇒ Object
deprecated
Deprecated.
use workspace.prefix_dir= instead
-
.prepare_environment(env = Autoproj.env, manifest = Autoproj.manifest) ⇒ Object
deprecated
Deprecated.
call Autoproj.env.prepare directly
- .reconfigure? ⇒ Boolean
-
.remotes_dir ⇒ Object
deprecated
Deprecated.
use workspace.remotes_dir instead
-
.remove_source_handler(name) ⇒ Object
Deregister a source handler defined with Autoproj.add_source_handler.
- .report(root_dir: nil, silent: nil, debug: Autobuild.debug, on_package_success: :report, on_package_failures: Autobuild::Reporting .default_report_on_package_failures) ⇒ Object
- .report_interrupt(io = STDERR) ⇒ Object
-
.reset_option(key) ⇒ Object
deprecated
Deprecated.
use config.reset instead
-
.resolve_constant_definitions(constants, definitions = Hash.new) ⇒ Object
Resolves all possible variable references from
constants
. - .resolve_one_constant(name, value, result, definitions) ⇒ Object
-
.root_dir(dir = Dir.pwd) ⇒ Object
Returns the root directory of the current autoproj installation.
-
.root_dir=(dir) ⇒ Object
Forcefully sets the root directory.
-
.ruby_executable ⇒ Object
deprecated
Deprecated.
use Workspace.config.ruby_executable instead, or Autoproj.config.ruby_executable if you don’t have a workspace context object
-
.run_as_root(*args, env: workspace.env) ⇒ Object
Run the provided command as root, using sudo to gain root access.
-
.run_as_user(*args) ⇒ Object
Run the provided command as user.
- .save_config ⇒ Object
-
.set_initial_env ⇒ Object
deprecated
Deprecated.
use Autoproj.env.isolate instead
-
.shell_helpers=(flag) ⇒ Object
deprecated
Deprecated.
use config.shell_helpers= instead
-
.shell_helpers? ⇒ Boolean
deprecated
Deprecated.
use config.shell_helpers? instead
- .silent(&block) ⇒ Object
- .silent=(value) ⇒ Object
- .silent? ⇒ Boolean
-
.single_expansion(data, definitions) ⇒ Object
Does a non-recursive expansion in
data
of configuration variables ($VAR_NAME) listed indefinitions
. -
.user_config(key) ⇒ Object
deprecated
Deprecated.
use config.get(key) instead
-
.validate_solib_dependencies(dir, exclude_paths = []) ⇒ Object
Look into
dir
, searching for shared libraries. -
.warn(message, *style) ⇒ Object
Displays a warning message.
- .warn_deprecated(method, msg = nil, level = 0) ⇒ Object
- .warn_deprecated_level ⇒ Object
- .warn_deprecated_level=(level) ⇒ Object
- .workspace ⇒ Object
- .workspace=(ws) ⇒ Object
Class Attribute Details
.custom_package_handlers ⇒ Object
26 27 28 |
# File 'lib/autoproj/autobuild_extensions/dsl.rb', line 26 def custom_package_handlers @custom_package_handlers ||= [] end |
.logger ⇒ Object
Returns the value of attribute logger.
66 67 68 |
# File 'lib/autoproj.rb', line 66 def logger @logger end |
.post_import_blocks ⇒ Object (readonly)
Returns the value of attribute post_import_blocks.
27 28 29 |
# File 'lib/autoproj/base.rb', line 27 def post_import_blocks @post_import_blocks end |
.reconfigure ⇒ Object
Returns the value of attribute reconfigure.
78 79 80 |
# File 'lib/autoproj/options.rb', line 78 def reconfigure @reconfigure end |
.verbose ⇒ Object
Returns the value of attribute verbose.
4 5 6 |
# File 'lib/autoproj/reporter.rb', line 4 def verbose @verbose end |
Class Method Details
.add_osdeps_overrides(*args, **kw, &block) ⇒ Object
1249 1250 1251 |
# File 'lib/autoproj/manifest.rb', line 1249 def self.add_osdeps_overrides(*args, **kw, &block) manifest.add_osdeps_overrides(*args, **kw, &block) end |
.add_source_handler(name) {|url, the| ... } ⇒ Hash
Add a custom source handler named name
Custom source handlers are shortcuts that can be used to represent VCS information. For instance, the 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
351 352 353 |
# 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 ⇒ Object
use workspace.prefix_dir instead
88 89 90 91 |
# 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) ⇒ Object
Shim for a smooth upgrade path to bundler 2.1+
61 62 63 64 65 66 67 |
# File 'lib/autoproj/base.rb', line 61 def self.bundler_unbundled_system(*args, **) if Bundler.respond_to?(:unbundled_system) Bundler.unbundled_system(*args, **) else Bundler.clean_system(*args, **) end end |
.bundler_with_unbundled_env(&block) ⇒ Object
Shim for a smooth upgrade path to bundler 2.1+
70 71 72 73 74 75 76 |
# 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) ⇒ Object
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
321 322 323 324 325 326 327 328 |
# File 'lib/autoproj/vcs_definition.rb', line 321 def self.call_source_handler(vcs, url, ) handler = @custom_source_handlers[vcs.to_s] if handler handler.call(url, **) else raise ArgumentError, "there is no source handler for #{vcs}" end end |
.change_option(key, value, user_validated = false) ⇒ Object
use config.set(key, value, user_validated) instead
15 16 17 18 |
# 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) ⇒ Object
32 33 34 |
# File 'lib/autoproj/reporter.rb', line 32 def self.color(*args) Autobuild.color(*args) end |
.config ⇒ Object
1245 1246 1247 |
# File 'lib/autoproj/manifest.rb', line 1245 def self.config workspace.config end |
.config_dir ⇒ Object
use workspace.config_dir instead
48 49 50 51 52 |
# 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) ⇒ Object
compute the full path with File.join(config_dir, file) directly instead
95 96 97 98 |
# 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) ⇒ Object
use config.declare(name, type, options, &validator) instead
33 34 35 36 |
# File 'lib/autoproj/options.rb', line 33 def self.configuration_option(name, type, , &validator) Autoproj.warn_deprecated __method__, "use the API on Autoproj.config (from Autoproj::Configuration) instead" config.declare(name, type, , &validator) end |
.configure(option_name) ⇒ Object
use config.configure(option_name) instead
45 46 47 48 |
# 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) ⇒ Boolean
True if the given string contains expansions
82 83 84 |
# File 'lib/autoproj/variable_expansion.rb', line 82 def self.contains_expansion?(string) string.respond_to?(:to_str) && string.to_str =~ /\$/ end |
.create_symlink(from, to) ⇒ Object
OS-independent creation of symbolic links. Note that on windows, it only works for directories
4 5 6 7 8 9 10 |
# File 'lib/autoproj/system.rb', line 4 def self.create_symlink(from, to) if Autobuild.windows? Dir.create_junction(to, from) else FileUtils.ln_sf from, to end end |
.current_file ⇒ Object
use Autoproj.workspace.current_file or add a proper Loader object to your class
69 70 71 72 73 74 75 |
# 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 ⇒ Object
use Autoproj.workspace.current_package_set or add a proper Loader object to your class
79 80 81 82 83 84 85 |
# 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) ⇒ Object
Registers a block that will be called to determine a package handler for the package in full_path.
41 42 43 |
# File 'lib/autoproj/autobuild_extensions/dsl.rb', line 41 def self.custom_package_handler(&block) custom_package_handlers << block end |
.declared_option?(name) ⇒ Boolean
use config.declared?(name, type, options, &validator) instead
39 40 41 42 |
# 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 ⇒ Object
The base path from which we search for workspaces
6 7 8 |
# 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) ⇒ Object
use Autoproj::Workspace#define_package directly instead. Beware that the return value changed from Autobuild::Package to Autoproj::PackageDefinition
90 91 92 93 94 95 96 97 98 |
# 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) ⇒ Object
31 32 33 34 35 36 37 |
# 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) ⇒ Object
Enumerate the post-import blocks registered for the given package
34 35 36 37 38 39 40 |
# 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 ⇒ Object
947 948 949 |
# File 'lib/autoproj/workspace.rb', line 947 def self.env workspace.env end |
.env_add(name, *value) ⇒ Object
call Autoproj.env.add instead
93 94 95 |
# File 'lib/autoproj/environment.rb', line 93 def self.env_add(name, *value) env.add(name, *value) end |
.env_add_path(name, *value) ⇒ Object
call Autoproj.env.add_path instead
103 104 105 |
# File 'lib/autoproj/environment.rb', line 103 def self.env_add_path(name, *value) env.add_path(name, *value) end |
.env_inherit(*names) ⇒ Object
call Autoproj.env.inherit instead
123 124 125 |
# File 'lib/autoproj/environment.rb', line 123 def self.env_inherit(*names) env.inherit(*names) end |
.env_set(name, *value) ⇒ Object
call Autoproj.env.set instead
88 89 90 |
# File 'lib/autoproj/environment.rb', line 88 def self.env_set(name, *value) env.set(name, *value) end |
.env_set_path(name, *value) ⇒ Object
call Autoproj.env.set_path instead
98 99 100 |
# 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") ⇒ Object
call Autoproj.env.source_after instead
113 114 115 |
# 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") ⇒ Object
call Autoproj.env.source_before instead
118 119 120 |
# 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") ⇒ Object
call Autoproj.env.source_after instead
108 109 110 |
# File 'lib/autoproj/environment.rb', line 108 def self.env_source_file(file, shell: "sh") env.source_after(file, shell: shell) end |
.error(message) ⇒ Object
Displays an error message
37 38 39 |
# File 'lib/autoproj/reporter.rb', line 37 def self.error() Autobuild.error() end |
.expand(value, definitions = Hash.new) ⇒ Object
Expand constants within value
The list of constants is given in definitions
. It raises ConfigError if some values are not found
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/autoproj/variable_expansion.rb', line 63 def self.(value, definitions = Hash.new) if value.respond_to?(:to_hash) value.dup.each do |name, definition| value[name] = (definition, definitions) end value elsif value.respond_to?(:to_ary) value.map { |val| (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) ⇒ Object
use Autoproj.env.export_env_sh instead
143 144 145 |
# 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) ⇒ Object
Filters in the given list of paths the paths that are within a workspace
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# 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) ⇒ Object
use Autobuild.find_in_path instead
Warning: the autobuild method returns nil (instead of raising) if the argument cannot be found
65 66 67 68 69 70 71 72 73 |
# 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) ⇒ String?
Looks for the autoproj prefix that contains a given directory
20 21 22 |
# 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) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# 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) ⇒ Object
#find_workspace_dir for v1 workspaces
Note that for v1 workspaces #find_prefix_dir cannot be implemented
109 110 111 112 113 114 115 116 117 118 |
# 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) ⇒ Object
#find_prefix_dir for v2 workspaces
102 103 104 |
# 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) ⇒ String?
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
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# 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.(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) ⇒ (String,Hash)?
Find a workspace configuration file in the parent tree of a given directory
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/autoproj/find_workspace.rb', line 30 def self.find_v2_workspace_config(base_dir) path = Pathname.new(base_dir). 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) ⇒ Object
#find_workspace_dir for v2 workspaces
97 98 99 |
# 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) ⇒ String?
Looks for the autoproj workspace that is related to a given directory
13 14 15 |
# 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 = "") ⇒ {String=>String}
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.
17 18 19 20 21 22 23 24 25 26 27 |
# 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://#{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) ⇒ Object
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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 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 |
# 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, **| 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() end end |
.git_server_resolve_master_config(name, config, base_url:, git_url:, http_url:, ssh_url:, disabled_methods:) ⇒ 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.
Helper for git_server_configuration
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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. 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:) ⇒ 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.
Helper for git_server_configuration
12 13 14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/autoproj/git_server_configuration.rb', line 130 def self.gitorious_server_configuration(name, base_url, **) 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, **) end |
.has_config_key?(name) ⇒ Boolean
use config.has_value_for?(name)
51 52 53 54 |
# 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) ⇒ Boolean
Returns true if vcs
refers to a source handler name added by #add_source_handler
312 313 314 |
# 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) ⇒ Object
107 108 109 110 111 112 113 |
# 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) ⇒ Boolean
Returns true if path
is part of an autoproj installation
13 14 15 |
# 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) ⇒ Object
Yields, and if the given block raises a ConfigError with no file assigned, add that file to both the object and the exception message
12 13 14 15 16 17 18 19 20 21 22 23 |
# 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.}", e.backtrace elsif !e.file e.file = file raise e, "in #{file}: #{e.}", e.backtrace else raise e end end |
.in_package_set(package_set, path, &block) ⇒ Object
use Autoproj.workspace.in_package_set or add a proper Loader object to your class
59 60 61 62 63 64 65 |
# 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 ⇒ Object
use Autoproj.env.isolate instead
133 134 135 |
# File 'lib/autoproj/environment.rb', line 133 def self.isolate_environment env.isolate end |
.load(package_set, *path) ⇒ Object
use workspace.load or add a separate Loader object to your class
107 108 109 110 111 112 113 |
# 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 ⇒ Object
73 74 75 |
# File 'lib/autoproj/options.rb', line 73 def self.load_config workspace.load_config end |
.load_if_present(package_set, *path) ⇒ Object
use workspace.load_if_present or add a separate Loader object to your class
116 117 118 119 120 121 122 |
# 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 ⇒ Object
100 101 102 103 104 105 |
# 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 ⇒ Object
1229 1230 1231 1232 1233 1234 1235 |
# File 'lib/autoproj/manifest.rb', line 1229 def self.manifest Autoproj.warn_deprecated( __method__, "use workspace.manifest instead" ) workspace.manifest end |
.message(*args) ⇒ Object
28 29 30 |
# File 'lib/autoproj/reporter.rb', line 28 def self.(*args) Autobuild.(*args) end |
.not_silent ⇒ Object
20 21 22 23 24 25 26 |
# 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 ⇒ Object
use config.validated_values instead
21 22 23 24 |
# 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 ⇒ Object
1237 1238 1239 1240 1241 1242 1243 |
# File 'lib/autoproj/manifest.rb', line 1237 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) ⇒ Object
use config.override instead
3 4 5 6 |
# 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 ⇒ Object
use workspace.overrides_dir instead
55 56 57 58 59 |
# 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) ⇒ Object
Tries to find a handler automatically for ‘full_path’
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# 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) ⇒ 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.
Helper method that extracts the package name from a Rake-style package definition (e.g. package_name => package_deps)
49 50 51 52 53 54 55 |
# File 'lib/autoproj/autobuild_extensions/dsl.rb', line 49 def self.(spec) if spec.kind_of?(Hash) spec.to_a.first.first.to_str else spec.to_str end end |
.post_import(&block) ⇒ Object .post_import(*packages, &block) ⇒ Object
Register a block that should be called after a set of package(s) have been imported
48 49 50 51 52 53 54 55 56 57 58 |
# 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 ⇒ Object
use workspace.prefix_dir instead
76 77 78 79 |
# File 'lib/autoproj/system.rb', line 76 def self.prefix Autoproj.warn_deprecated(__method__, "workspace.prefix_dir") workspace.prefix_dir end |
.prefix=(path) ⇒ Object
use workspace.prefix_dir= instead
82 83 84 85 |
# 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) ⇒ Object
call Autoproj.env.prepare directly
138 139 140 |
# File 'lib/autoproj/environment.rb', line 138 def self.prepare_environment(env = Autoproj.env, manifest = Autoproj.manifest) env.prepare(manifest) end |
.reconfigure? ⇒ Boolean
80 81 82 |
# File 'lib/autoproj/options.rb', line 80 def self.reconfigure? @reconfigure end |
.remotes_dir ⇒ Object
use workspace.remotes_dir instead
101 102 103 104 |
# 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) ⇒ Object
Deregister a source handler defined with add_source_handler
356 357 358 |
# 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) ⇒ Object
95 96 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# 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. end [e] elsif on_package_failures == :exit Autoproj.not_silent do Autoproj.error e. 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) ⇒ Object
46 47 48 49 |
# 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) ⇒ Object
use config.reset instead
9 10 11 12 |
# 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) ⇒ Object
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
97 98 99 100 101 102 103 104 105 106 |
# 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) ⇒ Object
86 87 88 89 90 91 |
# 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) ⇒ Object
Returns the root directory of the current autoproj installation.
If the current directory is not in an autoproj installation, raises UserError.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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) ⇒ Object
Forcefully sets the root directory
This is mostly useful during bootstrapping (i.e. when the search would fail)
21 22 23 24 25 26 27 |
# 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 ⇒ Object
use Workspace.config.ruby_executable instead, or Autoproj.config.ruby_executable if you don’t have a workspace context object
10 11 12 |
# File 'lib/autoproj/autobuild_extensions/dsl.rb', line 10 def self.ruby_executable config.ruby_executable end |
.run_as_root(*args, env: workspace.env) ⇒ Object
Run the provided command as root, using sudo to gain root access
130 131 132 133 134 |
# 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) ⇒ Object
Run the provided command as user
125 126 127 |
# 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 ⇒ Object
68 69 70 71 |
# 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 ⇒ Object
use Autoproj.env.isolate instead
128 129 130 |
# File 'lib/autoproj/environment.rb', line 128 def self.set_initial_env isolate_environment end |
.shell_helpers=(flag) ⇒ Object
use config.shell_helpers= instead
63 64 65 66 |
# 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? ⇒ Boolean
use config.shell_helpers? instead
57 58 59 60 |
# 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) ⇒ Object
16 17 18 |
# File 'lib/autoproj/reporter.rb', line 16 def self.silent(&block) Autobuild.silent(&block) end |
.silent=(value) ⇒ Object
10 11 12 |
# File 'lib/autoproj/reporter.rb', line 10 def silent=(value) Autobuild.silent = value end |
.silent? ⇒ Boolean
6 7 8 |
# File 'lib/autoproj/reporter.rb', line 6 def silent? Autobuild.silent? end |
.single_expansion(data, definitions) ⇒ Object
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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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) ⇒ Object
use config.get(key) instead
27 28 29 30 |
# 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 = []) ⇒ Object
Look into dir
, searching for shared libraries. For each library, display a warning message if this library has undefined symbols.
138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/autoproj/system.rb', line 138 def self.validate_solib_dependencies(dir, exclude_paths = []) Find.find(File.(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.(" WARN: #{name} has undefined symbols", :magenta) end end end |
.warn(message, *style) ⇒ Object
Displays a warning message
42 43 44 |
# File 'lib/autoproj/reporter.rb', line 42 def self.warn(, *style) Autobuild.warn(, *style) end |
.warn_deprecated(method, msg = nil, level = 0) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# 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 ⇒ Object
73 74 75 |
# File 'lib/autoproj.rb', line 73 def self.warn_deprecated_level @warn_deprecated_level end |
.warn_deprecated_level=(level) ⇒ Object
77 78 79 |
# File 'lib/autoproj.rb', line 77 def self.warn_deprecated_level=(level) @warn_deprecated_level = level end |
.workspace ⇒ Object
938 939 940 |
# File 'lib/autoproj/workspace.rb', line 938 def self.workspace @workspace ||= Workspace.new(root_dir) end |
.workspace=(ws) ⇒ Object
942 943 944 945 |
# File 'lib/autoproj/workspace.rb', line 942 def self.workspace=(ws) @workspace = ws self.root_dir = ws&.root_dir end |