|
std::string | bindir () |
| Get absolute path to directory containing runtime executables. More...
|
|
std::string | datadir () |
| Get absolute path to directory containing auxiliary data. More...
|
|
int | execute (const std::string &cmd, bool quiet=false, std::ostream *out=NULL, bool allow_fail=false, int verbose=0, bool simulate=false) |
| Execute command as subprocess. More...
|
|
int | execute (std::vector< std::string > args, bool quiet=false, std::ostream *out=NULL, bool allow_fail=false, int verbose=0, bool simulate=false) |
| Execute command as subprocess. More...
|
|
std::string | exedir (const std::string &name=std::string()) |
| Get directory of executable file. More...
|
|
std::string | exename (const std::string &name=std::string()) |
| Get name of executable file. More...
|
|
std::string | exepath (const std::string &name=std::string()) |
| Get absolute path of executable file. More...
|
|
int | get_terminal_columns () |
| Get maximum number of columns of terminal window. More...
|
|
int | get_terminal_lines () |
| Get maximum number of lines of terminal window. More...
|
|
void | get_terminal_size (int &lines, int &columns) |
| Get size of terminal window. More...
|
|
bool | istarget (const std::string &name) |
| Determine whether a given build target is known. More...
|
|
std::string | libdir () |
| Get absolute path to directory containing libraries. More...
|
|
std::string | libexecdir () |
| Get absolute path to directory containing auxiliary executables. More...
|
|
void | print_contact (const char *contact=NULL) |
| Print contact information. More...
|
|
void | print_version (const char *name, const char *version=NULL, const char *project=NULL, const char *copyright=NULL, const char *license=NULL) |
| Print version information including copyright and license notices. More...
|
|
std::ostream & | print_wrapped (std::ostream &os, const std::string &text, int width, int indent, int offset) |
| Print text, wrapped at a fixed maximum number of columns. More...
|
|
std::string | targetuid (const std::string &name) |
| Get UID of build target. More...
|
|
|
const char * | CONTACT = "andreas.schuh.84@gmail.com" |
| Default contact to use for help output of executables. More...
|
|
const char * | COPYRIGHT = "2011-12 University of Pennsylvania, 2013-14 Carnegie Mellon University, 2013-16 Andreas Schuh" |
| Default copyright of executables. More...
|
|
const char * | LICENSE = "See https://cmake-basis.github.io/download.html#license or COPYING file." |
| Default license of executables. More...
|
|
const char * | PROJECT = "BASIS" |
| The project name. More...
|
|
const char * | RELEASE = "v3.3 (fb18c98)" |
| Complete version information as output by –version option. More...
|
|
const char * | VERSION = "3.3.1" |
| The version string given as "<major>.<minor>.<patch>". More...
|
|
const unsigned int | VERSION_MAJOR = 3 |
| The major version number. More...
|
|
const unsigned int | VERSION_MINOR = 3 |
| The minor version number. More...
|
|
const unsigned int | VERSION_PATCH = 0 |
| The patch number. More...
|
|
int basis::execute |
( |
const std::string & |
cmd, |
|
|
bool |
quiet = false , |
|
|
std::ostream * |
out = NULL , |
|
|
bool |
allow_fail = false , |
|
|
int |
verbose = 0 , |
|
|
bool |
simulate = false |
|
) |
| |
Execute command as subprocess.
This function is a replacement for system() on Unix and is furthermore less platform dependent. The first argument of the given command-line string is mapped to an absolute executable file using exepath() if the given first argument is a know build target name. Otherwise, the command-line is used unmodified.
- Parameters
-
[in] | cmd | Command-line given as double quoted string. Arguments containing whitespaces have to be quoted using double quotes. Use a backslash (\) to escape double quotes inside an argument as well as to escape a backslash itself (required if backslash at end of double quoted argument, e.g., "this argument \\"). |
[in] | quiet | Turns off output of stdout of child process to stdout of parent process. |
[out] | out | Output stream where command output is written to. |
[in] | allow_fail | If true, no exception is thrown if the exit code of the child process is non-zero. Otherwise, a SubprocessException object is thrown in that case. |
[in] | verbose | Verbosity of output messages. Does not affect verbosity of executed command. |
[in] | simulate | Whether to simulate command execution only. |
- Returns
- Exit code of command or -1 if subprocess creation failed.
- Exceptions
-
SubprocessError | If subprocess creation failed or command returned a non-zero exit code while allow_fail is false. |
Definition at line 297 of file basis.cxx.
int basis::execute |
( |
std::vector< std::string > |
args, |
|
|
bool |
quiet = false , |
|
|
std::ostream * |
out = NULL , |
|
|
bool |
allow_fail = false , |
|
|
int |
verbose = 0 , |
|
|
bool |
simulate = false |
|
) |
| |
Execute command as subprocess.
This function is a replacement for system() on Unix and is furthermore less platform dependent. The first argument of the given command-line string is mapped to an absolute executable file using exepath() if the given first argument is a know build target name. Otherwise, the command-line is used unmodified.
- Parameters
-
[in,out] | args | Command-line given as argument vector. The first argument has to be either a build target name or the name/path of the command to execute. |
[in] | quiet | Turns off output of stdout of child process to stdout of parent process. |
[out] | out | Output stream where command output is written to. |
[in] | allow_fail | If true, no exception is thrown if the exit code of the child process is non-zero. Otherwise, a SubprocessException object is thrown in that case. |
[in] | verbose | Verbosity of output messages. Does not affect verbosity of executed command. |
[in] | simulate | Whether to simulate command execution only. |
- Returns
- Exit code of command or -1 if subprocess creation failed.
- Exceptions
-
SubprocessError | If subprocess creation failed or command returned a non-zero exit code while allow_fail is false. |
Definition at line 305 of file basis.cxx.
string basis::exepath |
( |
const std::string & |
name = std::string() | ) |
|
Get absolute path of executable file.
This function determines the absolute file path of an executable. If no arguments are given, the absolute path of this executable is returned. If the command names a known executable build target, the absolute path to the corresonding built (and installed) executable file is returned. Otherwise, the named command is searched in the system PATH
and its absolute path returned if found. If the executable is not found, an empty string is returned.
- Todo:
- This function currently makes use of the which command implemented in Python and called as subprocess in order to search a command in the system
PATH
. This which command is part of BASIS and can also be used on Windows. However, a native C++ implementation would be desireable.
- Parameters
-
[in] | name | Name of command or NULL . |
- Returns
- Absolute path of executable or an empty string if not found. If
name
is NULL
, the path of this executable is returned.
- See also
- exename()
-
exedir()
Definition at line 275 of file basis.cxx.