From 44aaf108d132e7b961db8600c16d19d6d3f37eb4 Mon Sep 17 00:00:00 2001 From: Bonta <40473493+Bonta0@users.noreply.github.com> Date: Sun, 4 Jul 2021 12:41:46 +0200 Subject: [PATCH] Externals: Integrate mGBA as a submodule --- .gitignore | 1 + .gitmodules | 5 + CMakeLists.txt | 9 + Externals/ExternalsReferenceAll.props | 3 + Externals/licenses.md | 2 + Externals/mGBA/CMakeLists.txt | 13 + Externals/mGBA/make_version.c.js | 140 +++++++++ Externals/mGBA/mgba | 1 + Externals/mGBA/mgba.vcxproj | 241 +++++++++++++++ Externals/mGBA/mgba.vcxproj.filters | 427 ++++++++++++++++++++++++++ Source/Core/Common/SCMRevGen.vcxproj | 4 - Source/Core/Core/CMakeLists.txt | 5 + Source/VSProps/Base.Macros.props | 2 + Source/VSProps/Base.props | 2 + Source/dolphin-emu.sln | 11 + 15 files changed, 862 insertions(+), 4 deletions(-) create mode 100644 Externals/mGBA/CMakeLists.txt create mode 100644 Externals/mGBA/make_version.c.js create mode 160000 Externals/mGBA/mgba create mode 100644 Externals/mGBA/mgba.vcxproj create mode 100644 Externals/mGBA/mgba.vcxproj.filters diff --git a/.gitignore b/.gitignore index deef6c5b0a..cebabd2c39 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Thumbs.db # Ignore Finder view option files created by OS X .DS_Store # Ignore autogenerated source files +Externals/mGBA/version.c Source/Core/Common/scmrev.h # Ignore files output by build /[Bb]uild*/ diff --git a/.gitmodules b/.gitmodules index 7082458311..3459dd91fb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,3 +3,8 @@ url = https://github.com/dolphin-emu/ext-win-qt.git branch = master shallow = true +[submodule "Externals/mGBA/mgba"] + path = Externals/mGBA/mgba + url = https://github.com/mgba-emu/mgba.git + branch = master + shallow = true diff --git a/CMakeLists.txt b/CMakeLists.txt index a480467b3e..d446e0b465 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ option(ENABLE_LLVM "Enables LLVM support, for disassembly" ON) option(ENABLE_TESTS "Enables building the unit tests" ON) option(ENABLE_VULKAN "Enables vulkan video backend" ON) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence, show the current game on Discord" ON) +option(USE_MGBA "Enables GBA controllers emulation using libmgba" ON) # Maintainers: if you consider blanket disabling this for your users, please # consider the following points: @@ -826,6 +827,14 @@ if(USE_DISCORD_PRESENCE) include_directories(Externals/discord-rpc/include) endif() +if(NOT ENABLE_QT) + set(USE_MGBA 0) +endif() +if(USE_MGBA) + message(STATUS "Using static libmgba from Externals") + add_subdirectory(Externals/mGBA) +endif() + find_package(SYSTEMD) if(SYSTEMD_FOUND) message(STATUS "libsystemd found, enabling traversal server watchdog support") diff --git a/Externals/ExternalsReferenceAll.props b/Externals/ExternalsReferenceAll.props index 0d7de6fecd..38ec0bd827 100644 --- a/Externals/ExternalsReferenceAll.props +++ b/Externals/ExternalsReferenceAll.props @@ -58,6 +58,9 @@ {bdb6578b-0691-4e80-a46c-df21639fd3b8} + + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6} + {31643fdb-1bb8-4965-9de7-000fc88d35ae} diff --git a/Externals/licenses.md b/Externals/licenses.md index f7b20041b9..716b794fb0 100644 --- a/Externals/licenses.md +++ b/Externals/licenses.md @@ -38,6 +38,8 @@ Dolphin includes or links code of the following third-party software projects: [University of Illinois/NCSA Open Source license](http://llvm.org/docs/DeveloperPolicy.html#license) - [LZO](http://www.oberhumer.com/opensource/lzo/): [GPLv2+](http://www.oberhumer.com/opensource/gpl.html) +- [mGBA](http://mgba.io) + [MPL 2.0](https://github.com/mgba-emu/mgba/blob/master/LICENSE) - [MiniUPnPc](http://miniupnp.free.fr/): [3-clause BSD](https://github.com/miniupnp/miniupnp/blob/master/miniupnpc/LICENSE) - [Microsoft Visual C++ Runtime Library](http://www.microsoft.com/en-us/download/details.aspx?id=40784): diff --git a/Externals/mGBA/CMakeLists.txt b/Externals/mGBA/CMakeLists.txt new file mode 100644 index 0000000000..4a87c7b58c --- /dev/null +++ b/Externals/mGBA/CMakeLists.txt @@ -0,0 +1,13 @@ +set(LIBMGBA_ONLY ON) +set(USE_LZMA ON) +add_subdirectory(mgba EXCLUDE_FROM_ALL) + +if(NOT MSVC) + target_compile_options(mgba PRIVATE -Wno-unused-parameter -Wno-unused-result -Wno-unused-variable) +endif() + +if(ANDROID) + target_compile_definitions(mgba PRIVATE -Dfutimes=futimens) +endif() + +add_library(mGBA::mgba ALIAS mgba) diff --git a/Externals/mGBA/make_version.c.js b/Externals/mGBA/make_version.c.js new file mode 100644 index 0000000000..d52d9e9a05 --- /dev/null +++ b/Externals/mGBA/make_version.c.js @@ -0,0 +1,140 @@ +var wshShell = new ActiveXObject("WScript.Shell") +var oFS = new ActiveXObject("Scripting.FileSystemObject"); + +wshShell.CurrentDirectory += "\\mgba"; +var outfile = "../version.c"; +var cmd_commit = " describe --always --abbrev=40 --dirty"; +var cmd_commit_short = " describe --always --dirty"; +var cmd_branch = " symbolic-ref --short HEAD"; +var cmd_rev = " rev-list HEAD --count"; +var cmd_tag = " describe --tag --exact-match"; + +function GetGitExe() +{ + try + { + gitexe = wshShell.RegRead("HKCU\\Software\\GitExtensions\\gitcommand"); + wshShell.Exec(gitexe); + return gitexe; + } + catch (e) + {} + + for (var gitexe in {"git.cmd":1, "git":1, "git.bat":1}) + { + try + { + wshShell.Exec(gitexe); + return gitexe; + } + catch (e) + {} + } + + // last try - msysgit not in path (vs2015 default) + msyspath = "\\Git\\cmd\\git.exe"; + gitexe = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%") + msyspath; + if (oFS.FileExists(gitexe)) { + return gitexe; + } + gitexe = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%") + msyspath; + if (oFS.FileExists(gitexe)) { + return gitexe; + } + + WScript.Echo("Cannot find git or git.cmd, check your PATH:\n" + + wshShell.ExpandEnvironmentStrings("%PATH%")); + WScript.Quit(1); +} + +function GetFirstStdOutLine(cmd) +{ + try + { + return wshShell.Exec(cmd).StdOut.ReadLine(); + } + catch (e) + { + // catch "the system cannot find the file specified" error + WScript.Echo("Failed to exec " + cmd + " this should never happen"); + WScript.Quit(1); + } +} + +function GetFileContents(f) +{ + try + { + return oFS.OpenTextFile(f).ReadAll(); + } + catch (e) + { + // file doesn't exist + return ""; + } +} + +// get version from version.cmake +var version_cmake = GetFileContents("version.cmake"); +var version_major = version_cmake.match(/set\(LIB_VERSION_MAJOR (.*)\)/)[1]; +var version_minor = version_cmake.match(/set\(LIB_VERSION_MINOR (.*)\)/)[1]; +var version_patch = version_cmake.match(/set\(LIB_VERSION_PATCH (.*)\)/)[1]; +var version_abi = version_cmake.match(/set\(LIB_VERSION_ABI (.*)\)/)[1]; +var version_string = version_major + "." + version_minor + "." + version_patch; + +// get info from git +var gitexe = GetGitExe(); +var commit = GetFirstStdOutLine(gitexe + cmd_commit); +var commit_short = GetFirstStdOutLine(gitexe + cmd_commit_short); +var branch = GetFirstStdOutLine(gitexe + cmd_branch); +var rev = GetFirstStdOutLine(gitexe + cmd_rev); +var tag = GetFirstStdOutLine(gitexe + cmd_tag); +var binary_name = "mgba"; +var project_name = "mGBA"; + +if (!rev) + rev = -1; + +if (tag) +{ + version_string = tag; +} +else if (branch) +{ + if (branch == "master") + version_string = rev + "-" + commit_short; + else + version_string = branch + "-" + rev + "-" + commit_short; + + if (branch != version_abi) + version_string = version_abi + "-" + version_string; +} + +if (!commit) + commit = "(unknown)"; +if (!commit_short) + commit_short = "(unknown)"; +if (!branch) + branch = "(unknown)"; + +var out_contents = + "#include \n" + + "MGBA_EXPORT const char* const gitCommit = \"" + commit + "\";\n" + + "MGBA_EXPORT const char* const gitCommitShort = \"" + commit_short + "\";\n" + + "MGBA_EXPORT const char* const gitBranch = \"" + branch + "\";\n" + + "MGBA_EXPORT const int gitRevision = " + rev + ";\n" + + "MGBA_EXPORT const char* const binaryName = \"" + binary_name + "\";\n" + + "MGBA_EXPORT const char* const projectName = \"" + project_name + "\";\n" + + "MGBA_EXPORT const char* const projectVersion = \"" + version_string + "\";\n"; + +// check if file needs updating +if (out_contents == GetFileContents(outfile)) +{ + WScript.Echo(project_name + ": " + outfile + " current at " + version_string); +} +else +{ + // needs updating - writeout current info + oFS.CreateTextFile(outfile, true).Write(out_contents); + WScript.Echo(project_name + ": " + outfile + " updated to " + version_string); +} diff --git a/Externals/mGBA/mgba b/Externals/mGBA/mgba new file mode 160000 index 0000000000..9cccc5197e --- /dev/null +++ b/Externals/mGBA/mgba @@ -0,0 +1 @@ +Subproject commit 9cccc5197ed73ba0a54f584d3121c27dc97405f5 diff --git a/Externals/mGBA/mgba.vcxproj b/Externals/mGBA/mgba.vcxproj new file mode 100644 index 0000000000..2338faa0d8 --- /dev/null +++ b/Externals/mGBA/mgba.vcxproj @@ -0,0 +1,241 @@ + + + + + + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6} + + + + + + + + + + + + + + mgba\include;mgba\src;mgba\src\third-party\lzma;%(AdditionalIncludeDirectories) + BUILD_STATIC;M_CORE_GB;M_CORE_GBA;USE_LZMA;_7ZIP_PPMD_SUPPPORT;HAVE_STRDUP;HAVE_SETLOCALE;HAVE_CHMOD;HAVE_UMASK;%(PreprocessorDefinitions) + + + "$(CScript)" /nologo /E:JScript "make_version.c.js" + + + + + + $(IntDir)/src/core/cache-set.c.obj + + + $(IntDir)/src/core/cheats.c.obj + + + + $(IntDir)/src/core/core.c.obj + + + + $(IntDir)/src/core/input.c.obj + + + + + $(IntDir)/src/core/lockstep.c.obj + + + + + + + + $(IntDir)/src/core/serialize.c.obj + + + + + + + $(IntDir)/src/sm83/decoder.c.obj + + + + + $(IntDir)/src/gb/audio.c.obj + + + $(IntDir)/src/gb/cheats.c.obj + + + $(IntDir)/src/gb/core.c.obj + + + + $(IntDir)/src/gb/input.c.obj + + + $(IntDir)/src/gb/io.c.obj + + + + $(IntDir)/src/gb/memory.c.obj + + + $(IntDir)/src/gb/overrides.c.obj + + + $(IntDir)/src/gb/serialize.c.obj + + + $(IntDir)/src/gb/renderers/cache-set.c.obj + + + + $(IntDir)/src/gb/sio.c.obj + + + $(IntDir)/src/gb/timer.c.obj + + + $(IntDir)/src/gb/video.c.obj + + + + + $(IntDir)/src/arm/decoder.c.obj + + + + + + $(IntDir)/src/gba/audio.c.obj + + + + + + + + $(IntDir)/src/gba/cheats.c.obj + + + + + + $(IntDir)/src/gba/core.c.obj + + + + + + $(IntDir)/src/gba/input.c.obj + + + $(IntDir)/src/gba/io.c.obj + + + $(IntDir)/src/gba/memory.c.obj + + + $(IntDir)/src/gba/overrides.c.obj + + + $(IntDir)/src/gba/renderers/cache-set.c.obj + + + + + + + + + + $(IntDir)/src/gba/serialize.c.obj + + + + $(IntDir)/src/gba/sio.c.obj + + + + + $(IntDir)/src/gba/timer.c.obj + + + $(IntDir)/src/gba/video.c.obj + + + + + + + + + + + + + + + + + + + + + + + + + + + $(IntDir)/src/platform/windows/memory.c.obj + + + + + + + + + + + + + + + + + + + + + + + + + + $(IntDir)/src/gba/sio/lockstep.c.obj + + + $(IntDir)/src/gb/sio/lockstep.c.obj + + + + + + $(IntDir)/src/gba/extra/proxy.c.obj + + + $(IntDir)/src/gb/extra/proxy.c.obj + + + + + + + + + \ No newline at end of file diff --git a/Externals/mGBA/mgba.vcxproj.filters b/Externals/mGBA/mgba.vcxproj.filters new file mode 100644 index 0000000000..b5e7b0ed6a --- /dev/null +++ b/Externals/mGBA/mgba.vcxproj.filters @@ -0,0 +1,427 @@ + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Generated sources + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Windows-specific code + + + Third-party code + + + Third-party code + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Virtual files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + {57438DCC-46E8-3FBA-90F2-185F80CEBE2C} + + + {C0CFD641-7357-3B1D-B2A3-B2477AEF3147} + + + {6C07F537-79D5-3651-A634-9E523B9936B2} + + + {AFF59D0C-C624-393F-8703-2FB3784928C8} + + + {37E5D4D5-B263-3B94-8968-21228F26DF67} + + + diff --git a/Source/Core/Common/SCMRevGen.vcxproj b/Source/Core/Common/SCMRevGen.vcxproj index f8c9829144..938df1c6f7 100644 --- a/Source/Core/Common/SCMRevGen.vcxproj +++ b/Source/Core/Common/SCMRevGen.vcxproj @@ -35,10 +35,6 @@ - - %windir%\System32\cscript - %windir%\Sysnative\cscript - diff --git a/Source/dolphin-emu.sln b/Source/dolphin-emu.sln index 0f31f47801..1fdc7499b3 100644 --- a/Source/dolphin-emu.sln +++ b/Source/dolphin-emu.sln @@ -73,6 +73,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblzma", "..\Externals\lib EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstd", "..\Externals\zstd\zstd.vcxproj", "{1BEA10F3-80CE-4BC4-9331-5769372CDF99}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mgba", "..\Externals\mGBA\mgba.vcxproj", "{864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -349,6 +351,14 @@ Global {1BEA10F3-80CE-4BC4-9331-5769372CDF99}.Release|ARM64.Build.0 = Release|ARM64 {1BEA10F3-80CE-4BC4-9331-5769372CDF99}.Release|x64.ActiveCfg = Release|x64 {1BEA10F3-80CE-4BC4-9331-5769372CDF99}.Release|x64.Build.0 = Release|x64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Debug|ARM64.Build.0 = Debug|ARM64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Debug|x64.ActiveCfg = Debug|x64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Debug|x64.Build.0 = Debug|x64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Release|ARM64.ActiveCfg = Release|ARM64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Release|ARM64.Build.0 = Release|ARM64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Release|x64.ActiveCfg = Release|x64 + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -379,6 +389,7 @@ Global {1D8C51D2-FFA4-418E-B183-9F42B6A6717E} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} {055A775F-B4F5-4970-9240-F6CF7661F37B} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} {1BEA10F3-80CE-4BC4-9331-5769372CDF99} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} + {864C4C8E-296D-3DBC-AD83-F1D5CB6E8EC6} = {87ADDFF9-5768-4DA2-A33B-2477593D6677} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {64B0A343-3B94-4522-9C24-6937FE5EFB22}