Externals/FatFs: Build as part of Dolphin.

Co-authored-by: Pablo Stebler <pablo@stebler.xyz>
This commit is contained in:
Admiral H. Curtiss 2022-04-17 03:06:55 +02:00
parent 4ad00e84e7
commit fdc327c252
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
10 changed files with 145 additions and 0 deletions

View File

@ -969,6 +969,8 @@ include_directories(Externals/picojson)
add_subdirectory(Externals/rangeset)
add_subdirectory(Externals/FatFs)
########################################
# Pre-build events: Define configuration variables and write SCM info header
#

View File

@ -34,6 +34,9 @@
<ProjectReference Include="$(ExternalsDir)enet\enet.vcxproj">
<Project>{cbc76802-c128-4b17-bf6c-23b08c313e5e}</Project>
</ProjectReference>
<ProjectReference Include="$(ExternalsDir)FatFs\FatFs.vcxproj">
<Project>{3F17D282-A77D-4931-B844-903AD0809A5E}</Project>
</ProjectReference>
<ProjectReference Include="$(ExternalsDir)fmt\fmt.vcxproj">
<Project>{4BC5A148-0AB3-440F-A980-A29B4B999190}</Project>
</ProjectReference>

12
Externals/FatFs/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,12 @@
add_library(FatFs STATIC
ff.c
ffunicode.c
diskio.h
ff.h
ffconf.h
)
target_include_directories(FatFs
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

33
Externals/FatFs/FatFs.vcxproj vendored Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\Source\VSProps\Base.Macros.props" />
<Import Project="$(VSPropsDir)Base.Targets.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{3F17D282-A77D-4931-B844-903AD0809A5E}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VSPropsDir)Configuration.StaticLibrary.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VSPropsDir)Base.props" />
<Import Project="$(VSPropsDir)ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
<ClCompile Include="ff.c" />
<ClCompile Include="ffunicode.c" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="diskio.h" />
<ClInclude Include="ff.h" />
<ClInclude Include="ffconf.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -14,6 +14,8 @@ Dolphin includes or links code of the following third-party software projects:
[MIT](https://github.com/discordapp/discord-rpc/blob/master/LICENSE)
- [ENet](http://enet.bespin.org/):
[MIT](http://enet.bespin.org/License.html)
- [FatFs](http://elm-chan.org/fsw/ff/00index_e.html):
[BSD-1-Clause](http://elm-chan.org/fsw/ff/doc/appnote.html#license)
- [GCEmu](http://sourceforge.net/projects/gcemu-project/):
GPLv2+
- [gettext](https://www.gnu.org/software/gettext/):

View File

@ -44,6 +44,7 @@ add_library(common
EnumFormatter.h
EnumMap.h
Event.h
FatFsUtil.cpp
FileSearch.cpp
FileSearch.h
FileUtil.cpp
@ -144,6 +145,7 @@ PUBLIC
PRIVATE
${CURL_LIBRARIES}
FatFs
${ICONV_LIBRARIES}
png
${VTUNE_LIBRARIES}

View File

@ -0,0 +1,78 @@
// Copyright 2022 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <cstdlib>
#include <mutex>
// Does not compile if diskio.h is included first.
// clang-format off
#include "ff.h"
#include "diskio.h"
// clang-format on
// For now this is just mostly dummy functions so FatFs actually links.
extern "C" DSTATUS disk_status(BYTE pdrv)
{
return STA_NOINIT;
}
extern "C" DSTATUS disk_initialize(BYTE pdrv)
{
return STA_NOINIT;
}
extern "C" DRESULT disk_read(BYTE pdrv, BYTE* buff, LBA_t sector, UINT count)
{
return RES_PARERR;
}
extern "C" DRESULT disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count)
{
return RES_PARERR;
}
extern "C" DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff)
{
return RES_PARERR;
}
extern "C" DWORD get_fattime(void)
{
return 0;
}
extern "C" void* ff_memalloc(UINT msize)
{
return std::malloc(msize);
}
extern "C" void ff_memfree(void* mblock)
{
return std::free(mblock);
}
extern "C" int ff_cre_syncobj(BYTE vol, FF_SYNC_t* sobj)
{
*sobj = new std::recursive_mutex();
return *sobj != nullptr;
}
extern "C" int ff_req_grant(FF_SYNC_t sobj)
{
std::recursive_mutex* m = reinterpret_cast<std::recursive_mutex*>(sobj);
m->lock();
return 1;
}
extern "C" void ff_rel_grant(FF_SYNC_t sobj)
{
std::recursive_mutex* m = reinterpret_cast<std::recursive_mutex*>(sobj);
m->unlock();
}
extern "C" int ff_del_syncobj(FF_SYNC_t sobj)
{
delete reinterpret_cast<std::recursive_mutex*>(sobj);
return 1;
}

View File

@ -725,6 +725,7 @@
<ClCompile Include="Common\Debug\Watches.cpp" />
<ClCompile Include="Common\DynamicLibrary.cpp" />
<ClCompile Include="Common\ENetUtil.cpp" />
<ClCompile Include="Common\FatFsUtil.cpp" />
<ClCompile Include="Common\FileSearch.cpp" />
<ClCompile Include="Common\FileUtil.cpp" />
<ClCompile Include="Common\FloatUtils.cpp" />

View File

@ -35,6 +35,7 @@
<AdditionalIncludeDirectories>$(ExternalsDir)ed25519;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ExternalsDir)enet\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ExternalsDir)FFmpeg-bin\$(Platform)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ExternalsDir)FatFs;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ExternalsDir)fmt\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ExternalsDir)GL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ExternalsDir)glslang;$(ExternalsDir)glslang\StandAlone;$(ExternalsDir)glslang\glslang\Public;$(ExternalsDir)glslang\SPIRV;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

View File

@ -83,6 +83,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spirv_cross", "..\Externals
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "..\Externals\SDL\SDL2.vcxproj", "{8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FatFs", "..\Externals\FatFs\FatFs.vcxproj", "{3F17D282-A77D-4931-B844-903AD0809A5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
@ -399,6 +401,14 @@ Global
{8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Release|ARM64.Build.0 = Release|ARM64
{8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Release|x64.ActiveCfg = Release|x64
{8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA}.Release|x64.Build.0 = Release|x64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Debug|ARM64.ActiveCfg = Debug|ARM64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Debug|ARM64.Build.0 = Debug|ARM64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Debug|x64.ActiveCfg = Debug|x64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Debug|x64.Build.0 = Debug|x64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Release|ARM64.ActiveCfg = Release|ARM64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Release|ARM64.Build.0 = Release|ARM64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Release|x64.ActiveCfg = Release|x64
{3F17D282-A77D-4931-B844-903AD0809A5E}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -433,6 +443,7 @@ Global
{4BC5A148-0AB3-440F-A980-A29B4B999190} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{3D780617-EC8C-4721-B9FD-DFC9BB658C7C} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{8DC244EE-A0BD-4038-BAF7-CFAFA5EB2BAA} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
{3F17D282-A77D-4931-B844-903AD0809A5E} = {87ADDFF9-5768-4DA2-A33B-2477593D6677}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {64B0A343-3B94-4522-9C24-6937FE5EFB22}