This commit is contained in:
Mars 2025-03-05 13:44:56 -05:00
parent 55f0027969
commit e4e80568da
4 changed files with 76 additions and 45 deletions

View file

@ -5,8 +5,9 @@ project(
default_options: [
'default_library=static',
'warning_level=everything',
'buildtype=release',
'buildtype=debug',
'cpp_args=-fvisibility=hidden',
'cpp_std=c++latest'
],
)
@ -35,28 +36,36 @@ if host_machine.system() == 'darwin'
)
endif
common_cpp_args = [
'-std=c++26',
'-Wno-c++20-compat',
'-Wno-c++20-extensions',
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic',
'-Wno-disabled-macro-expansion',
'-Wno-missing-prototypes',
'-Wno-padded',
'-Wno-pre-c++20-compat-pedantic',
'-Wno-switch-default',
'-Wunused-function',
'-fno-strict-enums',
'-nostdlib++',
'-march=native',
]
common_cpp_args = []
if host_machine.system() == 'windows'
common_cpp_args += ['-DCURL_STATICLIB']
if cpp.get_id() == 'msvc' or cpp.get_id() == 'clang-cl'
common_cpp_args += [
'/std:c++latest',
'/Zc:__cplusplus',
'-DNOMINMAX',
]
add_project_arguments(common_cpp_args, language: 'cpp')
else
common_cpp_args += [
'-std=c++26',
'-Wno-c++20-compat',
'-Wno-c++20-extensions',
'-Wno-c++98-compat',
'-Wno-c++98-compat-pedantic',
'-Wno-disabled-macro-expansion',
'-Wno-missing-prototypes',
'-Wno-padded',
'-Wno-pre-c++20-compat-pedantic',
'-Wunused-function',
'-fno-strict-enums',
'-nostdlib++',
'-march=native',
]
add_project_arguments(cpp.get_supported_arguments(common_cpp_args), language: 'cpp')
endif
add_project_arguments(cpp.get_supported_arguments(common_cpp_args), language: 'cpp')
source_file_names = ['src/main.cpp', 'src/config/config.cpp', 'src/config/weather.cpp']
@ -81,7 +90,6 @@ endforeach
deps = [
dependency('fmt', include_type: 'system', static: true),
dependency('openssl', include_type: 'system', static: true),
dependency('libcurl', include_type: 'system', static: true),
dependency('tomlplusplus', include_type: 'system', static: true),
]
@ -131,23 +139,35 @@ deps += ftxui_dep
cmake_opts = cmake.subproject_options()
cmake_opts.add_cmake_defines(
{
'CMAKE_CXX_FLAGS': '-Wno-everything',
},
)
cmake_opts.append_compile_args('cpp', '-Wno-everything')
if cpp.get_id() == 'msvc'
cmake_opts.add_cmake_defines(
{
'CMAKE_CXX_FLAGS': '/w',
'REFLECTCPP_USE_STD_EXPECTED': 'ON',
},
)
cmake_opts.append_compile_args('cpp', '/w')
else
cmake_opts.add_cmake_defines(
{
'CMAKE_CXX_FLAGS': '-Wno-everything -std=c++26',
'REFLECTCPP_USE_STD_EXPECTED': 'ON',
},
)
cmake_opts.append_compile_args('cpp', '-Wno-everything -std=c++26')
endif
reflectcpp_proj = cmake.subproject('reflectcpp', options: cmake_opts)
reflectcpp_dep = reflectcpp_proj.dependency('reflectcpp', include_type: 'system')
deps += reflectcpp_dep
objc_args = []
link_args = ['-static-libgcc', '-static-libstdc++', '-static']
link_args = []
if host_machine.system() == 'darwin'
objc_args += ['-fobjc-arc']
elif host_machine.system() == 'linux'
link_args += ['-static-libgcc', '-static-libstdc++', '-static']
endif
executable(

View file

@ -1,4 +1,5 @@
#include <ctime>
#include <expected>
#include <fmt/chrono.h>
#include <fmt/color.h>
#include <fmt/core.h>
@ -37,7 +38,7 @@ namespace {
std::time_t now = std::time(nullptr);
std::tm localTime;
#ifdef __WIN32__
#ifdef _WIN32
if (localtime_s(&localTime, &now) != 0)
ERROR_LOG("localtime_s failed");
#else
@ -53,11 +54,11 @@ namespace {
date.erase(date.begin());
// Append appropriate suffix for the datE
if (date.ends_with("1") && date != "11")
if (date.back() == '1' && date != "11")
date += "st";
else if (date.ends_with("2") && date != "12")
else if (date.back() == '2' && date != "12")
date += "nd";
else if (date.ends_with("3") && date != "13")
else if (date.back() == '3' && date != "13")
date += "rd";
else
date += "th";
@ -89,9 +90,9 @@ namespace {
data.os_version = GetOSVersion();
data.mem_info = GetMemInfo();
// Desktop environment info (not relevant for Windows)
data.desktop_environment = std::nullopt;
data.window_manager = "Windows";
// Desktop environment info
data.desktop_environment = GetDesktopEnvironment();
data.window_manager = GetWindowManager();
// Parallel execution for disk/shell only
auto diskShell = std::async(std::launch::async, [] {
@ -287,7 +288,7 @@ namespace {
DEBUG_LOG("DBus error: {}", std::get<LinuxError>(error));
#endif
#ifdef __WIN32__
#ifdef _WIN32
if (std::holds_alternative<WindowsError>(error))
DEBUG_LOG("WinRT error: {}", to_string(std::get<WindowsError>(error).message()));
#endif

View file

@ -1,4 +1,4 @@
#ifdef __WIN32__
#ifdef _WIN32
// clang-format off
#define WIN32_LEAN_AND_MEAN
@ -11,6 +11,7 @@
#include <cstring>
// clang-format on
#include <guiddef.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Media.Control.h>
#include <winrt/base.h>
@ -113,7 +114,7 @@ namespace {
while (true) {
if (pe32.th32ProcessID == pid) {
// Explicitly cast array to string to avoid implicit array decay
processName = std::string(static_cast<const char*>(pe32.szExeFile));
processName = string(reinterpret_cast<const char*>(pe32.szExeFile));
break;
}
@ -239,7 +240,7 @@ fn GetWindowManager() -> string {
if (windowManager.empty()) {
BOOL compositionEnabled = FALSE;
if (SUCCEEDED(DwmIsCompositionEnabled(&compositionEnabled)))
windowManager = compositionEnabled ? "Desktop Window Manager" : "Windows Manager (Basic)";
windowManager = compositionEnabled ? "DWM" : "Windows Manager (Basic)";
else
windowManager = "Windows Manager";
}
@ -252,8 +253,12 @@ fn GetDesktopEnvironment() -> optional<string> {
const string buildStr =
GetRegistryValue(HKEY_LOCAL_MACHINE, R"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)", "CurrentBuildNumber");
if (buildStr.empty())
DEBUG_LOG("buildStr: {}", buildStr);
if (buildStr.empty()) {
DEBUG_LOG("Failed to get CurrentBuildNumber from registry");
return std::nullopt;
}
try {
const i32 build = stoi(buildStr);
@ -287,7 +292,10 @@ fn GetDesktopEnvironment() -> optional<string> {
// Older versions
return "Classic";
} catch (...) { return std::nullopt; }
} catch (...) {
DEBUG_LOG("Failed to parse CurrentBuildNumber");
return std::nullopt;
}
}
fn GetShell() -> string {

View file

@ -4,7 +4,9 @@
#include <cstdint>
#include <string>
#ifdef __WIN32__
#ifdef _WIN32
#include <guiddef.h>
#include <variant>
#include <winrt/base.h>
#endif
@ -155,7 +157,7 @@ using LinuxError = std::string;
* @brief Represents a macOS-specific error.
*/
using MacError = std::string;
#elif defined(__WIN32__)
#elif defined(_WIN32)
/**
* @typedef WindowsError
* @brief Represents a Windows-specific error.
@ -170,7 +172,7 @@ using NowPlayingError = std::variant<
LinuxError
#elif defined(__APPLE__)
MacError
#elif defined(__WIN32__)
#elif defined(_WIN32)
WindowsError
#endif
>;