Qt: Fix building on Linux

This commit is contained in:
Connor McLaughlin 2022-05-13 02:07:09 +10:00 committed by refractionpcsx2
parent 7f8bfb22de
commit fbd36a4347
6 changed files with 48 additions and 9 deletions

View File

@ -42,8 +42,12 @@ add_subdirectory(pcsx2)
if (QT_BUILD) if (QT_BUILD)
add_subdirectory(pcsx2-qt) add_subdirectory(pcsx2-qt)
# Updater is Windows only for now.
if (WIN32)
add_subdirectory(updater) add_subdirectory(updater)
endif() endif()
endif()
# tests # tests
if(ACTUALLY_ENABLE_TESTS) if(ACTUALLY_ENABLE_TESTS)

View File

@ -14,6 +14,9 @@ target_sources(pcsx2-qt PRIVATE
AboutDialog.cpp AboutDialog.cpp
AboutDialog.h AboutDialog.h
AboutDialog.ui AboutDialog.ui
AutoUpdaterDialog.cpp
AutoUpdaterDialog.h
AutoUpdaterDialog.ui
DisplayWidget.cpp DisplayWidget.cpp
DisplayWidget.h DisplayWidget.h
EmuThread.cpp EmuThread.cpp
@ -118,3 +121,11 @@ target_link_libraries(pcsx2-qt PRIVATE
Qt6::Widgets Qt6::Widgets
Qt6::Network Qt6::Network
) )
# Currently, 7z is only needed for the Windows updater.
if(WIN32)
target_link_libraries(pcsx2-qt PRIVATE
LZMA::LZMA
)
endif()

View File

@ -3,9 +3,12 @@ add_executable(updater
Updater.h Updater.h
) )
target_link_libraries(updater PRIVATE common fmt::fmt lzma) target_link_libraries(updater PRIVATE common fmt::fmt)
if(WIN32) if(WIN32)
target_link_libraries(updater PRIVATE
LZMA::LZMA
)
target_sources(updater PRIVATE target_sources(updater PRIVATE
Win32Update.cpp Win32Update.cpp
) )

View File

