added license and description to project
This commit is contained in:
parent
0c722f3635
commit
c527c99392
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include <cfg/opt.h>
|
#include <cfg/opt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
TargetConfig default_target_config() {
|
TargetConfig default_target_config() {
|
||||||
TargetConfig config;
|
TargetConfig config;
|
||||||
|
@ -74,19 +73,30 @@ static int parse_project_table(ProjectConfig *config, toml_table_t *project_tabl
|
||||||
// author names
|
// author names
|
||||||
toml_array_t *authors = toml_array_in(project_table, "authors");
|
toml_array_t *authors = toml_array_in(project_table, "authors");
|
||||||
if (authors) {
|
if (authors) {
|
||||||
unsigned int len = 0;
|
config->authors = g_array_new(FALSE, FALSE, sizeof(char*));
|
||||||
config->authors = malloc(sizeof(const char *) * 2);
|
|
||||||
|
|
||||||
for (int i = 0;; i++) {
|
for (int i = 0;; i++) {
|
||||||
toml_datum_t author = toml_string_at(authors, i);
|
toml_datum_t author = toml_string_at(authors, i);
|
||||||
if (!author.ok)
|
if (!author.ok)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
char** new_authors = realloc(config->authors, sizeof(const char *) * ++len);
|
g_array_append_val(config->authors, author.u.s);
|
||||||
config->authors = new_authors;
|
|
||||||
config->authors[len] = author.u.s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// project description
|
||||||
|
toml_datum_t description = toml_string_in(project_table, "description");
|
||||||
|
if (description.ok) {
|
||||||
|
config->desc = description.u.s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// project license
|
||||||
|
toml_datum_t license = toml_string_in(project_table, "license");
|
||||||
|
if (license.ok) {
|
||||||
|
config->license = license.u.s;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PROJECT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int load_project_config(ProjectConfig *config) {
|
int load_project_config(ProjectConfig *config) {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define GEMSTONE_OPT_H
|
#define GEMSTONE_OPT_H
|
||||||
|
|
||||||
#include <toml.h>
|
#include <toml.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
typedef struct TargetConfig_t {
|
typedef struct TargetConfig_t {
|
||||||
char* name;
|
char* name;
|
||||||
|
@ -21,8 +22,10 @@ typedef struct ProjectConfig_t {
|
||||||
char* desc;
|
char* desc;
|
||||||
// version
|
// version
|
||||||
char* version;
|
char* version;
|
||||||
|
// license
|
||||||
|
char* license;
|
||||||
// list of authors
|
// list of authors
|
||||||
char** authors;
|
GArray* authors;
|
||||||
} ProjectConfig;
|
} ProjectConfig;
|
||||||
|
|
||||||
TargetConfig default_target_config();
|
TargetConfig default_target_config();
|
||||||
|
|
Loading…
Reference in New Issue