Files
gbuild/include/config.h
T

57 lines
1.7 KiB
C
Raw Normal View History

2026-05-21 14:27:40 +02:00
#ifndef CONFIG_H
#define CONFIG_H
#include <stdbool.h>
#include <stddef.h>
#define CFG_MAX 512
2026-05-23 21:03:54 +02:00
/*
* Per-project hook override loaded from a [project:<name>] section.
* Up to CFG_MAX_PROJECT_OVERRIDES overrides are supported.
*/
#define CFG_MAX_PROJECT_OVERRIDES 64
#define CFG_PROJECT_NAME_LEN 128
typedef struct {
char name[CFG_PROJECT_NAME_LEN]; /* project name, e.g. "myproject" */
char post_build_hook[CFG_MAX]; /* hook command for this project */
} GProjectOverride;
2026-05-21 14:27:40 +02:00
typedef struct {
char git_url[CFG_MAX];
char git_user[256];
char git_token[256];
char git_password[256];
char default_target[128];
char clone_dir[CFG_MAX];
bool log_enabled;
char log_dir[CFG_MAX];
2026-05-23 21:03:54 +02:00
/* Post-build hook run after every successful make invocation.
* The hook is executed with the repo directory as its CWD.
* An empty string means "no hook". */
char post_build_hook[CFG_MAX];
/* Per-project hook overrides from [project:<name>] sections. */
GProjectOverride project_overrides[CFG_MAX_PROJECT_OVERRIDES];
int project_override_count;
2026-05-21 14:27:40 +02:00
} GConfig;
2026-05-23 21:03:54 +02:00
/*
* Return the effective post-build hook for a given project name.
* Checks [project:<name>] overrides first; falls back to the global hook.
* Returns a pointer into cfg — do not free.
*/
const char *config_hook_for(const GConfig *cfg, const char *project);
2026-05-21 14:27:40 +02:00
void config_defaults(GConfig *cfg);
int config_load(GConfig *cfg, const char *path);
int config_save(const GConfig *cfg, const char *path);
int config_init(const char *path, bool force);
void config_show(const GConfig *cfg);
void config_get_path(char *out, size_t n);
char *expand_tilde(const char *in, char *out, size_t n);
#endif /* CONFIG_H */