#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;
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) {
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) {
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);
}
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");
}
--- /dev/null
+#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;
+}