mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-02 19:31:10 +01:00
better support for building without features
This commit is contained in:
+14
-2
@@ -1,12 +1,22 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
#define FF_GPU_MODULE_NAME "GPU"
|
||||
#define FF_GPU_NUM_FORMAT_ARGS 4
|
||||
|
||||
#ifndef FF_HAVE_LIBPCI
|
||||
|
||||
void ffPrintGPU(FFinstance* instance)
|
||||
{
|
||||
ffPrintError(instance, FF_GPU_MODULE_NAME, 0, &instance->config.gpuKey, &instance->config.gpuFormat, FF_GPU_NUM_FORMAT_ARGS, "Fastfetch was compiled without libpci support");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pci/pci.h>
|
||||
|
||||
static void printGPU(FFinstance* instance, struct pci_access* pacc, struct pci_dev* dev, FFcache* cache, uint8_t counter, char*(*ffpci_lookup_name)(struct pci_access*, char*, int, int, ...))
|
||||
{
|
||||
char vendor[512];
|
||||
@@ -144,3 +154,5 @@ void ffPrintGPU(FFinstance* instance)
|
||||
ffpci_cleanup(pacc);
|
||||
dlclose(pci);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+25
-32
@@ -5,19 +5,11 @@
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#if FF_HAS_X11
|
||||
# include <X11/Xlib.h>
|
||||
#endif
|
||||
#if FF_HAS_XRANDR
|
||||
# include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
#if FF_HAS_WAYLAND
|
||||
# include <wayland-client.h>
|
||||
#endif
|
||||
|
||||
#define FF_RESOLUTION_MODULE_NAME "Resolution"
|
||||
#define FF_RESOLUTION_NUM_FORMAT_ARGS 3
|
||||
|
||||
typedef void* DynamicLibrary;
|
||||
|
||||
#define FF_LIBRARY_LOAD(libraryNameUser, libraryNameDefault) dlopen(libraryNameUser.length == 0 ? libraryNameDefault : libraryNameUser.chars, RTLD_LAZY); \
|
||||
if(dlerror() != NULL) \
|
||||
return false;
|
||||
@@ -28,8 +20,6 @@
|
||||
return false; \
|
||||
}
|
||||
|
||||
typedef void* DynamicLibrary;
|
||||
|
||||
typedef struct ResolutionResult
|
||||
{
|
||||
int width;
|
||||
@@ -69,7 +59,6 @@ static bool printResolutionResultList(FFinstance* instance, FFlist* results)
|
||||
return res;
|
||||
}
|
||||
|
||||
#if FF_HAS_XRANDR || FF_HAS_WAYLAND
|
||||
static int parseRefreshRate(int32_t refreshRate)
|
||||
{
|
||||
if(refreshRate <= 0)
|
||||
@@ -87,7 +76,6 @@ static int parseRefreshRate(int32_t refreshRate)
|
||||
|
||||
return refreshRate;
|
||||
}
|
||||
#endif // FF_HAS_XRANDR || FF_HAS_WAYLAND
|
||||
|
||||
static void printResolutionDRMBackend(FFinstance* instance)
|
||||
{
|
||||
@@ -149,7 +137,9 @@ static void printResolutionDRMBackend(FFinstance* instance)
|
||||
printResolutionResultList(instance, &modes);
|
||||
}
|
||||
|
||||
#if FF_HAS_X11
|
||||
#ifdef FF_HAVE_X11
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
static void x11AddScreenAsResult(FFlist* results, Screen* screen, int refreshRate)
|
||||
{
|
||||
if(WidthOfScreen(screen) == 0 || HeightOfScreen(screen) == 0)
|
||||
@@ -186,9 +176,12 @@ static bool printResolutionX11Backend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &results);
|
||||
}
|
||||
#endif // FF_HAS_XLIB
|
||||
|
||||
#if FF_HAS_XRANDR
|
||||
#endif //FF_HAVE_X11
|
||||
|
||||
#ifdef FF_HAVE_XRANDR
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
typedef struct XrandrData
|
||||
{
|
||||
XRRScreenConfiguration*(*ffXRRGetScreenInfo)(Display* display, Window window);
|
||||
@@ -370,9 +363,11 @@ static bool printResolutionXrandrBackend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &data.results);
|
||||
}
|
||||
#endif // FF_HAS_XRANDR
|
||||
#endif // FF_HAVE_XRANDR
|
||||
|
||||
#ifdef FF_HAVE_WAYLAND
|
||||
#include <wayland-client.h>
|
||||
|
||||
#if FF_HAS_WAYLAND
|
||||
typedef struct WaylandData
|
||||
{
|
||||
FFinstance* instance;
|
||||
@@ -517,25 +512,23 @@ static bool printResolutionWaylandBackend(FFinstance* instance)
|
||||
|
||||
return printResolutionResultList(instance, &data.results);
|
||||
}
|
||||
#endif // FF_HAS_WAYLAND
|
||||
|
||||
#endif //FF_HAVE_WAYLAND
|
||||
|
||||
void ffPrintResolution(FFinstance* instance)
|
||||
{
|
||||
if(
|
||||
#if FF_HAS_WAYLAND
|
||||
printResolutionWaylandBackend(instance) ||
|
||||
#endif
|
||||
#if FF_HAS_XRANDR
|
||||
printResolutionXrandrBackend(instance) ||
|
||||
#endif
|
||||
#if FF_HAS_X11
|
||||
printResolutionX11Backend(instance) ||
|
||||
#endif
|
||||
#if FF_HAVE_WAYLAND
|
||||
printResolutionWaylandBackend(instance) ||
|
||||
#endif
|
||||
#if FF_HAVE_XRANDR
|
||||
printResolutionXrandrBackend(instance) ||
|
||||
#endif
|
||||
#if FF_HAVE_X11
|
||||
printResolutionX11Backend(instance) ||
|
||||
#endif
|
||||
false
|
||||
) return;
|
||||
|
||||
printResolutionDRMBackend(instance);
|
||||
}
|
||||
|
||||
#undef FF_LIBRARY_LOAD
|
||||
#undef FF_LIBRARY_LOAD_SYMBOL
|
||||
|
||||
Reference in New Issue
Block a user