aboutsummaryrefslogtreecommitdiff
path: root/programs/src/kconfig_parser
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-03-22 22:05:56 +0100
committerKarel Kočí <cynerd@email.cz>2015-03-22 22:05:56 +0100
commit3b4fbaa22233e764f6b94effd1b21c494061d32c (patch)
treea7da885e905077137f61f9c5898ade4cbc9da5e5 /programs/src/kconfig_parser
parentf0ade98600d1fdcaeb4476ee80fb12b834f61f84 (diff)
downloadlinux-conf-perf-3b4fbaa22233e764f6b94effd1b21c494061d32c.tar.gz
linux-conf-perf-3b4fbaa22233e764f6b94effd1b21c494061d32c.tar.bz2
linux-conf-perf-3b4fbaa22233e764f6b94effd1b21c494061d32c.zip
kconfig_parser: Fix rev_dep and implement verbose level output
After this fix, generated dependency should be all right. Verbose output implementation is only temporally. It needs better implementation. And command line arguments should be parsed with argp.
Diffstat (limited to 'programs/src/kconfig_parser')
-rw-r--r--programs/src/kconfig_parser/cnfexpr.c3
-rw-r--r--programs/src/kconfig_parser/cnfexpr.h2
-rw-r--r--programs/src/kconfig_parser/kconfig_parser.c44
-rw-r--r--programs/src/kconfig_parser/macros.h11
-rw-r--r--programs/src/kconfig_parser/output.c15
5 files changed, 53 insertions, 22 deletions
diff --git a/programs/src/kconfig_parser/cnfexpr.c b/programs/src/kconfig_parser/cnfexpr.c
index 50f0929..3e1dcd6 100644
--- a/programs/src/kconfig_parser/cnfexpr.c
+++ b/programs/src/kconfig_parser/cnfexpr.c
@@ -7,7 +7,7 @@ struct cnfexpr *cnf_or(struct cnfexpr *e1, struct cnfexpr *e2);
struct cnfexpr *cnf_and(struct cnfexpr *e1, struct cnfexpr *e2);
void free_cnf(struct cnfexpr *e);
-struct cnfexpr *kconfig_cnfexpr(struct symlist *sl, struct expr *expr) {
+struct cnfexpr *kconfig_cnfexpr(struct symlist *sl, bool nt, struct expr *expr) {
struct stck {
struct expr *expr;
struct cnfexpr *cnf;
@@ -19,7 +19,6 @@ struct cnfexpr *kconfig_cnfexpr(struct symlist *sl, struct expr *expr) {
int stack_size = 2, stack_pos = -1;
stack = malloc((unsigned) stack_size * sizeof(struct stck));
struct cnfexpr *rtrn = NULL;
- bool nt = false;
while (expr != NULL) {
if ((back_pos >= 0 && back[back_pos] != expr) || back_pos < 0) {
diff --git a/programs/src/kconfig_parser/cnfexpr.h b/programs/src/kconfig_parser/cnfexpr.h
index ed5c2fb..0473368 100644
--- a/programs/src/kconfig_parser/cnfexpr.h
+++ b/programs/src/kconfig_parser/cnfexpr.h
@@ -18,7 +18,7 @@ struct cnfexpr {
unsigned size;
};
-struct cnfexpr *kconfig_cnfexpr(struct symlist *sl, struct expr *expr);
+struct cnfexpr *kconfig_cnfexpr(struct symlist *sl, bool nt, struct expr *expr);
void cnf_printf(struct cnfexpr *);
struct boolexp *printf_original(struct symlist *sl, struct expr *expr);
diff --git a/programs/src/kconfig_parser/kconfig_parser.c b/programs/src/kconfig_parser/kconfig_parser.c
index c4ee358..ef49551 100644
--- a/programs/src/kconfig_parser/kconfig_parser.c
+++ b/programs/src/kconfig_parser/kconfig_parser.c
@@ -10,9 +10,14 @@
#include <unistd.h>
#include <locale.h>
#include <stdbool.h>
+#include <argp.h>
#include "kconfig/lkc.h"
#include "symlist.h"
#include "output.h"
+#include "macros.h"
+
+int verbose_level;
+char *file;
struct symlist *gsymlist;
int noname_num;
@@ -21,12 +26,22 @@ void build_symlist();
void cpy_dep();
int main(int argc, char **argv) {
+ // TODO argp
+ verbose_level = 1;
+ int i;
+ for (i = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "-v"))
+ verbose_level++;
+ else if (file == NULL)
+ file = argv[i];
+ }
+
if (argc < 2) {
- printf("No input file specified\n");
+ Eprintf("No input file specified\n");
exit(1);
}
if (argc < 3) {
- printf("No output folder specified\n");
+ Eprintf("No output folder specified\n");
exit(2);
}
@@ -73,23 +88,24 @@ void cpy_dep() {
for_all_symbols(i, sym) {
if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE)
&& strstr(sym->name, "NONAMEGEN") == NULL) {
- printf("working: %s\n", sym->name);
+ Iprintf("working: %s\n", sym->name);
el = symlist_find(gsymlist, sym->name);
if (sym->dir_dep.expr != NULL) {
- printf_original(gsymlist, sym->dir_dep.expr);
- printf("Direct:\n");
- el->be = kconfig_cnfexpr(gsymlist, sym->dir_dep.expr);
- cnf_printf(el->be);
+ if (verbose_level > 2)
+ printf_original(gsymlist, sym->dir_dep.expr);
+ el->be = kconfig_cnfexpr(gsymlist, false, sym->dir_dep.expr);
+ Iprintf("Direct:\n");
+ if (verbose_level > 2)
+ cnf_printf(el->be);
}
if (sym->rev_dep.expr != NULL) {
- if (!strcmp(sym->name, "CRC32"))
- continue;
- printf_original(gsymlist, sym->rev_dep.expr);
- printf("Revers:\n");
- el->re_be = kconfig_cnfexpr(gsymlist, sym->rev_dep.expr);
- cnf_printf(el->re_be);
- el->re_be = kconfig_cnfexpr(gsymlist, sym->rev_dep.expr);
+ if (verbose_level > 2)
+ printf_original(gsymlist, sym->rev_dep.expr);
+ el->re_be = kconfig_cnfexpr(gsymlist, true, sym->rev_dep.expr);
+ Iprintf("Revers:\n");
+ if (verbose_level > 2)
+ cnf_printf(el->re_be);
}
}
}
diff --git a/programs/src/kconfig_parser/macros.h b/programs/src/kconfig_parser/macros.h
new file mode 100644
index 0000000..6044f31
--- /dev/null
+++ b/programs/src/kconfig_parser/macros.h
@@ -0,0 +1,11 @@
+extern int verbose_level; // Defined in kconfig_parser.c
+
+#define Eprintf(...) printf(stderr, __VA_ARGS__)
+#define Wprintf(...) if (verbose_level > 1) printf(__VA_ARGS__)
+#define Iprintf(...) if (verbose_level > 2) printf(__VA_ARGS__)
+
+#ifndef DEBUG
+#define Dprintf(...)
+#else
+#define Dprintf(...) if (verbose_level > 2) printf(a, __VA_ARGS__)
+#endif /* DEBUG */
diff --git a/programs/src/kconfig_parser/output.c b/programs/src/kconfig_parser/output.c
index 942693b..149a7b6 100644
--- a/programs/src/kconfig_parser/output.c
+++ b/programs/src/kconfig_parser/output.c
@@ -1,18 +1,23 @@
#include "output.h"
-void fprint_rules_cnf(FILE * f, unsigned id, struct cnfexpr *cnf) {
+void fprint_rules_cnf(FILE * f, unsigned id, struct cnfexpr *cnf, bool nt) {
unsigned i, y;
switch (cnf->type) {
case CT_FALSE:
// Never satisfiable
- fprintf(f, "-%d\n", id);
+ if (!nt)
+ fprintf(f, "-%d\n", id);
break;
case CT_TRUE:
// Always satisfiable
+ if (nt)
+ fprintf(f, "%d\n", id);
break;
case CT_EXPR:
for (i = 0; i < cnf->size; i++) {
- fprintf(f, "-%d ", id);
+ if (!nt)
+ fprintf(f, "-");
+ fprintf(f, "%d ", id);
for (y = 0; y < cnf->sizes[i] - 1; y++) {
fprintf(f, "%d ", cnf->exprs[i][y]);
}
@@ -36,10 +41,10 @@ void fprint_rules(struct symlist *sl, char *output) {
if (sl->array[i].be != NULL) {
el = sl->array + i;
if (el->be != NULL) {
- fprint_rules_cnf(f, el->id, el->be);
+ fprint_rules_cnf(f, el->id, el->be, false);
}
if (el->re_be != NULL) {
- fprint_rules_cnf(f, el->id, el->be);
+ fprint_rules_cnf(f, el->id, el->re_be, true);
}
}
}