diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2017-05-26 17:19:53 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2017-05-26 18:02:03 +0200 |
commit | cdb49509e85443129f2d60180eb818813030901e (patch) | |
tree | 5b1f769cd54e12c3d3dc19bdba35ba3f4d8cac7a | |
parent | a0128522e5fb4ee50fe10450ad8255cd1729bde4 (diff) | |
download | libsigrokdecode-cdb49509e85443129f2d60180eb818813030901e.tar.gz libsigrokdecode-cdb49509e85443129f2d60180eb818813030901e.zip |
Show lib versions in the debug output.
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | libsigrokdecode.h | 2 | ||||
-rw-r--r-- | srd.c | 34 | ||||
-rw-r--r-- | version.c | 31 |
4 files changed, 70 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 279abf2..8b6b2b4 100644 --- a/configure.ac +++ b/configure.ac @@ -136,6 +136,9 @@ PKG_CHECK_MODULES([TESTS], [$SRD_PKGLIBS_TESTS glib-2.0 $SRD_PKGLIBS]) srd_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD` +AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"], + [The canonical host libsigrokdecode will run on.]) + AC_CONFIG_FILES([Makefile libsigrokdecode.pc]) AC_OUTPUT diff --git a/libsigrokdecode.h b/libsigrokdecode.h index 549bd25..ae96d95 100644 --- a/libsigrokdecode.h +++ b/libsigrokdecode.h @@ -363,6 +363,8 @@ SRD_API int srd_lib_version_current_get(void); SRD_API int srd_lib_version_revision_get(void); SRD_API int srd_lib_version_age_get(void); SRD_API const char *srd_lib_version_string_get(void); +SRD_API GSList *srd_buildinfo_libs_get(void); +SRD_API char *srd_buildinfo_host_get(void); #include "version.h" @@ -112,6 +112,38 @@ static int searchpath_add_xdg_dir(const char *datadir) return ret; } +static void print_versions(void) +{ + GString *s; + GSList *l, *l_orig, *m; + char *str; + const char *lib, *version; + + srd_dbg("libsigrokdecode %s/%s (rt: %s/%s).", + 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: "); + 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, ", lib, version); + g_slist_free_full(m, g_free); + } + g_slist_free(l_orig); + s->str[s->len - 2] = '.'; + s->str[s->len - 1] = '\0'; + srd_dbg("%s", s->str); + g_string_free(s, TRUE); + + str = srd_buildinfo_host_get(); + srd_dbg("Host: %s.", str); + g_free(str); +} + /** * Initialize libsigrokdecode. * @@ -151,6 +183,8 @@ SRD_API int srd_init(const char *path) return SRD_ERR; } + print_versions(); + srd_dbg("Initializing libsigrokdecode."); /* Add our own module to the list of built-in modules. */ @@ -18,6 +18,7 @@ */ #include <config.h> +#include "libsigrokdecode-internal.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */ #include "libsigrokdecode.h" /** @@ -145,4 +146,34 @@ SRD_API const char *srd_lib_version_string_get(void) return SRD_LIB_VERSION_STRING; } +SRD_API GSList *srd_buildinfo_libs_get(void) +{ + GSList *l = NULL, *m = NULL; + + m = g_slist_append(NULL, g_strdup("glib")); + m = g_slist_append(m, g_strdup_printf("%d.%d.%d (rt: %d.%d.%d/%d:%d)", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION, + glib_major_version, glib_minor_version, glib_micro_version, + glib_binary_age, glib_interface_age)); + l = g_slist_append(l, m); + + m = g_slist_append(NULL, g_strdup("Python")); + m = g_slist_append(m, g_strdup_printf("%s / 0x%x (API %s, ABI %s)", + PY_VERSION, PY_VERSION_HEX, PYTHON_API_STRING, PYTHON_ABI_STRING)); + l = g_slist_append(l, m); + + return l; +} + +SRD_API char *srd_buildinfo_host_get(void) +{ + return g_strdup_printf("%s, %s-endian", CONF_HOST, +#ifdef WORDS_BIGENDIAN + "big" +#else + "little" +#endif + ); +} + /** @} */ |