From f98f7d19289cd40e59420942ba766eca21cf9e15 Mon Sep 17 00:00:00 2001 From: Owen Phillips Date: Tue, 28 Apr 2026 12:03:17 -0600 Subject: [PATCH 1/6] Use unified core --- src/lib/deskflow/win32/DaemonApp.cpp | 49 +++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/lib/deskflow/win32/DaemonApp.cpp b/src/lib/deskflow/win32/DaemonApp.cpp index 32afb1f8a..dd1710069 100644 --- a/src/lib/deskflow/win32/DaemonApp.cpp +++ b/src/lib/deskflow/win32/DaemonApp.cpp @@ -99,20 +99,51 @@ void DaemonApp::setElevate(bool elevate) void DaemonApp::applyWatchdogCommand() const { #if SYSAPI_WIN32 - QString binName; - if (m_mode == "server") { - binName = QStringLiteral(SERVER_BINARY_NAME ".exe"); - } else if (m_mode == "client") { - binName = QStringLiteral(CLIENT_BINARY_NAME ".exe"); - } else { + if (m_mode != "server" && m_mode != "client") { LOG_ERR("cannot apply watchdog command: invalid or unset mode: %s", m_mode.toUtf8().constData()); return; } - const auto binPath = QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), binName); - const auto command = QStringLiteral("\"%1\" %2").arg(binPath, m_args).toStdString(); + const auto appDir = QCoreApplication::applicationDirPath(); + const auto splitBinName = (m_mode == "server") // + ? QStringLiteral(SERVER_BINARY_NAME ".exe") + : QStringLiteral(CLIENT_BINARY_NAME ".exe"); + const auto coreBinName = QStringLiteral(CORE_BINARY_NAME ".exe"); + + const auto splitBinPath = QStringLiteral("%1/%2").arg(appDir, splitBinName); + const auto coreBinPath = QStringLiteral("%1/%2").arg(appDir, coreBinName); + + const bool splitExists = std::filesystem::exists(splitBinPath.toStdString()); + const bool coreExists = std::filesystem::exists(coreBinPath.toStdString()); + + LOG_INFO("watchdog binary probe: appDir=%s", appDir.toUtf8().constData()); + LOG_INFO( + "watchdog binary probe: split=%s exists=%s", splitBinPath.toUtf8().constData(), splitExists ? "yes" : "no" + ); + LOG_INFO( + "watchdog binary probe: core=%s exists=%s", coreBinPath.toUtf8().constData(), coreExists ? "yes" : "no" + ); + + std::string command; + const char *chosen = nullptr; + if (splitExists) { + chosen = "split"; + command = QStringLiteral("\"%1\" %2").arg(splitBinPath, m_args).toStdString(); + } else if (coreExists) { + // Unified build (BUILD_UNIFIED): no separate server/client exe is produced, so dispatch + // through the core binary using its server|client subcommand. + chosen = "core"; + command = QStringLiteral("\"%1\" %2 %3").arg(coreBinPath, m_mode, m_args).toStdString(); + } else { + LOG_ERR( + "cannot apply watchdog command: neither %s nor %s found in %s", // + splitBinName.toUtf8().constData(), coreBinName.toUtf8().constData(), appDir.toUtf8().constData() + ); + return; + } - LOG_DEBUG("applying watchdog command (elevate: %s)", m_elevate ? "yes" : "no"); + LOG_INFO("watchdog binary chosen: %s", chosen); + LOG_INFO("watchdog command (elevate: %s): %s", m_elevate ? "yes" : "no", command.c_str()); m_pWatchdog->setProcessConfig(command, m_elevate); #else LOG_ERR("applying watchdog command not implemented on this platform"); From ef9bfef3819af59674131fc82d6cc9436fa2decb Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 28 Apr 2026 19:22:15 +0100 Subject: [PATCH 2/6] feat: implement unified build support for watchdog command Co-authored-by: Copilot --- src/apps/CMakeLists.txt | 1 + src/lib/deskflow/win32/DaemonApp.cpp | 51 +++++++++------------------- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 33e833b06..adb7c0deb 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -17,6 +17,7 @@ add_subdirectory(deskflow-daemon) if(BUILD_UNIFIED) + add_definitions(-DBUILD_UNIFIED) add_subdirectory(deskflow-core) else() add_subdirectory(deskflow-client) diff --git a/src/lib/deskflow/win32/DaemonApp.cpp b/src/lib/deskflow/win32/DaemonApp.cpp index dd1710069..3704a46be 100644 --- a/src/lib/deskflow/win32/DaemonApp.cpp +++ b/src/lib/deskflow/win32/DaemonApp.cpp @@ -105,45 +105,26 @@ void DaemonApp::applyWatchdogCommand() const } const auto appDir = QCoreApplication::applicationDirPath(); - const auto splitBinName = (m_mode == "server") // - ? QStringLiteral(SERVER_BINARY_NAME ".exe") - : QStringLiteral(CLIENT_BINARY_NAME ".exe"); - const auto coreBinName = QStringLiteral(CORE_BINARY_NAME ".exe"); - - const auto splitBinPath = QStringLiteral("%1/%2").arg(appDir, splitBinName); - const auto coreBinPath = QStringLiteral("%1/%2").arg(appDir, coreBinName); - - const bool splitExists = std::filesystem::exists(splitBinPath.toStdString()); - const bool coreExists = std::filesystem::exists(coreBinPath.toStdString()); - - LOG_INFO("watchdog binary probe: appDir=%s", appDir.toUtf8().constData()); - LOG_INFO( - "watchdog binary probe: split=%s exists=%s", splitBinPath.toUtf8().constData(), splitExists ? "yes" : "no" - ); - LOG_INFO( - "watchdog binary probe: core=%s exists=%s", coreBinPath.toUtf8().constData(), coreExists ? "yes" : "no" - ); +#ifdef BUILD_UNIFIED + const auto binName = QStringLiteral(CORE_BINARY_NAME ".exe"); +#else + QString binName; + if (m_mode == "server") { + binName = QStringLiteral(SERVER_BINARY_NAME ".exe"); + } else if (m_mode == "client") { + binName = QStringLiteral(CLIENT_BINARY_NAME ".exe"); + } +#endif - std::string command; - const char *chosen = nullptr; - if (splitExists) { - chosen = "split"; - command = QStringLiteral("\"%1\" %2").arg(splitBinPath, m_args).toStdString(); - } else if (coreExists) { - // Unified build (BUILD_UNIFIED): no separate server/client exe is produced, so dispatch - // through the core binary using its server|client subcommand. - chosen = "core"; - command = QStringLiteral("\"%1\" %2 %3").arg(coreBinPath, m_mode, m_args).toStdString(); - } else { - LOG_ERR( - "cannot apply watchdog command: neither %s nor %s found in %s", // - splitBinName.toUtf8().constData(), coreBinName.toUtf8().constData(), appDir.toUtf8().constData() - ); + const auto binPath = QStringLiteral("%1/%2").arg(appDir, binName); + if (!std::filesystem::exists(binPath.toStdString())) { + LOG_ERR("cannot apply watchdog command: binary does not exist at path: %s", binPath.toUtf8().constData()); return; } - LOG_INFO("watchdog binary chosen: %s", chosen); - LOG_INFO("watchdog command (elevate: %s): %s", m_elevate ? "yes" : "no", command.c_str()); + const auto command = QStringLiteral("\"%1\" %2").arg(binPath, m_args).toStdString(); + + LOG_INFO("running command (%s): %s", m_elevate ? "elevated" : "non-elevated", command.c_str()); m_pWatchdog->setProcessConfig(command, m_elevate); #else LOG_ERR("applying watchdog command not implemented on this platform"); From f1a288057ea9519ebe7ce89277e5923509b301fa Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 28 Apr 2026 19:25:44 +0100 Subject: [PATCH 3/6] fix: replace add_definitions with add_compile_definitions for BUILD_UNIFIED --- src/apps/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index adb7c0deb..7840b1fcb 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -17,7 +17,7 @@ add_subdirectory(deskflow-daemon) if(BUILD_UNIFIED) - add_definitions(-DBUILD_UNIFIED) + add_compile_definitions(BUILD_UNIFIED) add_subdirectory(deskflow-core) else() add_subdirectory(deskflow-client) From cea9165242023ea1b9887396e9b73a861ada6757 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 28 Apr 2026 19:27:33 +0100 Subject: [PATCH 4/6] fix: move add_compile_definitions for BUILD_UNIFIED to configure_options macro Co-authored-by: Copilot --- cmake/Definitions.cmake | 4 ++++ src/apps/CMakeLists.txt | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/Definitions.cmake b/cmake/Definitions.cmake index 9cd7b5f0a..b2eae35ab 100644 --- a/cmake/Definitions.cmake +++ b/cmake/Definitions.cmake @@ -214,4 +214,8 @@ macro(configure_options) option(BUILD_UNIFIED "Build unified binary" ${DEFAULT_BUILD_UNIFIED}) option(ENABLE_COVERAGE "Enable test coverage" ${DEFAULT_ENABLE_COVERAGE}) + if(BUILD_UNIFIED) + add_compile_definitions(BUILD_UNIFIED) + endif() + endmacro() diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 7840b1fcb..33e833b06 100644 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -17,7 +17,6 @@ add_subdirectory(deskflow-daemon) if(BUILD_UNIFIED) - add_compile_definitions(BUILD_UNIFIED) add_subdirectory(deskflow-core) else() add_subdirectory(deskflow-client) From 6ff27dc2b01bb2497577ec02dd1d49ee9a09dce0 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 28 Apr 2026 19:27:55 +0100 Subject: [PATCH 5/6] fix: add missing newline before binName declaration in applyWatchdogCommand --- src/lib/deskflow/win32/DaemonApp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/deskflow/win32/DaemonApp.cpp b/src/lib/deskflow/win32/DaemonApp.cpp index 3704a46be..7099fbc07 100644 --- a/src/lib/deskflow/win32/DaemonApp.cpp +++ b/src/lib/deskflow/win32/DaemonApp.cpp @@ -105,6 +105,7 @@ void DaemonApp::applyWatchdogCommand() const } const auto appDir = QCoreApplication::applicationDirPath(); + #ifdef BUILD_UNIFIED const auto binName = QStringLiteral(CORE_BINARY_NAME ".exe"); #else From 8755223b667da9df4a54b0a2081cf9973f703375 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 28 Apr 2026 19:33:16 +0100 Subject: [PATCH 6/6] fix: update applyWatchdogCommand to support unified build command format Co-authored-by: Copilot --- src/lib/deskflow/win32/DaemonApp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/deskflow/win32/DaemonApp.cpp b/src/lib/deskflow/win32/DaemonApp.cpp index 7099fbc07..4bc14bed0 100644 --- a/src/lib/deskflow/win32/DaemonApp.cpp +++ b/src/lib/deskflow/win32/DaemonApp.cpp @@ -123,7 +123,11 @@ void DaemonApp::applyWatchdogCommand() const return; } +#ifdef BUILD_UNIFIED + const auto command = QStringLiteral("\"%1\" %2 %3").arg(binPath, m_mode, m_args).toStdString(); +#else const auto command = QStringLiteral("\"%1\" %2").arg(binPath, m_args).toStdString(); +#endif LOG_INFO("running command (%s): %s", m_elevate ? "elevated" : "non-elevated", command.c_str()); m_pWatchdog->setProcessConfig(command, m_elevate);