--list-supported: Show detailed library/feature info.
authorUwe Hermann <uwe@hermann-uwe.de>
Sat, 3 Jun 2017 15:17:04 +0000 (17:17 +0200)
committerUwe Hermann <uwe@hermann-uwe.de>
Sat, 3 Jun 2017 15:24:07 +0000 (17:24 +0200)
show.c

diff --git a/show.c b/show.c
index 1c5aad09f47760e4d6752a5236311da58926b374..c93a6be4c8c397bf7096857880bb17b9c6963f3e 100644 (file)
--- a/show.c
+++ b/show.c
@@ -58,14 +58,64 @@ static gint sort_pds(gconstpointer a, gconstpointer b)
 
 void show_version(void)
 {
+       GString *s;
+       GSList *l, *l_orig, *m;
+       char *str;
+       const char *lib, *version;
+
        printf("sigrok-cli %s\n\n", SC_PACKAGE_VERSION_STRING);
 
-       printf("Using libsigrok %s (lib version %s).\n",
-              sr_package_version_string_get(), sr_lib_version_string_get());
-#ifdef HAVE_SRD
-       printf("Using libsigrokdecode %s (lib version %s).\n\n",
-              srd_package_version_string_get(), srd_lib_version_string_get());
-#endif
+       printf("Libraries and features:\n");
+
+       printf("- libsigrok %s/%s (rt: %s/%s).\n",
+               SR_PACKAGE_VERSION_STRING, SR_LIB_VERSION_STRING,
+               sr_package_version_string_get(), sr_lib_version_string_get());
+
+       s = g_string_sized_new(200);
+       g_string_append(s, " - Libs:\n");
+       l_orig = sr_buildinfo_libs_get();
+       for (l = l_orig; l; l = l->next) {
+               m = l->data;
+               lib = m->data;
+               version = m->next->data;
+               g_string_append_printf(s, "  - %s %s\n", lib, version);
+               g_slist_free_full(m, g_free);
+       }
+       g_slist_free(l_orig);
+       s->str[s->len - 1] = '\0';
+       printf("%s\n", s->str);
+       g_string_free(s, TRUE);
+
+       str = sr_buildinfo_host_get();
+       printf("  - Host: %s.\n", str);
+       g_free(str);
+
+       str = sr_buildinfo_scpi_backends_get();
+       printf("  - SCPI backends: %s.\n", str);
+       g_free(str);
+
+       printf("- libsigrokdecode %s/%s (rt: %s/%s).\n",
+               SRD_PACKAGE_VERSION_STRING, SRD_LIB_VERSION_STRING,
+               srd_package_version_string_get(), srd_lib_version_string_get());
+
+       s = g_string_sized_new(200);
+       g_string_append(s, " - Libs:\n");
+       l_orig = srd_buildinfo_libs_get();
+       for (l = l_orig; l; l = l->next) {
+               m = l->data;
+               lib = m->data;
+               version = m->next->data;
+               g_string_append_printf(s, "  - %s %s\n", lib, version);
+               g_slist_free_full(m, g_free);
+       }
+       g_slist_free(l_orig);
+       s->str[s->len - 1] = '\0';
+       printf("%s\n", s->str);
+       g_string_free(s, TRUE);
+
+       str = srd_buildinfo_host_get();
+       printf("  - Host: %s.\n", str);
+       g_free(str);
 }
 
 void show_supported(void)