Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .codacy/codacy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
runtimes:
- dart@3.7.2
- go@1.24.13
- java@17.0.10
- node@22.2.0
- python@3.11.11
tools:
- dartanalyzer@3.7.2
- eslint@8.57.0
- lizard@1.17.31
- opengrep@1.16.4
- pmd@7.11.0
- pylint@3.3.6
- revive@1.7.0
- trivy@0.69.3
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
check-filenames =
builtin = clear,rare,usage,informal
skip = */.git,*/cmake-build-*,*/.idea,*/completions,*/presets,*/screenshots,*/tests,*/3rdparty,*/logo/ascii,./src/detection/gpu/asahi_drm.h
skip = */.git,*/cmake-build-*,*/.idea,*/completions,*/presets,*/screenshots,*/tests,*/3rdparty,*/logo/ascii,./src/detection/gpu/asahi_drm.h,./src/detection/cpu/cpu_x86.c
ignore-words-list = iterm,compiletime,unknwn,pengwin,siduction,master,slave,sur,doas,conexant,ags,bu
2 changes: 1 addition & 1 deletion .github/workflows/build-openbsd-amd64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
architecture: x86-64
cpu_count: 4
shell: bash
version: '7.8'
version: '7.9'
environment_variables: 'CMAKE_BUILD_TYPE'
run: |
uname -a
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
uses: ./.github/workflows/build-spellcheck.yml

no-features-test:
needs: spellcheck
name: No-features-test
permissions:
security-events: write
Expand All @@ -17,6 +18,7 @@ jobs:
secrets: inherit

linux-hosts:
needs: no-features-test
name: Linux-${{ matrix.arch }}
permissions:
security-events: write
Expand All @@ -35,6 +37,7 @@ jobs:
secrets: inherit

linux-i686:
needs: no-features-test
name: Linux-i686
permissions:
security-events: write
Expand All @@ -43,6 +46,7 @@ jobs:
secrets: inherit

linux-armv7l:
needs: no-features-test
name: Linux-armv7l
permissions:
security-events: write
Expand All @@ -51,6 +55,7 @@ jobs:
secrets: inherit

linux-armv6l:
needs: no-features-test
name: Linux-armv6l
permissions:
security-events: write
Expand All @@ -59,6 +64,7 @@ jobs:
secrets: inherit

linux-vms:
needs: no-features-test
name: Linux-${{ matrix.arch }}
permissions:
security-events: write
Expand All @@ -75,11 +81,13 @@ jobs:
secrets: inherit

musl-amd64:
needs: no-features-test
name: Musl-amd64
uses: ./.github/workflows/build-musl-amd64.yml
secrets: inherit

macos-hosts:
needs: no-features-test
name: macOS-${{ matrix.arch }}
permissions:
security-events: write
Expand All @@ -98,16 +106,19 @@ jobs:
secrets: inherit

omnios-amd64:
needs: no-features-test
name: OmniOS-amd64
uses: ./.github/workflows/build-omnios-amd64.yml
secrets: inherit

solaris-amd64:
needs: no-features-test
name: Solaris-amd64
uses: ./.github/workflows/build-solaris-amd64.yml
secrets: inherit

freebsd-amd64:
needs: no-features-test
name: FreeBSD-amd64
permissions:
security-events: write
Expand All @@ -116,6 +127,7 @@ jobs:
secrets: inherit

openbsd-amd64:
needs: no-features-test
name: OpenBSD-amd64
permissions:
security-events: write
Expand All @@ -124,6 +136,7 @@ jobs:
secrets: inherit

netbsd-amd64:
needs: no-features-test
name: NetBSD-amd64
permissions:
security-events: write
Expand All @@ -132,6 +145,7 @@ jobs:
secrets: inherit

dragonfly-amd64:
needs: no-features-test
name: DragonFly-amd64
permissions:
security-events: write
Expand All @@ -140,6 +154,7 @@ jobs:
secrets: inherit

haiku-amd64:
needs: no-features-test
name: Haiku-amd64
permissions:
security-events: write
Expand All @@ -148,6 +163,7 @@ jobs:
secrets: inherit

