Commit 374c57f7 authored by Rusty Russell's avatar Rusty Russell

tools/configurator: support --var-file for outputting VAR=VAL format.

Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 33a9e453
...@@ -684,13 +684,14 @@ int main(int argc, const char *argv[]) ...@@ -684,13 +684,14 @@ int main(int argc, const char *argv[])
const char *outflag = DEFAULT_OUTPUT_EXE_FLAG; const char *outflag = DEFAULT_OUTPUT_EXE_FLAG;
const char *configurator_cc = NULL; const char *configurator_cc = NULL;
const char *orig_cc; const char *orig_cc;
const char *varfile = NULL;
if (argc > 0) if (argc > 0)
progname = argv[0]; progname = argv[0];
while (argc > 1) { while (argc > 1) {
if (strcmp(argv[1], "--help") == 0) { if (strcmp(argv[1], "--help") == 0) {
printf("Usage: configurator [-v] [-O<outflag>] [--configurator-cc=<compiler-for-tests>] [<compiler> <flags>...]\n" printf("Usage: configurator [-v] [--var-file=<filename>] [-O<outflag>] [--configurator-cc=<compiler-for-tests>] [<compiler> <flags>...]\n"
" <compiler> <flags> will have \"<outflag> <outfile> <infile.c>\" appended\n" " <compiler> <flags> will have \"<outflag> <outfile> <infile.c>\" appended\n"
"Default: %s %s %s\n", "Default: %s %s %s\n",
DEFAULT_COMPILER, DEFAULT_FLAGS, DEFAULT_COMPILER, DEFAULT_FLAGS,
...@@ -719,6 +720,10 @@ int main(int argc, const char *argv[]) ...@@ -719,6 +720,10 @@ int main(int argc, const char *argv[])
configurator_cc = argv[1] + 18; configurator_cc = argv[1] + 18;
argc--; argc--;
argv++; argv++;
} else if (strncmp(argv[1], "--var-file=", 11) == 0) {
varfile = argv[1] + 11;
argc--;
argv++;
} else { } else {
break; break;
} }
...@@ -739,6 +744,24 @@ int main(int argc, const char *argv[]) ...@@ -739,6 +744,24 @@ int main(int argc, const char *argv[])
remove(OUTPUT_FILE); remove(OUTPUT_FILE);
remove(INPUT_FILE); remove(INPUT_FILE);
if (varfile) {
FILE *vars;
if (strcmp(varfile, "-") == 0)
vars = stdout;
else {
vars = fopen(varfile, "a");
if (!vars)
c12r_err(2, "Could not open %s", varfile);
}
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
fprintf(vars, "%s=%u\n", tests[i].name, tests[i].answer);
if (vars != stdout) {
if (fclose(vars) != 0)
c12r_err(2, "Closing %s", varfile);
}
}
printf("/* Generated by CCAN configurator */\n" printf("/* Generated by CCAN configurator */\n"
"#ifndef CCAN_CONFIG_H\n" "#ifndef CCAN_CONFIG_H\n"
"#define CCAN_CONFIG_H\n"); "#define CCAN_CONFIG_H\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment