ManaPlus
Macros | Functions
dumplibs.cpp File Reference

(986a3bf)

#include "utils/dumplibs.h"
#include "logger.h"
#include "utils/stringutils.h"
#include <png.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
#include <SDL_net.h>
#include <SDL_ttf.h>
#include <zlib.h>
#include <curl/curl.h>
#include <libxml/globals.h>
#include "debug.h"

Go to the source code of this file.

Macros

#define dumpCompiledSdlVersion(text, prefix)
 
#define sdlVersionJoin(prefix)
 

Functions

static void dumpLinkedSdlVersion (char *text, SDL_version *version)
 
static void compareVersions (char *libName, char *buildVersion, char *linkedVersion)
 
static void compareSDLVersions (char *libName, int major, int minor, int patch, SDL_version *linkedVersion)
 
void dumpLibs ()
 

Macro Definition Documentation

◆ dumpCompiledSdlVersion

#define dumpCompiledSdlVersion (   text,
  prefix 
)
Value:
logger->log(" " text ": %d.%d.%d", \
prefix##_MAJOR_VERSION, \
prefix##_MINOR_VERSION, \
prefix##_PATCHLEVEL)
void log(const char *const log_text,...)
Definition: logger.cpp:269
Logger * logger
Definition: logger.cpp:89

Definition at line 54 of file dumplibs.cpp.

◆ sdlVersionJoin

#define sdlVersionJoin (   prefix)
Value:
prefix##_MAJOR_VERSION, \
prefix##_MINOR_VERSION, \
prefix##_PATCHLEVEL

Definition at line 60 of file dumplibs.cpp.

Function Documentation

◆ compareSDLVersions()

static void compareSDLVersions ( char *  libName,
int  major,
int  minor,
int  patch,
SDL_version *  linkedVersion 
)
static

Definition at line 92 of file dumplibs.cpp.

97 {
98  const std::string buildVersionStr = strprintf("%d.%d.%d",
99  major,
100  minor,
101  patch);
102  const std::string linkedVersionStr = strprintf("%d.%d.%d",
103  linkedVersion->major,
104  linkedVersion->minor,
105  linkedVersion->patch);
106  if (buildVersionStr != linkedVersionStr)
107  {
108  logger->assertLog(
109  "%s: compiled and linked versions not same: %s vs %s",
110  libName,
111  buildVersionStr.c_str(),
112  linkedVersionStr.c_str());
113  }
114 }
void assertLog(const char *const log_text,...)
Definition: logger.cpp:316
std::string strprintf(const char *const format,...)

References Logger::assertLog(), logger, and strprintf().

Referenced by dumpLibs().

◆ compareVersions()

static void compareVersions ( char *  libName,
char *  buildVersion,
char *  linkedVersion 
)
static

Definition at line 78 of file dumplibs.cpp.

81 {
82  if (strcmp(buildVersion, linkedVersion) != 0)
83  {
85  "%s: compiled and linked versions not same: %s vs %s",
86  libName,
87  buildVersion,
88  linkedVersion);
89  }
90 }

References Logger::assertLog(), and logger.

Referenced by dumpLibs().

◆ dumpLibs()

void dumpLibs ( )

Definition at line 116 of file dumplibs.cpp.