@ -14,7 +14,6 @@
*/ */
#include "Updater.h" #include "Updater.h"
#include "SZErrors.h"
#include "common/Console.h" #include "common/Console.h"
#include "common/FileSystem.h" #include "common/FileSystem.h"
@ -22,9 +21,6 @@
#include "common/ScopedGuard.h" #include "common/ScopedGuard.h"
#include "common/StringUtil.h" #include "common/StringUtil.h"
#include "7zAlloc.h"
#include "7zCrc.h"
#include <algorithm> #include <algorithm>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
@ -37,8 +33,15 @@
#include <shellapi.h> #include <shellapi.h>
#endif #endif
#ifdef _WIN32
#include "7zAlloc.h"
#include "7zCrc.h"
#include "SZErrors.h"
static constexpr size_t kInputBufSize = ((size_t)1 << 18); static constexpr size_t kInputBufSize = ((size_t)1 << 18);
static constexpr ISzAlloc g_Alloc = {SzAlloc, SzFree}; static constexpr ISzAlloc g_Alloc = {SzAlloc, SzFree};
#endif
static std::FILE* s_file_console_stream; static std::FILE* s_file_console_stream;
static constexpr IConsoleWriter s_file_console_writer = { static constexpr IConsoleWriter s_file_console_writer = {
@ -81,6 +84,7 @@ Updater::Updater(ProgressCallback* progress)
Updater::~Updater() Updater::~Updater()
{ {
#ifdef _WIN32
if (m_archive_opened) if (m_archive_opened)
SzArEx_Free(&m_archive, &g_Alloc); SzArEx_Free(&m_archive, &g_Alloc);
@ -88,6 +92,7 @@ Updater::~Updater()
if (m_file_opened) if (m_file_opened)
File_Close(&m_archive_stream.file); File_Close(&m_archive_stream.file);
#endif
} }
void Updater::SetupLogging(ProgressCallback* progress, const std::string& destination_directory) 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) bool Updater::OpenUpdateZip(const char* path)
{ {
#ifdef _WIN32
FileInStream_CreateVTable(&m_archive_stream); FileInStream_CreateVTable(&m_archive_stream);
LookToRead2_CreateVTable(&m_look_stream, False); LookToRead2_CreateVTable(&m_look_stream, False);
CrcGenerateTable(); CrcGenerateTable();
@ -155,6 +161,9 @@ bool Updater::OpenUpdateZip(const char* path)
m_archive_opened = true; m_archive_opened = true;
m_progress->SetStatusText("Parsing update zip..."); m_progress->SetStatusText("Parsing update zip...");
return ParseZip(); return ParseZip();
#else
return false;
#endif
} }
bool Updater::RecursiveDeleteDirectory(const char* path) bool Updater::RecursiveDeleteDirectory(const char* path)
@ -171,12 +180,13 @@ bool Updater::RecursiveDeleteDirectory(const char* path)
return (SHFileOperationW(&op) == 0 && !op.fAnyOperationsAborted); return (SHFileOperationW(&op) == 0 && !op.fAnyOperationsAborted);
#else #else
return FileSystem::DeleteDirectory(path, true); return FileSystem::RecursiveDeleteDirectory(path);
#endif #endif
} }
bool Updater::ParseZip() bool Updater::ParseZip()
{ {
#ifdef _WIN32
std::vector<UInt16> filename_buffer; std::vector<UInt16> filename_buffer;
for (u32 file_index = 0; file_index < m_archive.NumFiles; file_index++) 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()); m_progress->DisplayFormattedDebugMessage("Directory: %s", dir.c_str());
return true; return true;
#else
return false;
#endif
} }
bool Updater::PrepareStagingDirectory() bool Updater::PrepareStagingDirectory()
@ -292,6 +305,7 @@ bool Updater::StageUpdate()
m_progress->SetProgressRange(static_cast<u32>(m_update_paths.size())); m_progress->SetProgressRange(static_cast<u32>(m_update_paths.size()));
m_progress->SetProgressValue(0); m_progress->SetProgressValue(0);
#ifdef _WIN32
UInt32 block_index = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */ 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. */ 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) */ 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; return true;
#else
return false;
#endif
} }
bool Updater::CommitUpdate() bool Updater::CommitUpdate()

View File

@ -17,8 +17,10 @@
#include "common/ProgressCallback.h" #include "common/ProgressCallback.h"
#ifdef _WIN32
#include "7z.h" #include "7z.h"
#include "7zFile.h" #include "7zFile.h"
#endif
#include <string> #include <string>
#include <vector> #include <vector>
@ -57,10 +59,13 @@ private:
std::vector<std::string> m_update_directories; std::vector<std::string> m_update_directories;
ProgressCallback* m_progress; ProgressCallback* m_progress;
#ifdef _WIN32
CFileInStream m_archive_stream = {}; CFileInStream m_archive_stream = {};
CLookToRead2 m_look_stream = {}; CLookToRead2 m_look_stream = {};
CSzArEx m_archive = {}; CSzArEx m_archive = {};
bool m_file_opened = false; bool m_file_opened = false;
bool m_archive_opened = false; bool m_archive_opened = false;
#endif
}; };

View File

@ -15,8 +15,6 @@
#pragma once #pragma once
#include "SZErrors.h"
#include "common/FileSystem.h" #include "common/FileSystem.h"
#include "common/ScopedGuard.h" #include "common/ScopedGuard.h"
#include "common/StringUtil.h" #include "common/StringUtil.h"
@ -28,6 +26,7 @@
#include "7zAlloc.h" #include "7zAlloc.h"
#include "7zCrc.h" #include "7zCrc.h"
#include "7zFile.h" #include "7zFile.h"
#include "SZErrors.h"
#endif #endif
#include <cstdio> #include <cstdio>