From 4ea6801df2cd08abfd1fffc11ea44ab3660f9031 Mon Sep 17 00:00:00 2001 From: Mars Date: Fri, 7 Jun 2024 13:45:59 -0400 Subject: [PATCH] i think this works --- flake.nix | 1 + meson.build | 29 +++++++++++++++++++++++++---- src/config/weather.cpp | 4 ++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 4cf74a5..abf0984 100644 --- a/flake.nix +++ b/flake.nix @@ -73,6 +73,7 @@ darwinPkgs = nixpkgs.lib.optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ Foundation + MediaPlayer ]); in with pkgs; { diff --git a/meson.build b/meson.build index 6f26ace..2fddf49 100644 --- a/meson.build +++ b/meson.build @@ -79,13 +79,34 @@ endforeach deps = [] -deps += dependency('fmt') -deps += dependency('libcurl') -deps += dependency('tomlplusplus') -deps += dependency('yyjson') +fmt = dependency('fmt', required: false) +libcurl = dependency('libcurl', required: false) +tomlpp = dependency('tomlplusplus', required: false) +yyjson = dependency('yyjson', required: false) + +if not fmt.found() + fmt = cpp.find_library('fmt', required: true) +endif + +if not libcurl.found() + libcurl = cpp.find_library('curl', required: true) +endif + +if not tomlpp.found() + tomlpp = cpp.find_library('tomlplusplus', required: true) +endif + +if not yyjson.found() + yyjson = cpp.find_library('yyjson', required: true) +endif + +foreach dep : [fmt, libcurl, tomlpp, yyjson] + deps += dep +endforeach if host_machine.system() == 'darwin' deps += dependency('Foundation') + deps += dependency('MediaPlayer') endif if host_machine.system() == 'linux' diff --git a/src/config/weather.cpp b/src/config/weather.cpp index ca66293..8d2a880 100644 --- a/src/config/weather.cpp +++ b/src/config/weather.cpp @@ -130,7 +130,7 @@ WeatherOutput Weather::getWeatherInfo() const { "weather?q={}&appid={}&units={}", location, apiKey, units); - result = MakeApiRequest(apiUrl); + result = MakeApiRequest(apiUrl).value(); } else { const auto [lat, lon] = get(loc); @@ -141,7 +141,7 @@ WeatherOutput Weather::getWeatherInfo() const { "weather?lat={:.3f}&lon={:.3f}&appid={}&units={}", lat, lon, apiKey, units); - result = MakeApiRequest(apiUrl); + result = MakeApiRequest(apiUrl).value(); } // Update the cache with the new data