From fbd36a43476d6fd9d2e20c2a81ad01d5a12abff4 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 13 May 2022 02:07:09 +1000 Subject: [PATCH] Qt: Fix building on Linux --- CMakeLists.txt | 6 +++++- pcsx2-qt/CMakeLists.txt | 11 +++++++++++ updater/CMakeLists.txt | 5 ++++- updater/Updater.cpp | 27 ++++++++++++++++++++++----- updater/Updater.h | 5 +++++ updater/UpdaterExtractor.h | 3 +-- 6 files changed, 48 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1ec133da4..91a2c67569 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,11 @@ add_subdirectory(pcsx2) if (QT_BUILD) add_subdirectory(pcsx2-qt) - add_subdirectory(updater) + + # Updater is Windows only for now. + if (WIN32) + add_subdirectory(updater) + endif() endif() # tests diff --git a/pcsx2-qt/CMakeLists.txt b/pcsx2-qt/CMakeLists.txt index 9643bf325f..bdcc02057d 100644 --- a/pcsx2-qt/CMakeLists.txt +++ b/pcsx2-qt/CMakeLists.txt @@ -14,6 +14,9 @@ target_sources(pcsx2-qt PRIVATE AboutDialog.cpp AboutDialog.h AboutDialog.ui + AutoUpdaterDialog.cpp + AutoUpdaterDialog.h + AutoUpdaterDialog.ui DisplayWidget.cpp DisplayWidget.h EmuThread.cpp @@ -118,3 +121,11 @@ target_link_libraries(pcsx2-qt PRIVATE Qt6::Widgets Qt6::Network ) + +# Currently, 7z is only needed for the Windows updater. +if(WIN32) + target_link_libraries(pcsx2-qt PRIVATE + LZMA::LZMA + ) +endif() + diff --git a/updater/CMakeLists.txt b/updater/CMakeLists.txt index 5711bbcc2c..19b7192f0c 100644 --- a/updater/CMakeLists.txt +++ b/updater/CMakeLists.txt @@ -3,9 +3,12 @@ add_executable(updater Updater.h ) -target_link_libraries(updater PRIVATE common fmt::fmt lzma) +target_link_libraries(updater PRIVATE common fmt::fmt) if(WIN32) + target_link_libraries(updater PRIVATE + LZMA::LZMA + ) target_sources(updater PRIVATE Win32Update.cpp ) diff --git a/updater/Updater.cpp b/updater/Updater.cpp index 087f98120e..d09773463b 100644 --- a/updater/Updater.cpp +++ b/updater/Updater.cpp @@ -14,7 +14,6 @@ */ #include "Updater.h" -#include "SZErrors.h" #include "common/Console.h" #include "common/FileSystem.h" @@ -22,9 +21,6 @@ #include "common/ScopedGuard.h" #include "common/StringUtil.h" -#include "7zAlloc.h" -#include "7zCrc.h" - #include #include #include @@ -37,8 +33,15 @@ #include #endif +#ifdef _WIN32 + +#include "7zAlloc.h" +#include "7zCrc.h" +#include "SZErrors.h" + static constexpr size_t kInputBufSize = ((size_t)1 << 18); static constexpr ISzAlloc g_Alloc = {SzAlloc, SzFree}; +#endif static std::FILE* s_file_console_stream; static constexpr IConsoleWriter s_file_console_writer = { @@ -81,6 +84,7 @@ Updater::Updater(ProgressCallback* progress) Updater::~Updater() { +#ifdef _WIN32 if (m_archive_opened) SzArEx_Free(&m_archive, &g_Alloc); @@ -88,6 +92,7 @@ Updater::~Updater() if (m_file_opened) File_Close(&m_archive_stream.file); +#endif } void Updater::SetupLogging(ProgressCallback* progress, const std::string& destination_directory) @@ -116,6 +121,7 @@ bool Updater::Initialize(std::string destination_directory) bool Updater::OpenUpdateZip(const char* path) { +#ifdef _WIN32 FileInStream_CreateVTable(&m_archive_stream); LookToRead2_CreateVTable(&m_look_stream, False); CrcGenerateTable(); @@ -155,6 +161,9 @@ bool Updater::OpenUpdateZip(const char* path) m_archive_opened = true; m_progress->SetStatusText("Parsing update zip..."); return ParseZip(); +#else + return false; +#endif } bool Updater::RecursiveDeleteDirectory(const char* path) @@ -171,12 +180,13 @@ bool Updater::RecursiveDeleteDirectory(const char* path) return (SHFileOperationW(&op) == 0 && !op.fAnyOperationsAborted); #else - return FileSystem::DeleteDirectory(path, true); + return FileSystem::RecursiveDeleteDirectory(path); #endif } bool Updater::ParseZip() { +#ifdef _WIN32 std::vector filename_buffer; for (u32 file_index = 0; file_index < m_archive.NumFiles; file_index++) @@ -250,6 +260,9 @@ bool Updater::ParseZip() m_progress->DisplayFormattedDebugMessage("Directory: %s", dir.c_str()); return true; +#else + return false; +#endif } bool Updater::PrepareStagingDirectory() @@ -292,6 +305,7 @@ bool Updater::StageUpdate() m_progress->SetProgressRange(static_cast(m_update_paths.size())); m_progress->SetProgressValue(0); +#ifdef _WIN32 UInt32 block_index = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */ Byte* out_buffer = 0; /* it must be 0 before first call for each new archive. */ size_t out_buffer_size = 0; /* it can have any value before first call (if outBuffer = 0) */ @@ -339,6 +353,9 @@ bool Updater::StageUpdate() } return true; +#else + return false; +#endif } bool Updater::CommitUpdate() diff --git a/updater/Updater.h b/updater/Updater.h index b697091c85..9503b436d7 100644 --- a/updater/Updater.h +++ b/updater/Updater.h @@ -17,8 +17,10 @@ #include "common/ProgressCallback.h" +#ifdef _WIN32 #include "7z.h" #include "7zFile.h" +#endif #include #include @@ -57,10 +59,13 @@ private: std::vector m_update_directories; ProgressCallback* m_progress; + +#ifdef _WIN32 CFileInStream m_archive_stream = {}; CLookToRead2 m_look_stream = {}; CSzArEx m_archive = {}; bool m_file_opened = false; bool m_archive_opened = false; +#endif }; diff --git a/updater/UpdaterExtractor.h b/updater/UpdaterExtractor.h index 608e861c15..6dc26ad6d0 100644 --- a/updater/UpdaterExtractor.h +++ b/updater/UpdaterExtractor.h @@ -15,8 +15,6 @@ #pragma once -#include "SZErrors.h" - #include "common/FileSystem.h" #include "common/ScopedGuard.h" #include "common/StringUtil.h" @@ -28,6 +26,7 @@ #include "7zAlloc.h" #include "7zCrc.h" #include "7zFile.h" +#include "SZErrors.h" #endif #include