Browse code

cmdutils: Add -buildconf option.

The output is formatted to display one option per line.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Stephen Hutchinson authored on 2013/08/12 01:17:57
Showing 3 changed files
... ...
@@ -1079,6 +1079,32 @@ static void print_program_info(int flags, int level)
1079 1079
     av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent);
1080 1080
 }
1081 1081
 
1082
+static void print_buildconf(int flags, int level)
1083
+{
1084
+    const char *indent = flags & INDENT? "  " : "";
1085
+    char str[] = { FFMPEG_CONFIGURATION };
1086
+    char *conflist, *remove_tilde, *splitconf;
1087
+
1088
+    // Change all the ' --' strings to '~--' so that
1089
+    // they can be identified as tokens.
1090
+    while( (conflist = strstr(str, " --")) != NULL ) {
1091
+        strncpy(conflist, "~--", 3);
1092
+    }
1093
+
1094
+    // Compensate for the weirdness this would cause
1095
+    // when passing 'pkg-config --static'.
1096
+    while( (remove_tilde = strstr(str, "pkg-config~")) != NULL ) {
1097
+        strncpy(remove_tilde, "pkg-config ",11);
1098
+    }
1099
+
1100
+    splitconf = strtok(str, "~");
1101
+    av_log(NULL, level, "\n%sconfiguration:\n",indent);
1102
+    while(splitconf != NULL) {
1103
+        av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf);
1104
+        splitconf = strtok(NULL, "~");
1105
+    }
1106
+}
1107
+
1082 1108
 void show_banner(int argc, char **argv, const OptionDef *options)
1083 1109
 {
1084 1110
     int idx = locate_option(argc, argv, options, "version");
... ...
@@ -1099,6 +1125,14 @@ int show_version(void *optctx, const char *opt, const char *arg)
1099 1099
     return 0;
1100 1100
 }
1101 1101
 
1102
+int show_buildconf(void *optctx, const char *opt, const char *arg)
1103
+{
1104
+    av_log_set_callback(log_callback_help);
1105
+    print_buildconf      (INDENT|0, AV_LOG_INFO);
1106
+
1107
+    return 0;
1108
+}
1109
+
1102 1110
 int show_license(void *optctx, const char *opt, const char *arg)
1103 1111
 {
1104 1112
 #if CONFIG_NONFREE
... ...
@@ -415,6 +415,13 @@ void show_banner(int argc, char **argv, const OptionDef *options);
415 415
 int show_version(void *optctx, const char *opt, const char *arg);
416 416
 
417 417
 /**
418
+ * Print the build configuration of the program to stdout. The contents
419
+ * depend on the definition of FFMPEG_CONFIGURATION.
420
+ * This option processing function does not utilize the arguments.
421
+ */
422
+int show_buildconf(void *optctx, const char *opt, const char *arg);
423
+
424
+/**
418 425
  * Print the license of the program to stdout. The license depends on
419 426
  * the license of the libraries compiled into the program.
420 427
  * This option processing function does not utilize the arguments.
... ...
@@ -4,6 +4,7 @@
4 4
     { "help"       , OPT_EXIT, {.func_arg = show_help},         "show help", "topic" },
5 5
     { "-help"      , OPT_EXIT, {.func_arg = show_help},         "show help", "topic" },
6 6
     { "version"    , OPT_EXIT, {.func_arg = show_version},      "show version" },
7
+    { "buildconf"  , OPT_EXIT, {.func_arg = show_buildconf},    "show build configuration" },
7 8
     { "formats"    , OPT_EXIT, {.func_arg = show_formats  },    "show available formats" },
8 9
     { "codecs"     , OPT_EXIT, {.func_arg = show_codecs   },    "show available codecs" },
9 10
     { "decoders"   , OPT_EXIT, {.func_arg = show_decoders },    "show available decoders" },