From f2540f00a5d0774aa2e71dcf976c3bf82201d6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 9 Oct 2022 23:23:46 +0800 Subject: [PATCH] Address some feedbacks --- CMakeLists.txt | 71 ++++++++++--------- ...{battery_android.c => battery_nosupport.c} | 2 +- src/detection/bios/bios_apple.c | 11 --- .../bios/{bios_android.c => bios_nosupport.c} | 2 +- src/detection/board/board_android.c | 10 --- .../{board_apple.c => board_nosupport.c} | 2 +- ...er_android.c => displayserver_nosupport.c} | 0 .../font/{font_android.c => font_nosupport.c} | 2 +- .../gpu/{gpu_android.c => gpu_nosupport.c} | 2 +- .../{media_android.c => media_nosupport.c} | 2 +- ...apter_linux.c => poweradapter_nosupport.c} | 2 +- ...{wmtheme_android.c => wmtheme_nosupport.c} | 2 +- 12 files changed, 45 insertions(+), 63 deletions(-) rename src/detection/battery/{battery_android.c => battery_nosupport.c} (77%) delete mode 100644 src/detection/bios/bios_apple.c rename src/detection/bios/{bios_android.c => bios_nosupport.c} (75%) delete mode 100644 src/detection/board/board_android.c rename src/detection/board/{board_apple.c => board_nosupport.c} (72%) rename src/detection/displayserver/{displayserver_android.c => displayserver_nosupport.c} (100%) rename src/detection/font/{font_android.c => font_nosupport.c} (66%) rename src/detection/gpu/{gpu_android.c => gpu_nosupport.c} (73%) rename src/detection/media/{media_android.c => media_nosupport.c} (63%) rename src/detection/poweradapter/{poweradapter_linux.c => poweradapter_nosupport.c} (75%) rename src/detection/wmtheme/{wmtheme_android.c => wmtheme_nosupport.c} (71%) diff --git a/CMakeLists.txt b/CMakeLists.txt index de7d36a6f..54871bab5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs project(fastfetch VERSION 1.7.2 - LANGUAGES C CXX # Windows part requires C++ compiler + LANGUAGES C DESCRIPTION "Fast system information tool" HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch" ) @@ -13,14 +13,16 @@ project(fastfetch if("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Ll]inux.*") set(LINUX TRUE CACHE BOOL "..." FORCE) # LINUX means GNU/Linux, not just the kernel -elseif("${CMAKE_SYSTEM_NAME}" MATCHES "MSYS|Windows") - set(WIN_MSYS TRUE CACHE BOOL "..." FORCE) # Windows on msys2 elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*[Bb][Ss][Dd].*") set(BSD TRUE CACHE BOOL "..." FORCE) -elseif(NOT APPLE AND NOT ANDROID) +elseif(NOT APPLE AND NOT ANDROID AND NOT MSYS) message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}") endif() +if(MSYS) + enable_language(CXX) +endif() + ##################### # Configure options # ##################### @@ -28,7 +30,7 @@ endif() include(CMakeDependentOption) cmake_dependent_option(ENABLE_LIBPCI "Enable libpci" ON "LINUX OR BSD" OFF) -cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR BSD OR WIN_MSYS" OFF) +cmake_dependent_option(ENABLE_VULKAN "Enable vulkan" ON "LINUX OR APPLE OR BSD OR MSYS" OFF) cmake_dependent_option(ENABLE_WAYLAND "Enable wayland-client" ON "LINUX OR BSD" OFF) cmake_dependent_option(ENABLE_XCB_RANDR "Enable xcb-randr" ON "LINUX OR BSD" OFF) cmake_dependent_option(ENABLE_XCB "Enable xcb" ON "LINUX OR BSD" OFF) @@ -47,8 +49,8 @@ cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENAB cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR BSD" OFF) cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR BSD" OFF) cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR BSD" OFF) -cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN_MSYS" OFF) -cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX OR WIN_MSYS" OFF) +cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR MSYS" OFF) +cmake_dependent_option(ENABLE_LIBCJSON "Enable libcjson" ON "LINUX OR MSYS" OFF) cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF) option(BUILD_TESTS "Build tests" OFF) # Also create test executables @@ -78,7 +80,7 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") set(CMAKE_C_STANDARD 11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion") -if(WIN_MSYS) +if(MSYS) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -fno-exceptions -fno-rtti") endif() @@ -90,7 +92,7 @@ if(APPLE AND DEFINED ENV{HOMEBREW_PREFIX}) endif() set(FASTFETCH_FLAGS_DEBUG "-fno-omit-frame-pointer") -if(NOT WIN_MSYS) +if(NOT MSYS) set(FASTFETCH_FLAGS_DEBUG "${FASTFETCH_FLAGS_DEBUG} -fsanitize=address -fsanitize=undefined") endif() set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FASTFETCH_FLAGS_DEBUG}") @@ -298,10 +300,11 @@ if(LINUX OR ANDROID OR BSD) list(APPEND LIBFASTFETCH_SRC src/detection/cpuUsage/cpuUsage_linux.c src/detection/disk/disk_linux.c - src/detection/poweradapter/poweradapter_linux.c src/detection/temps/temps_linux.c src/detection/opengl/opengl_linux.c src/detection/processes/processes_linux.c + + src/detection/poweradapter/poweradapter_nosupport.c ) endif() @@ -327,7 +330,7 @@ if(LINUX OR BSD) ) endif() -if(WIN_MSYS) +if(MSYS) list(APPEND LIBFASTFETCH_SRC src/common/processing_linux.c src/detection/host/host_windows.cpp @@ -349,17 +352,15 @@ if(WIN_MSYS) src/detection/font/font_windows.cpp src/detection/terminalshell/terminalshell_linux.c src/detection/terminalshell/terminalshell_windows.cpp + src/detection/terminalfont/terminalfont_linux.c src/detection/packages/packages_linux.c src/detection/packages/packages_windows.c src/detection/kernel/kernel_windows.cpp src/detection/localip/localip_windows.c src/util/windows/wmi.cpp - # Shared - src/detection/terminalfont/terminalfont_linux.c - src/detection/poweradapter/poweradapter_linux.c - src/detection/media/media_linux.c - src/detection/temps/temps_linux.c + src/detection/poweradapter/poweradapter_nosupport.c + src/detection/media/media_nosupport.c ) endif() @@ -369,8 +370,6 @@ if(APPLE) src/util/apple/cf_helpers.c src/util/apple/osascript.m src/detection/host/host_apple.c - src/detection/bios/bios_apple.c - src/detection/board/board_apple.c src/detection/os/os_apple.m src/detection/cpu/cpu_apple.c src/detection/gpu/gpu_apple.c @@ -386,6 +385,9 @@ if(APPLE) src/detection/font/font_apple.m src/detection/opengl/opengl_apple.c src/detection/processes/processes_apple.c + + src/detection/bios/bios_nosupport.c + src/detection/board/board_nosupport.c ) endif() @@ -399,16 +401,17 @@ endif() if(ANDROID) list(APPEND LIBFASTFETCH_SRC src/detection/host/host_android.c - src/detection/bios/bios_android.c - src/detection/board/board_android.c src/detection/os/os_android.c - src/detection/gpu/gpu_android.c - src/detection/battery/battery_android.c - src/detection/displayserver/displayserver_android.c src/detection/terminalfont/terminalfont_android.c - src/detection/media/media_android.c - src/detection/wmtheme/wmtheme_android.c - src/detection/font/font_android.c + + src/detection/bios/bios_nosupport.c + src/detection/board/board_nosupport.c + src/detection/displayserver/displayserver_nosupport.c + src/detection/battery/battery_nosupport.c + src/detection/gpu/gpu_nosupport.c + src/detection/font/font_nosupport.c + src/detection/media/media_nosupport.c + src/detection/wmtheme/wmtheme_nosupport.c ) endif() @@ -486,15 +489,15 @@ if(APPLE) PRIVATE "-framework Cocoa" PRIVATE "-weak_framework MediaRemote -F /System/Library/PrivateFrameworks" ) -elseif(WIN_MSYS) +elseif(MSYS) target_link_libraries(libfastfetch - PRIVATE "-lwbemuuid" - PRIVATE "-lole32" - PRIVATE "-loleaut32" - PRIVATE "-ldwmapi" - PRIVATE "-lopengl32" - PRIVATE "-lgdi32" - PRIVATE "-liphlpapi" + PRIVATE "wbemuuid" + PRIVATE "ole32" + PRIVATE "oleaut32" + PRIVATE "dwmapi" + PRIVATE "opengl32" + PRIVATE "gdi32" + PRIVATE "iphlpapi" ) endif() diff --git a/src/detection/battery/battery_android.c b/src/detection/battery/battery_nosupport.c similarity index 77% rename from src/detection/battery/battery_android.c rename to src/detection/battery/battery_nosupport.c index 6a59625d7..40ca05241 100644 --- a/src/detection/battery/battery_android.c +++ b/src/detection/battery/battery_nosupport.c @@ -4,5 +4,5 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) { FF_UNUSED(instance, results) - return "Unimplemented"; + return "Not supported on this platform"; } diff --git a/src/detection/bios/bios_apple.c b/src/detection/bios/bios_apple.c deleted file mode 100644 index f22dca253..000000000 --- a/src/detection/bios/bios_apple.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "bios.h" - -void ffDetectBios(FFBiosResult* bios) -{ - ffStrbufInitS(&bios->error, "Not supported on macOS"); - - ffStrbufInit(&bios->biosDate); - ffStrbufInit(&bios->biosRelease); - ffStrbufInit(&bios->biosVendor); - ffStrbufInit(&bios->biosVersion); -} diff --git a/src/detection/bios/bios_android.c b/src/detection/bios/bios_nosupport.c similarity index 75% rename from src/detection/bios/bios_android.c rename to src/detection/bios/bios_nosupport.c index c767f3616..f8d886182 100644 --- a/src/detection/bios/bios_android.c +++ b/src/detection/bios/bios_nosupport.c @@ -2,7 +2,7 @@ void ffDetectBios(FFBiosResult* bios) { - ffStrbufInitS(&bios->error, "Not supported on Android"); + ffStrbufInitS(&bios->error, "Not supported on this platform"); ffStrbufInit(&bios->biosDate); ffStrbufInit(&bios->biosRelease); diff --git a/src/detection/board/board_android.c b/src/detection/board/board_android.c deleted file mode 100644 index d55dfe453..000000000 --- a/src/detection/board/board_android.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "board.h" - -void ffDetectBoard(FFBoardResult* board) -{ - ffStrbufInitS(&board->error, "Not supported on Android"); - - ffStrbufInit(&board->boardName); - ffStrbufInit(&board->boardVendor); - ffStrbufInit(&board->boardVersion); -} diff --git a/src/detection/board/board_apple.c b/src/detection/board/board_nosupport.c similarity index 72% rename from src/detection/board/board_apple.c rename to src/detection/board/board_nosupport.c index 76704dbd7..0b182ba3e 100644 --- a/src/detection/board/board_apple.c +++ b/src/detection/board/board_nosupport.c @@ -2,7 +2,7 @@ void ffDetectBoard(FFBoardResult* board) { - ffStrbufInitS(&board->error, "Not supported on macOS"); + ffStrbufInitS(&board->error, "Not supported on this platform"); ffStrbufInit(&board->boardName); ffStrbufInit(&board->boardVendor); diff --git a/src/detection/displayserver/displayserver_android.c b/src/detection/displayserver/displayserver_nosupport.c similarity index 100% rename from src/detection/displayserver/displayserver_android.c rename to src/detection/displayserver/displayserver_nosupport.c diff --git a/src/detection/font/font_android.c b/src/detection/font/font_nosupport.c similarity index 66% rename from src/detection/font/font_android.c rename to src/detection/font/font_nosupport.c index f2331a302..f88ad8395 100644 --- a/src/detection/font/font_android.c +++ b/src/detection/font/font_nosupport.c @@ -4,5 +4,5 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result) { FF_UNUSED(instance); - ffStrbufAppendS(&result->error, "Not implemented"); + ffStrbufAppendS(&result->error, "Not supported on this platform"); } diff --git a/src/detection/gpu/gpu_android.c b/src/detection/gpu/gpu_nosupport.c similarity index 73% rename from src/detection/gpu/gpu_android.c rename to src/detection/gpu/gpu_nosupport.c index 6e0afe389..ef2d54abd 100644 --- a/src/detection/gpu/gpu_android.c +++ b/src/detection/gpu/gpu_nosupport.c @@ -3,5 +3,5 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance) { FF_UNUSED(gpus, instance); - return "Unimplemented"; + return "Not supported on this platform"; } diff --git a/src/detection/media/media_android.c b/src/detection/media/media_nosupport.c similarity index 63% rename from src/detection/media/media_android.c rename to src/detection/media/media_nosupport.c index 0cf6d53d1..e3d038186 100644 --- a/src/detection/media/media_android.c +++ b/src/detection/media/media_nosupport.c @@ -3,5 +3,5 @@ void ffDetectMediaImpl(const FFinstance* instance, FFMediaResult* media) { FF_UNUSED(instance); - ffStrbufAppendS(&media->error, "Media not supported on Android"); + ffStrbufAppendS(&media->error, "Not supported on this platform"); } diff --git a/src/detection/poweradapter/poweradapter_linux.c b/src/detection/poweradapter/poweradapter_nosupport.c similarity index 75% rename from src/detection/poweradapter/poweradapter_linux.c rename to src/detection/poweradapter/poweradapter_nosupport.c index 4e5bebd80..cf6d1c841 100644 --- a/src/detection/poweradapter/poweradapter_linux.c +++ b/src/detection/poweradapter/poweradapter_nosupport.c @@ -3,5 +3,5 @@ const char* ffDetectPowerAdapterImpl(FFinstance* instance, FFlist* results) { FF_UNUSED(instance, results); - return "Unimplemented"; + return "Not supported on this platform"; } diff --git a/src/detection/wmtheme/wmtheme_android.c b/src/detection/wmtheme/wmtheme_nosupport.c similarity index 71% rename from src/detection/wmtheme/wmtheme_android.c rename to src/detection/wmtheme/wmtheme_nosupport.c index 7d9da9a5d..5dc5691d3 100644 --- a/src/detection/wmtheme/wmtheme_android.c +++ b/src/detection/wmtheme/wmtheme_nosupport.c @@ -5,6 +5,6 @@ bool ffDetectWmTheme(FFinstance* instance, FFstrbuf* themeOrError) { FF_UNUSED(instance); - ffStrbufAppendS(themeOrError, "WM theme detection is not supported on Android"); + ffStrbufAppendS(themeOrError, "Not supported on this platform"); return false; }