]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
Allconfig add inv option
authorKarel Kočí <cynerd@email.cz>
Tue, 28 Jul 2015 08:23:29 +0000 (10:23 +0200)
committerKarel Kočí <cynerd@email.cz>
Tue, 28 Jul 2015 08:23:29 +0000 (10:23 +0200)
Added inv option for generating inverted configurations.
Inverted configuration contains configuration options that are not in original configuration file.

scripts/allconfig/Makefile
scripts/allconfig/allconfig.c
scripts/allconfig/inv.c [new file with mode: 0644]
scripts/allconfig/inv.h [new file with mode: 0644]

index ffe320ebe12f9c6712d2baf24b467a109910f7a4..44e7b7b5b1feafb1886e9fd25b73a6f7c45aa884 100644 (file)
@@ -7,7 +7,8 @@ all: allconfig
 KCONFIG_PREFIX = ../shared/kconfig
 include $(KCONFIG_PREFIX)/files.mk
 
-SRC  = allconfig.c
+SRC  = allconfig.c \
+          inv.c
 OBJ = $(patsubst %.c,%.o,$(SRC))
 CFLAGS = -O0 -Wall -ggdb -DDEBUG
 INCLUDES = -I../shared
index acd105097ca6907d7b0318bca9b15e6d7292938a..19486e4dcf478ad72aadf73c60ad8eb4cc517df1 100644 (file)
@@ -7,9 +7,10 @@
 #include <kconfig/lkc.h>
 #include <build_files.h>
 #include <macros.h>
+#include "inv.h"
 
 int verbose_level;
-bool full_config;
+bool full_config, inv_config;
 
 char *kconfig_file;
 char *output_config_file;
@@ -25,10 +26,12 @@ int main(int argc, char **argv) {
         if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
             print_help();
             exit(0);
-        } else if (!strcmp(argv[i], "-v")) {
+        } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")) {
             verbose_level++;
         } else if (!strcmp(argv[i], "--all")) {
             full_config = true;
+        } else if (!strcmp(argv[i], "--inv")) {
+            inv_config = true;
         } else if (kconfig_file == NULL) {
             kconfig_file = argv[i];
         } else if (input_config_file == NULL) {
@@ -55,6 +58,10 @@ int main(int argc, char **argv) {
     conf_parse(kconfig_file);
     conf_read(input_config_file);
 
+    if (inv_config) {
+        inv_prepare(input_config_file);
+    }
+
     struct symbol *sym;
     sym = sym_find("MODULES");
     if (sym == NULL) {
@@ -83,8 +90,9 @@ int main(int argc, char **argv) {
                 goto printit;
             continue;
           printit:
-            fprintf(f, "CONFIG_%s=%s\n", sym->name,
-                    sym_get_tristate_value(sym) == no ? "n" : "y");
+            if (!inv_config || !inv_fixed(sym))
+                fprintf(f, "CONFIG_%s=%s\n", sym->name,
+                        sym_get_tristate_value(sym) == no ? "n" : "y");
         }
     }
     fclose(f);
@@ -93,7 +101,17 @@ int main(int argc, char **argv) {
 }
 
 void print_help() {
-    printf("Usage: allconfig [-v] [-h] Kconfig Input Output\n");
+    printf
+        ("Usage: allconfig [-v] [-h] [--all] [--inv] Kconfig Input Output\n");
     printf("  This is generating full configuration.\n");
     printf("  Output configuration has all configuration options.\n");
+    printf("\n");
+    printf(" Options:\n");
+    printf("  -v, --verbose Increase level of verbose output.\n");
+    printf("  -h, --help    Print this help text.\n");
+    printf
+        ("  --all         Genetate full configuration. Including non dependency\n");
+    printf("                configuration options");
+    printf
+        ("  --inv         Generate configuration of missing configratuon options.\n");
 }
diff --git a/scripts/allconfig/inv.c b/scripts/allconfig/inv.c
new file mode 100644 (file)
index 0000000..0e87163
--- /dev/null
@@ -0,0 +1,53 @@
+#include "inv.h"
+
+void inv_prepare(char *input_file) {
+    FILE *f;
+    f = fopen(input_file, "r");
+    if (f == NULL) {
+        Eprintf("Can't open input file: %s\n", input_file);
+        exit(-2);
+    }
+
+    struct property *fixed_prop;
+    fixed_prop = malloc(sizeof(struct property));
+    fixed_prop->type = P_UNKNOWN;
+    fixed_prop->lineno = LINENUM_IDENTIFICATOR;
+    fixed_prop->next = NULL;
+    char buffer[READBUFFER_SIZE];
+    while (fgets(buffer, READBUFFER_SIZE, f) != NULL) {
+        if (buffer[0] == '\0' || buffer[1] == '\0')
+            continue;
+        if (buffer[0] != '#') {
+            char *wstr = buffer + 7;
+            char *end = strchr(wstr, '=');
+            *end = '\0';
+            struct symbol *sym = sym_find(wstr);
+            if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
+                continue;
+            if (sym->prop == NULL) {
+                sym->prop = fixed_prop;
+                continue;
+            }
+            struct property *prop;
+            prop = sym->prop;
+            while (prop->next != NULL)
+                prop = prop->next;
+            prop->next = fixed_prop;
+        }
+    }
+
+    fclose(f);
+}
+
+bool inv_fixed(struct symbol *sym) {
+    if (sym->prop == NULL)
+        return false;
+    struct property *prop;
+    prop = sym->prop;
+    while (prop->next != NULL)
+        prop = prop->next;
+    if (prop->type == P_UNKNOWN && prop->lineno == LINENUM_IDENTIFICATOR)
+        return true;
+    else
+        return false;
+}
diff --git a/scripts/allconfig/inv.h b/scripts/allconfig/inv.h
new file mode 100644 (file)
index 0000000..718a688
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include <macros.h>
+#include <kconfig/lkc.h>
+
+#ifndef _INV_H_
+#define _INV_H_
+
+#define READBUFFER_SIZE 127
+#define LINENUM_IDENTIFICATOR -10
+
+void inv_prepare(char *input_file);
+bool inv_fixed(struct symbol *sym);
+
+#endif /* _INV_H_ */