OPT__START = 256,
OPT_BASECONFIG,
OPT_CNF,
+ OPT_DUMP,
OPT_ENV,
OPT_HELP,
OPT_KCONFIG,
void print_help()
{
- printf("kconfig2sat [ options ]\n"
+ printf("Usage: kconfig2sat [options/actions]\n"
"\n"
"Options:\n"
- "-b, --baseconf <.config> Linux .config file with base configuration\n"
- "--env <.conf.mk> .conf.mk file for setting variables such as ARCH\n"
- "-k, --kconfig <Kconfig> Kconfig file (with path)\n"
- "--varfile <file> File listing variable options (one option per line)\n"
- "--cnf <file> Generate CNF representation to <file>\n"
- );
+ " -b, --baseconf <.config> Linux .config file with base configuration\n"
+ " --env <.conf.mk> Set env. variables such as ARCH from .conf.mk\n"
+ " -k, --kconfig <Kconfig> Kconfig file (with path)\n"
+ " --varfile <file> File listing variable options (one option per line)\n"
+ "\n"
+ "Actions:\n"
+ " --dump Dump internal data (for debugging)\n"
+ " --cnf <file> Generate CNF representation to <file>\n"
+ );
+}
+
+void do_dump()
+{
+ int i;
+ struct symbol *sym;
+ struct property *prop;
+ for_all_symbols(i, sym) {
+ const char *name = sym->name;
+ const char *type = NULL;
+ const char *prompt = NULL;
+ char val = '.';
+
+ switch (sym->type) {
+#define P(t) case t: type = #t; break
+ P(S_UNKNOWN);
+ P(S_BOOLEAN);
+ P(S_TRISTATE);
+ P(S_INT);
+ P(S_HEX);
+ P(S_STRING);
+ P(S_OTHER);
+#undef P
+ }
+ if (sym->type == S_BOOLEAN || sym->type == S_TRISTATE) {
+ switch (sym->curr.tri) {
+ case no: val = 'n'; break;
+ case mod: val = 'm'; break;
+ case yes: val = 'y'; break;
+ }
+ }
+
+ for_all_properties(sym, prop, P_PROMPT) {
+ prompt = prop->text;
+ }
+
+ printf("%-40s %c %-10s %s\n", name, val, type, prompt);
+ }
}
int main(int argc, char **argv)
char *cnf = NULL;
char *kconfig = NULL;
char *varfile = NULL;
+ int dump = false;
while (1) {
int option_index = 0;
static struct option long_options[] = {
- {"baseconf", required_argument, 0, OPT_BASECONFIG },
- {"cnf", required_argument, 0, OPT_CNF },
- {"env", required_argument, 0, OPT_ENV },
- {"help", no_argument, 0, OPT_HELP },
- {"kconfig", required_argument, 0, OPT_KCONFIG },
- {"varfile", required_argument, 0, OPT_VARFILE },
-// {"varopt", required_argument, 0, OPT_VAROPTION },
- {"verbose", no_argument, 0, OPT_VERBOSE },
- {0, 0, 0, 0 }
+ {"baseconf", required_argument, 0, OPT_BASECONFIG },
+ {"cnf", required_argument, 0, OPT_CNF },
+ {"env", required_argument, 0, OPT_ENV },
+ {"dump", no_argument, &dump, true },
+ {"help", no_argument, 0, OPT_HELP },
+ {"kconfig", required_argument, 0, OPT_KCONFIG },
+ {"varfile", required_argument, 0, OPT_VARFILE },
+// {"varopt", required_argument, 0, OPT_VAROPTION },
+ {"verbose", no_argument, 0, OPT_VERBOSE },
+ {0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "b:hk:v",
break;
switch (c) {
+ case 0: /* long option with flag != NULL */
+ break;
case 'b':
case OPT_BASECONFIG:
baseconf = optarg;
conf_parse_path(kconfig);
+ if (baseconf)
+ conf_read(baseconf);
+
+ if (dump)
+ do_dump();
+
// char *rules_file, *symbol_map_file, *variable_count_file;
// asprintf(&rules_file, "%s/%s", folder, DEFAULT_RULES_FILE);
// asprintf(&symbol_map_file, "%s/%s", folder, DEFAULT_SYMBOL_MAP_FILE);