Move flatpak utils into common

This commit is contained in:
Patrick Nicolas
2024-11-07 19:41:33 +01:00
parent 4123b35175
commit 19a399640a
12 changed files with 69 additions and 67 deletions
+8 -4
View File
@@ -23,6 +23,12 @@ endif()
configure_file(wivrn_config.h.in wivrn_config.h)
add_library(wivrn-common-base STATIC
utils/xdg_base_directory.cpp
utils/flatpak.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
)
add_library(wivrn-common STATIC
wivrn_sockets.cpp
utils/xdg_base_directory.cpp
@@ -30,7 +36,6 @@ add_library(wivrn-common STATIC
vk/error_category.cpp
vk/vk_allocator.cpp
vk/vk_mem_alloc.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
)
if(ANDROID)
@@ -55,8 +60,7 @@ else()
target_link_libraries(wivrn-common PUBLIC Vulkan::Headers)
endif()
target_link_libraries(wivrn-common PUBLIC Boost::pfr wivrn-external)
target_include_directories(wivrn-common-base PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(wivrn-common PUBLIC Boost::pfr wivrn-external wivrn-common-base)
target_compile_features(wivrn-common PRIVATE cxx_std_20)
target_compile_definitions(wivrn-common PUBLIC VULKAN_HPP_NO_STRUCT_CONSTRUCTORS)
target_include_directories(wivrn-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+10
View File
@@ -0,0 +1,10 @@
#include "wivrn_packets.h"
#include "wivrn_serialization.h"
#pragma once
namespace wivrn
{
using protocol = std::variant<from_headset::packets, to_headset::packets>;
static inline const constinit auto protocol_version = serialization_type_hash<protocol>();
} // namespace wivrn
+43
View File
@@ -0,0 +1,43 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "flatpak.h"
#include <filesystem>
#include <fstream>
static const std::filesystem::path info_path = "/.flatpak-info";
bool wivrn::is_flatpak()
{
return std::filesystem::exists(info_path);
}
std::optional<std::string> wivrn::flatpak_key(std::string key)
{
key += "=";
std::string line;
std::ifstream info(info_path);
while (std::getline(info, line))
{
if (line.starts_with(key))
return line.substr(key.size());
}
return {};
}
+29
View File
@@ -0,0 +1,29 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <optional>
#include <string>
namespace wivrn
{
bool is_flatpak();
std::optional<std::string> flatpak_key(std::string key);
} // namespace wivrn
-6
View File
@@ -1,13 +1,7 @@
#pragma once
#include "wivrn_packets.h"
#include "wivrn_serialization.h"
namespace wivrn
{
using protocol = std::variant<from_headset::packets, to_headset::packets>;
extern const char git_version[];
extern const char git_commit[];
static inline const constinit auto protocol_version = serialization_type_hash<protocol>();
} // namespace wivrn