The base class for package/stack ("stackage") crawlers. Users of the library should use the functionality provided here through one of the derived classes, Rosstack or Rospack. More...
#include <rospack.h>
Public Member Functions | |
void | _rosdeps (Stackage *stackage, std::set< std::string > &rosdeps, const char *tag_name) |
bool | contains (const std::string &name, std::string &stack, std::string &path) |
Find the stack that contains a package. More... | |
bool | contents (const std::string &name, std::set< std::string > &packages) |
Compute the packages that are contained in a stack. More... | |
bool | cpp_exports (const std::string &name, const std::string &type, const std::string &attrib, bool deps_only, std::vector< std::pair< std::string, bool > > &flags) |
Compute cpp exports declared in a package and its dependencies. Used by rosbuild. More... | |
void | crawl (std::vector< std::string > search_path, bool force) |
Crawl the filesystem, accumulating a database of stackages. May read results from a cache file instead of crawling. This method should be called before any making any queries (find, list, etc.). More... | |
bool | deps (const std::string &name, bool direct, std::vector< std::string > &deps) |
Compute dependencies of a stackage (i.e., stackages that this stackages depends on). More... | |
bool | depsDetail (const std::string &name, bool direct, std::vector< Stackage * > &deps) |
Compute dependencies of a stackage (i.e., stackages that this stackages depends on), taking and returning stackage objects.. More... | |
bool | depsIndent (const std::string &name, bool direct, std::vector< std::string > &deps) |
bool | depsManifests (const std::string &name, bool direct, std::vector< std::string > &manifests) |
List the manifests of a stackage's dependencies. Used by rosbuild. More... | |
bool | depsMsgSrv (const std::string &name, bool direct, std::vector< std::string > &gens) |
List the marker files in a packages's dependencies that indicate that those packages contain auto-generated message and/or service code. Used by rosbuild. More... | |
bool | depsOn (const std::string &name, bool direct, std::vector< std::string > &deps) |
Compute reverse dependencies of a stackage (i.e., stackages that depend on this stackage). Forces crawl. More... | |
bool | depsOnDetail (const std::string &name, bool direct, std::vector< Stackage * > &deps, bool ignore_missing=false) |
Compute reverse dependencies of a stackage (i.e., stackages that depend on this stackage), taking and returning stackage objects. Forces crawl. More... | |
bool | depsWhy (const std::string &from, const std::string &to, std::string &output) |
bool | exports (const std::string &name, const std::string &lang, const std::string &attrib, bool deps_only, std::vector< std::string > &flags) |
Compute exports declared in a package and its dependencies. Used by rosbuild. More... | |
bool | exports_dry_package (Stackage *stackage, const std::string &lang, const std::string &attrib, std::vector< std::string > &flags) |
Compute exports declared in a dry package. More... | |
bool | find (const std::string &name, std::string &path) |
Look for a stackage. More... | |
virtual std::string | get_manifest_type () |
const std::string & | getName () |
Get the name of the tool that's in use (e.g., "rospack" or "rosstack") More... | |
bool | getSearchPathFromEnv (std::vector< std::string > &sp) |
Helper method to construct a directory search path by looking at relevant environment variables. The value of ROS_ROOT goes first, followed by each element of a colon-separated ROS_PACKAGE_PATH. More... | |
bool | inStackage (std::string &name) |
Is the current working directory a stackage? More... | |
void | list (std::set< std::pair< std::string, std::string > > &list) |
List names and paths of all stackages. More... | |
void | listDuplicates (std::vector< std::string > &dups) |
Identify duplicate stackages. Forces crawl. More... | |
void | listDuplicatesWithPaths (std::map< std::string, std::vector< std::string > > &dups) |
Identify duplicate stackages and provide their paths. Forces crawl. More... | |
void | logError (const std::string &msg, bool append_errno=false) |
Log a error (usually goes to stderr). More... | |
void | logWarn (const std::string &msg, bool append_errno=false) |
Log a warning (usually goes to stderr). More... | |
bool | plugins (const std::string &name, const std::string &attrib, const std::string &top, std::vector< std::string > &flags) |
Compute exported plugins declared in packages that depend on a package. Forces crawl. Used by rosbuild and roslib. More... | |
bool | profile (const std::vector< std::string > &search_path, bool zombie_only, int length, std::vector< std::string > &dirs) |
bool | reorder_paths (const std::string &paths, std::string &reordered) |
Reorder the paths according to the workspace chaining. More... | |
bool | rosdeps (const std::string &name, bool direct, std::set< std::string > &rosdeps) |
Compute rosdep entries that are declared in manifest of a package and its dependencies. Used by rosmake. More... | |
void | setQuiet (bool quiet) |
Control warning and error console output. More... | |
virtual const char * | usage () |
Usage string, to be overridden by derived classes. More... | |
bool | vcs (const std::string &name, bool direct, std::vector< std::string > &vcs) |
Compute vcs entries that are declared in manifest of a package and its dependencies. Was used by Hudson build scripts; might not be needed. More... | |
virtual | ~Rosstackage () |
Destructor. More... | |
Protected Member Functions | |
Rosstackage (const std::string &manifest_name, const std::string &cache_prefix, const std::string &name, const std::string &tag) | |
Constructor, only used by derived classes. More... | |
Private Member Functions | |
void | addStackage (const std::string &path) |
void | clearStackages () |
bool | computeDeps (Stackage *stackage, bool ignore_errors=false, bool ignore_missing=false) |
bool | computeDepsInternal (Stackage *stackage, bool ignore_errors, const std::string &depend_tag, bool ignore_missing=false) |
void | crawlDetail (const std::string &path, bool force, int depth, bool collect_profile_data, std::vector< DirectoryCrawlRecord * > &profile_data, boost::unordered_set< std::string > &profile_hash) |
bool | depsWhyDetail (Stackage *from, Stackage *to, std::list< std::list< Stackage * > > &acc_list) |
bool | expandExportString (Stackage *stackage, const std::string &instring, std::string &outstring) |
Stackage * | findWithRecrawl (const std::string &name) |
void | gatherDeps (Stackage *stackage, bool direct, traversal_order_t order, std::vector< Stackage * > &deps, bool no_recursion_on_wet=false) |
void | gatherDepsFull (Stackage *stackage, bool direct, traversal_order_t order, int depth, boost::unordered_set< Stackage * > &deps_hash, std::vector< Stackage * > &deps, bool get_indented_deps, std::vector< std::string > &indented_deps, bool no_recursion_on_wet=false) |
std::string | getCacheHash () |
std::string | getCachePath () |
void | initPython () |
bool | isStackage (const std::string &path) |
bool | isSysPackage (const std::string &pkgname) |
void | loadManifest (Stackage *stackage) |
void | log (const std::string &level, const std::string &msg, bool append_errno) |
bool | readCache () |
FILE * | validateCache () |
void | writeCache () |
Private Attributes | |
std::string | cache_prefix_ |
bool | crawled_ |
boost::unordered_map< std::string, std::vector< std::string > > | dups_ |
std::string | manifest_name_ |
std::string | name_ |
bool | quiet_ |
std::vector< std::string > | search_paths_ |
boost::unordered_map< std::string, Stackage * > | stackages_ |
std::string | tag_ |
The base class for package/stack ("stackage") crawlers. Users of the library should use the functionality provided here through one of the derived classes, Rosstack or Rospack.
|
protected |
Constructor, only used by derived classes.
manifest_name | What the manifest is called (e.g., "manifest.xml or stack.xml") |
cache_prefix | What the cache is called (e.g., "rospack_cache" or "rosstack_cache") excluding the appended search path hash |
name | Name of the tool we're building (e.g., "rospack" or "rosstack") |
tag | Name of the attribute we look for in a "depend" tag in a manifest (e.g., "package" or "stack") |
Definition at line 241 of file rospack.cpp.
|
virtual |
Destructor.
Definition at line 253 of file rospack.cpp.
void rospack::Rosstackage::_rosdeps | ( | Stackage * | stackage, |
std::set< std::string > & | rosdeps, | ||
const char * | tag_name | ||
) |
Definition at line 739 of file rospack.cpp.
|
private |
Definition at line 1397 of file rospack.cpp.
|
private |
Definition at line 258 of file rospack.cpp.
|
private |
Definition at line 1588 of file rospack.cpp.
|
private |
Definition at line 1622 of file rospack.cpp.
bool rospack::Rosstackage::contains | ( | const std::string & | name, |
std::string & | stack, | ||
std::string & | path | ||
) |
Find the stack that contains a package.
name | The package to work on. |
stack | If the containing stack is found, its name is written here. |
path | If the containing stack is found, its absolute path is written here. |
Definition at line 475 of file rospack.cpp.
bool rospack::Rosstackage::contents | ( | const std::string & | name, |
std::set< std::string > & | packages | ||
) |
Compute the packages that are contained in a stack.
name | The stack to work on. |
packages | The stack's constituent packages are written here. |
Definition at line 449 of file rospack.cpp.
bool rospack::Rosstackage::cpp_exports | ( | const std::string & | name, |
const std::string & | type, | ||
const std::string & | attrib, | ||
bool | deps_only, | ||
std::vector< std::pair< std::string, bool > > & | flags | ||
) |
Compute cpp exports declared in a package and its dependencies. Used by rosbuild.
name | The package to work on. |
type | The option to pass to pkg-config for wet packages. |
attrib | The value of the 'attrib' attribute to search for. |
deps_only | If true, then only return information from the pacakge's dependencies; if false, then also include the package's own export information. |
flags | The pairs of export flags and is-wet are written here. |
Definition at line 815 of file rospack.cpp.
void rospack::Rosstackage::crawl | ( | std::vector< std::string > | search_path, |
bool | force | ||
) |
Crawl the filesystem, accumulating a database of stackages. May read results from a cache file instead of crawling. This method should be called before any making any queries (find, list, etc.).
search_path | List of directories to crawl, in precenence order. Directories should be absolute paths. It's passed by value to allow callers (e.g., find()) to safely pass in search_paths_. |
force | If true, then crawl even if the cache looks valid |
Definition at line 361 of file rospack.cpp.
|
private |
Definition at line 1452 of file rospack.cpp.
bool rospack::Rosstackage::deps | ( | const std::string & | name, |
bool | direct, | ||
std::vector< std::string > & | deps | ||
) |
Compute dependencies of a stackage (i.e., stackages that this stackages depends on).
name | The stackage to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
deps | If dependencies are computed, then they're written here. |
Definition at line 555 of file rospack.cpp.
bool rospack::Rosstackage::depsDetail | ( | const std::string & | name, |
bool | direct, | ||
std::vector< Stackage * > & | deps | ||
) |
Compute dependencies of a stackage (i.e., stackages that this stackages depends on), taking and returning stackage objects..
name | The stackage to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
deps | If dependencies are computed, then they're written here in stackage objects. |
Definition at line 1233 of file rospack.cpp.
bool rospack::Rosstackage::depsIndent | ( | const std::string & | name, |
bool | direct, | ||
std::vector< std::string > & | deps | ||
) |
@brief Generate indented list of a stackage's dependencies, including duplicates. Intended for visual debugging of dependency structures. @param name The stackage to work on. @param direct If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. @param deps List of the stackage's dependencies, with leading spaces to indicate depth, is written here. Print this list to console, with newlines separating each element. Example output:
roscpp_traits cpp_common cpp_common rostime cpp_common
Definition at line 594 of file rospack.cpp.
bool rospack::Rosstackage::depsManifests | ( | const std::string & | name, |
bool | direct, | ||
std::vector< std::string > & | manifests | ||
) |
List the manifests of a stackage's dependencies. Used by rosbuild.
name | The stackage to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
manifests | The list of absolute paths to manifests of stackages that the given stackage depends on is written here. |
Definition at line 665 of file rospack.cpp.
bool rospack::Rosstackage::depsMsgSrv | ( | const std::string & | name, |
bool | direct, | ||
std::vector< std::string > & | gens | ||
) |
List the marker files in a packages's dependencies that indicate that those packages contain auto-generated message and/or service code. Used by rosbuild.
name | The package to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
gens | The list of absolute paths to marker files (e.g., "/opt/ros/electric/stacks/ros_comm/messages/std_msgs/msg_gen/generated") is written here. |
Definition at line 1160 of file rospack.cpp.
bool rospack::Rosstackage::depsOn | ( | const std::string & | name, |
bool | direct, | ||
std::vector< std::string > & | deps | ||
) |
Compute reverse dependencies of a stackage (i.e., stackages that depend on this stackage). Forces crawl.
name | The stackage to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
deps | If dependencies are computed, then they're written here. |
Definition at line 581 of file rospack.cpp.
bool rospack::Rosstackage::depsOnDetail | ( | const std::string & | name, |
bool | direct, | ||
std::vector< Stackage * > & | deps, | ||
bool | ignore_missing = false |
||
) |
Compute reverse dependencies of a stackage (i.e., stackages that depend on this stackage), taking and returning stackage objects. Forces crawl.
name | The stackage to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
deps | List of Stackage objects. If dependencies are computed, then they're written here in stackage objects. |
Definition at line 1297 of file rospack.cpp.
bool rospack::Rosstackage::depsWhy | ( | const std::string & | from, |
const std::string & | to, | ||
std::string & | output | ||
) |
@brief Compute all dependency chains from one stackage to another. Intended for visual debugging of dependency structures. @param from The stackage that depends on. @param to The stackage that is depended on. @param output A list of dependency chains. Print this list to console, with newlines separating each element. Example output:
Dependency chains from roscpp to roslib: * roscpp -> roslib * roscpp -> std_msgs -> roslib * roscpp -> rosgraph_msgs -> std_msgs -> roslib
Definition at line 622 of file rospack.cpp.
|
private |
Definition at line 1264 of file rospack.cpp.
|
private |
Definition at line 2194 of file rospack.cpp.
bool rospack::Rosstackage::exports | ( | const std::string & | name, |
const std::string & | lang, | ||
const std::string & | attrib, | ||
bool | deps_only, | ||
std::vector< std::string > & | flags | ||
) |
Compute exports declared in a package and its dependencies. Used by rosbuild.
name | The package to work on. |
lang | The value of the 'lang' attribute to search for. |
attrib | The value of the 'attrib' attribute to search for. |
deps_only | If true, then only return information from the pacakge's dependencies; if false, then also include the package's own export information. |
flags | The accumulated flags are written here. |
Definition at line 991 of file rospack.cpp.
bool rospack::Rosstackage::exports_dry_package | ( | Stackage * | stackage, |
const std::string & | lang, | ||
const std::string & | attrib, | ||
std::vector< std::string > & | flags | ||
) |
Compute exports declared in a dry package.
name | The package to work on. |
lang | The value of the 'lang' attribute to search for. |
attrib | The value of the 'attrib' attribute to search for. |
flags | The accumulated flags are written here. |
Definition at line 1025 of file rospack.cpp.
bool rospack::Rosstackage::find | ( | const std::string & | name, |
std::string & | path | ||
) |
Look for a stackage.
name | The stackage to look for. |
path | If found, the absolute path to the stackage is written here. |
Definition at line 436 of file rospack.cpp.
|
private |
Definition at line 1216 of file rospack.cpp.
|
private |
Definition at line 1811 of file rospack.cpp.
|
private |
Definition at line 1909 of file rospack.cpp.
|
inlinevirtual |
Reimplemented in rospack::Rosstack, and rospack::Rospack.
|
private |
Definition at line 1978 of file rospack.cpp.
|
private |
Definition at line 1930 of file rospack.cpp.
|
inline |
bool rospack::Rosstackage::getSearchPathFromEnv | ( | std::vector< std::string > & | sp | ) |
Helper method to construct a directory search path by looking at relevant environment variables. The value of ROS_ROOT goes first, followed by each element of a colon-separated ROS_PACKAGE_PATH.
sp | The computed search path is written here. |
defined(WIN32)
Definition at line 284 of file rospack.cpp.
|
private |
Definition at line 1691 of file rospack.cpp.
bool rospack::Rosstackage::inStackage | ( | std::string & | name | ) |
Is the current working directory a stackage?
name | If in a stackage, then the stackage's name is written here. |
Definition at line 400 of file rospack.cpp.
|
private |
Definition at line 318 of file rospack.cpp.
|
private |
Definition at line 1702 of file rospack.cpp.
void rospack::Rosstackage::list | ( | std::set< std::pair< std::string, std::string > > & | list | ) |
List names and paths of all stackages.
list | Pairs of (name,path) are written here. |
Definition at line 507 of file rospack.cpp.
void rospack::Rosstackage::listDuplicates | ( | std::vector< std::string > & | dups | ) |
Identify duplicate stackages. Forces crawl.
dups | Names of stackages that are found more than once while crawling are written here. |
Definition at line 521 of file rospack.cpp.
void rospack::Rosstackage::listDuplicatesWithPaths | ( | std::map< std::string, std::vector< std::string > > & | dups | ) |
Identify duplicate stackages and provide their paths. Forces crawl.
dups | Names of stackages that are found more than once while crawling are mapped to the found paths of these packages. |
Definition at line 535 of file rospack.cpp.
|
private |
Definition at line 1573 of file rospack.cpp.
|
private |
Definition at line 1201 of file rospack.cpp.
void rospack::Rosstackage::logError | ( | const std::string & | msg, |
bool | append_errno = false |
||
) |
Log a error (usually goes to stderr).
msg | The error. |
append_errno | If true, then append a colon, a space, and the return from 'sterror(errno)'. |
Definition at line 277 of file rospack.cpp.
void rospack::Rosstackage::logWarn | ( | const std::string & | msg, |
bool | append_errno = false |
||
) |
Log a warning (usually goes to stderr).
msg | The warning. |
append_errno | If true, then append a colon, a space, and the return from 'sterror(errno)'. |
Definition at line 271 of file rospack.cpp.
bool rospack::Rosstackage::plugins | ( | const std::string & | name, |
const std::string & | attrib, | ||
const std::string & | top, | ||
std::vector< std::string > & | flags | ||
) |
Compute exported plugins declared in packages that depend on a package. Forces crawl. Used by rosbuild and roslib.
name | The package to work on. |
attrib | The value of the 'attrib' attribute to search for. |
top | If non-empty, then limit the reverse dependency search to packages that 'top' depends on. Otherwise, examine all packages that depend on 'name'. |
flags | The accumulated flags are written here. |
Definition at line 1093 of file rospack.cpp.
bool rospack::Rosstackage::profile | ( | const std::vector< std::string > & | search_path, |
bool | zombie_only, | ||
int | length, | ||
std::vector< std::string > & | dirs | ||
) |
@brief Report on time taken to crawl for stackages. Intended for use in debugging misconfigured stackage trees. Forces crawl. @param search_path Directories to search; passed to crawl(). @param zombie_only If false, then produce formatted output, with timing information. Example output:
Full tree crawl took 0.014954 seconds. Directories marked with (*) contain no manifest. You may want to delete these directories. To get just of list of directories without manifests, re-run the profile with --zombie-only ------------------------------------------------------------- 0.013423 /opt/ros/electric/stacks 0.002989 /opt/ros/electric/stacks/ros_comm
If true, then produce a list of absolute paths that contain no stackages ("zombies"); these directories can likely be safely deleted. Example output:
/opt/ros/electric/stacks/pr2_controllers/trajectory_msgs /opt/ros/electric/stacks/pr2_controllers/trajectory_msgs/msg
length | Limit on how many directories to include in report (ordered in decreasing order of time taken to crawl). |
dirs | Profile output. Print this list to console, with newlines separating each element. |
Definition at line 1337 of file rospack.cpp.
|
private |
Definition at line 1992 of file rospack.cpp.
bool rospack::Rosstackage::reorder_paths | ( | const std::string & | paths, |
std::string & | reordered | ||
) |
Reorder the paths according to the workspace chaining.
paths | The paths. |
reordered | The reordered paths are written here. |
Definition at line 927 of file rospack.cpp.
bool rospack::Rosstackage::rosdeps | ( | const std::string & | name, |
bool | direct, | ||
std::set< std::string > & | rosdeps | ||
) |
Compute rosdep entries that are declared in manifest of a package and its dependencies. Used by rosmake.
name | The package to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
rosdeps | List of rosdep entries found in the package and its dependencies is written here. |
Definition at line 691 of file rospack.cpp.
void rospack::Rosstackage::setQuiet | ( | bool | quiet | ) |
Control warning and error console output.
quiet | If true, then don't output any warnings or errors to console. If false, then output warnings and errors to stderr (default behavior). |
Definition at line 312 of file rospack.cpp.
|
inlinevirtual |
Usage string, to be overridden by derived classes.
Reimplemented in rospack::Rosstack, and rospack::Rospack.
|
private |
Definition at line 2122 of file rospack.cpp.
bool rospack::Rosstackage::vcs | ( | const std::string & | name, |
bool | direct, | ||
std::vector< std::string > & | vcs | ||
) |
Compute vcs entries that are declared in manifest of a package and its dependencies. Was used by Hudson build scripts; might not be needed.
name | The package to work on. |
direct | If true, then compute only direct dependencies. If false, then compute full (including indirect) dependencies. |
vcs | List of vcs entries found in the package and its dependencies is written here. |
Definition at line 766 of file rospack.cpp.
|
private |
Definition at line 2022 of file rospack.cpp.
|
private |
|
private |
|
private |