117 {
118  logger->log("Compiled with:");
119  logger->log(" zLib: %s", ZLIB_VERSION);
120 #ifdef ENABLE_LIBXML
121  logger->log(" libxml2: %s, %s",
122  LIBXML_DOTTED_VERSION,
123  LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA);
124 #endif // ENABLE_LIBXML
125 
126  logger->log(" libcurl: %s", LIBCURL_VERSION);
127  logger->log(" libpng: %s", PNG_LIBPNG_VER_STRING);
128 
129  dumpCompiledSdlVersion("SDL", SDL);
130  dumpCompiledSdlVersion("SDL_net", SDL_NET);
131  dumpCompiledSdlVersion("SDL_image", SDL_IMAGE);
132  dumpCompiledSdlVersion("SDL_mixer", SDL_MIXER);
133  dumpCompiledSdlVersion("SDL_ttf", SDL_TTF);
134 
135  logger->log("Linked with:");
136 #if ZLIB_VERNUM >= 0x1020
137  logger->log(" zLib: %s", zlibVersion());
138 #endif // ZLIB_VERNUM >= 0x1020
139 #ifdef LIBXML_TEST_VERSION
140  LIBXML_TEST_VERSION
141 #endif // LIBXML_TEST_VERSION
142 #ifdef ENABLE_LIBXML
143  const char **xmlVersion = __xmlParserVersion();
144  if (xmlVersion != nullptr)
145  logger->log(" libxml2: %s", *xmlVersion);
146 #endif // ENABLE_LIBXML
147 #ifdef USE_SDL2
148  SDL_version sdlVersion;
149  sdlVersion.major = 0;
150  sdlVersion.minor = 0;
151  sdlVersion.patch = 0;
152  SDL_GetVersion(&sdlVersion);
153  dumpLinkedSdlVersion("SDL", &sdlVersion);
154 #else // USE_SDL2
155  dumpLinkedSdlVersion("SDL", SDL_Linked_Version());
156 #endif // USE_SDL2
157  dumpLinkedSdlVersion("SDL_net", SDLNet_Linked_Version());
158  dumpLinkedSdlVersion("SDL_image", IMG_Linked_Version());
159  dumpLinkedSdlVersion("SDL_mixer", Mix_Linked_Version());
160  dumpLinkedSdlVersion("SDL_ttf", TTF_Linked_Version());
161 
162  compareVersions("zLib", ZLIB_VERSION, zlibVersion());
163 #ifdef ENABLE_LIBXML
164  if (xmlVersion != nullptr)
165  {
166  compareVersions("libxml2",
167  LIBXML_VERSION_STRING LIBXML_VERSION_EXTRA,
168  *xmlVersion);
169  }
170 #endif // ENABLE_LIBXML
171 #ifdef USE_SDL2
172  compareSDLVersions("SDL", sdlVersionJoin(SDL), &sdlVersion);
173 #else // USE_SDL2
174  compareSDLVersions("SDL", sdlVersionJoin(SDL), SDL_Linked_Version());
175 #endif // USE_SDL2
176 
177  compareSDLVersions("SDL_net",
178  sdlVersionJoin(SDL_NET),
179  SDLNet_Linked_Version());
180  compareSDLVersions("SDL_image",
181  sdlVersionJoin(SDL_IMAGE),
182  IMG_Linked_Version());
183  compareSDLVersions("SDL_mixer",
184  sdlVersionJoin(SDL_MIXER),
185  Mix_Linked_Version());
186  compareSDLVersions("SDL_ttf",
187  sdlVersionJoin(SDL_TTF),
188  TTF_Linked_Version());
189 }
#define dumpCompiledSdlVersion(text, prefix)
Definition: dumplibs.cpp:54
static void compareSDLVersions(char *libName, int major, int minor, int patch, SDL_version *linkedVersion)
Definition: dumplibs.cpp:92
static void compareVersions(char *libName, char *buildVersion, char *linkedVersion)
Definition: dumplibs.cpp:78
static void dumpLinkedSdlVersion(char *text, SDL_version *version)
Definition: dumplibs.cpp:65
#define sdlVersionJoin(prefix)
Definition: dumplibs.cpp:60
Definition: sdlhelper.h:45

References compareSDLVersions(), compareVersions(), dumpCompiledSdlVersion, dumpLinkedSdlVersion(), Logger::log(), logger, and sdlVersionJoin.

◆ dumpLinkedSdlVersion()

static void dumpLinkedSdlVersion ( char *  text,
SDL_version *  version 
)
static

Definition at line 65 of file dumplibs.cpp.

67 {
68  if (version != nullptr)
69  {
70  logger->log(" %s: %d.%d.%d",
71  text,
72  version->major,
73  version->minor,
74  version->patch);
75  }
76 }

References Logger::log(), and logger.

Referenced by dumpLibs().