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.
.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
#include <stdbool.h>
#include <kconfig/lkc.h>
#include <build_files.h>
-#include "symlist.h"
#ifndef _SOLUTION_H_
#define _SOLUTION_H_
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_ */
+++ /dev/null
-#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;
-}
+++ /dev/null
-#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_ */
+++ /dev/null
-#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;
-}
--- /dev/null
+#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.");
+}