windows-hosts:
needs: no-features-test
name: Windows-${{ matrix.arch }}
permissions:
security-events: write
Expand Down
47 changes: 24 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ set(LIBFASTFETCH_SRC
src/detection/codec/codec.c
src/detection/codec/codec_vulkan.c
src/detection/cpu/cpu.c
src/detection/cpu/cpu_x86.c
src/detection/cpuusage/cpuusage.c
src/detection/command/command.c
src/detection/disk/disk.c
Expand Down Expand Up @@ -1576,24 +1577,24 @@ endif()

if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})
endif()
if(NOT "${CUSTOM_AMDGPU_IDS_PATH}" STREQUAL "")
message(STATUS "Custom file path of amdgpu.ids: ${CUSTOM_AMDGPU_IDS_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH})
target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH})
endif()
if(NOT "${CUSTOM_OS_RELEASE_PATH}" STREQUAL "")
message(STATUS "Custom file path of os_release: ${CUSTOM_OS_RELEASE_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH})
target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH})
endif()
if(NOT "${CUSTOM_LSB_RELEASE_PATH}" STREQUAL "")
message(STATUS "Custom file path of lsb_release: ${CUSTOM_LSB_RELEASE_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_LSB_RELEASE_PATH=${CUSTOM_LSB_RELEASE_PATH})
target_compile_definitions(libfastfetch PUBLIC FF_CUSTOM_LSB_RELEASE_PATH=${CUSTOM_LSB_RELEASE_PATH})
endif()

if(NOT BINARY_LINK_TYPE STREQUAL "dlopen")
message(STATUS "Enabling custom link type: ${BINARY_LINK_TYPE}")
target_compile_definitions(libfastfetch PRIVATE FF_DISABLE_DLOPEN=1)
target_compile_definitions(libfastfetch PUBLIC FF_DISABLE_DLOPEN=1)
if(NOT WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--copy-dt-needed-entries")
endif()
Expand Down Expand Up @@ -1659,18 +1660,18 @@ function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME) # [CMAKE_TARGET_NAME]

message(STATUS "Library: found ${VARNAME} by ${${VARNAME}_FOUND}")

target_compile_definitions(libfastfetch PRIVATE FF_HAVE_${VARNAME}=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_${VARNAME}=1)
target_include_directories(libfastfetch PRIVATE ${${VARNAME}_INCLUDE_DIRS})

if(NOT BINARY_LINK_TYPE STREQUAL "dlopen")
target_link_directories(libfastfetch PUBLIC ${${VARNAME}_LIBRARY_DIRS})
target_link_directories(libfastfetch PRIVATE ${${VARNAME}_LIBRARY_DIRS})
target_link_libraries(libfastfetch PRIVATE ${${VARNAME}_LIBRARIES})
endif()

foreach(FLAG ${${VARNAME}_CFLAGS_OTHER})
if(FLAG MATCHES "-D.*")
string(SUBSTRING ${FLAG} 2 -1 FLAG)
target_compile_definitions(libfastfetch PRIVATE ${FLAG})
target_compile_definitions(libfastfetch PUBLIC ${FLAG})
endif()
endforeach()
endfunction()
Expand Down Expand Up @@ -1800,8 +1801,8 @@ if(ENABLE_LUA)
message(STATUS "Library: Lua version ${Lua_VERSION} is not supported, requires 5.3-5.5")
unset(Lua_FOUND)
else()
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LUA=1)
target_include_directories(libfastfetch PRIVATE ${LUA_INCLUDE_DIR})
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_LUA=1)
target_include_directories(libfastfetch PUBLIC ${LUA_INCLUDE_DIR})

if(NOT BINARY_LINK_TYPE STREQUAL "dlopen")
target_link_libraries(libfastfetch PRIVATE ${LUA_LIBRARIES})
Expand All @@ -1814,20 +1815,20 @@ if(ENABLE_LUA)
endif()

if(ENABLE_THREADS)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_THREADS=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_THREADS=1)
if(CMAKE_USE_PTHREADS_INIT) #Threads::Threads is not set for WIN32
target_link_libraries(libfastfetch PRIVATE Threads::Threads)
endif()
endif()

if(ENABLE_EMBEDDED_PCIIDS)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EMBEDDED_PCIIDS=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_EMBEDDED_PCIIDS=1)
endif()
if(ENABLE_EMBEDDED_AMDGPUIDS)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EMBEDDED_AMDGPUIDS=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_EMBEDDED_AMDGPUIDS=1)
endif()
if(ENABLE_LIBZFS)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LIBZFS=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_LIBZFS=1)

