bootstrap/include/config.h

60 lines
1.4 KiB
C
Raw Permalink Normal View History

/**
@file
@brief A `spec` configuration.
*/
2023-11-23 18:02:40 +00:00
#ifndef _BOOTSTRAP_CONFIG_H
#define _BOOTSTRAP_CONFIG_H
#include "error.h"
/**
@brief A collection of parameters that identify a `spec`.
Each member of the @ref Config is expected to outlive the @ref Config instance
itself.
*/
struct Config {
/// @brief The directory the `bootstrap` command was run from. Does not take
/// ownership of this pointer.
2023-11-23 15:07:22 +00:00
const char *cwd;
/// @brief The root directory housing our specs. Does not take ownership of
/// this pointer.
const char *root_dir;
/// @brief The name of the spec we want to bootstrap. Does not take ownership
/// of this pointer.
const char *target;
};
/**
@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
);
/**
@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-23 18:02:40 +00:00
#endif /* BOOTSTRAP_CONFIG_H */