![]() |
bob.hpp
|
Contains the functionality of the Bob build system. More...
Namespaces | |
namespace | term |
Terminal related constants and functions. | |
Classes | |
class | Cli |
A command line interface (CLI) that can be used to run commands and subcommands. More... | |
class | CliCommand |
Represents a CLI command. More... | |
struct | CliFlag |
Represents a command flag argument. More... | |
class | Cmd |
Represents a command to be executed in the operating system shell. More... | |
struct | CmdFuture |
Represents a command that being executed in the background. More... | |
class | CmdRunner |
A class for running many commands in parallel. More... | |
struct | RebuildConfig |
Configuration for rebuilding the current executable. More... | |
class | Recipe |
A build recipe that defiles how to produce outputs from inputs. More... | |
Typedefs | |
typedef std::vector< fs::path > | Paths |
A list of file paths. | |
typedef std::function< void(const vector< path > &, const vector< path > &)> | RecipeFunc |
A function that can be used in a Recipe to build outputs from inputs. | |
typedef std::vector< CliFlag > | CliFlags |
A list of command line flags. | |
typedef std::function< int(CliCommand &)> | CliCommandFunc |
A function that can be used to handle a command in a CLI. | |
Enumerations | |
enum class | CliFlagType { Bool , Value } |
Types of command line flags. More... | |
Functions | |
void | go_rebuild_yourself (int argc, char *argv[], path source_file_name) |
int | run_yourself (fs::path bin, int argc, char *argv[]) |
bool | file_needs_rebuild (path input, path output) |
path | mkdirs (path dir) |
string | I (path p) |
path | search_path (const string &bin_name) |
void | checklist (const vector< string > &items, const vector< bool > &statuses) |
void | ensure_installed (vector< string > packages) |
bool | find_root (path *root, string marker_file) |
bool | git_root (path *root) |
void | print_cli_args (const CliFlags &args) |
Prints the command line flags and their descriptions. Used for help output. | |
Contains the functionality of the Bob build system.
|
strong |
void bob::checklist | ( | const vector< string > & | items, |
const vector< bool > & | statuses | ||
) |
Displays a checklist of items with their statuses.
items | A list of checklist item names. |
statuses | A list of boolean statuses; true means complete, false means incomplete. |
void bob::ensure_installed | ( | vector< string > | packages | ) |
Ensures that the specified packages are installed. If they are not, a checklist is printed of the missing and found packages, and the program exits with an error code.
packages | A list of package names to verify and install if missing. |
bool bob::file_needs_rebuild | ( | path | input, |
path | output | ||
) |
Checks if an output file is older than its input file and needs to be rebuilt.
input | The source file path. |
output | The target file path. |
true
if the output is missing or older than the input; false otherwise.bool bob::find_root | ( | path * | root, |
string | marker_file | ||
) |
Finds the root directory containing a specific marker file.
root | Pointer to store the found root path. |
marker_file | The file name to look for in the directory hierarchy. |
bool bob::git_root | ( | path * | root | ) |
Finds the root of a Git repository.
root | Pointer to store the Git repository root path. |
void bob::go_rebuild_yourself | ( | int | argc, |
char * | argv[], | ||
path | source_file_name | ||
) |
Rebuilds the current executable from its source file. After building the new executable, it will run the new executable with the same arguments as the current one. This function is called with GO_REBUILD_YOURSELF(argc, argv)
macro which provides the source_file_name
argument automatically.
string bob::I | ( | path | p | ) |
Converts a path to a string with the -I
prefix for use in compiler commands.
p | The path to convert. |
path bob::mkdirs | ( | path | dir | ) |
Creates a directory and all necessary parent directories.
dir | The directory path to create. |
int bob::run_yourself | ( | fs::path | bin, |
int | argc, | ||
char * | argv[] | ||
) |
Runs the current executable and returns the exit status. This is used in the go_rebuild_yourself(int argc, char * argv[], path source_file_name)
function.
path bob::search_path | ( | const string & | bin_name | ) |
Searches for a binary in the system $PATH variable.
bin_name | The name of the binary to search for. |