Start work on GNU

This commit is contained in:
Yelninei
2025-05-19 15:07:46 +00:00
committed by Carter Li
parent f2f9b10b18
commit 71fbe04367
8 changed files with 121 additions and 8 deletions
+87
View File
@@ -32,6 +32,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
set(SunOS TRUE CACHE BOOL "..." FORCE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
set(Haiku TRUE CACHE BOOL "..." FORCE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
set(GNU TRUE CACHE BOOL "..." FORCE)
elseif(NOT APPLE AND NOT WIN32)
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
@@ -1192,6 +1194,83 @@ elseif(Haiku)
src/util/binary_linux.c
src/util/haiku/version.cpp
)
elseif(GNU)
list(APPEND LIBFASTFETCH_SRC
src/common/dbus.c
src/common/io/io_unix.c
src/common/netif/netif_linux.c
src/common/networking/networking_linux.c
src/common/processing_linux.c
src/detection/battery/battery_nosupport.c
src/detection/bios/bios_nosupport.c
src/detection/board/board_nosupport.c
src/detection/bootmgr/bootmgr_nosupport.c
src/detection/brightness/brightness_nosupport.c
src/detection/btrfs/btrfs_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_linux.c
src/detection/cpucache/cpucache_nosupport.c
src/detection/cpuusage/cpuusage_linux.c
src/detection/cursor/cursor_linux.c
src/detection/bluetooth/bluetooth_linux.c
src/detection/bluetoothradio/bluetoothradio_linux.c
src/detection/disk/disk_linux.c
src/detection/dns/dns_linux.c
src/detection/physicaldisk/physicaldisk_nosupport.c
src/detection/physicalmemory/physicalmemory_nosupport.c
src/detection/diskio/diskio_nosupport.c
src/detection/displayserver/linux/displayserver_linux.c
src/detection/displayserver/linux/drm.c
src/detection/displayserver/linux/wayland/wayland.c
src/detection/displayserver/linux/wayland/global-output.c
src/detection/displayserver/linux/wayland/zwlr-output.c
src/detection/displayserver/linux/wayland/wlr-output-management-unstable-v1-protocol.c
src/detection/displayserver/linux/wmde.c
src/detection/displayserver/linux/xcb.c
src/detection/displayserver/linux/xlib.c
src/detection/font/font_linux.c
src/detection/gpu/gpu_nosupport.c
src/detection/gpu/gpu_pci.c
src/detection/gtk_qt/gtk.c
src/detection/host/host_nosupport.c
src/detection/icons/icons_linux.c
src/detection/initsystem/initsystem_linux.c
src/detection/keyboard/keyboard_nosupport.c
src/detection/libc/libc_linux.c
src/detection/lm/lm_linux.c
src/detection/loadavg/loadavg_linux.c
src/detection/locale/locale_linux.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_linux.c
src/detection/memory/memory_linux.c
src/detection/mouse/mouse_nosupport.c
src/detection/netio/netio_nosupport.c
src/detection/opengl/opengl_linux.c
src/detection/os/os_linux.c
src/detection/packages/packages_linux.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_linux.c
src/detection/gtk_qt/qt.c
src/detection/sound/sound_linux.c
src/detection/swap/swap_linux.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/terminalsize/terminalsize_linux.c
src/detection/theme/theme_linux.c
src/detection/tpm/tpm_nosupport.c
src/detection/uptime/uptime_linux.c
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_linux.c
src/detection/wifi/wifi_linux.c
src/detection/wm/wm_nosupport.c
src/detection/de/de_linux.c
src/detection/wmtheme/wmtheme_linux.c
src/detection/camera/camera_nosupport.c
src/detection/zpool/zpool_nosupport.c
src/util/platform/FFPlatform_unix.c
src/util/binary_linux.c
)
endif()
if(ENABLE_DIRECTX_HEADERS)
@@ -1315,6 +1394,10 @@ elseif(NetBSD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/X11R7/lib -Wl,-rpath,/usr/pkg/lib") # ditto
elseif(Haiku)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
elseif(GNU)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE)
# On Hurd PATH_MAX is not defined. Set an arbitrary limit as workaround.
target_compile_definitions(libfastfetch PUBLIC PATH_MAX=4096)
endif()
if(FreeBSD OR OpenBSD OR NetBSD)
@@ -1639,6 +1722,10 @@ elseif(SunOS)
PRIVATE "nvpair"
PRIVATE "devinfo"
)
elseif(GNU)
target_link_libraries(libfastfetch
PRIVATE "m"
)
elseif(ANDROID)
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)
if(HAVE_LIBANDROID_WORDEXP_STATIC)
+21 -2
View File
@@ -234,7 +234,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
assert(processName->length > 0);
ffStrbufClear(exe);
#ifdef __linux__
#if defined(__linux__) || defined(__GNU__)
char filePath[64];
snprintf(filePath, sizeof(filePath), "/proc/%d/cmdline", (int)pid);
@@ -436,7 +436,7 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
if (pid <= 0)
return "Invalid pid";
#ifdef __linux__
#if defined(__linux__) || defined(__GNU__)
char procFilePath[64];
if (ppid)
@@ -465,11 +465,30 @@ const char* ffProcessGetBasicInfoLinux(pid_t pid, FFstrbuf* name, pid_t* ppid, i
}
else
{
#ifndef __GNU__
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/comm", (int)pid);
ssize_t nRead = ffReadFileBuffer(procFilePath, name);
if(nRead <= 0)
return "ffReadFileBuffer(/proc/pid/comm, name) failed";
ffStrbufTrimRightSpace(name);
#else
// No /proc/1/comm on Hurd so read /proc/1/stat again
snprintf(procFilePath, sizeof(procFilePath), "/proc/%d/stat", (int)pid);
char buf[PROC_FILE_BUFFSIZ];
ssize_t nRead = ffReadFileData(procFilePath, sizeof(buf) - 1, buf);
if(nRead <= 8)
return "ffReadFileData(/proc/pid/stat, PROC_FILE_BUFFSIZ-1, buf) failed";
buf[nRead] = '\0';
ffStrbufEnsureFixedLengthFree(name, 255);
if(
sscanf(buf, "%*s (%255[^)]) %*c %*d %*d %*d %*d", name->chars) == 0 || //stat (comm) state ppid pgrp session tty
name->chars[0] == '\0'
)
return "sscanf(stat) failed";
ffStrbufRecalculateLength(name);
#endif
}
#elif defined(__APPLE__)
+2 -1
View File
@@ -19,7 +19,7 @@ const char* ffDetectLoadavg(double result[3])
}
#endif
#ifndef __GNU__
// getloadavg requires higher ANDROID_API version
struct sysinfo si;
if (sysinfo(&si) < 0)
@@ -27,5 +27,6 @@ const char* ffDetectLoadavg(double result[3])
for (int i = 0; i < 3; i++)
result[i] = (double) si.loads[i] / (1 << SI_LOAD_SHIFT);
#endif
return NULL;
}
+5 -1
View File
@@ -29,6 +29,7 @@
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) || defined(__HAIKU__)
#include <net/if_media.h>
#include <net/if_dl.h>
#elif defined(__GNU__)
#else
#include <netpacket/packet.h>
#endif
@@ -69,12 +70,14 @@ static const FFLocalIpNIFlag niFlagOptions[] = {
#ifdef IFF_NOTRAILERS
FF_LOCALIP_NIFLAG(NOTRAILERS),
#endif
#ifdef __linux__
#if defined( __linux__) || defined (__GNU__)
FF_LOCALIP_NIFLAG(MASTER),
FF_LOCALIP_NIFLAG(SLAVE),
FF_LOCALIP_NIFLAG(PORTSEL),
FF_LOCALIP_NIFLAG(AUTOMEDIA),
FF_LOCALIP_NIFLAG(DYNAMIC),
#endif
#ifdef __linux__
FF_LOCALIP_NIFLAG(LOWER_UP),
FF_LOCALIP_NIFLAG(DORMANT),
FF_LOCALIP_NIFLAG(ECHO),
@@ -562,6 +565,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
FF_DEBUG("No MAC address available for interface %s", adapter->mac->ifa_name);
}
}
#elif defined(__GNU__)
#else
(void) adapter;
#endif
+2 -2
View File
@@ -26,13 +26,13 @@ const char* ffDetectUptime(FFUptimeResult* result)
}
#endif
#ifndef __GNU__
struct timespec uptime;
if (clock_gettime(CLOCK_BOOTTIME, &uptime) != 0)
return "clock_gettime(CLOCK_BOOTTIME) failed";
result->uptime = (uint64_t) uptime.tv_sec * 1000 + (uint64_t) uptime.tv_nsec / 1000000;
result->bootTime = ffTimeGetNow() - result->uptime;
#endif
return NULL;
}
+2
View File
@@ -54,6 +54,8 @@
#define FF_SYSNAME "NetBSD"
#elif defined(__HAIKU__)
#define FF_SYSNAME "Haiku"
#elif defined(__GNU__)
#define FF_SYSNAME "GNU"
#else
#define FF_SYSNAME "Unknown"
#endif
+1 -1
View File
@@ -16,7 +16,7 @@ typedef struct FFOptionsGeneral
bool detectVersion;
// Module options that cannot be put in module option structure
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(__GNU__)
FFstrbuf playerName;
FFDsForceDrmType dsForceDrm;
#elif defined(_WIN32)
+1 -1
View File
@@ -22,7 +22,7 @@
static void getExePath(FFPlatform* platform)
{
char exePath[PATH_MAX + 1];
#ifdef __linux__
#if defined(__linux__) || defined (__GNU__)
ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1);
if (exePathLen >= 0)
exePath[exePathLen] = '\0';