Skip to content

Commit e6db860

Browse files
authored
Merge pull request #362 from LinusDierheimer/dev
Merge macOS Bios module support for 1.8.0
2 parents f2bae20 + f0ec3cb commit e6db860

File tree

6 files changed

+95
-7
lines changed

6 files changed

+95
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Features:
2525
* Supports GPU detection on Android
2626
* Supports Kitty Terminal terminal font
2727
* Supports bar output for percentage values
28+
* Supports Bios module on macOS
2829
* Supports eopkg package manager detection
2930
* Supports iTerm image logo protocol
3031
* Supports image logo printing on macOS

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ elseif(APPLE)
420420
src/common/processing_linux.c
421421
src/common/sysctl.c
422422
src/detection/battery/battery_apple.c
423-
src/detection/bios/bios_nosupport.c
423+
src/detection/bios/bios_apple.c
424424
src/detection/board/board_nosupport.c
425425
src/detection/chassis/chassis_nosupport.c
426426
src/detection/cpu/cpu_apple.c

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ For the image logo, iTerm with iterm image protocol should work. Apple Terminal
6161

6262
### Windows
6363

64-
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Used for Windows Terminal font detection.
6564
* [`wlanapi`](https://learn.microsoft.com/en-us/windows/win32/api/wlanapi/): A system dll which isn't supported by Windows Server by default. Used for Wifi info detection.
66-
* [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers.
67-
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module
65+
* [`libcJSON`](https://github.com/DaveGamble/cJSON): Used for Windows Terminal font detection. [`cjson`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-cjson)
66+
* [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers)
67+
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd)
6868

6969
Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, special build `fastfetch-windows-old` in [Github Actions](https://github.com/LinusDierheimer/fastfetch/actions) is provided to support these old systems, which
7070

@@ -75,8 +75,8 @@ For the image logo, only chafa is supported due to [the design flaw of ConPTY](h
7575

7676
### Android
7777

78-
* [`freetype`](https://www.freetype.org/): Used for Termux font detection.
79-
* [`libvulkan`](https://www.vulkan.org/): Vulkan module, also used for GPU detection. Usually has been provided by Android system.
78+
* [`freetype`](https://www.freetype.org/): Used for Termux font detection. [`freetype`](https://github.com/termux/termux-packages/tree/master/packages/freetype)
79+
* [`libvulkan`](https://www.vulkan.org/): Vulkan module, also used for GPU detection. Usually has been provided by Android system. [`vulkan-loader-android`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-loader-android) [`vulkan-headers`](https://github.com/termux/termux-packages/tree/master/packages/vulkan-headers)
8080

8181
## Support status
8282
All categories not listed here should work without needing a specific implementation.
@@ -130,7 +130,15 @@ If the build process fails to find the headers for a library listed in [dependen
130130

131131
### Building on Windows
132132

133-
Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 sub system is suggested (and tested) to build fastfetch.
133+
Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 subsystem (or CLANGARM64 if needed) is suggested (and tested) to build fastfetch. If you need Windows 7 / 8.x support, using MINGW64 is suggested.
134+
135+
1. Install [MSYS2](https://www.msys2.org/#installation)
136+
1. Open `MSYS2 CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime)
137+
1. Install dependencies
138+
```bash
139+
pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd
140+
```
141+
1. Follow building instructions of Linux
134142

135143
## Packaging
136144

src/detection/bios/bios_apple.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include "bios.h"
2+
#include "util/apple/cf_helpers.h"
3+
4+
#include <IOKit/IOKitLib.h>
5+
6+
void ffDetectBios(FFBiosResult* bios)
7+
{
8+
ffStrbufInit(&bios->error);
9+
ffStrbufInit(&bios->biosDate);
10+
ffStrbufInit(&bios->biosRelease);
11+
ffStrbufInit(&bios->biosVendor);
12+
ffStrbufInit(&bios->biosVersion);
13+
14+
io_registry_entry_t registryEntry;
15+
16+
#ifndef __aarch64__
17+
18+
//https://github.com/osquery/osquery/blob/master/osquery/tables/system/darwin/smbios_tables.cpp
19+
//For Intel
20+
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/rom")))
21+
{
22+
CFMutableDictionaryRef properties;
23+
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) != kIOReturnSuccess)
24+
{
25+
IOObjectRelease(registryEntry);
26+
ffStrbufAppendS(&bios->error, "IORegistryEntryCreateCFProperties(registryEntry) failed");
27+
return;
28+
}
29+
30+
ffCfDictGetString(properties, CFSTR("vendor"), &bios->biosVendor);
31+
ffCfDictGetString(properties, CFSTR("version"), &bios->biosVersion);
32+
ffCfDictGetString(properties, CFSTR("release-date"), &bios->biosDate);
33+
if(!ffStrbufContainC(&bios->biosDate, '-'))
34+
ffStrbufAppendS(&bios->biosRelease, "Efi-");
35+
ffStrbufAppend(&bios->biosRelease, &bios->biosVersion);
36+
37+
CFRelease(properties);
38+
IOObjectRelease(registryEntry);
39+
return;
40+
}
41+
42+
#else
43+
44+
//For arm64
45+
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/")))
46+
{
47+
CFMutableDictionaryRef properties;
48+
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
49+
{
50+
ffCfDictGetString(properties, CFSTR("manufacturer"), &bios->biosVendor);
51+
CFRelease(properties);
52+
}
53+
IOObjectRelease(registryEntry);
54+
}
55+
56+
if((registryEntry = IORegistryEntryFromPath(MACH_PORT_NULL, "IODeviceTree:/chosen")))
57+
{
58+
CFMutableDictionaryRef properties;
59+
if(IORegistryEntryCreateCFProperties(registryEntry, &properties, kCFAllocatorDefault, kNilOptions) == kIOReturnSuccess)
60+
{
61+
ffCfDictGetString(properties, CFSTR("system-firmware-version"), &bios->biosRelease);
62+
ffStrbufAppend(&bios->biosVersion, &bios->biosRelease);
63+
ffStrbufSubstrAfterFirstC(&bios->biosVersion, '-');
64+
CFRelease(properties);
65+
}
66+
IOObjectRelease(registryEntry);
67+
}
68+
69+
#endif
70+
}

src/util/FFstrbuf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ static inline FF_C_NODISCARD bool ffStrbufIgnCaseEqual(const FFstrbuf* strbuf, c
189189
return ffStrbufIgnCaseComp(strbuf, comp) == 0;
190190
}
191191

192+
static inline FF_C_NODISCARD bool ffStrbufContainC(const FFstrbuf* strbuf, char c)
193+
{
194+
return memchr(strbuf->chars, c, strbuf->length) != NULL;
195+
}
196+
192197
static inline FF_C_NODISCARD bool ffStrbufContainS(const FFstrbuf* strbuf, const char* str)
193198
{
194199
return strstr(strbuf->chars, str) != NULL;

tests/strbuf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ int main(void)
204204
VERIFY(strbuf.allocated == 32);
205205
VERIFY(ffStrbufEqualS(&strbuf, "1234567890123456789012345678901"));
206206

207+
//containC
208+
VERIFY(ffStrbufContainC(&strbuf, '1'));
209+
VERIFY(!ffStrbufContainC(&strbuf, '-'));
210+
207211
ffStrbufDestroy(&strbuf);
208212

209213
//Success

0 commit comments

Comments
 (0)