Skip to content

Commit cdb4950

Browse files
committed
Show lib versions in the debug output.
1 parent a012852 commit cdb4950

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

configure.ac

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ PKG_CHECK_MODULES([TESTS], [$SRD_PKGLIBS_TESTS glib-2.0 $SRD_PKGLIBS])
136136

137137
srd_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD`
138138

139+
AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"],
140+
[The canonical host libsigrokdecode will run on.])
141+
139142
AC_CONFIG_FILES([Makefile libsigrokdecode.pc])
140143

141144
AC_OUTPUT

libsigrokdecode.h

+2
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ SRD_API int srd_lib_version_current_get(void);
363363
SRD_API int srd_lib_version_revision_get(void);
364364
SRD_API int srd_lib_version_age_get(void);
365365
SRD_API const char *srd_lib_version_string_get(void);
366+
SRD_API GSList *srd_buildinfo_libs_get(void);
367+
SRD_API char *srd_buildinfo_host_get(void);
366368

367369
#include "version.h"
368370

srd.c

+34
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,38 @@ static int searchpath_add_xdg_dir(const char *datadir)
112112
return ret;
113113
}
114114

115+
static void print_versions(void)
116+
{
117+
GString *s;
118+
GSList *l, *l_orig, *m;
119+
char *str;
120+
const char *lib, *version;
121+
122+
srd_dbg("libsigrokdecode %s/%s (rt: %s/%s).",
123+
SRD_PACKAGE_VERSION_STRING, SRD_LIB_VERSION_STRING,
124+
srd_package_version_string_get(), srd_lib_version_string_get());
125+
126+
s = g_string_sized_new(200);
127+
g_string_append(s, "Libs: ");
128+
l_orig = srd_buildinfo_libs_get();
129+
for (l = l_orig; l; l = l->next) {
130+
m = l->data;
131+
lib = m->data;
132+
version = m->next->data;
133+
g_string_append_printf(s, "%s %s, ", lib, version);
134+
g_slist_free_full(m, g_free);
135+
}
136+
g_slist_free(l_orig);
137+
s->str[s->len - 2] = '.';
138+
s->str[s->len - 1] = '\0';
139+
srd_dbg("%s", s->str);
140+
g_string_free(s, TRUE);
141+
142+
str = srd_buildinfo_host_get();
143+
srd_dbg("Host: %s.", str);
144+
g_free(str);
145+
}
146+
115147
/**
116148
* Initialize libsigrokdecode.
117149
*
@@ -151,6 +183,8 @@ SRD_API int srd_init(const char *path)
151183
return SRD_ERR;
152184
}
153185

186+
print_versions();
187+
154188
srd_dbg("Initializing libsigrokdecode.");
155189

156190
/* Add our own module to the list of built-in modules. */

version.c

+31
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include <config.h>
21+
#include "libsigrokdecode-internal.h" /* First, so we avoid a _POSIX_C_SOURCE warning. */
2122
#include "libsigrokdecode.h"
2223

2324
/**
@@ -145,4 +146,34 @@ SRD_API const char *srd_lib_version_string_get(void)
145146
return SRD_LIB_VERSION_STRING;
146147
}
147148

149+
SRD_API GSList *srd_buildinfo_libs_get(void)
150+
{
151+
GSList *l = NULL, *m = NULL;
152+
153+
m = g_slist_append(NULL, g_strdup("glib"));
154+
m = g_slist_append(m, g_strdup_printf("%d.%d.%d (rt: %d.%d.%d/%d:%d)",
155+
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION,
156+
glib_major_version, glib_minor_version, glib_micro_version,
157+
glib_binary_age, glib_interface_age));
158+
l = g_slist_append(l, m);
159+
160+
m = g_slist_append(NULL, g_strdup("Python"));
161+
m = g_slist_append(m, g_strdup_printf("%s / 0x%x (API %s, ABI %s)",
162+
PY_VERSION, PY_VERSION_HEX, PYTHON_API_STRING, PYTHON_ABI_STRING));
163+
l = g_slist_append(l, m);
164+
165+
return l;
166+
}
167+
168+
SRD_API char *srd_buildinfo_host_get(void)
169+
{
170+
return g_strdup_printf("%s, %s-endian", CONF_HOST,
171+
#ifdef WORDS_BIGENDIAN
172+
"big"
173+
#else
174+
"little"
175+
#endif
176+
);
177+
}
178+
148179
/** @} */

0 commit comments

Comments
 (0)