mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-21 03:55:41 -04:00
Build: Use deps DLLs on Windows
This commit is contained in:
@ -33,7 +33,6 @@ add_library(common
|
||||
md5_digest.h
|
||||
memory_settings_interface.cpp
|
||||
memory_settings_interface.h
|
||||
minizip_helpers.cpp
|
||||
minizip_helpers.h
|
||||
path.h
|
||||
perf_scope.cpp
|
||||
@ -61,7 +60,7 @@ add_library(common
|
||||
target_include_directories(common PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_include_directories(common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_link_libraries(common PUBLIC fmt Threads::Threads fast_float)
|
||||
target_link_libraries(common PRIVATE ZLIB::ZLIB minizip "${CMAKE_DL_LIBS}")
|
||||
target_link_libraries(common PRIVATE "${CMAKE_DL_LIBS}")
|
||||
|
||||
if(WIN32)
|
||||
target_sources(common PRIVATE
|
||||
|
@ -2,7 +2,7 @@
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories);$(SolutionDir)dep\fast_float\include;$(SolutionDir)dep\fmt\include;$(SolutionDir)dep\zlib\include;$(SolutionDir)dep\minizip\include;$(SolutionDir)dep\stb\include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories);$(SolutionDir)dep\fast_float\include;$(SolutionDir)dep\fmt\include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions);FMT_EXCEPTIONS=0</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
|
@ -56,7 +56,6 @@
|
||||
<ClCompile Include="memmap.cpp" />
|
||||
<ClCompile Include="memory_settings_interface.cpp" />
|
||||
<ClCompile Include="md5_digest.cpp" />
|
||||
<ClCompile Include="minizip_helpers.cpp" />
|
||||
<ClCompile Include="perf_scope.cpp" />
|
||||
<ClCompile Include="progress_callback.cpp" />
|
||||
<ClCompile Include="sha1_digest.cpp" />
|
||||
@ -87,15 +86,6 @@
|
||||
<ProjectReference Include="..\..\dep\fmt\fmt.vcxproj">
|
||||
<Project>{8be398e6-b882-4248-9065-fecc8728e038}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\minizip\minizip.vcxproj">
|
||||
<Project>{8bda439c-6358-45fb-9994-2ff083babe06}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\zlib\zlib.vcxproj">
|
||||
<Project>{7ff9fdb9-d504-47db-a16a-b08071999620}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\dep\zstd\zstd.vcxproj">
|
||||
<Project>{73ee0c55-6ffe-44e7-9c12-baa52434a797}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\marmasm.targets" />
|
||||
@ -113,7 +103,6 @@
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)/</ObjectFileName>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)dep\zstd\lib</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="..\..\dep\msvc\vsprops\Targets.props" />
|
||||
|
@ -56,7 +56,6 @@
|
||||
<ClCompile Include="string_util.cpp" />
|
||||
<ClCompile Include="md5_digest.cpp" />
|
||||
<ClCompile Include="progress_callback.cpp" />
|
||||
<ClCompile Include="minizip_helpers.cpp" />
|
||||
<ClCompile Include="thirdparty\StackWalker.cpp">
|
||||
<Filter>thirdparty</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1,93 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "minizip_helpers.h"
|
||||
#include "file_system.h"
|
||||
#include "ioapi.h"
|
||||
#include "types.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace MinizipHelpers {
|
||||
|
||||
unzFile OpenUnzMemoryFile(const void* memory, size_t memory_size)
|
||||
{
|
||||
struct MemoryFileInfo
|
||||
{
|
||||
const u8* data;
|
||||
ZPOS64_T data_size;
|
||||
ZPOS64_T position;
|
||||
};
|
||||
|
||||
MemoryFileInfo* fi = new MemoryFileInfo;
|
||||
fi->data = static_cast<const u8*>(memory);
|
||||
fi->data_size = static_cast<ZPOS64_T>(memory_size);
|
||||
fi->position = 0;
|
||||
|
||||
#define FI static_cast<MemoryFileInfo*>(stream)
|
||||
|
||||
zlib_filefunc64_def funcs = {
|
||||
[](voidpf opaque, const void* filename, int mode) -> voidpf { return opaque; }, // open
|
||||
[](voidpf opaque, voidpf stream, void* buf, uLong size) -> uLong { // read
|
||||
const ZPOS64_T remaining = FI->data_size - FI->position;
|
||||
const ZPOS64_T to_read = std::min(remaining, static_cast<ZPOS64_T>(size));
|
||||
if (to_read > 0)
|
||||
{
|
||||
std::memcpy(buf, FI->data + FI->position, to_read);
|
||||
FI->position += to_read;
|
||||
}
|
||||
|
||||
return static_cast<uLong>(to_read);
|
||||
},
|
||||
[](voidpf opaque, voidpf stream, const void* buf, uLong size) -> uLong { return 0; }, // write
|
||||
[](voidpf opaque, voidpf stream) -> ZPOS64_T { return static_cast<ZPOS64_T>(FI->position); }, // tell
|
||||
[](voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) -> long { // seek
|
||||
ZPOS64_T new_position = FI->position;
|
||||
if (origin == SEEK_SET)
|
||||
new_position = static_cast<int>(offset);
|
||||
else if (origin == SEEK_CUR)
|
||||
new_position += static_cast<int>(offset);
|
||||
else
|
||||
new_position = FI->data_size;
|
||||
if (new_position < 0 || new_position > FI->data_size)
|
||||
return -1;
|
||||
|
||||
FI->position = new_position;
|
||||
return 0;
|
||||
},
|
||||
[](voidpf opaque, voidpf stream) -> int {
|
||||
delete FI;
|
||||
return 0;
|
||||
}, // close
|
||||
[](voidpf opaque, voidpf stream) -> int { return 0; }, // testerror
|
||||
static_cast<voidpf>(fi)};
|
||||
|
||||
#undef FI
|
||||
|
||||
unzFile zf = unzOpen2_64("", &funcs);
|
||||
if (!zf)
|
||||
delete fi;
|
||||
|
||||
return zf;
|
||||
}
|
||||
|
||||
unzFile OpenUnzFile(const char* filename)
|
||||
{
|
||||
zlib_filefunc64_def funcs;
|
||||
fill_fopen64_filefunc(&funcs);
|
||||
|
||||
funcs.zopen64_file = [](voidpf opaque, const void* filename, int mode) -> voidpf {
|
||||
const char* mode_fopen = NULL;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = "r+b";
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = "wb";
|
||||
|
||||
return FileSystem::OpenCFile(static_cast<const char*>(filename), mode_fopen);
|
||||
};
|
||||
|
||||
return unzOpen2_64(filename, &funcs);
|
||||
}
|
||||
|
||||
} // namespace MinizipHelpers
|
@ -1,12 +1,95 @@
|
||||
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "file_system.h"
|
||||
#include "ioapi.h"
|
||||
#include "types.h"
|
||||
#include "unzip.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace MinizipHelpers {
|
||||
|
||||
unzFile OpenUnzMemoryFile(const void* memory, size_t memory_size);
|
||||
unzFile OpenUnzFile(const char* filename);
|
||||
[[maybe_unused]] static unzFile OpenUnzMemoryFile(const void* memory, size_t memory_size)
|
||||
{
|
||||
struct MemoryFileInfo
|
||||
{
|
||||
const u8* data;
|
||||
ZPOS64_T data_size;
|
||||
ZPOS64_T position;
|
||||
};
|
||||
|
||||
MemoryFileInfo* fi = new MemoryFileInfo;
|
||||
fi->data = static_cast<const u8*>(memory);
|
||||
fi->data_size = static_cast<ZPOS64_T>(memory_size);
|
||||
fi->position = 0;
|
||||
|
||||
#define FI static_cast<MemoryFileInfo*>(stream)
|
||||
|
||||
zlib_filefunc64_def funcs = {
|
||||
[](voidpf opaque, const void* filename, int mode) -> voidpf { return opaque; }, // open
|
||||
[](voidpf opaque, voidpf stream, void* buf, uLong size) -> uLong { // read
|
||||
const ZPOS64_T remaining = FI->data_size - FI->position;
|
||||
const ZPOS64_T to_read = std::min(remaining, static_cast<ZPOS64_T>(size));
|
||||
if (to_read > 0)
|
||||
{
|
||||
std::memcpy(buf, FI->data + FI->position, to_read);
|
||||
FI->position += to_read;
|
||||
}
|
||||
|
||||
return static_cast<uLong>(to_read);
|
||||
},
|
||||
[](voidpf opaque, voidpf stream, const void* buf, uLong size) -> uLong { return 0; }, // write
|
||||
[](voidpf opaque, voidpf stream) -> ZPOS64_T { return static_cast<ZPOS64_T>(FI->position); }, // tell
|
||||
[](voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) -> long { // seek
|
||||
ZPOS64_T new_position = FI->position;
|
||||
if (origin == SEEK_SET)
|
||||
new_position = static_cast<int>(offset);
|
||||
else if (origin == SEEK_CUR)
|
||||
new_position += static_cast<int>(offset);
|
||||
else
|
||||
new_position = FI->data_size;
|
||||
if (new_position < 0 || new_position > FI->data_size)
|
||||
return -1;
|
||||
|
||||
FI->position = new_position;
|
||||
return 0;
|
||||
},
|
||||
[](voidpf opaque, voidpf stream) -> int {
|
||||
delete FI;
|
||||
return 0;
|
||||
}, // close
|
||||
[](voidpf opaque, voidpf stream) -> int { return 0; }, // testerror
|
||||
static_cast<voidpf>(fi)};
|
||||
|
||||
#undef FI
|
||||
|
||||
unzFile zf = unzOpen2_64("", &funcs);
|
||||
if (!zf)
|
||||
delete fi;
|
||||
|
||||
return zf;
|
||||
}
|
||||
|
||||
[[maybe_unused]] static unzFile OpenUnzFile(const char* filename)
|
||||
{
|
||||
zlib_filefunc64_def funcs;
|
||||
fill_fopen64_filefunc(&funcs);
|
||||
|
||||
funcs.zopen64_file = [](voidpf opaque, const void* filename, int mode) -> voidpf {
|
||||
const char* mode_fopen = NULL;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = "rb";
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = "r+b";
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = "wb";
|
||||
|
||||
return FileSystem::OpenCFile(static_cast<const char*>(filename), mode_fopen);
|
||||
};
|
||||
|
||||
return unzOpen2_64(filename, &funcs);
|
||||
}
|
||||
|
||||
} // namespace MinizipHelpers
|
Reference in New Issue
Block a user