Make zstd mandatory - it'll also be used for compression in online nifi

This commit is contained in:
Nadia Holmquist Pedersen 2023-04-28 19:04:08 +02:00
parent 3f61538844
commit 4846219327
3 changed files with 4 additions and 25 deletions

View File

@ -82,9 +82,7 @@ endif()
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2)
pkg_check_modules(Slirp REQUIRED IMPORTED_TARGET slirp)
pkg_check_modules(LibArchive REQUIRED IMPORTED_TARGET libarchive)
pkg_check_modules(Zstd IMPORTED_TARGET libzstd)
cmake_dependent_option(ENABLE_ZSTD "Enable support for Zstandard-compressed ROMs" ON "Zstd_FOUND" OFF)
pkg_check_modules(Zstd REQUIRED IMPORTED_TARGET libzstd)
fix_interface_includes(PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
@ -157,14 +155,9 @@ else()
target_include_directories(melonDS PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif()
target_link_libraries(melonDS PRIVATE core)
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive PkgConfig::Zstd)
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
if (ENABLE_ZSTD)
target_compile_definitions(melonDS PRIVATE ZSTD_ENABLED)
target_link_libraries(melonDS PRIVATE PkgConfig::Zstd)
endif()
if (UNIX)
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF)
elseif (WIN32)

View File

@ -22,9 +22,7 @@
#include <string>
#include <utility>
#ifdef ZSTD_ENABLED
#include <zstd.h>
#endif
#ifdef ARCHIVE_SUPPORT_ENABLED
#include "ArchiveUtil.h"
#endif
@ -481,7 +479,6 @@ bool LoadBIOS()
return true;
}
#ifdef ZSTD_ENABLED
u32 DecompressROM(const u8* inContent, const u32 inSize, u8** outContent)
{
u64 realSize = ZSTD_getFrameContentSize(inContent, inSize);
@ -503,7 +500,6 @@ u32 DecompressROM(const u8* inContent, const u32 inSize, u8** outContent)
*outContent = realContent;
return realSize;
}
#endif
bool LoadROM(QStringList filepath, bool reset)
{
@ -546,7 +542,6 @@ bool LoadROM(QStringList filepath, bool reset)
fclose(f);
filelen = (u32)len;
#if ZSTD_ENABLED
if (filename.length() > 4 && filename.substr(filename.length() - 4) == ".zst")
{
u8* outContent = nullptr;
@ -565,7 +560,6 @@ bool LoadROM(QStringList filepath, bool reset)
return false;
}
}
#endif
int pos = LastSep(filename);
if(pos != -1)
@ -729,7 +723,6 @@ bool LoadGBAROM(QStringList filepath)
fclose(f);
filelen = (u32)len;
#if ZSTD_ENABLED
if (filename.length() > 4 && filename.substr(filename.length() - 4) == ".zst")
{
u8* outContent = nullptr;
@ -748,7 +741,6 @@ bool LoadGBAROM(QStringList filepath)
return false;
}
}
#endif
int pos = LastSep(filename);
basepath = filename.substr(0, pos);

View File

@ -1568,7 +1568,6 @@ static bool SupportedArchiveByMimetype(const QMimeType& mimetype)
return MimeTypeInList(mimetype, ArchiveMimeTypes);
}
#ifdef ZSTD_ENABLED
static bool ZstdNdsRomByExtension(const QString& filename)
{
if (filename.endsWith(".zst", Qt::CaseInsensitive))
@ -1580,14 +1579,12 @@ static bool ZstdGbaRomByExtension(const QString& filename)
if (filename.endsWith(".zst", Qt::CaseInsensitive))
return GbaRomByExtension(filename.left(filename.size() - 4));
}
#endif
static bool FileIsSupportedFiletype(const QString& filename, bool insideArchive = false)
{
#ifdef ZSTD_ENABLED
if (ZstdNdsRomByExtension(filename) || ZstdGbaRomByExtension(filename))
return true;
#endif
if (NdsRomByExtension(filename) || GbaRomByExtension(filename) || SupportedArchiveByExtension(filename))
return true;
@ -2226,10 +2223,8 @@ void MainWindow::dropEvent(QDropEvent* event)
bool isNdsRom = NdsRomByExtension(filename) || NdsRomByMimetype(mimetype);
bool isGbaRom = GbaRomByExtension(filename) || GbaRomByMimetype(mimetype);
#ifdef ZSTD_ENABLED
isNdsRom |= ZstdNdsRomByExtension(filename);
isGbaRom |= ZstdGbaRomByExtension(filename);
#endif
if (isNdsRom)
{
@ -2480,11 +2475,10 @@ QStringList MainWindow::pickROM(bool gba)
QString extraFilters = ";;" + console + " ROMs (*" + rawROMs;
QString allROMs = rawROMs;
#ifdef ZSTD_ENABLED
QString zstdROMs = "*" + romexts.join(".zst *") + ".zst";
extraFilters += ");;Zstandard-compressed " + console + " ROMs (" + zstdROMs + ")";
allROMs += " " + zstdROMs;
#endif
#ifdef ARCHIVE_SUPPORT_ENABLED
QString archives = "*" + ArchiveExtensions.join(" *");
extraFilters += ";;Archives (" + archives + ")";