diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2024-05-17 17:58:38 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2024-05-17 17:58:38 +0200 |
| commit | 577fc0845718ed8ad5bebf02a277c0579a817f77 (patch) | |
| tree | 3d1cdc53c426a0ba60a7996619a7b787850bb3b3 /source/lib | |
| parent | de5bf7ca3b7a2bf6be35b86486b00dc6a071b950 (diff) | |
| download | wanda-577fc0845718ed8ad5bebf02a277c0579a817f77.tar.xz wanda-577fc0845718ed8ad5bebf02a277c0579a817f77.zip | |
Diffstat (limited to 'source/lib')
| -rw-r--r-- | source/lib/CMakeLists.txt | 76 | ||||
| -rw-r--r-- | source/lib/control/CMakeLists.txt | 43 | ||||
| -rw-r--r-- | source/lib/include/wanda/control/commander.hpp (renamed from source/lib/control/include/wanda/control/commander.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/control/connection.hpp (renamed from source/lib/control/include/wanda/control/connection.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/control/interface.hpp (renamed from source/lib/control/include/wanda/control/interface.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/meta/deferred_failure.hpp (renamed from source/lib/meta/include/wanda/meta/deferred_failure.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/meta/keyed.hpp (renamed from source/lib/meta/include/wanda/meta/keyed.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/meta/type_wrapper.hpp (renamed from source/lib/meta/include/wanda/meta/type_wrapper.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/proto/command.hpp (renamed from source/lib/proto/include/wanda/proto/command.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/proto/message.hpp (renamed from source/lib/proto/include/wanda/proto/message.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/proto/version.hpp (renamed from source/lib/proto/include/wanda/proto/version.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/std_ext/expected.hpp (renamed from source/lib/std_ext/include/wanda/std_ext/expected.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/std_ext/optional.hpp (renamed from source/lib/std_ext/include/wanda/std_ext/optional.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/system/environment.hpp (renamed from source/lib/system/include/wanda/system/environment.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/system/filesystem.hpp (renamed from source/lib/system/include/wanda/system/filesystem.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/system/logging.hpp (renamed from source/lib/system/include/wanda/system/logging.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/system/magic.hpp (renamed from source/lib/system/include/wanda/system/magic.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/system/setting.hpp (renamed from source/lib/system/include/wanda/system/setting.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/system/wallpaper.hpp (renamed from source/lib/system/include/wanda/system/wallpaper.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/include/wanda/system/xdg.hpp (renamed from source/lib/system/include/wanda/system/xdg.hpp) | 0 | ||||
| -rw-r--r-- | source/lib/meta/CMakeLists.txt | 31 | ||||
| -rw-r--r-- | source/lib/proto/CMakeLists.txt | 38 | ||||
| -rw-r--r-- | source/lib/src/control/commander.cpp (renamed from source/lib/control/src/commander.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/control/connection.cpp (renamed from source/lib/control/src/connection.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/control/interface.cpp (renamed from source/lib/control/src/interface.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/proto/command.cpp (renamed from source/lib/proto/src/command.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/proto/message.cpp (renamed from source/lib/proto/src/message.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/system/environment.cpp (renamed from source/lib/system/src/environment.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/system/filesystem.cpp (renamed from source/lib/system/src/filesystem.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/system/logging.cpp (renamed from source/lib/system/src/logging.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/system/setting.cpp (renamed from source/lib/system/src/setting.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/system/wallpaper.cpp (renamed from source/lib/system/src/wallpaper.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/src/system/xdg.cpp (renamed from source/lib/system/src/xdg.cpp) | 0 | ||||
| -rw-r--r-- | source/lib/std_ext/CMakeLists.txt | 31 | ||||
| -rw-r--r-- | source/lib/system/CMakeLists.txt | 63 | ||||
| -rw-r--r-- | source/lib/tests/xdg.cpp | 171 |
36 files changed, 238 insertions, 215 deletions
diff --git a/source/lib/CMakeLists.txt b/source/lib/CMakeLists.txt index b9cafe7..f8f2bdb 100644 --- a/source/lib/CMakeLists.txt +++ b/source/lib/CMakeLists.txt @@ -1,9 +1,67 @@ -if(WANDA_APPLICATIONS_ONLY) - set(WANDA_LIBRARY_TYPE OBJECT) -endif() - -add_subdirectory("control") -add_subdirectory("meta") -add_subdirectory("proto") -add_subdirectory("std_ext") -add_subdirectory("system") +file(GLOB_RECURSE HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "include/*.hpp") +file(GLOB_RECURSE SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "src/*.cpp") + +find_package("JPEG" REQUIRED) +find_package("PNG" REQUIRED) +find_package("PkgConfig" REQUIRED) + +pkg_check_modules("GIO" + REQUIRED + IMPORTED_TARGET + GLOBAL + "gio-2.0" +) + +pkg_check_modules("libmagic" + REQUIRED + IMPORTED_TARGET + GLOBAL + "libmagic" +) + +add_library("wanda" + ${SOURCES} +) + +target_sources("wanda" INTERFACE + FILE_SET HEADERS + FILES ${HEADERS} + BASE_DIRS "include" +) + +target_include_directories("wanda" PUBLIC + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" +) + +target_include_directories("wanda" SYSTEM PUBLIC + "$<INSTALL_INTERFACE:include>" +) + +target_compile_features("wanda" PUBLIC + "cxx_std_20" +) + +target_link_libraries("wanda" PUBLIC + "Boost::headers" + "JPEG::JPEG" + "PNG::PNG" + "spdlog::spdlog_header_only" + + "PkgConfig::libmagic" + "PkgConfig::GIO" +) + +add_executable("wanda-tests" + "tests/xdg.cpp" +) + +target_link_libraries("wanda-tests" PRIVATE + "wanda" + "Catch2::Catch2WithMain" +) + +catch_discover_tests("wanda-tests") + +install(TARGETS "wanda" + FILE_SET HEADERS +) diff --git a/source/lib/control/CMakeLists.txt b/source/lib/control/CMakeLists.txt deleted file mode 100644 index b4a4b02..0000000 --- a/source/lib/control/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -cmake_path(GET CMAKE_CURRENT_SOURCE_DIR STEM LIB_NAME) - -file(GLOB_RECURSE LIB_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.hpp") -file(GLOB_RECURSE LIB_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.cpp") - -add_library("wanda-${LIB_NAME}" ${WANDA_LIBRARY_TYPE} - ${LIB_SOURCES} -) - -target_sources("wanda-${LIB_NAME}" INTERFACE - FILE_SET HEADERS - FILES ${LIB_HEADERS} - BASE_DIRS "include" -) - -target_include_directories("wanda-${LIB_NAME}" PUBLIC - "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" -) - -target_include_directories("wanda-${LIB_NAME}" SYSTEM PUBLIC - "$<INSTALL_INTERFACE:include>" -) - -target_compile_features("wanda-${LIB_NAME}" PUBLIC - "cxx_std_20" -) - -target_link_libraries("wanda-${LIB_NAME}" PUBLIC - "wanda::meta" - "wanda::proto" - "wanda::system" - - "Boost::headers" - "spdlog::spdlog_header_only" -) - -if(NOT WANDA_APPLICATIONS_ONLY) - install(TARGETS "wanda-${LIB_NAME}" - FILE_SET HEADERS - ) -endif() - -add_library("wanda::${LIB_NAME}" ALIAS "wanda-${LIB_NAME}") diff --git a/source/lib/control/include/wanda/control/commander.hpp b/source/lib/include/wanda/control/commander.hpp index d7ca73d..d7ca73d 100644 --- a/source/lib/control/include/wanda/control/commander.hpp +++ b/source/lib/include/wanda/control/commander.hpp diff --git a/source/lib/control/include/wanda/control/connection.hpp b/source/lib/include/wanda/control/connection.hpp index 0284fd7..0284fd7 100644 --- a/source/lib/control/include/wanda/control/connection.hpp +++ b/source/lib/include/wanda/control/connection.hpp diff --git a/source/lib/control/include/wanda/control/interface.hpp b/source/lib/include/wanda/control/interface.hpp index e895b68..e895b68 100644 --- a/source/lib/control/include/wanda/control/interface.hpp +++ b/source/lib/include/wanda/control/interface.hpp diff --git a/source/lib/meta/include/wanda/meta/deferred_failure.hpp b/source/lib/include/wanda/meta/deferred_failure.hpp index f74d923..f74d923 100644 --- a/source/lib/meta/include/wanda/meta/deferred_failure.hpp +++ b/source/lib/include/wanda/meta/deferred_failure.hpp diff --git a/source/lib/meta/include/wanda/meta/keyed.hpp b/source/lib/include/wanda/meta/keyed.hpp index a09d1eb..a09d1eb 100644 --- a/source/lib/meta/include/wanda/meta/keyed.hpp +++ b/source/lib/include/wanda/meta/keyed.hpp diff --git a/source/lib/meta/include/wanda/meta/type_wrapper.hpp b/source/lib/include/wanda/meta/type_wrapper.hpp index 1d34c09..1d34c09 100644 --- a/source/lib/meta/include/wanda/meta/type_wrapper.hpp +++ b/source/lib/include/wanda/meta/type_wrapper.hpp diff --git a/source/lib/proto/include/wanda/proto/command.hpp b/source/lib/include/wanda/proto/command.hpp index c8dae65..c8dae65 100644 --- a/source/lib/proto/include/wanda/proto/command.hpp +++ b/source/lib/include/wanda/proto/command.hpp diff --git a/source/lib/proto/include/wanda/proto/message.hpp b/source/lib/include/wanda/proto/message.hpp index 03a30c2..03a30c2 100644 --- a/source/lib/proto/include/wanda/proto/message.hpp +++ b/source/lib/include/wanda/proto/message.hpp diff --git a/source/lib/proto/include/wanda/proto/version.hpp b/source/lib/include/wanda/proto/version.hpp index faa17d7..faa17d7 100644 --- a/source/lib/proto/include/wanda/proto/version.hpp +++ b/source/lib/include/wanda/proto/version.hpp diff --git a/source/lib/std_ext/include/wanda/std_ext/expected.hpp b/source/lib/include/wanda/std_ext/expected.hpp index 83629db..83629db 100644 --- a/source/lib/std_ext/include/wanda/std_ext/expected.hpp +++ b/source/lib/include/wanda/std_ext/expected.hpp diff --git a/source/lib/std_ext/include/wanda/std_ext/optional.hpp b/source/lib/include/wanda/std_ext/optional.hpp index 763e8ac..763e8ac 100644 --- a/source/lib/std_ext/include/wanda/std_ext/optional.hpp +++ b/source/lib/include/wanda/std_ext/optional.hpp diff --git a/source/lib/system/include/wanda/system/environment.hpp b/source/lib/include/wanda/system/environment.hpp index 8cd9ecf..8cd9ecf 100644 --- a/source/lib/system/include/wanda/system/environment.hpp +++ b/source/lib/include/wanda/system/environment.hpp diff --git a/source/lib/system/include/wanda/system/filesystem.hpp b/source/lib/include/wanda/system/filesystem.hpp index 971db90..971db90 100644 --- a/source/lib/system/include/wanda/system/filesystem.hpp +++ b/source/lib/include/wanda/system/filesystem.hpp diff --git a/source/lib/system/include/wanda/system/logging.hpp b/source/lib/include/wanda/system/logging.hpp index 8a9a90e..8a9a90e 100644 --- a/source/lib/system/include/wanda/system/logging.hpp +++ b/source/lib/include/wanda/system/logging.hpp diff --git a/source/lib/system/include/wanda/system/magic.hpp b/source/lib/include/wanda/system/magic.hpp index a8ea1ba..a8ea1ba 100644 --- a/source/lib/system/include/wanda/system/magic.hpp +++ b/source/lib/include/wanda/system/magic.hpp diff --git a/source/lib/system/include/wanda/system/setting.hpp b/source/lib/include/wanda/system/setting.hpp index e0be3f4..e0be3f4 100644 --- a/source/lib/system/include/wanda/system/setting.hpp +++ b/source/lib/include/wanda/system/setting.hpp diff --git a/source/lib/system/include/wanda/system/wallpaper.hpp b/source/lib/include/wanda/system/wallpaper.hpp index 7965fb0..7965fb0 100644 --- a/source/lib/system/include/wanda/system/wallpaper.hpp +++ b/source/lib/include/wanda/system/wallpaper.hpp diff --git a/source/lib/system/include/wanda/system/xdg.hpp b/source/lib/include/wanda/system/xdg.hpp index ae01feb..ae01feb 100644 --- a/source/lib/system/include/wanda/system/xdg.hpp +++ b/source/lib/include/wanda/system/xdg.hpp diff --git a/source/lib/meta/CMakeLists.txt b/source/lib/meta/CMakeLists.txt deleted file mode 100644 index d21d45c..0000000 --- a/source/lib/meta/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_path(GET CMAKE_CURRENT_SOURCE_DIR STEM LIB_NAME) - -file(GLOB_RECURSE LIB_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.hpp") - -add_library("wanda-${LIB_NAME}" INTERFACE) - -target_sources("wanda-${LIB_NAME}" INTERFACE - FILE_SET HEADERS - FILES ${LIB_HEADERS} - BASE_DIRS "include" -) - -target_include_directories("wanda-${LIB_NAME}" INTERFACE - "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" -) - -target_include_directories("wanda-${LIB_NAME}" SYSTEM INTERFACE - "$<INSTALL_INTERFACE:include>" -) - -target_compile_features("wanda-${LIB_NAME}" INTERFACE - "cxx_std_20" -) - -if(NOT WANDA_APPLICATIONS_ONLY) - install(TARGETS "wanda-${LIB_NAME}" - FILE_SET HEADERS - ) -endif() - -add_library("wanda::${LIB_NAME}" ALIAS "wanda-${LIB_NAME}") diff --git a/source/lib/proto/CMakeLists.txt b/source/lib/proto/CMakeLists.txt deleted file mode 100644 index b20663c..0000000 --- a/source/lib/proto/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_path(GET CMAKE_CURRENT_SOURCE_DIR STEM LIB_NAME) - -file(GLOB_RECURSE LIB_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.hpp") -file(GLOB_RECURSE LIB_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.cpp") - -add_library("wanda-${LIB_NAME}" ${WANDA_LIBRARY_TYPE} - ${LIB_SOURCES} -) - -target_sources("wanda-${LIB_NAME}" INTERFACE - FILE_SET HEADERS - FILES ${LIB_HEADERS} - BASE_DIRS "include" -) - -target_include_directories("wanda-${LIB_NAME}" PUBLIC - "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" -) - -target_include_directories("wanda-${LIB_NAME}" SYSTEM PUBLIC - "$<INSTALL_INTERFACE:include>" -) - -target_compile_features("wanda-${LIB_NAME}" PUBLIC - "cxx_std_20" -) - -target_link_libraries("wanda-${LIB_NAME}" PUBLIC - "spdlog::spdlog_header_only" -) - -if(NOT WANDA_APPLICATIONS_ONLY) - install(TARGETS "wanda-${LIB_NAME}" - FILE_SET HEADERS - ) -endif() - -add_library("wanda::${LIB_NAME}" ALIAS "wanda-${LIB_NAME}") diff --git a/source/lib/control/src/commander.cpp b/source/lib/src/control/commander.cpp index 4490bb7..4490bb7 100644 --- a/source/lib/control/src/commander.cpp +++ b/source/lib/src/control/commander.cpp diff --git a/source/lib/control/src/connection.cpp b/source/lib/src/control/connection.cpp index 97f41dd..97f41dd 100644 --- a/source/lib/control/src/connection.cpp +++ b/source/lib/src/control/connection.cpp diff --git a/source/lib/control/src/interface.cpp b/source/lib/src/control/interface.cpp index 3ebc55a..3ebc55a 100644 --- a/source/lib/control/src/interface.cpp +++ b/source/lib/src/control/interface.cpp diff --git a/source/lib/proto/src/command.cpp b/source/lib/src/proto/command.cpp index 5a669f5..5a669f5 100644 --- a/source/lib/proto/src/command.cpp +++ b/source/lib/src/proto/command.cpp diff --git a/source/lib/proto/src/message.cpp b/source/lib/src/proto/message.cpp index f44ca06..f44ca06 100644 --- a/source/lib/proto/src/message.cpp +++ b/source/lib/src/proto/message.cpp diff --git a/source/lib/system/src/environment.cpp b/source/lib/src/system/environment.cpp index 8f79531..8f79531 100644 --- a/source/lib/system/src/environment.cpp +++ b/source/lib/src/system/environment.cpp diff --git a/source/lib/system/src/filesystem.cpp b/source/lib/src/system/filesystem.cpp index 04dfff3..04dfff3 100644 --- a/source/lib/system/src/filesystem.cpp +++ b/source/lib/src/system/filesystem.cpp diff --git a/source/lib/system/src/logging.cpp b/source/lib/src/system/logging.cpp index 83dc9f6..83dc9f6 100644 --- a/source/lib/system/src/logging.cpp +++ b/source/lib/src/system/logging.cpp diff --git a/source/lib/system/src/setting.cpp b/source/lib/src/system/setting.cpp index 1553eae..1553eae 100644 --- a/source/lib/system/src/setting.cpp +++ b/source/lib/src/system/setting.cpp diff --git a/source/lib/system/src/wallpaper.cpp b/source/lib/src/system/wallpaper.cpp index 11a6402..11a6402 100644 --- a/source/lib/system/src/wallpaper.cpp +++ b/source/lib/src/system/wallpaper.cpp diff --git a/source/lib/system/src/xdg.cpp b/source/lib/src/system/xdg.cpp index 109beb1..109beb1 100644 --- a/source/lib/system/src/xdg.cpp +++ b/source/lib/src/system/xdg.cpp diff --git a/source/lib/std_ext/CMakeLists.txt b/source/lib/std_ext/CMakeLists.txt deleted file mode 100644 index d21d45c..0000000 --- a/source/lib/std_ext/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_path(GET CMAKE_CURRENT_SOURCE_DIR STEM LIB_NAME) - -file(GLOB_RECURSE LIB_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.hpp") - -add_library("wanda-${LIB_NAME}" INTERFACE) - -target_sources("wanda-${LIB_NAME}" INTERFACE - FILE_SET HEADERS - FILES ${LIB_HEADERS} - BASE_DIRS "include" -) - -target_include_directories("wanda-${LIB_NAME}" INTERFACE - "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" -) - -target_include_directories("wanda-${LIB_NAME}" SYSTEM INTERFACE - "$<INSTALL_INTERFACE:include>" -) - -target_compile_features("wanda-${LIB_NAME}" INTERFACE - "cxx_std_20" -) - -if(NOT WANDA_APPLICATIONS_ONLY) - install(TARGETS "wanda-${LIB_NAME}" - FILE_SET HEADERS - ) -endif() - -add_library("wanda::${LIB_NAME}" ALIAS "wanda-${LIB_NAME}") diff --git a/source/lib/system/CMakeLists.txt b/source/lib/system/CMakeLists.txt deleted file mode 100644 index 7589c56..0000000 --- a/source/lib/system/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -cmake_path(GET CMAKE_CURRENT_SOURCE_DIR STEM LIB_NAME) - -file(GLOB_RECURSE LIB_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.hpp") -file(GLOB_RECURSE LIB_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "**/*.cpp") - -find_package("PkgConfig" REQUIRED) - -pkg_check_modules("GIO" - REQUIRED - IMPORTED_TARGET - GLOBAL - "gio-2.0" -) - -pkg_check_modules("libmagic" - REQUIRED - IMPORTED_TARGET - GLOBAL - "libmagic" -) - -add_library("wanda-${LIB_NAME}" ${WANDA_LIBRARY_TYPE} - ${LIB_SOURCES} -) - -target_sources("wanda-${LIB_NAME}" INTERFACE - FILE_SET HEADERS - FILES ${LIB_HEADERS} - BASE_DIRS "include" -) - -target_include_directories("wanda-${LIB_NAME}" PUBLIC - "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" -) - -target_include_directories("wanda-${LIB_NAME}" SYSTEM PUBLIC - "$<INSTALL_INTERFACE:include>" -) - -target_compile_features("wanda-${LIB_NAME}" PUBLIC - "cxx_std_20" -) - -target_link_libraries("wanda-${LIB_NAME}" PUBLIC - "wanda::meta" - "wanda::std_ext" - - "Boost::headers" - "JPEG::JPEG" - "PNG::PNG" - "spdlog::spdlog_header_only" - - "PkgConfig::libmagic" - "PkgConfig::GIO" -) - -if(NOT WANDA_APPLICATIONS_ONLY) - install(TARGETS "wanda-${LIB_NAME}" - FILE_SET HEADERS - ) -endif() - -add_library("wanda::${LIB_NAME}" ALIAS "wanda-${LIB_NAME}") diff --git a/source/lib/tests/xdg.cpp b/source/lib/tests/xdg.cpp new file mode 100644 index 0000000..5872dc6 --- /dev/null +++ b/source/lib/tests/xdg.cpp @@ -0,0 +1,171 @@ +#include "wanda/system/xdg.hpp" + +#include "wanda/system/environment.hpp" + +#include <catch2/catch_all.hpp> +#include <unistd.h> + +#include <filesystem> +#include <string> +#include <utility> + +using namespace std::string_literals; + +namespace wanda::system::test +{ + + TEST_CASE("XDG variable names match the specification", "[system][xdg][spec]") + { + REQUIRE(xdg_variable(xdg_directory::data_home) == "XDG_DATA_HOME"); + REQUIRE(xdg_variable(xdg_directory::config_home) == "XDG_CONFIG_HOME"); + REQUIRE(xdg_variable(xdg_directory::cache_home) == "XDG_CACHE_HOME"); + REQUIRE(xdg_variable(xdg_directory::runtime_dir) == "XDG_RUNTIME_DIR"); + } + + SCENARIO("The values of the XDG variables depend on the environment", "[system][xdg][spec]") + { + auto const home_directory = std::filesystem::path{"/home/test"}; + auto const run_directory = std::filesystem::path{"/run/user"}; + auto const uid = std::to_string(::getuid()); + + GIVEN("An environment that only contains HOME") + { + auto home = "HOME="s + home_directory.native(); + char const * env_data[] = {home.c_str(), nullptr}; + auto env = environment{env_data}; + + THEN("the data home is '<home_directory>/.local/share") + { + REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share"); + } + + THEN("the config home is '<home_directory>/.config") + { + REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config"); + } + + THEN("the cache home is '<home_directory>/.cache") + { + REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache"); + } + + THEN("the runtime directory is '<run_directory>/<uid>'") + { + REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid); + } + } + + GIVEN("An environment that only contains HOME and XDG_DATA_HOME") + { + auto home = "HOME="s + home_directory.native(); + auto data_home = "XDG_DATA_HOME=/home/test/xdg_data_home"s; + char const * env_data[] = {home.c_str(), data_home.c_str(), nullptr}; + auto env = environment{env_data}; + + THEN("the data home is '$XDG_DATA_HOME") + { + REQUIRE(xdg_path_for(xdg_directory::data_home, env) == env["XDG_DATA_HOME"]); + } + + THEN("the config home is '<home_directory>/.config") + { + REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config"); + } + + THEN("the cache home is '<home_directory>/.cache") + { + REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache"); + } + + THEN("the runtime directory is '<run_directory>/<uid>'") + { + REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid); + } + } + + GIVEN("An environment that only contains HOME and XDG_CONFIG_HOME") + { + auto home = "HOME="s + home_directory.native(); + auto config_home = "XDG_CONFIG_HOME=/home/test/xdg_config_home"s; + char const * env_data[] = {home.c_str(), config_home.c_str(), nullptr}; + auto env = environment{env_data}; + + THEN("the data home is '<home_directory>/.local/share") + { + REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share"); + } + + THEN("the config home is '$XDG_CONFIG_HOME") + { + REQUIRE(xdg_path_for(xdg_directory::config_home, env) == env["XDG_CONFIG_HOME"]); + } + + THEN("the cache home is '<home_directory>/.cache") + { + REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache"); + } + + THEN("the runtime directory is '<run_directory>/<uid>'") + { + REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid); + } + } + + GIVEN("An environment that only contains HOME and XDG_CACHE_HOME") + { + auto home = "HOME="s + home_directory.native(); + auto cache_home = "XDG_CACHE_HOME=/home/test/xdg_cache_home"s; + char const * env_data[] = {home.c_str(), cache_home.c_str(), nullptr}; + auto env = environment{env_data}; + + THEN("the data home is '<home_directory>/.local/share") + { + REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share"); + } + + THEN("the cache home is '<home_directory>/.config") + { + REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config"); + } + + THEN("the config home is '$XDG_CACHE_HOME") + { + REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == env["XDG_CACHE_HOME"]); + } + + THEN("the runtime directory is '<run_directory>/<uid>'") + { + REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid); + } + } + + GIVEN("An environment that only contains HOME and XDG_RUNTIME_DIR") + { + auto home = "HOME="s + home_directory.native(); + auto runtime_dir = "XDG_RUNTIME_DIR=/home/test/xdg_runtime_dir"s; + char const * env_data[] = {home.c_str(), runtime_dir.c_str(), nullptr}; + auto env = environment{env_data}; + + THEN("the data home is '<home_directory>/.local/share") + { + REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share"); + } + + THEN("the config home is '<home_directory>/.config") + { + REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config"); + } + + THEN("the cache home is '<home_directory>/.cache") + { + REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache"); + } + + THEN("the runtime directory is '$XDG_RUNTIME_DIR'") + { + REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == env["XDG_RUNTIME_DIR"]); + } + } + } + +} // namespace wanda::system::test
\ No newline at end of file |
