From 5f2ecf8cae5081dfcff2cf12bb1b083eacfb60cf Mon Sep 17 00:00:00 2001 From: Mars Date: Wed, 29 Jan 2025 17:08:40 -0500 Subject: [PATCH] start out updating macos --- .gitignore | 1 + flake.nix | 3 +-- meson.build | 3 ++- src/os/macos.cpp | 27 +++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e67dd66..6b549df 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ .vs/ .vscode/ .xmake/ +.DS_Store bin/ build/ diff --git a/flake.nix b/flake.nix index 8d721f0..2dfb3d6 100644 --- a/flake.nix +++ b/flake.nix @@ -77,6 +77,7 @@ systemdLibs sdbus-cpp valgrind + linuxKernel.packages.linux_zen.perf.out ]); darwinPkgs = nixpkgs.lib.optionals stdenv.isDarwin (with pkgs.pkgsStatic.darwin.apple_sdk.frameworks; [ @@ -145,8 +146,6 @@ nvfetcher pkg-config unzip - nixvim.packages.${system}.default - linuxKernel.packages.linux_zen.perf.out (writeScriptBin "build" "meson compile -C build") (writeScriptBin "clean" "meson setup build --wipe") diff --git a/meson.build b/meson.build index 947340f..58e98a3 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,6 @@ project( 'draconis++', 'cpp', version: '0.1.0', default_options: [ - 'cpp_std=c++26', 'default_library=static', 'warning_level=everything', 'buildtype=debugoptimized' @@ -16,6 +15,7 @@ if host_machine.system() == 'darwin' objcpp = meson.get_compiler('objcpp') add_project_arguments( objcpp.get_supported_arguments([ + '-std=c++2b', '-Wno-c++20-compat', '-Wno-c++20-extensions', '-Wno-c++98-compat', @@ -33,6 +33,7 @@ if host_machine.system() == 'darwin' endif common_cpp_args = [ + '-std=c++26', '-Wno-c++20-compat', '-Wno-c++20-extensions', '-Wno-c++98-compat', diff --git a/src/os/macos.cpp b/src/os/macos.cpp index e8bc12b..cdab7a2 100644 --- a/src/os/macos.cpp +++ b/src/os/macos.cpp @@ -1,6 +1,8 @@ #ifdef __APPLE__ +#include #include +#include #include "macos/bridge.h" #include "os.h" @@ -25,4 +27,29 @@ fn GetOSVersion() -> string { return GetMacOSVersion(); } fn GetDesktopEnvironment() -> string { return "Aqua"; } +fn GetKernelVersion() -> string { + struct utsname uts; + + if (uname(&uts) == -1) { + ERROR_LOG("uname() failed: {}", std::strerror(errno)); + return ""; + } + + return static_cast(uts.release); +} + +fn GetHost() -> string { + std::array hwModel; + size_t hwModelLen = sizeof(hwModel); + + sysctlbyname("hw.model", hwModel.data(), &hwModelLen, nullptr, 0); + + // shamelessly stolen from https://github.com/fastfetch-cli/fastfetch/blob/dev/src/detection/host/host_mac.c + std::map modelNameByHwModel = { + { "Mac14,2", "MacBook Air (M2, 2022)" } + }; + + return modelNameByHwModel[hwModel.data()]; +} + #endif