1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <stdbool.h>
#include <libintl.h>
#include <kconfig/lkc.h>
#include "symlist.h"
#include "output.h"
#include "macros.h"
int verbose_level;
char *file, *folder;
struct symlist *gsymlist;
int noname_num;
void build_symlist();
void cpy_dep();
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);
}
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
conf_parse(file);
//sym_clear_all_valid();
gsymlist = symlist_create();
build_symlist();
cpy_dep();
char *rules_file, *symbol_map_file;
asprintf(&rules_file, "%s/%s", folder, DEFAULT_RULES_FILE);
asprintf(&symbol_map_file, "%s/%s", folder, DEFAULT_SYMBOL_MAP_FILE);
fprint_rules(gsymlist, rules_file);
fprint_symbol_map(gsymlist, symbol_map_file);
return 0;
}
void build_symlist() {
int i;
struct symbol *sym;
for_all_symbols(i, sym) {
if (sym->type == S_BOOLEAN || sym->type == S_TRISTATE) {
if (sym->name != NULL) {
symlist_add(gsymlist, sym->name);
} else {
sym->name = malloc((9 + 7) * sizeof(char));
sprintf(sym->name, "NONAMEGEN%d", noname_num++);
symlist_add(gsymlist, sym->name);
}
}
struct property *prop;
for_all_prompts(sym, prop) {
gsymlist->array[gsymlist->pos - 1].prompt = true;
break;
}
}
}
void cpy_dep() {
int i;
struct symbol *sym;
struct symlist_el *el;
for_all_symbols(i, sym) {
if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE)) {
el = symlist_find(gsymlist, sym->name);
Iprintf("working: %s(%d)\n", sym->name, el->id);
if (sym->dir_dep.expr != NULL) {
if (verbose_level > 3)
printf_original(gsymlist, sym->dir_dep.expr);
el->be =
kconfig_cnfexpr(gsymlist, false, sym,
sym->dir_dep.expr);
Iprintf("Direct:\n");
if (verbose_level > 2)
cnf_printf(el->be);
} else
el->be = NULL;
if (sym->rev_dep.expr != NULL) {
if (verbose_level > 3)
printf_original(gsymlist, sym->rev_dep.expr);
el->re_be =
kconfig_cnfexpr(gsymlist, true, sym,
sym->rev_dep.expr);
Iprintf("Revers:\n");
if (verbose_level > 2)
cnf_printf(el->re_be);
} else
el->re_be = NULL;
}
}
}
|