2023-11-25 18:51:42 +00:00
|
|
|
/**
|
|
|
|
@file
|
|
|
|
@brief A `spec` configuration.
|
|
|
|
*/
|
2023-11-23 18:02:40 +00:00
|
|
|
#ifndef _BOOTSTRAP_CONFIG_H
|
|
|
|
#define _BOOTSTRAP_CONFIG_H
|
2023-11-22 21:39:27 +00:00
|
|
|
|
2023-11-25 15:55:02 +00:00
|
|
|
#include "error.h"
|
|
|
|
|
2023-11-25 18:51:42 +00:00
|
|
|
/**
|
|
|
|
@brief A collection of parameters that identify a `spec`.
|
|
|
|
|
|
|
|
Each member of the @ref Config is expected to outlive the @ref Config instance
|
|
|
|
itself.
|
|
|
|
*/
|
2023-11-22 21:39:27 +00:00
|
|
|
struct Config {
|
2023-11-25 19:18:36 +00:00
|
|
|
/// @brief The directory the `bootstrap` command was run from. Does not take
|
2023-11-25 18:51:42 +00:00
|
|
|
/// ownership of this pointer.
|
2023-11-23 15:07:22 +00:00
|
|
|
const char *cwd;
|
2023-11-25 19:18:36 +00:00
|
|
|
/// @brief The root directory housing our specs. Does not take ownership of
|
2023-11-25 18:51:42 +00:00
|
|
|
/// this pointer.
|
2023-11-25 19:18:36 +00:00
|
|
|
const char *root_dir;
|
|
|
|
/// @brief The name of the spec we want to bootstrap. Does not take ownership
|
|
|
|
/// of this pointer.
|
2023-11-22 21:39:27 +00:00
|
|
|
const char *target;
|
|
|
|
};
|
|
|
|
|
2023-11-25 18:51:42 +00:00
|
|
|
/**
|
|
|
|
@brief Create a new @ref Config instance.
|
|
|
|
|
|
|
|
@param cwd
|
|
|
|
The current working directory the `bootstrap` command was invoked from.
|
|
|
|
@param root_dir
|
|
|
|
An absolute path to the collection of specs `bootstrap` will search through.
|
|
|
|
@param target
|
|
|
|
The `spec` that should be bootstrapped.
|
|
|
|
@return
|
|
|
|
A new @ref Config instance. The caller takes ownership of this value.
|
|
|
|
|
|
|
|
@see config_free
|
|
|
|
*/
|
|
|
|
struct Error *config_new(
|
2023-11-23 15:07:22 +00:00
|
|
|
const char *cwd,
|
2023-11-23 11:09:32 +00:00
|
|
|
const char *root_dir,
|
|
|
|
const char *target,
|
2023-11-23 14:40:17 +00:00
|
|
|
struct Config **config
|
2023-11-23 11:09:32 +00:00
|
|
|
);
|
2023-11-22 21:39:27 +00:00
|
|
|
|
2023-11-25 18:51:42 +00:00
|
|
|
/**
|
|
|
|
@brief Deallocates a previously allocated @ref Config instance.
|
|
|
|
|
|
|
|
@param config
|
|
|
|
A pointer to a @ref Config instance. If null, this function is a no-op.
|
|
|
|
|
|
|
|
@see config_new
|
|
|
|
*/
|
2023-11-23 14:40:17 +00:00
|
|
|
void config_free(struct Config *config);
|
2023-11-22 21:39:27 +00:00
|
|
|
|
2023-11-23 18:02:40 +00:00
|
|
|
#endif /* BOOTSTRAP_CONFIG_H */
|