Skip to content

Commit

Permalink
Add a Win32 NoGUI platform and project
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Dec 27, 2019
1 parent 0755f92 commit 5a65031
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 7 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,6 @@ if(ENABLE_VTUNE)
)
endif()

if(WIN32)
message(STATUS "Building for Windows, disabling NoGUI frontend.")
set(ENABLE_NOGUI OFF)
endif()

if(ANDROID)
message(STATUS "Building for Android")
if(NOT ENABLE_HEADLESS)
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/DolphinNoGUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ if(ENABLE_X11 AND X11_FOUND)
target_sources(dolphin-nogui PRIVATE PlatformX11.cpp)
endif()

if(WIN32)
target_sources(dolphin-nogui PRIVATE PlatformWin32.cpp)
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_sources(dolphin-nogui PRIVATE PlatformFBDev.cpp)
endif()
Expand Down
30 changes: 30 additions & 0 deletions Source/Core/DolphinNoGUI/DolphinNoGUI.exe.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="amd64"
name="DolphinTeam.DolphinEmuNoGUI"
type="win32"
/>
<description>Dolphin NoGUI Frontend</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
6 changes: 6 additions & 0 deletions Source/Core/DolphinNoGUI/DolphinNoGUI.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
IDI_ICON1 ICON "..\\..\\..\\Installer\\Dolphin.ico"
"dolphin" ICON "..\\..\\..\\Installer\\Dolphin.ico"

107 changes: 107 additions & 0 deletions Source/Core/DolphinNoGUI/DolphinNoGUI.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{974E563D-23F8-4E8F-9083-F62876B04E08}</ProjectGuid>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\VSProps\Base.props" />
<Import Project="..\..\VSProps\PCHUse.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>avrt.lib;iphlpapi.lib;winmm.lib;setupapi.lib;rpcrt4.lib;comctl32.lib;Shlwapi.lib;discord-rpc.lib;opengl32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ExternalsDir)ffmpeg\lib;$(IntDir)..\discord-rpc\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Externals\cpp-optparse\cpp-optparse.vcxproj">
<Project>{c636d9d1-82fe-42b5-9987-63b7d4836341}</Project>
</ProjectReference>
<ProjectReference Include="..\Core\Core.vcxproj">
<Project>{e54cf649-140e-4255-81a5-30a673c1fb36}</Project>
</ProjectReference>
<ProjectReference Include="..\UICommon\UICommon.vcxproj">
<Project>{604c8368-f34a-4d55-82c8-cc92a0c13254}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoBackends\D3D\D3D.vcxproj">
<Project>{96020103-4ba5-4fd2-b4aa-5b6d24492d4e}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoBackends\Null\Null.vcxproj">
<Project>{53a5391b-737e-49a8-bc8f-312ada00736f}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoBackends\OGL\OGL.vcxproj">
<Project>{ec1a314c-5588-4506-9c1e-2e58e5817f75}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoBackends\Software\Software.vcxproj">
<Project>{a4c423aa-f57c-46c7-a172-d1a777017d29}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoBackends\Vulkan\Vulkan.vcxproj">
<Project>{29f29a19-f141-45ad-9679-5a2923b49da3}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoCommon\VideoCommon.vcxproj">
<Project>{3de9ee35-3e91-4f27-a014-2866ad8c3fe3}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoBackends\D3D12\D3D12.vcxproj">
<Project>{570215b7-e32f-4438-95ae-c8d955f9fca3}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MainNoGUI.cpp" />
<ClCompile Include="Platform.cpp" />
<ClCompile Include="PlatformHeadless.cpp" />
<ClCompile Include="PlatformWin32.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<!--Copy the .exe to binary output folder-->
<ItemGroup>
<SourceFiles Include="$(TargetPath)" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Platform.h" />
</ItemGroup>
<ItemGroup>
<Manifest Include="DolphinNoGUI.exe.manifest" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="DolphinNoGUI.rc" />
</ItemGroup>
<Target Name="AfterBuild" Inputs="@(SourceFiles)" Outputs="@(SourceFiles -> '$(BinaryOutputDir)%(Filename)%(Extension)')">
<Message Text="Copy: @(SourceFiles) -&gt; $(BinaryOutputDir)" Importance="High" />
<Copy SourceFiles="@(SourceFiles)" DestinationFolder="$(BinaryOutputDir)" />
</Target>
</Project>
21 changes: 21 additions & 0 deletions Source/Core/DolphinNoGUI/DolphinNoGUI.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Platform.cpp" />
<ClCompile Include="PlatformHeadless.cpp" />
<ClCompile Include="MainNoGUI.cpp" />
<ClCompile Include="PlatformWin32.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Platform.h" />
</ItemGroup>
<ItemGroup>
<Manifest Include="DolphinNoGUI.exe.manifest" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="DolphinNoGUI.rc" />
</ItemGroup>
</Project>
17 changes: 17 additions & 0 deletions Source/Core/DolphinNoGUI/MainNoGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
#include <string>
#ifndef _WIN32
#include <unistd.h>
#else
#include <Windows.h>
#endif

#include "Common/StringUtil.h"
#include "Core/Analytics.h"
#include "Core/Boot/Boot.h"
#include "Core/BootManager.h"
Expand Down Expand Up @@ -121,6 +124,11 @@ static std::unique_ptr<Platform> GetPlatform(const optparse::Values& options)
return Platform::CreateFBDevPlatform();
#endif

#ifdef _WIN32
if (platform_name == "win32" || platform_name.empty())
return Platform::CreateWin32Platform();
#endif

if (platform_name == "headless" || platform_name.empty())
return Platform::CreateHeadlessPlatform();

Expand All @@ -142,6 +150,10 @@ int main(int argc, char* argv[])
#if HAVE_X11
,
"x11"
#endif
#ifdef _WIN32
,
"win32"
#endif
});

Expand Down Expand Up @@ -198,13 +210,18 @@ int main(int argc, char* argv[])
s_platform->Stop();
});

#ifdef _WIN32
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
#else
// Shut down cleanly on SIGINT and SIGTERM
struct sigaction sa;
sa.sa_handler = signal_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sa, nullptr);
sigaction(SIGTERM, &sa, nullptr);
#endif

DolphinAnalytics::Instance().ReportDolphinStart("nogui");

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DolphinNoGUI/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ class Platform
#ifdef HAVE_X11
static std::unique_ptr<Platform> CreateX11Platform();
#endif

#ifdef __linux__
static std::unique_ptr<Platform> CreateFBDevPlatform();
#endif

#ifdef _WIN32
static std::unique_ptr<Platform> CreateWin32Platform();
#endif

protected:
void UpdateRunningFlag();

Expand Down
Loading

0 comments on commit 5a65031

Please sign in to comment.