diff options
Diffstat (limited to 'scripts/write_config')
-rw-r--r-- | scripts/write_config/Makefile | 3 | ||||
-rw-r--r-- | scripts/write_config/solution.c | 48 | ||||
-rw-r--r-- | scripts/write_config/solution.h | 13 | ||||
-rw-r--r-- | scripts/write_config/write.c | 94 |
4 files changed, 119 insertions, 39 deletions
diff --git a/scripts/write_config/Makefile b/scripts/write_config/Makefile index a4926e8..bab1f4b 100644 --- a/scripts/write_config/Makefile +++ b/scripts/write_config/Makefile @@ -8,7 +8,8 @@ KCONFIG_PREFIX = ../shared/kconfig include $(KCONFIG_PREFIX)/files.mk SRC = write.c \ - symlist.c + symlist.c \ + solution.c OBJ = $(patsubst %.c,%.o,$(SRC)) CFLAGS = -O0 -w -ggdb INCLUDES = -I../shared diff --git a/scripts/write_config/solution.c b/scripts/write_config/solution.c new file mode 100644 index 0000000..fd3d2cf --- /dev/null +++ b/scripts/write_config/solution.c @@ -0,0 +1,48 @@ +#include "solution.h" + +void solution_set(struct symlist *sl, FILE * f) { + int c; + // skip first line + do + c = fgetc(f); + while (c != EOF && c != '\n'); + + char *w; + size_t w_size = 1, w_pos = 0; + w = malloc((w_size + 1) * sizeof(char)); + do { + c = fgetc(f); + if (c == ' ' || c == '\n') { + w[w_pos] = '\0'; + w_pos = 0; + char *ww = w; + bool neg = false; + if (w[0] == '-') { + neg = true; + ww = w + 1; + } + int id = atoi(ww); + if (id == 0) + continue; + if (sl->array[id - 1].sym == NULL) + continue; + tristate val = sym_get_tristate_value(sl->array[id - 1].sym); + sym_set_tristate_value(sl->array[id - 1].sym, neg ? no : yes); + sym_calc_value(sl->array[id - 1].sym); + if (neg == + (sym_get_tristate_value(sl->array[id - 1].sym) == + no ? true : false)) + printf("Ok\n"); + else + printf("Problem %s\n", sl->array[id - 1].sym->name); + if (sym_get_tristate_value(sl->array[id - 1].sym) != val) + printf("Change\n"); + } else { + if (w_pos >= w_size) { + w_size *= 2; + w = realloc(w, (w_size + 1) * sizeof(char)); + } + w[w_pos++] = (char) c; + } + } while (c != EOF && c != '\n'); +} diff --git a/scripts/write_config/solution.h b/scripts/write_config/solution.h new file mode 100644 index 0000000..fb1ebed --- /dev/null +++ b/scripts/write_config/solution.h @@ -0,0 +1,13 @@ +#include <stdlib.h> +#include <stdio.h> +#include <stdbool.h> +#include <kconfig/lkc.h> +#include <build_files.h> +#include "symlist.h" + +#ifndef _SOLUTION_H_ +#define _SOLUTION_H_ + +void solution_set(struct symlist *sl, FILE * f); + +#endif /* _SOLUTION_H_ */ diff --git a/scripts/write_config/write.c b/scripts/write_config/write.c index f5a3181..9ba95ab 100644 --- a/scripts/write_config/write.c +++ b/scripts/write_config/write.c @@ -6,54 +6,72 @@ #include <macros.h> #include <build_files.h> #include "symlist.h" +#include "solution.h" int verbose_level; char *file, *folder; int main(int argc, char **argv) { - verbose_level = 1; - int i; - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-v")) - verbose_level++; - else if (file == NULL) - file = argv[i]; - else if (folder == NULL) - folder = argv[i]; - else { - Eprintf("Unknown parameter: %s\n", argv[i]); - exit(1); - } - } - - if (file == NULL) { - Eprintf("No Kconfig input file specified\n"); - exit(2); - } - if (folder == NULL) { - Eprintf("No output folder specified\n"); - exit(3); - } - - char *rules_file, *symbol_map_file, *def_config_file; - asprintf(&rules_file, "%s/%s", folder, DEFAULT_RULES_FILE); - asprintf(&symbol_map_file, "%s/%s", folder, DEFAULT_SYMBOL_MAP_FILE); - asprintf(&def_config_file, "%s/%s", folder, DEFAULT_DEF_CONFIG_FILE); - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - conf_parse(file); - conf_read(def_config_file); + conf_parse("Kconfig"); + conf_read(".config"); + //conf_write(".config"); + /* verbose_level = 1; + int i; + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-v")) + verbose_level++; + else if (file == NULL) + file = argv[i]; + else if (folder == NULL) + folder = argv[i]; + else { + Eprintf("Unknown parameter: %s\n", argv[i]); + exit(1); + } + } + + if (file == NULL) { + Eprintf("No Kconfig input file specified\n"); + exit(2); + } + if (folder == NULL) { + Eprintf("No output folder specified\n"); + exit(3); + } + + char *rules_file, *symbol_map_file, *def_config_file, *solution_file; + asprintf(&rules_file, "%s/%s", folder, DEFAULT_RULES_FILE); + asprintf(&symbol_map_file, "%s/%s", folder, DEFAULT_SYMBOL_MAP_FILE); + asprintf(&def_config_file, "%s/%s", folder, DEFAULT_DEF_CONFIG_FILE); + asprintf(&solution_file, "%s/%s", folder, DEFAULT_SOLUTION_FILE); + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + conf_parse(file); + conf_read(def_config_file); + + FILE *f = fopen(symbol_map_file, "r"); + if (f == NULL) { + Eprintf("Can't open file: %s\n", symbol_map_file); + exit(1); + } + struct symlist *sl = symlist_read(f); + fclose(f); - FILE *f = fopen(symbol_map_file, "r"); - if (f == NULL) { - Eprintf("Can't open file: %s\n", symbol_map_file); - exit(1); - } - struct symlist *sl = symlist_read(f); - fclose(f); + f = fopen(solution_file, "r"); + if (f == NULL) { + Eprintf("Can't open file: %s\n", solution_file); + exit(2); + } + solution_set(sl, f); + fclose(f); + */ return 0; } |