mrow
This commit is contained in:
parent
d776ddf807
commit
427b7b48a5
8 changed files with 255 additions and 251 deletions
|
@ -13,16 +13,16 @@
|
||||||
"name": null,
|
"name": null,
|
||||||
"owner": "fmtlib",
|
"owner": "fmtlib",
|
||||||
"repo": "fmt",
|
"repo": "fmt",
|
||||||
"rev": "11.1.3",
|
"rev": "11.1.4",
|
||||||
"sha256": "sha256-6r9D/csVSgS+T/H0J8cSR+YszxnH/h2V2odi2s6VYN8=",
|
"sha256": "sha256-sUbxlYi/Aupaox3JjWFqXIjcaQa0LFjclQAOleT+FRA=",
|
||||||
"sparseCheckout": [],
|
"sparseCheckout": [],
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"version": "11.1.3"
|
"version": "11.1.4"
|
||||||
},
|
},
|
||||||
"reflect-cpp": {
|
"reflect-cpp": {
|
||||||
"cargoLocks": null,
|
"cargoLocks": null,
|
||||||
"date": null,
|
"date": "2025-03-02",
|
||||||
"extract": null,
|
"extract": null,
|
||||||
"name": "reflect-cpp",
|
"name": "reflect-cpp",
|
||||||
"passthru": null,
|
"passthru": null,
|
||||||
|
@ -34,12 +34,12 @@
|
||||||
"name": null,
|
"name": null,
|
||||||
"owner": "getml",
|
"owner": "getml",
|
||||||
"repo": "reflect-cpp",
|
"repo": "reflect-cpp",
|
||||||
"rev": "v0.17.0",
|
"rev": "ec8c19fa3e931d736b3f3ff2e400fce4a5f97829",
|
||||||
"sha256": "sha256-ugMop4Gsw46zFA7mESNzDTAZVzIg3szAX8ND1kUiF2A=",
|
"sha256": "sha256-3bbaVbU9ICQ8no/3W4M8ePsnrZR3e3CWhT3RO3lL3r0=",
|
||||||
"sparseCheckout": [],
|
"sparseCheckout": [],
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"version": "v0.17.0"
|
"version": "ec8c19fa3e931d736b3f3ff2e400fce4a5f97829"
|
||||||
},
|
},
|
||||||
"sdbus-cpp": {
|
"sdbus-cpp": {
|
||||||
"cargoLocks": null,
|
"cargoLocks": null,
|
||||||
|
|
|
@ -3,25 +3,26 @@
|
||||||
{
|
{
|
||||||
fmt = {
|
fmt = {
|
||||||
pname = "fmt";
|
pname = "fmt";
|
||||||
version = "11.1.3";
|
version = "11.1.4";
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "fmtlib";
|
owner = "fmtlib";
|
||||||
repo = "fmt";
|
repo = "fmt";
|
||||||
rev = "11.1.3";
|
rev = "11.1.4";
|
||||||
fetchSubmodules = false;
|
fetchSubmodules = false;
|
||||||
sha256 = "sha256-6r9D/csVSgS+T/H0J8cSR+YszxnH/h2V2odi2s6VYN8=";
|
sha256 = "sha256-sUbxlYi/Aupaox3JjWFqXIjcaQa0LFjclQAOleT+FRA=";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
reflect-cpp = {
|
reflect-cpp = {
|
||||||
pname = "reflect-cpp";
|
pname = "reflect-cpp";
|
||||||
version = "v0.17.0";
|
version = "ec8c19fa3e931d736b3f3ff2e400fce4a5f97829";
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "getml";
|
owner = "getml";
|
||||||
repo = "reflect-cpp";
|
repo = "reflect-cpp";
|
||||||
rev = "v0.17.0";
|
rev = "ec8c19fa3e931d736b3f3ff2e400fce4a5f97829";
|
||||||
fetchSubmodules = false;
|
fetchSubmodules = false;
|
||||||
sha256 = "sha256-ugMop4Gsw46zFA7mESNzDTAZVzIg3szAX8ND1kUiF2A=";
|
sha256 = "sha256-3bbaVbU9ICQ8no/3W4M8ePsnrZR3e3CWhT3RO3lL3r0=";
|
||||||
};
|
};
|
||||||
|
date = "2025-03-02";
|
||||||
};
|
};
|
||||||
sdbus-cpp = {
|
sdbus-cpp = {
|
||||||
pname = "sdbus-cpp";
|
pname = "sdbus-cpp";
|
||||||
|
|
37
flake.nix
37
flake.nix
|
@ -35,27 +35,15 @@
|
||||||
inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;
|
inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkPkg = name:
|
fmt = pkgs.pkgsStatic.fmt.overrideAttrs (old: {
|
||||||
pkgs.pkgsStatic.${name}.overrideAttrs {
|
inherit (sources.fmt) pname version src;
|
||||||
inherit (sources.${name}) pname version src;
|
});
|
||||||
};
|
|
||||||
|
|
||||||
fmt = mkPkg "fmt";
|
|
||||||
|
|
||||||
tomlplusplus = pkgs.pkgsStatic.tomlplusplus.overrideAttrs {
|
tomlplusplus = pkgs.pkgsStatic.tomlplusplus.overrideAttrs {
|
||||||
inherit (sources.tomlplusplus) pname version src;
|
inherit (sources.tomlplusplus) pname version src;
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
sdbus-cpp = pkgs.sdbus-cpp.overrideAttrs {
|
|
||||||
inherit (sources.sdbus-cpp) pname version src;
|
|
||||||
|
|
||||||
cmakeFlags = [
|
|
||||||
(pkgs.lib.cmakeBool "BUILD_CODE_GEN" true)
|
|
||||||
(pkgs.lib.cmakeBool "BUILD_SHARED_LIBS" false)
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
yyjson = pkgs.pkgsStatic.stdenv.mkDerivation {
|
yyjson = pkgs.pkgsStatic.stdenv.mkDerivation {
|
||||||
inherit (sources.yyjson) pname version src;
|
inherit (sources.yyjson) pname version src;
|
||||||
|
|
||||||
|
@ -70,6 +58,8 @@
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DCMAKE_TOOLCHAIN_FILE=OFF"
|
"-DCMAKE_TOOLCHAIN_FILE=OFF"
|
||||||
|
"-DCMAKE_CXX_VISIBILITY_PRESET=hidden"
|
||||||
|
"-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON"
|
||||||
"-DREFLECTCPP_TOML=ON"
|
"-DREFLECTCPP_TOML=ON"
|
||||||
"-DREFLECTCPP_JSON=ON"
|
"-DREFLECTCPP_JSON=ON"
|
||||||
"-DREFLECTCPP_USE_STD_EXPECTED=ON"
|
"-DREFLECTCPP_USE_STD_EXPECTED=ON"
|
||||||
|
@ -78,14 +68,14 @@
|
||||||
|
|
||||||
deps = with pkgs.pkgsStatic;
|
deps = with pkgs.pkgsStatic;
|
||||||
[
|
[
|
||||||
# curl
|
curl
|
||||||
# fmt
|
fmt
|
||||||
# libiconv
|
libiconv
|
||||||
# tomlplusplus
|
tomlplusplus
|
||||||
# yyjson
|
yyjson
|
||||||
# reflect-cpp
|
reflect-cpp
|
||||||
# sqlitecpp
|
sqlitecpp
|
||||||
# ftxui
|
ftxui
|
||||||
]
|
]
|
||||||
++ linuxPkgs;
|
++ linuxPkgs;
|
||||||
|
|
||||||
|
@ -167,6 +157,7 @@
|
||||||
++ deps;
|
++ deps;
|
||||||
|
|
||||||
LD_LIBRARY_PATH = "${lib.makeLibraryPath deps}";
|
LD_LIBRARY_PATH = "${lib.makeLibraryPath deps}";
|
||||||
|
NIX_ENFORCE_NO_NATIVE = 0;
|
||||||
|
|
||||||
name = "C++";
|
name = "C++";
|
||||||
};
|
};
|
||||||
|
|
266
meson.build
266
meson.build
|
@ -1,3 +1,6 @@
|
||||||
|
# ----------------------- #
|
||||||
|
# Project Configuration #
|
||||||
|
# ----------------------- #
|
||||||
project(
|
project(
|
||||||
'draconis++',
|
'draconis++',
|
||||||
'cpp',
|
'cpp',
|
||||||
|
@ -5,47 +8,17 @@ project(
|
||||||
default_options: [
|
default_options: [
|
||||||
'default_library=static',
|
'default_library=static',
|
||||||
'warning_level=everything',
|
'warning_level=everything',
|
||||||
'buildtype=debug',
|
'buildtype=release',
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cpp = meson.get_compiler('cpp')
|
cpp = meson.get_compiler('cpp')
|
||||||
|
host_system = host_machine.system()
|
||||||
|
|
||||||
if host_machine.system() == 'darwin'
|
# ------------------------ #
|
||||||
add_languages('objcpp')
|
# Compiler Configuration #
|
||||||
objcpp = meson.get_compiler('objcpp')
|
# ------------------------ #
|
||||||
add_project_arguments(
|
common_warning_flags = [
|
||||||
objcpp.get_supported_arguments(
|
|
||||||
[
|
|
||||||
'-std=c++2b',
|
|
||||||
'-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',
|
|
||||||
],
|
|
||||||
),
|
|
||||||
language: 'objcpp',
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
|
|
||||||
common_cpp_args = []
|
|
||||||
|
|
||||||
if cpp.get_id() == 'msvc' or cpp.get_id() == 'clang-cl'
|
|
||||||
common_cpp_args += [
|
|
||||||
'/std:c++latest',
|
|
||||||
'/Zc:__cplusplus',
|
|
||||||
'-DNOMINMAX',
|
|
||||||
]
|
|
||||||
|
|
||||||
if cpp.get_id() == 'clang-cl'
|
|
||||||
common_cpp_args += [
|
|
||||||
'-std=c++26',
|
|
||||||
'-Wno-c++20-compat',
|
'-Wno-c++20-compat',
|
||||||
'-Wno-c++20-extensions',
|
'-Wno-c++20-extensions',
|
||||||
'-Wno-c++98-compat',
|
'-Wno-c++98-compat',
|
||||||
|
@ -55,76 +28,99 @@ if cpp.get_id() == 'msvc' or cpp.get_id() == 'clang-cl'
|
||||||
'-Wno-padded',
|
'-Wno-padded',
|
||||||
'-Wno-pre-c++20-compat-pedantic',
|
'-Wno-pre-c++20-compat-pedantic',
|
||||||
'-Wunused-function',
|
'-Wunused-function',
|
||||||
'-fno-strict-enums',
|
|
||||||
]
|
|
||||||
endif
|
|
||||||
|
|
||||||
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',
|
|
||||||
]
|
|
||||||
|
|
||||||
if host_machine.system() == 'windows'
|
|
||||||
common_cpp_args += '-DCURL_STATICLIB'
|
|
||||||
endif
|
|
||||||
|
|
||||||
add_project_arguments(cpp.get_supported_arguments(common_cpp_args), language: 'cpp')
|
|
||||||
endif
|
|
||||||
|
|
||||||
source_file_names = ['src/main.cpp', 'src/config/config.cpp', 'src/config/weather.cpp']
|
|
||||||
|
|
||||||
if host_machine.system() == 'linux'
|
|
||||||
source_file_names += ['src/os/linux.cpp', 'src/os/linux/issetugid_stub.cpp']
|
|
||||||
elif host_machine.system() == 'freebsd'
|
|
||||||
source_file_names += ['src/os/freebsd.cpp']
|
|
||||||
elif host_machine.system() == 'darwin'
|
|
||||||
source_file_names += [
|
|
||||||
'src/os/macos.cpp',
|
|
||||||
'src/os/macos/bridge.mm',
|
|
||||||
]
|
|
||||||
elif host_machine.system() == 'windows'
|
|
||||||
source_file_names += ['src/os/windows.cpp']
|
|
||||||
endif
|
|
||||||
|
|
||||||
sources = []
|
|
||||||
|
|
||||||
foreach file : source_file_names
|
|
||||||
sources += files(file)
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
deps = [
|
|
||||||
dependency('fmt', include_type: 'system', static: true),
|
|
||||||
dependency('openssl', include_type: 'system', static: true, required: false),
|
|
||||||
dependency('libcurl', include_type: 'system', static: true),
|
|
||||||
dependency('tomlplusplus', include_type: 'system', static: true),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if host_machine.system() == 'darwin'
|
common_cpp_flags = {
|
||||||
deps += dependency(
|
'common': [
|
||||||
'appleframeworks',
|
'-fno-strict-enums',
|
||||||
modules: ['foundation', 'mediaplayer', 'systemconfiguration'],
|
'-fvisibility=hidden',
|
||||||
static: true,
|
'-fvisibility-inlines-hidden',
|
||||||
)
|
'-std=c++26',
|
||||||
elif host_machine.system() == 'windows'
|
],
|
||||||
deps += [
|
'msvc': [
|
||||||
|
'-DNOMINMAX',
|
||||||
|
'/Zc:__cplusplus',
|
||||||
|
'/std:c++latest',
|
||||||
|
],
|
||||||
|
'unix_extra': [
|
||||||
|
'-march=native',
|
||||||
|
'-nostdlib++',
|
||||||
|
],
|
||||||
|
'windows_extra': '-DCURL_STATICLIB'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure Objective-C++ for macOS
|
||||||
|
if host_system == 'darwin'
|
||||||
|
add_languages('objcpp', native: false)
|
||||||
|
objcpp = meson.get_compiler('objcpp')
|
||||||
|
objcpp_flags = common_warning_flags + [
|
||||||
|
'-Wno-switch-default',
|
||||||
|
'-std=c++2b',
|
||||||
|
'-fvisibility=hidden',
|
||||||
|
'-fvisibility-inlines-hidden',
|
||||||
|
]
|
||||||
|
add_project_arguments(objcpp.get_supported_arguments(objcpp_flags), language: 'objcpp')
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Apply C++ compiler arguments
|
||||||
|
if cpp.get_id() in ['msvc', 'clang-cl']
|
||||||
|
common_cpp_args = common_cpp_flags['msvc']
|
||||||
|
if cpp.get_id() == 'clang-cl'
|
||||||
|
common_cpp_args += common_warning_flags + common_cpp_flags['common']
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
common_cpp_args = common_warning_flags + common_cpp_flags['common'] + common_cpp_flags['unix_extra']
|
||||||
|
if host_system == 'windows'
|
||||||
|
common_cpp_args += common_cpp_flags['windows_extra']
|
||||||
|
endif
|
||||||
|
common_cpp_args = cpp.get_supported_arguments(common_cpp_args)
|
||||||
|
endif
|
||||||
|
|
||||||
|
add_project_arguments(common_cpp_args, language: 'cpp')
|
||||||
|
|
||||||
|
# ------- #
|
||||||
|
# Files #
|
||||||
|
# ------- #
|
||||||
|
base_sources = files(
|
||||||
|
'src/main.cpp',
|
||||||
|
'src/config/config.cpp',
|
||||||
|
'src/config/weather.cpp'
|
||||||
|
)
|
||||||
|
|
||||||
|
platform_sources = {
|
||||||
|
'linux': ['src/os/linux.cpp', 'src/os/linux/issetugid_stub.cpp'],
|
||||||
|
'freebsd': ['src/os/freebsd.cpp'],
|
||||||
|
'darwin': ['src/os/macos.cpp', 'src/os/macos/bridge.mm'],
|
||||||
|
'windows': ['src/os/windows.cpp']
|
||||||
|
}
|
||||||
|
|
||||||
|
sources = base_sources + files(platform_sources.get(host_system, []))
|
||||||
|
|
||||||
|
# --------------------- #
|
||||||
|
# Dependencies Config #
|
||||||
|
# --------------------- #
|
||||||
|
common_deps = [
|
||||||
|
dependency('fmt', include_type: 'system', static: true),
|
||||||
|
dependency('libcurl', include_type: 'system', static: true),
|
||||||
|
dependency('tomlplusplus', include_type: 'system', static: true),
|
||||||
|
dependency('openssl', include_type: 'system', static: true, required: false),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Platform-specific dependencies
|
||||||
|
platform_deps = []
|
||||||
|
|
||||||
|
if host_system == 'darwin'
|
||||||
|
platform_deps += [
|
||||||
|
dependency('appleframeworks', modules: ['foundation', 'mediaplayer', 'systemconfiguration'], static: true),
|
||||||
|
dependency('iconv')
|
||||||
|
]
|
||||||
|
elif host_system == 'windows'
|
||||||
|
platform_deps += [
|
||||||
cpp.find_library('dwmapi'),
|
cpp.find_library('dwmapi'),
|
||||||
cpp.find_library('windowsapp'),
|
cpp.find_library('windowsapp'),
|
||||||
]
|
]
|
||||||
elif host_machine.system() == 'linux' or host_machine.system() == 'freebsd'
|
elif host_system == 'linux' or host_system == 'freebsd'
|
||||||
deps += [
|
platform_deps += [
|
||||||
dependency('SQLiteCpp'),
|
dependency('SQLiteCpp'),
|
||||||
dependency('sdbus-c++'),
|
dependency('sdbus-c++'),
|
||||||
dependency('x11'),
|
dependency('x11'),
|
||||||
|
@ -136,60 +132,60 @@ elif host_machine.system() == 'linux' or host_machine.system() == 'freebsd'
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# FTXUI configuration
|
||||||
cmake = import('cmake')
|
cmake = import('cmake')
|
||||||
|
ftxui_components = ['ftxui::screen', 'ftxui::dom', 'ftxui::component']
|
||||||
ftxui_dep = dependency(
|
ftxui_dep = dependency('ftxui', modules: ftxui_components, include_type: 'system', static: true, required: false)
|
||||||
'ftxui',
|
|
||||||
modules: ['ftxui::screen', 'ftxui::dom', 'ftxui::component'],
|
|
||||||
include_type: 'system',
|
|
||||||
static: true,
|
|
||||||
required: false,
|
|
||||||
)
|
|
||||||
|
|
||||||
if not ftxui_dep.found()
|
if not ftxui_dep.found()
|
||||||
ftxui_dom = dependency('ftxui-dom', fallback: ['ftxui', 'dom_dep'])
|
ftxui_dep = declare_dependency(
|
||||||
ftxui_screen = dependency('ftxui-screen', fallback: ['ftxui', 'screen_dep'])
|
dependencies: [
|
||||||
ftxui_component = dependency('ftxui-component', fallback: ['ftxui', 'component_dep'])
|
dependency('ftxui-dom', fallback: ['ftxui', 'dom_dep']),
|
||||||
ftxui_dep = declare_dependency(dependencies: [ftxui_dom, ftxui_screen, ftxui_component])
|
dependency('ftxui-screen', fallback: ['ftxui', 'screen_dep']),
|
||||||
|
dependency('ftxui-component', fallback: ['ftxui', 'component_dep'])
|
||||||
|
]
|
||||||
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
deps += ftxui_dep
|
# ReflectCpp configuration
|
||||||
|
reflectcpp_dep = dependency('reflectcpp', include_type: 'system', required: false, static: true)
|
||||||
|
if not reflectcpp_dep.found()
|
||||||
|
cmake_opts = cmake.subproject_options()
|
||||||
|
cxx_flags = cpp.get_id() == 'msvc' ? '/w' : '-Wno-everything -std=c++26 -fvisibility=hidden' # Added visibility flag
|
||||||
|
|
||||||
cmake_opts = cmake.subproject_options()
|
cmake_opts.add_cmake_defines({
|
||||||
|
'CMAKE_CXX_FLAGS': cxx_flags,
|
||||||
|
'CMAKE_VISIBILITY_INLINES_HIDDEN': 'ON' # Add this line
|
||||||
|
})
|
||||||
|
cmake_opts.append_compile_args('cpp', cxx_flags)
|
||||||
|
|
||||||
if cpp.get_id() == 'msvc'
|
reflectcpp_proj = cmake.subproject('reflectcpp', options: cmake_opts)
|
||||||
cmake_opts.add_cmake_defines(
|
reflectcpp_dep = reflectcpp_proj.dependency('reflectcpp', include_type: 'system')
|
||||||
{
|
|
||||||
'CMAKE_CXX_FLAGS': '/w',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
cmake_opts.append_compile_args('cpp', '/w')
|
|
||||||
else
|
|
||||||
cmake_opts.add_cmake_defines(
|
|
||||||
{
|
|
||||||
'CMAKE_CXX_FLAGS': '-Wno-everything -std=c++26',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
cmake_opts.append_compile_args('cpp', '-Wno-everything -std=c++26')
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
reflectcpp_proj = cmake.subproject('reflectcpp', options: cmake_opts)
|
# Combine all dependencies
|
||||||
reflectcpp_dep = reflectcpp_proj.dependency('reflectcpp', include_type: 'system')
|
deps = common_deps + platform_deps + [ftxui_dep, reflectcpp_dep]
|
||||||
deps += reflectcpp_dep
|
|
||||||
|
|
||||||
objc_args = []
|
# ------------------------- #
|
||||||
|
# Link/ObjC Configuration #
|
||||||
|
# ------------------------- #
|
||||||
link_args = []
|
link_args = []
|
||||||
|
objc_args = []
|
||||||
|
|
||||||
if host_machine.system() == 'darwin'
|
if host_system == 'darwin'
|
||||||
objc_args += ['-fobjc-arc']
|
objc_args += ['-fobjc-arc']
|
||||||
elif host_machine.system() == 'linux'
|
elif host_system == 'linux'
|
||||||
link_args += ['-static-libgcc', '-static-libstdc++', '-static']
|
link_args += ['-static-libgcc', '-static-libstdc++', '-static']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# ------------------- #
|
||||||
|
# Executable Target #
|
||||||
|
# ------------------- #
|
||||||
executable(
|
executable(
|
||||||
'draconis++',
|
'draconis++',
|
||||||
sources,
|
sources,
|
||||||
objc_args: objc_args,
|
objc_args: objc_args,
|
||||||
link_args: link_args,
|
link_args: link_args,
|
||||||
dependencies: deps,
|
dependencies: deps,
|
||||||
|
install: true,
|
||||||
)
|
)
|
||||||
|
|
19
nvfetcher.toml
Normal file
19
nvfetcher.toml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
[fmt]
|
||||||
|
src.github = "fmtlib/fmt"
|
||||||
|
fetch.github = "fmtlib/fmt"
|
||||||
|
|
||||||
|
[reflect-cpp]
|
||||||
|
src.git = "https://github.com/getml/reflect-cpp"
|
||||||
|
fetch.github = "getml/reflect-cpp"
|
||||||
|
|
||||||
|
[sdbus-cpp]
|
||||||
|
src.github = "kistler-group/sdbus-cpp"
|
||||||
|
fetch.github = "kistler-group/sdbus-cpp"
|
||||||
|
|
||||||
|
[tomlplusplus]
|
||||||
|
src.github = "marzer/tomlplusplus"
|
||||||
|
fetch.github = "marzer/tomlplusplus"
|
||||||
|
|
||||||
|
[yyjson]
|
||||||
|
src.github = "ibireme/yyjson"
|
||||||
|
fetch.github = "ibireme/yyjson"
|
|
@ -40,7 +40,7 @@ namespace {
|
||||||
|
|
||||||
DEBUG_LOG("Reading from cache file...");
|
DEBUG_LOG("Reading from cache file...");
|
||||||
|
|
||||||
const std::string content((std::istreambuf_iterator(ifs)), std::istreambuf_iterator<char>());
|
const std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
rfl::Result<WeatherOutput> result = rfl::json::read<WeatherOutput>(content);
|
rfl::Result<WeatherOutput> result = rfl::json::read<WeatherOutput>(content);
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|
75
src/main.cpp
75
src/main.cpp
|
@ -8,6 +8,7 @@
|
||||||
#include <ftxui/screen/screen.hpp>
|
#include <ftxui/screen/screen.hpp>
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
@ -95,10 +96,10 @@ namespace {
|
||||||
data.window_manager = GetWindowManager();
|
data.window_manager = GetWindowManager();
|
||||||
|
|
||||||
// Parallel execution for disk/shell only
|
// Parallel execution for disk/shell only
|
||||||
auto diskShell = std::async(std::launch::async, [] {
|
// auto diskShell = std::async(std::launch::async, [] {
|
||||||
auto [used, total] = GetDiskUsage();
|
// auto [used, total] = GetDiskUsage();
|
||||||
return std::make_tuple(used, total, GetShell());
|
// return std::make_tuple(used, total, GetShell());
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Conditional tasks
|
// Conditional tasks
|
||||||
std::future<WeatherOutput> weather;
|
std::future<WeatherOutput> weather;
|
||||||
|
@ -113,10 +114,10 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get remaining results
|
// Get remaining results
|
||||||
auto [used, total, shell] = diskShell.get();
|
// auto [used, total, shell] = diskShell.get();
|
||||||
data.disk_used = used;
|
// data.disk_used = used;
|
||||||
data.disk_total = total;
|
// data.disk_total = total;
|
||||||
data.shell = shell;
|
// data.shell = shell;
|
||||||
|
|
||||||
if (weather.valid())
|
if (weather.valid())
|
||||||
data.weather_info = weather.get();
|
data.weather_info = weather.get();
|
||||||
|
@ -167,25 +168,21 @@ namespace {
|
||||||
|
|
||||||
content.push_back(text(" Hello " + name + "! ") | bold | color(Color::Cyan));
|
content.push_back(text(" Hello " + name + "! ") | bold | color(Color::Cyan));
|
||||||
content.push_back(separator() | color(borderColor));
|
content.push_back(separator() | color(borderColor));
|
||||||
content.push_back(hbox(
|
content.push_back(hbox({
|
||||||
{
|
|
||||||
text(" ") | color(iconColor), // Palette icon
|
text(" ") | color(iconColor), // Palette icon
|
||||||
CreateColorCircles(),
|
CreateColorCircles(),
|
||||||
}
|
}));
|
||||||
));
|
|
||||||
content.push_back(separator() | color(borderColor));
|
content.push_back(separator() | color(borderColor));
|
||||||
|
|
||||||
// Helper function for aligned rows
|
// Helper function for aligned rows
|
||||||
fn createRow = [&](const std::string& icon, const std::string& label, const std::string& value) {
|
fn createRow = [&](const std::string& icon, const std::string& label, const std::string& value) {
|
||||||
return hbox(
|
return hbox({
|
||||||
{
|
|
||||||
text(icon) | color(iconColor),
|
text(icon) | color(iconColor),
|
||||||
text(label) | color(labelColor),
|
text(label) | color(labelColor),
|
||||||
filler(),
|
filler(),
|
||||||
text(value) | color(valueColor),
|
text(value) | color(valueColor),
|
||||||
text(" "),
|
text(" "),
|
||||||
}
|
});
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// System info rows
|
// System info rows
|
||||||
|
@ -196,39 +193,31 @@ namespace {
|
||||||
const WeatherOutput& weatherInfo = data.weather_info.value();
|
const WeatherOutput& weatherInfo = data.weather_info.value();
|
||||||
|
|
||||||
if (weather.show_town_name)
|
if (weather.show_town_name)
|
||||||
content.push_back(hbox(
|
content.push_back(hbox({
|
||||||
{
|
|
||||||
text(weatherIcon) | color(iconColor),
|
text(weatherIcon) | color(iconColor),
|
||||||
text("Weather") | color(labelColor),
|
text("Weather") | color(labelColor),
|
||||||
filler(),
|
filler(),
|
||||||
|
|
||||||
hbox(
|
hbox({
|
||||||
{
|
|
||||||
text(fmt::format("{}°F ", std::lround(weatherInfo.main.temp))),
|
text(fmt::format("{}°F ", std::lround(weatherInfo.main.temp))),
|
||||||
text("in "),
|
text("in "),
|
||||||
text(weatherInfo.name),
|
text(weatherInfo.name),
|
||||||
text(" "),
|
text(" "),
|
||||||
}
|
}) |
|
||||||
) |
|
|
||||||
color(valueColor),
|
color(valueColor),
|
||||||
}
|
}));
|
||||||
));
|
|
||||||
else
|
else
|
||||||
content.push_back(hbox(
|
content.push_back(hbox({
|
||||||
{
|
|
||||||
text(weatherIcon) | color(iconColor),
|
text(weatherIcon) | color(iconColor),
|
||||||
text("Weather") | color(labelColor),
|
text("Weather") | color(labelColor),
|
||||||
filler(),
|
filler(),
|
||||||
|
|
||||||
hbox(
|
hbox({
|
||||||
{
|
|
||||||
text(fmt::format("{}°F, {}", std::lround(weatherInfo.main.temp), weatherInfo.weather[0].description)),
|
text(fmt::format("{}°F, {}", std::lround(weatherInfo.main.temp), weatherInfo.weather[0].description)),
|
||||||
text(" "),
|
text(" "),
|
||||||
}
|
}) |
|
||||||
) |
|
|
||||||
color(valueColor),
|
color(valueColor),
|
||||||
}
|
}));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content.push_back(separator() | color(borderColor));
|
content.push_back(separator() | color(borderColor));
|
||||||
|
@ -244,19 +233,18 @@ namespace {
|
||||||
else
|
else
|
||||||
ERROR_LOG("Failed to get OS version: {}", data.os_version.error());
|
ERROR_LOG("Failed to get OS version: {}", data.os_version.error());
|
||||||
|
|
||||||
// Add disk row after memory info
|
|
||||||
if (data.mem_info.has_value())
|
if (data.mem_info.has_value())
|
||||||
content.push_back(createRow(memoryIcon, "RAM", fmt::format("{}", BytesToGiB { *data.mem_info })));
|
content.push_back(createRow(memoryIcon, "RAM", fmt::format("{}", BytesToGiB { *data.mem_info })));
|
||||||
else
|
else
|
||||||
ERROR_LOG("Failed to get memory info: {}", data.mem_info.error());
|
ERROR_LOG("Failed to get memory info: {}", data.mem_info.error());
|
||||||
|
|
||||||
// Add Disk usage row
|
// Add Disk usage row
|
||||||
content.push_back(
|
// content.push_back(
|
||||||
createRow(" ", "Disk", fmt::format("{}/{}", BytesToGiB { data.disk_used }, BytesToGiB { data.disk_total }))
|
// createRow(" ", "Disk", fmt::format("{}/{}", BytesToGiB { data.disk_used }, BytesToGiB { data.disk_total
|
||||||
);
|
// }))
|
||||||
|
// );
|
||||||
|
|
||||||
// Add Shell row
|
// content.push_back(createRow(" ", "Shell", data.shell));
|
||||||
content.push_back(createRow(" ", "Shell", data.shell));
|
|
||||||
|
|
||||||
content.push_back(separator() | color(borderColor));
|
content.push_back(separator() | color(borderColor));
|
||||||
|
|
||||||
|
@ -274,16 +262,14 @@ namespace {
|
||||||
const std::string& npText = *nowPlayingResult;
|
const std::string& npText = *nowPlayingResult;
|
||||||
|
|
||||||
content.push_back(separator() | color(borderColor));
|
content.push_back(separator() | color(borderColor));
|
||||||
content.push_back(hbox(
|
content.push_back(hbox({
|
||||||
{
|
|
||||||
text(musicIcon) | color(iconColor),
|
text(musicIcon) | color(iconColor),
|
||||||
text("Playing") | color(labelColor),
|
text("Playing") | color(labelColor),
|
||||||
text(" "),
|
text(" "),
|
||||||
filler(),
|
filler(),
|
||||||
paragraph(npText) | color(Color::Magenta) | size(WIDTH, LESS_THAN, 30),
|
paragraph(npText) | color(Color::Magenta) | size(WIDTH, LESS_THAN, 30),
|
||||||
text(" "),
|
text(" "),
|
||||||
}
|
}));
|
||||||
));
|
|
||||||
} else {
|
} else {
|
||||||
const NowPlayingError& error = nowPlayingResult.error();
|
const NowPlayingError& error = nowPlayingResult.error();
|
||||||
|
|
||||||
|
@ -295,6 +281,11 @@ namespace {
|
||||||
case NowPlayingCode::NoActivePlayer:
|
case NowPlayingCode::NoActivePlayer:
|
||||||
DEBUG_LOG("No active player found");
|
DEBUG_LOG("No active player found");
|
||||||
break;
|
break;
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
default:
|
||||||
|
std::unreachable();
|
||||||
|
#pragma clang diagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// probably stupid but it fixes the issue with windows.h defining ERROR
|
// probably stupid but it fixes the issue with windows.h defining ERROR
|
||||||
|
#include <utility>
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
@ -35,6 +36,11 @@ void LogImpl(const LogLevel level, const std::source_location& loc, fmt::format_
|
||||||
return std::make_pair(log_colors::warn, "WARN ");
|
return std::make_pair(log_colors::warn, "WARN ");
|
||||||
case LogLevel::ERROR:
|
case LogLevel::ERROR:
|
||||||
return std::make_pair(log_colors::error, "ERROR");
|
return std::make_pair(log_colors::error, "ERROR");
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
default:
|
||||||
|
std::unreachable();
|
||||||
|
#pragma clang diagnostic pop
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
@ -45,7 +51,7 @@ void LogImpl(const LogLevel level, const std::source_location& loc, fmt::format_
|
||||||
if (localtime_s(&time, &now) != 0)
|
if (localtime_s(&time, &now) != 0)
|
||||||
throw std::runtime_error("localtime_s failed");
|
throw std::runtime_error("localtime_s failed");
|
||||||
#else
|
#else
|
||||||
if (localtime_r(&now, &localTime) == nullptr)
|
if (localtime_r(&now, &time) == nullptr)
|
||||||
throw std::runtime_error("localtime_r failed");
|
throw std::runtime_error("localtime_r failed");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue