mirror of https://github.com/stenzek/duckstation
Build: Use deps DLLs on Windows
parent
68ff16e187
commit
b143d96476
@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Label="UserMacros">
|
||||
<SDL2BinaryOutputDir>$(SolutionDir)bin\$(Platform)\</SDL2BinaryOutputDir>
|
||||
<SDL2Dir>$(SolutionDir)dep\msvc\sdl2\</SDL2Dir>
|
||||
<SDL2Dir Condition="'$(Platform)'=='x64'">$(SolutionDir)dep\msvc\deps-x64\</SDL2Dir>
|
||||
<SDL2Dir Condition="'$(Platform)'=='ARM64'">$(SolutionDir)dep\msvc\deps-arm64\</SDL2Dir>
|
||||
<SDL2LibSuffix></SDL2LibSuffix>
|
||||
<SDL2LibSuffix Condition="$(Configuration.Contains(Debug))">d</SDL2LibSuffix>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SDL2Dir)include\SDL2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(SDL2Dir)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>SDL2$(SDL2LibSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>$(SDL2Dir)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>SDL2$(SDL2LibSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<!--Copy the needed dlls-->
|
||||
<ItemGroup>
|
||||
<SDL2Dlls Include="$(SDL2Dir)bin\SDL2$(SDL2LibSuffix).dll" />
|
||||
</ItemGroup>
|
||||
<Target Name="SDL2CopyBinaries"
|
||||
AfterTargets="Build"
|
||||
Inputs="@(SDL2Dlls)"
|
||||
Outputs="@(SDL2Dlls -> '$(SDL2BinaryOutputDir)%(RecursiveDir)%(Filename)%(Extension)')">
|
||||
<Message Text="Copying SDL2 .dlls" Importance="High" />
|
||||
<Copy
|
||||
SourceFiles="@(SDL2Dlls)"
|
||||
DestinationFolder="$(SDL2BinaryOutputDir)"
|
||||
SkipUnchangedFiles="true"
|
||||
/>
|
||||
</Target>
|
||||
</Project>
|
||||
@ -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
|
||||
Loading…
Reference in New Issue