diff options
author | Karel Kočí <cynerd@email.cz> | 2015-07-24 17:19:22 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-07-24 17:19:22 +0200 |
commit | 4df04029a616013e1d795102eab790c628d6dac1 (patch) | |
tree | dc6c194934e371cae82d3b511673dec4b1f1f612 /scripts | |
parent | 2088e7c783964176076f83d8df04dac5adc9781d (diff) | |
download | linux-conf-perf-4df04029a616013e1d795102eab790c628d6dac1.tar.gz linux-conf-perf-4df04029a616013e1d795102eab790c628d6dac1.tar.bz2 linux-conf-perf-4df04029a616013e1d795102eab790c628d6dac1.zip |
Rewrite write_config
Write config don't need to load jobfiles any more.
We only have to load file passed via argument and save using kconfig code.
Configuration checking is disabled. It needs more editing.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/write_config/.gitignore | 2 | ||||
-rw-r--r-- | scripts/write_config/Makefile | 12 | ||||
-rw-r--r-- | scripts/write_config/solution.h | 5 | ||||
-rw-r--r-- | scripts/write_config/symlist.c | 54 | ||||
-rw-r--r-- | scripts/write_config/symlist.h | 24 | ||||
-rw-r--r-- | scripts/write_config/write.c | 84 | ||||
-rw-r--r-- | scripts/write_config/write_config.c | 65 |
7 files changed, 73 insertions, 173 deletions
diff --git a/scripts/write_config/.gitignore b/scripts/write_config/.gitignore index 77ec0be..60f5db0 100644 --- a/scripts/write_config/.gitignore +++ b/scripts/write_config/.gitignore @@ -1 +1 @@ -write +write_config diff --git a/scripts/write_config/Makefile b/scripts/write_config/Makefile index bab1f4b..ec56a87 100644 --- a/scripts/write_config/Makefile +++ b/scripts/write_config/Makefile @@ -2,24 +2,22 @@ MAKEFLAGS += --no-builtin-rules .PHONY: all clean .SUFFIXES: -all: write +all: write_config KCONFIG_PREFIX = ../shared/kconfig include $(KCONFIG_PREFIX)/files.mk -SRC = write.c \ - symlist.c \ - solution.c +SRC = write_config.c OBJ = $(patsubst %.c,%.o,$(SRC)) -CFLAGS = -O0 -w -ggdb +CFLAGS = -O0 -Wall -ggdb INCLUDES = -I../shared %.o: %.c gcc -c $(CFLAGS) -o $@ $^ $(INCLUDES) -write: $(OBJ) $(KCONFIG_OBJ) +write_config: $(OBJ) $(KCONFIG_OBJ) gcc -o $@ $^ clean:: $(RM) $(OBJ) - $(RM) write + $(RM) write_config diff --git a/scripts/write_config/solution.h b/scripts/write_config/solution.h index 100a9fe..7a37c15 100644 --- a/scripts/write_config/solution.h +++ b/scripts/write_config/solution.h @@ -3,7 +3,6 @@ #include <stdbool.h> #include <kconfig/lkc.h> #include <build_files.h> -#include "symlist.h" #ifndef _SOLUTION_H_ #define _SOLUTION_H_ @@ -15,7 +14,7 @@ struct solution { size_t size; }; -struct solution *solution_load(FILE *fmap, FILE *fsolved); -void solution_check(struct symlist *sl, struct solution *s); +struct solution *solution_load(char *source_config); +int solution_check(struct solution *s); #endif /* _SOLUTION_H_ */ diff --git a/scripts/write_config/symlist.c b/scripts/write_config/symlist.c deleted file mode 100644 index fd0aca8..0000000 --- a/scripts/write_config/symlist.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "symlist.h" - -#define NONAMEGEN "NONAMEGEN" - -struct symlist *symlist_read(FILE * f) { - struct symlist *ret; - ret = malloc(sizeof(struct symlist)); - ret->size = 1; - ret->maxid = 0; - ret->array = malloc(ret->size * sizeof(struct symlist_el)); - - unsigned int id; - char *w; - size_t w_pos = 0, w_size = 2; - w = malloc((w_size + 1) * sizeof(char)); - - int c; - do { - c = fgetc(f); - if (c == '\n') { - w[w_pos] = '\0'; - if ((size_t) id > ret->size) { - ret->size *= 2; - ret->array = - realloc(ret->array, - ret->size * sizeof(struct symlist_el)); - } - if (id > ret->maxid) - ret->maxid = id; - ret->array[(size_t) id - 1].id = id; - if (!strncmp(w, NONAMEGEN, strlen(NONAMEGEN))) - ret->array[(size_t) id - 1].sym = NULL; - else - ret->array[(size_t) id - 1].sym = sym_lookup(w, 0); - w_pos = 0; - } else if (c == ':') { - w[w_pos] = '\0'; - id = atoi(w); - w_pos = 0; - } 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); - - return ret; -} - -struct symbol *symlist_get(struct symlist *sl, unsigned int id) { - return sl->array[id].sym; -} diff --git a/scripts/write_config/symlist.h b/scripts/write_config/symlist.h deleted file mode 100644 index 8bc61c1..0000000 --- a/scripts/write_config/symlist.h +++ /dev/null @@ -1,24 +0,0 @@ -#include <stdlib.h> -#include <stdbool.h> -#include <string.h> -#include <stdio.h> -#include <kconfig/lkc.h> - -#ifndef _SYMLIST_H_ -#define _SYMLIST_H_ - -struct symlist_el { - unsigned int id; - struct symbol *sym; -}; - -struct symlist { - struct symlist_el *array; - size_t size; - unsigned maxid; -}; - -struct symlist *symlist_read(FILE *f); -struct symbol *symlist_get(struct symlist *, unsigned int id); - -#endif /* _SYMLIST_H_ */ diff --git a/scripts/write_config/write.c b/scripts/write_config/write.c deleted file mode 100644 index 5402286..0000000 --- a/scripts/write_config/write.c +++ /dev/null @@ -1,84 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <locale.h> -#include <libintl.h> -#include <kconfig/lkc.h> -#include <macros.h> -#include <build_files.h> -#include "symlist.h" -#include "solution.h" - -int verbose_level; -char *file, *folder; - -int exit_status; - -int main(int argc, char **argv) { - exit_status = 0; - 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, *config_map, *config_solved; - 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(&config_map, "%s/%s", folder, DEFAULT_CONFIG_MAP_FILE); - asprintf(&config_solved, "%s/%s", folder, DEFAULT_CONFIG_SOLVED_FILE); - - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - - conf_parse(file); - struct symbol *sym; - //conf_read(def_config_file); - conf_read(".config"); - - 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 *fconfig_map = fopen(config_map, "r"); - if (fconfig_map == NULL) { - Eprintf("Can't open file: %s\n", config_map); - exit(-2); - } - FILE *fconfig_solved = fopen(config_solved, "r"); - if (fconfig_map == NULL) { - Eprintf("Can't open file: %s\n", config_solved); - exit(-3); - } - //struct solution *sol = solution_load(fconfig_map, fconfig_solved); - //solution_check(sl, sol); - fclose(fconfig_map); - fclose(fconfig_solved); - - conf_write(".config"); - - return exit_status; -} diff --git a/scripts/write_config/write_config.c b/scripts/write_config/write_config.c new file mode 100644 index 0000000..1f061d1 --- /dev/null +++ b/scripts/write_config/write_config.c @@ -0,0 +1,65 @@ +#include <stdio.h> +#include <stdlib.h> +#include <locale.h> +#include <libintl.h> +#include <string.h> + +#include <kconfig/lkc.h> +#include <macros.h> +#include <build_files.h> +#include "solution.h" + +const char defkconfig_file[] = "Kconfig"; +const char defoutput_config[] = ".config"; + +int verbose_level; +char *kconfig_file; +char *input_config; + +void print_help(); + +int exit_status; + +int main(int argc, char **argv) { + exit_status = 0; + verbose_level = 1; + kconfig_file = (char*)defkconfig_file; + int i; + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { + print_help(); + exit(0); + } else if (!strcmp(argv[i], "-v")) { + verbose_level++; + } else if (input_config == NULL) { + input_config = argv[i]; + } else { + Eprintf("Unknown parameter: %s\n", argv[i]); + exit(-1); + } + } + + if (input_config == NULL) { + Eprintf("No input config specified."); + print_help(); + exit(2); + } + + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + + conf_parse(kconfig_file); + conf_read(input_config); + + // TODO configuration check disabled. It is not compatible after changes. + + conf_write(defoutput_config); + + return exit_status; +} + +void print_help() { + printf("Usage: write_config [-v] [-h] Input\n"); + printf(" This applies configuration to Linux."); +} |