chore: made pqxx statically linked

This commit is contained in:
Martin Slachta
2026-08-05 18:31:21 +02:00
parent b71f740b9a
commit 0260b4a0a0
16 changed files with 21 additions and 70 deletions
+2 -6
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.26) cmake_minimum_required(VERSION 3.26)
project(towards) project(tw_common)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
@@ -42,11 +42,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
PUBLIC PUBLIC
tw::network spdlog::spdlog
tw::protocol
loft::common
loft::base
loft::render_graph
glm::glm glm::glm
EnTT::EnTT EnTT::EnTT
Jolt Jolt
+3
View File
@@ -1,12 +1,15 @@
[requires] [requires]
protobuf/7.35.0 protobuf/7.35.0
sdl/3.4.8 sdl/3.4.8
libpqxx/8.0.2
[tool_requires] [tool_requires]
protobuf/7.35.0 protobuf/7.35.0
[options] [options]
protobuf/*:shared=False protobuf/*:shared=False
libpqxx/*:shared=False
libpq/*:shared=True
sdl/*:shared=False sdl/*:shared=False
sdl/*:camera=False sdl/*:camera=False
sdl/*:dialog=False sdl/*:dialog=False
+3
View File
@@ -83,6 +83,7 @@ RUN --mount=type=cache,target=/build \
&& mkdir -p /out/bin /out/shaders \ && mkdir -p /out/bin /out/shaders \
&& cp /build/modules/client/tw_client \ && cp /build/modules/client/tw_client \
/build/modules/mock_client/tw_mock_client \ /build/modules/mock_client/tw_mock_client \
/build/modules/server/tw_server \
/build/modules/chat_service/chat_server_exe/tw_chat_server_exe \ /build/modules/chat_service/chat_server_exe/tw_chat_server_exe \
/build/modules/chat_service/chat_service/tests/chat_mock_client/tw_chat_mock_client \ /build/modules/chat_service/chat_service/tests/chat_mock_client/tw_chat_mock_client \
/out/bin/ \ /out/bin/ \
@@ -94,6 +95,8 @@ RUN --mount=type=cache,target=/build \
FROM scratch AS export FROM scratch AS export
COPY --from=builder /out/bin/tw_client /tw_client COPY --from=builder /out/bin/tw_client /tw_client
COPY --from=builder /out/bin/tw_server /tw_server
COPY --from=builder /out/bin/tw_mock_client /tw_mock_client
COPY --from=builder /out/shaders/ /shaders/ COPY --from=builder /out/shaders/ /shaders/
+1 -3
View File
@@ -21,7 +21,7 @@ add_dependencies(tw_shaders imgui::plot imgui::plot)
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
PUBLIC PUBLIC
towards tw_common
tw::network tw::network
tw::metrics tw::metrics
tw::quicr tw::quicr
@@ -41,8 +41,6 @@ target_link_libraries(${PROJECT_NAME}
Jolt Jolt
Tracy::TracyClient Tracy::TracyClient
TracyClient TracyClient
# pqxx
# pq
) )
target_include_directories(${PROJECT_NAME} target_include_directories(${PROJECT_NAME}
@@ -10,34 +10,5 @@ class tw::dbg::ComponentGui<tw::CharacterController> {
public: public:
void draw(tw::CharacterController* instance) { void draw(tw::CharacterController* instance) {
ImGui::SeparatorText("Character Controller Component"); ImGui::SeparatorText("Character Controller Component");
if(ImGui::BeginTable("history", 3)) {
for(auto key : instance->input_history().buffer()) {
// ImGui::TableNextRow();
// ImGui::TableNextColumn();
// ImGui::Text("%u", key.first);
// ImGui::TableNextColumn();
// if(instance->input_history().get(key.first).has_value()) {
// glm::vec3 input_vec = *instance->input_history().get(key.first).value();
// std::string input = std::format("{} {} {}", input_vec.x, input_vec.y, input_vec.z);
// ImGui::Text("%s", input.c_str());
// } else {
// ImGui::Text("None");
// }
// ImGui::TableNextColumn();
// if(instance->position_history().get(key).has_value()) {
// glm::vec3 position_vec = *instance->position_history().get(key).value();
// std::string position = std::format("{} {} {}", position_vec.x, position_vec.y, position_vec.z);
// ImGui::Text("%s", position.c_str());
// } else {
// ImGui::Text("None");
// }
}
ImGui::EndTable();
}
} }
}; };
+1 -1
View File
@@ -8,7 +8,7 @@ add_executable(${PROJECT_NAME} ${FILES})
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
PUBLIC PUBLIC
towards tw_common
tw::network tw::network
tw::quicr tw::quicr
tw::protocol tw::protocol
+1 -5
View File
@@ -22,7 +22,7 @@ target_include_directories(tw_peer_to_peer_lib
target_link_libraries(tw_peer_to_peer_lib target_link_libraries(tw_peer_to_peer_lib
PUBLIC PUBLIC
towards tw_common
tw::network tw::network
tw::quicr tw::quicr
tw::protocol tw::protocol
@@ -32,8 +32,6 @@ target_link_libraries(tw_peer_to_peer_lib
spdlog::spdlog spdlog::spdlog
) )
# ── standalone executable ─────────────────────────────────────────────────────
add_executable(${PROJECT_NAME} src/PeerToPeer.cpp) add_executable(${PROJECT_NAME} src/PeerToPeer.cpp)
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
@@ -41,6 +39,4 @@ target_link_libraries(${PROJECT_NAME}
tw_peer_to_peer_lib tw_peer_to_peer_lib
) )
# ── tests ─────────────────────────────────────────────────────────────────────
add_subdirectory(tests) add_subdirectory(tests)
+1 -3
View File
@@ -20,8 +20,6 @@ target_link_libraries(tw_serialization
EnTT::EnTT EnTT::EnTT
) )
# Require C++20 for concepts / span
target_compile_features(tw_serialization INTERFACE cxx_std_20) target_compile_features(tw_serialization INTERFACE cxx_std_20)
# ── Tests / benchmarks ─────────────────────────────────────────────────────── # add_subdirectory(tests)
add_subdirectory(tests)
+1 -1
View File
@@ -17,7 +17,7 @@ file(GLOB FILES
# ) # )
# add_executable(${PROJECT_NAME}) # add_executable(${PROJECT_NAME})
add_executable(SerializationBenchmarks ./SerializationBenchmarks.cpp) # add_executable(SerializationBenchmarks ./SerializationBenchmarks.cpp)
target_compile_definitions(SerializationBenchmarks PRIVATE TRACY_ON_DEMAND=1) target_compile_definitions(SerializationBenchmarks PRIVATE TRACY_ON_DEMAND=1)
+3 -4
View File
@@ -14,6 +14,7 @@ file(GLOB FILES
src/network/*.cpp src/network/*.cpp
) )
find_package(libpqxx CONFIG REQUIRED)
add_library(tw_server_lib STATIC ${FILES}) add_library(tw_server_lib STATIC ${FILES})
target_include_directories(tw_server_lib target_include_directories(tw_server_lib
@@ -23,7 +24,7 @@ target_include_directories(tw_server_lib
target_link_libraries(tw_server_lib target_link_libraries(tw_server_lib
PUBLIC PUBLIC
towards tw_common
tw::io tw::io
tw::network tw::network
tw::protocol tw::protocol
@@ -35,10 +36,8 @@ target_link_libraries(tw_server_lib
Jolt Jolt
protobuf::libprotobuf protobuf::libprotobuf
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${LIBDECOR_LIB}
Tracy::TracyClient Tracy::TracyClient
pqxx libpqxx::pqxx
pq
) )
add_executable(${PROJECT_NAME} src/server.cpp) add_executable(${PROJECT_NAME} src/server.cpp)
@@ -7,7 +7,7 @@ TimescaleDbMetricsReporter::TimescaleDbMetricsReporter(const TimescaleDbConfigur
m_last_flush_time(std::chrono::steady_clock::now()) m_last_flush_time(std::chrono::steady_clock::now())
{ {
try { try {
m_connection = pqxx::connection(config.connection.to_string()); m_connection.emplace(config.connection.to_string());
spdlog::info("Connected to TimescaleDB at {}:{}", config.connection.host, config.connection.port); spdlog::info("Connected to TimescaleDB at {}:{}", config.connection.host, config.connection.port);
} catch (const std::exception& e) { } catch (const std::exception& e) {
spdlog::error("Failed to connect to TimescaleDB: {}", e.what()); spdlog::error("Failed to connect to TimescaleDB: {}", e.what());
@@ -23,9 +23,9 @@ void TimescaleDbMetricsReporter::flush() {
pqxx::work tx{*m_connection}; pqxx::work tx{*m_connection};
const auto table = m_connection->quote_name(m_metrics_table); const auto table = m_connection->quote_name(m_metrics_table);
tx.exec("INSERT INTO " + table + " (time, outbound, inbound, player_count) VALUES (NOW(), $1, $2, $3)", tx.exec_prepared("INSERT INTO " + table + " (time, outbound, inbound, player_count) VALUES (NOW(), $1, $2, $3)",
pqxx::params(m_outbound_bucket, m_inbound_bucket, m_player_count)) m_outbound_bucket, m_inbound_bucket, m_player_count)
.no_rows(); .empty();
tx.commit(); tx.commit();
TracyPlot("outbound", (int64_t)m_outbound_bucket); TracyPlot("outbound", (int64_t)m_outbound_bucket);
+1 -1
View File
@@ -24,7 +24,7 @@ target_link_libraries(
tw::protocol tw::protocol
tw::message_protocol tw::message_protocol
tw::quicr tw::quicr
towards tw_common
tw::gui tw::gui
imgui::imgui imgui::imgui
imgui::plot imgui::plot
-2
View File
@@ -33,8 +33,6 @@ target_link_libraries(tw_server_lib
protobuf::libprotobuf protobuf::libprotobuf
${Boost_LIBRARIES} ${Boost_LIBRARIES}
Tracy::TracyClient Tracy::TracyClient
pqxx
pq
) )
add_executable(${PROJECT_NAME} src/server.cpp) add_executable(${PROJECT_NAME} src/server.cpp)
-1
View File
@@ -1,6 +1,5 @@
#pragma once #pragma once
#include "metrics/HistoryBuffer.hpp"
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <Jolt/Jolt.h> #include <Jolt/Jolt.h>
-9
View File
@@ -4,8 +4,6 @@
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include "metrics/HistoryBuffer.hpp"
namespace tw { namespace tw {
/** /**
@@ -17,9 +15,6 @@ private:
using Clock = std::chrono::steady_clock; using Clock = std::chrono::steady_clock;
HistoryBuffer<Clock::time_point, glm::vec3> m_history;
HistoryBuffer<Clock::time_point, glm::vec3> m_position_history;
struct InputSlot { struct InputSlot {
uint32_t frame; uint32_t frame;
glm::vec3 input; glm::vec3 input;
@@ -34,13 +29,9 @@ private:
public: public:
GET(m_speed, speed); GET(m_speed, speed);
GET_MUT_REF(m_history, input_history);
GET_MUT_REF(m_position_history, position_history);
CharacterController(float speed) : CharacterController(float speed) :
m_speed(speed), m_speed(speed),
m_history(Clock::now(), glm::vec3(), 10 * 20),
m_position_history(Clock::now(), glm::vec3(), 10 * 20),
m_input_ring(64), m_input_ring(64),
m_last_input_frame(0), m_last_input_frame(0),
m_frame_idx(0) m_frame_idx(0)
-1
View File
@@ -3,7 +3,6 @@
#include "world/RigidBody.hpp" #include "world/RigidBody.hpp"
#include <iostream> #include <iostream>
#include <print> #include <print>
#include "metrics/HistoryBuffer.hpp"
#include <array> #include <array>
#include <glm/glm.hpp> #include <glm/glm.hpp>