if(NOT BINARY_LINK_TYPE STREQUAL "dlopen")
target_link_libraries(libfastfetch
Expand Down Expand Up @@ -1984,7 +1985,7 @@ target_link_libraries(libfastfetch
PRIVATE ${CMAKE_DL_LIBS}
)

target_compile_options(libfastfetch PRIVATE
target_compile_options(libfastfetch PUBLIC
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti>)

if(FreeBSD)
Expand All @@ -1993,18 +1994,18 @@ endif()
if(LINUX OR FreeBSD OR OpenBSD OR NetBSD)
CHECK_INCLUDE_FILE("linux/videodev2.h" HAVE_LINUX_VIDEODEV2)
if(HAVE_LINUX_VIDEODEV2)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_LINUX_VIDEODEV2=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_LINUX_VIDEODEV2=1)
endif()
endif()
if(NOT WIN32)
CHECK_INCLUDE_FILE("utmpx.h" HAVE_UTMPX)
if(HAVE_UTMPX)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_UTMPX=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_UTMPX=1)
endif()
if(ENABLE_WORDEXP)
CHECK_INCLUDE_FILE("wordexp.h" HAVE_WORDEXP)
if(HAVE_WORDEXP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WORDEXP=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WORDEXP=1)
message(STATUS "wordexp.h found, wordexp support enabled")
else()
set(ENABLE_WORDEXP OFF)
Expand All @@ -2016,19 +2017,19 @@ if(NOT WIN32)
if(ENABLE_THREADS AND CMAKE_USE_PTHREADS_INIT)
CHECK_INCLUDE_FILE("pthread_np.h" HAVE_PTHREAD_NP)
if(HAVE_PTHREAD_NP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_PTHREAD_NP=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_PTHREAD_NP=1)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} pthread_np.h)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} Threads::Threads)
check_function_exists("pthread_timedjoin_np" HAVE_TIMEDJOIN_NP)
if(HAVE_TIMEDJOIN_NP)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_TIMEDJOIN_NP=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_TIMEDJOIN_NP=1)
else()
message(WARNING "pthread_timedjoin_np was not found; networking timeout will not work")
endif()
endif()
elseif(HAVE_WINRT)
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WINRT=1)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WINRT=1)
endif()

set(PACKAGES_DISABLE_LIST "")
Expand All @@ -2045,9 +2046,9 @@ else()
list(TRANSFORM PACKAGES_DISABLE_LIST APPEND "_BIT")
list(JOIN PACKAGES_DISABLE_LIST " | " PACKAGES_DISABLE_LIST)
endif()
target_compile_definitions(libfastfetch PRIVATE "FF_PACKAGES_DISABLE_LIST=${PACKAGES_DISABLE_LIST}")
target_compile_definitions(libfastfetch PUBLIC "FF_PACKAGES_DISABLE_LIST=${PACKAGES_DISABLE_LIST}")
if(PACKAGES_REMOVE_DISABLED)
target_compile_definitions(libfastfetch PRIVATE FF_PACKAGES_REMOVE_DISABLED=1)
target_compile_definitions(libfastfetch PUBLIC FF_PACKAGES_REMOVE_DISABLED=1)
endif()

######################
Expand Down
1 change: 1 addition & 0 deletions src/common/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
#define FF_A_PACKED __attribute__((__packed__))
#define FF_A_WEAK_IMPORT __attribute__((__weak_import__))
#define FF_A_ALWAYS_INLINE __attribute__((__always_inline__))
#define FF_A_COLD __attribute__((__cold__))
36 changes: 20 additions & 16 deletions src/common/impl/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,30 @@ static void defaultConfig(void) {
ffOptionsInitDisplay(&instance.config.display);
}

#ifdef _WIN32
static volatile UINT oldCp = CP_UTF8;
void resetConsoleCP(void) {
if (oldCp != CP_UTF8) {
SetConsoleOutputCP(oldCp);
}
}
#endif

void ffInitInstance(void) {
#ifdef _WIN32
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?source=recommendat>
setlocale(LC_ALL, ".UTF8");

HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode = 0;
if (GetConsoleMode(hStdout, &mode)) {
SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
oldCp = GetConsoleOutputCP();
if (oldCp != CP_UTF8) {
SetConsoleOutputCP(CP_UTF8);
atexit(resetConsoleCP);
}
}
#else
// Never use `setlocale(LC_ALL, "")`
setlocale(LC_TIME, "");
Expand All @@ -61,9 +81,6 @@ void ffInitInstance(void) {

static volatile bool ffDisableLinewrap = false;
static volatile bool ffHideCursor = false;
#ifdef _WIN32
static volatile UINT oldCp = CP_UTF8;
#endif

static void resetConsole(void) {
if (ffDisableLinewrap) {
Expand All @@ -80,10 +97,6 @@ static void resetConsole(void) {

#if defined(_WIN32)
fflush(stdout);

if (oldCp != CP_UTF8) {
SetConsoleOutputCP(oldCp);
}
#endif
}

Expand Down Expand Up @@ -111,15 +124,6 @@ void ffStart(void) {
setvbuf(stdout, NULL, _IOFBF, 4096);
}
SetConsoleCtrlHandler(consoleHandler, TRUE);
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode = 0;
if (GetConsoleMode(hStdout, &mode)) {
SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
oldCp = GetConsoleOutputCP();
if (oldCp != CP_UTF8) {
SetConsoleOutputCP(CP_UTF8);
}
}
#else
if (instance.config.display.noBuffer) {
setvbuf(stdout, NULL, _IONBF, 0);
Expand Down
Loading