mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Enable build on MacOS
Note that this commit just makes fastfetch compile, not work properly
This commit is contained in:
@@ -43,6 +43,8 @@ find_package(Threads REQUIRED)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
include(CheckIncludeFile)
|
||||
|
||||
####################
|
||||
# Compiler options #
|
||||
####################
|
||||
@@ -212,6 +214,8 @@ set(LIBFASTFETCH_SRC
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/host/host_apple.c
|
||||
src/detection/os/os_apple.c
|
||||
)
|
||||
elseif(ANDROID)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
@@ -231,6 +235,12 @@ add_library(libfastfetch OBJECT
|
||||
${LIBFASTFETCH_SRC}
|
||||
)
|
||||
|
||||
CHECK_INCLUDE_FILE("sys/sysinfo.h" HAVE_SYSINFO_H)
|
||||
if(HAVE_SYSINFO_H)
|
||||
# needs to be public, because changes fastfech.h ABI
|
||||
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_SYSINFO_H)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIBPCI)
|
||||
pkg_check_modules(LIBPCI libpci)
|
||||
if(LIBPCI_FOUND)
|
||||
|
||||
+4
-1
@@ -110,7 +110,10 @@ static void initState(FFstate* state)
|
||||
state->keysHeight = 0;
|
||||
state->passwd = getpwuid(getuid());
|
||||
uname(&state->utsname);
|
||||
sysinfo(&state->sysinfo);
|
||||
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
sysinfo(&state->sysinfo);
|
||||
#endif
|
||||
|
||||
initConfigDirs(state);
|
||||
initCacheDir(state);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "host.h"
|
||||
|
||||
void ffDetectHostImpl(FFHostResult* host)
|
||||
{
|
||||
ffStrbufInitA(&host->productFamily, 0);
|
||||
ffStrbufInitA(&host->productName, 0);
|
||||
ffStrbufInitA(&host->sysVendor, 0);
|
||||
ffStrbufInitA(&host->productVersion, 0);
|
||||
ffStrbufInitA(&host->productSku, 0);
|
||||
ffStrbufInitA(&host->biosDate, 0);
|
||||
ffStrbufInitA(&host->biosRelease, 0);
|
||||
ffStrbufInitA(&host->biosVendor, 0);
|
||||
ffStrbufInitA(&host->biosVersion, 0);
|
||||
ffStrbufInitA(&host->boardName, 0);
|
||||
ffStrbufInitA(&host->boardVendor, 0);
|
||||
ffStrbufInitA(&host->boardVersion, 0);
|
||||
ffStrbufInitA(&host->chassisType, 0);
|
||||
ffStrbufInitA(&host->chassisVendor, 0);
|
||||
ffStrbufInitA(&host->chassisVersion, 0);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "os.h"
|
||||
#include "common/settings.h"
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance)
|
||||
{
|
||||
FF_UNUSED(instance);
|
||||
ffStrbufInitA(&os->name, 0);
|
||||
ffStrbufInitA(&os->prettyName, 0);
|
||||
ffStrbufInitA(&os->id, 0);
|
||||
ffStrbufInitA(&os->version, 0);
|
||||
ffStrbufInitA(&os->versionID, 0);
|
||||
ffStrbufInitA(&os->codename, 0);
|
||||
ffStrbufInitA(&os->buildID, 0);
|
||||
ffStrbufInitA(&os->systemName, 0);
|
||||
ffStrbufInitA(&os->architecture, 0);
|
||||
ffStrbufInitA(&os->idLike, 0);
|
||||
ffStrbufInitA(&os->variant, 0);
|
||||
ffStrbufInitA(&os->variantID, 0);
|
||||
}
|
||||
+8
-2
@@ -10,7 +10,10 @@
|
||||
|
||||
#include <pwd.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/sysinfo.h>
|
||||
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
#include "util/FFstrbuf.h"
|
||||
#include "util/FFlist.h"
|
||||
@@ -169,7 +172,10 @@ typedef struct FFstate
|
||||
|
||||
struct passwd* passwd;
|
||||
struct utsname utsname;
|
||||
struct sysinfo sysinfo;
|
||||
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
struct sysinfo sysinfo;
|
||||
#endif
|
||||
|
||||
FFlist configDirs;
|
||||
FFstrbuf cacheDir;
|
||||
|
||||
@@ -6,16 +6,22 @@
|
||||
|
||||
void ffPrintProcesses(FFinstance* instance)
|
||||
{
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
uint16_t numProcesses = instance->state.sysinfo.procs;
|
||||
#else
|
||||
uint16_t numProcesses = 0;
|
||||
#endif
|
||||
|
||||
if(instance->config.processes.outputFormat.length == 0)
|
||||
{
|
||||
ffPrintLogoAndKey(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processes.key);
|
||||
|
||||
printf("%hu\n", instance->state.sysinfo.procs);
|
||||
printf("%hu\n", numProcesses);
|
||||
}
|
||||
else
|
||||
{
|
||||
ffPrintFormat(instance, FF_PROCESSES_MODULE_NAME, 0, &instance->config.processes, FF_PROCESSES_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &instance->state.sysinfo.procs}
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &numProcesses}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+10
-4
@@ -6,10 +6,16 @@
|
||||
|
||||
void ffPrintUptime(FFinstance* instance)
|
||||
{
|
||||
uint32_t days = (uint32_t) instance->state.sysinfo.uptime / 86400;
|
||||
uint32_t hours = (uint32_t) (instance->state.sysinfo.uptime - (days * 86400)) / 3600;
|
||||
uint32_t minutes = (uint32_t) (instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600)) / 60;
|
||||
uint32_t seconds = (uint32_t) instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600) - (minutes * 60);
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
uint64_t uptime = (uint64_t) instance->state.sysinfo.uptime;
|
||||
#else
|
||||
uint64_t uptime = 0;
|
||||
#endif
|
||||
|
||||
uint32_t days = (uint32_t) uptime / 86400;
|
||||
uint32_t hours = (uint32_t) (uptime - (days * 86400)) / 3600;
|
||||
uint32_t minutes = (uint32_t) (uptime - (days * 86400) - (hours * 3600)) / 60;
|
||||
uint32_t seconds = (uint32_t) uptime - (days * 86400) - (hours * 3600) - (minutes * 60);
|
||||
|
||||
if(instance->config.uptime.outputFormat.length == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user