Introduce new OpenRA.exe entrypoint and change OpenRA.Game to a library.

This commit is contained in:
Paul Chote
2020-11-22 11:52:00 +00:00
committed by teinarss
parent 20fe59e844
commit 07a10069db
17 changed files with 130 additions and 63 deletions

View File

@@ -35,8 +35,7 @@
############################## TOOLCHAIN ###############################
#
# List of .NET assemblies that we can guarantee exist
# OpenRA.Game.dll is a harmless false positive that we can ignore
WHITELISTED_OPENRA_ASSEMBLIES = OpenRA.Game.exe OpenRA.Utility.exe OpenRA.Platforms.Default.dll OpenRA.Mods.Common.dll OpenRA.Mods.Cnc.dll OpenRA.Mods.D2k.dll OpenRA.Game.dll
WHITELISTED_OPENRA_ASSEMBLIES = OpenRA.exe OpenRA.Utility.exe OpenRA.Server.exe OpenRA.Platforms.Default.dll OpenRA.Game.dll OpenRA.Mods.Common.dll OpenRA.Mods.Cnc.dll OpenRA.Mods.D2k.dll
# These are explicitly shipped alongside our core files by the packaging script
WHITELISTED_THIRDPARTY_ASSEMBLIES = ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll Eluant.dll BeaconLib.dll Open.Nat.dll SDL2-CS.dll OpenAL-CS.Core.dll DiscordRPC.dll Newtonsoft.Json.dll
@@ -192,9 +191,10 @@ endif
install-engine:
@-echo "Installing OpenRA engine to $(DATA_INSTALL_DIR)"
@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) bin/OpenRA.Game.exe "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) bin/OpenRA.exe "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) bin/OpenRA.Server.exe "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) bin/OpenRA.Utility.exe "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) bin/OpenRA.Game.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) bin/OpenRA.Platforms.Default.dll "$(DATA_INSTALL_DIR)"
ifneq ($(TARGETPLATFORM), $(filter $(TARGETPLATFORM),win-x86 win-x64))

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<TargetFramework>net472</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
@@ -31,34 +31,13 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetPlatform)' == 'win-x86'">
<Prefer32bit>true</Prefer32bit>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Red Alert'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=ra</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Dune 2000'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=d2k</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Tiberian Dawn'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=cnc</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Tiberian Sun'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=ts</StartArguments>
</PropertyGroup>
<ItemGroup>
<None Include="App.config" />
<PackageReference Include="OpenRA-Eluant" Version="1.0.17" />
<PackageReference Include="OpenRA-Open.NAT" Version="1.0.0" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<AdditionalFiles Include="../stylecop.json" />
<AdditionalFiles Include="Properties/launchSettings.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->

View File

@@ -21,26 +21,4 @@ namespace OpenRA
Success = 0,
Running = int.MaxValue
}
static class Program
{
[STAThread]
static int Main(string[] args)
{
if (Debugger.IsAttached || args.Contains("--just-die"))
return (int)Game.InitializeAndRun(args);
AppDomain.CurrentDomain.UnhandledException += (_, e) => ExceptionHandler.HandleFatalError((Exception)e.ExceptionObject);
try
{
return (int)Game.InitializeAndRun(args);
}
catch (Exception e)
{
ExceptionHandler.HandleFatalError(e);
return (int)RunStatus.Error;
}
}
}
}

View File

@@ -3,4 +3,4 @@
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
</configuration>

View File

@@ -0,0 +1,65 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<UseVSHostingProcess>false</UseVSHostingProcess>
<LangVersion>7.3</LangVersion>
<DebugSymbols>true</DebugSymbols>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<OutputPath>../bin</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PlatformTarget>AnyCPU</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
<Configurations>Release;Debug</Configurations>
<AssemblyName>OpenRA</AssemblyName>
</PropertyGroup>
<PropertyGroup>
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Windows'))">win-x64</TargetPlatform>
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('Linux'))">linux-x64</TargetPlatform>
<TargetPlatform Condition="$([MSBuild]::IsOsPlatform('OSX'))">osx-x64</TargetPlatform>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
<Compile Include="**/*.cs" Exclude="$(DefaultItemExcludes)" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetPlatform)' == 'win-x86'">
<Prefer32bit>true</Prefer32bit>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Red Alert'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=ra</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Dune 2000'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=d2k</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Tiberian Dawn'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=cnc</StartArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(RunConfiguration)' == 'Tiberian Sun'">
<StartAction>Project</StartAction>
<StartArguments>Engine.EngineDir=".." Game.Mod=ts</StartArguments>
</PropertyGroup>
<ItemGroup>
<None Include="App.config" />
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj" />
<AdditionalFiles Include="../stylecop.json" />
<AdditionalFiles Include="Properties/launchSettings.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
</Project>

View File

@@ -0,0 +1,39 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Diagnostics;
using System.Linq;
namespace OpenRA.Launcher
{
static class Program
{
[STAThread]
static int Main(string[] args)
{
if (Debugger.IsAttached || args.Contains("--just-die"))
return (int)Game.InitializeAndRun(args);
AppDomain.CurrentDomain.UnhandledException += (_, e) => ExceptionHandler.HandleFatalError((Exception)e.ExceptionObject);
try
{
return (int)Game.InitializeAndRun(args);
}
catch (Exception e)
{
ExceptionHandler.HandleFatalError(e);
return (int)RunStatus.Error;
}
}
}
}

View File

@@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRA.Mods.Common", "OpenR
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRA.Test", "OpenRA.Test\OpenRA.Test.csproj", "{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRA.Launcher", "OpenRA.Launcher\OpenRA.Launcher.csproj", "{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -57,6 +59,10 @@ Global
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Release|Any CPU.Build.0 = Release|Any CPU
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54DAE0E0-3125-49D3-992E-A0E931EB5FC8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -17,11 +17,11 @@ after_test:
- python -c "from PIL import Image; i = Image.open('packaging/artwork/d2k_256x256.png'); i.save('d2k.ico')"
- move /Y %APPVEYOR_BUILD_FOLDER%\bin\* %APPVEYOR_BUILD_FOLDER%
- ps: (Get-Content "${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs.in").replace('DISPLAY_NAME', 'Red Alert').replace('MOD_ID', 'ra').replace('FAQ_URL', 'http://wiki.openra.net/FAQ') | Set-Content "${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs"
- ps: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /platform:x64 /reference:System.dll /reference:System.Core.dll /reference:System.Drawing.dll /reference:System.Windows.Forms.dll /reference:"${env:APPVEYOR_BUILD_FOLDER}\OpenRA.Game.exe" /out:"${env:APPVEYOR_BUILD_FOLDER}\RedAlert.exe" /win32icon:"${env:APPVEYOR_BUILD_FOLDER}\ra.ico" /target:winexe ${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs
- ps: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /platform:x64 /reference:System.dll /reference:System.Core.dll /reference:System.Drawing.dll /reference:System.Windows.Forms.dll /reference:"${env:APPVEYOR_BUILD_FOLDER}\OpenRA.Game.dll" /out:"${env:APPVEYOR_BUILD_FOLDER}\RedAlert.exe" /win32icon:"${env:APPVEYOR_BUILD_FOLDER}\ra.ico" /target:winexe ${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs
- ps: (Get-Content "${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs.in").replace('DISPLAY_NAME', 'Tiberian Dawn').replace('MOD_ID', 'cnc').replace('FAQ_URL', 'http://wiki.openra.net/FAQ') | Set-Content "${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs"
- ps: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /platform:x64 /reference:System.dll /reference:System.Core.dll /reference:System.Drawing.dll /reference:System.Windows.Forms.dll /reference:"${env:APPVEYOR_BUILD_FOLDER}\OpenRA.Game.exe" /out:"${env:APPVEYOR_BUILD_FOLDER}\TiberianDawn.exe" /win32icon:"${env:APPVEYOR_BUILD_FOLDER}\cnc.ico" /target:winexe ${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs
- ps: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /platform:x64 /reference:System.dll /reference:System.Core.dll /reference:System.Drawing.dll /reference:System.Windows.Forms.dll /reference:"${env:APPVEYOR_BUILD_FOLDER}\OpenRA.Game.dll" /out:"${env:APPVEYOR_BUILD_FOLDER}\TiberianDawn.exe" /win32icon:"${env:APPVEYOR_BUILD_FOLDER}\cnc.ico" /target:winexe ${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs
- ps: (Get-Content "${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs.in").replace('DISPLAY_NAME', 'Dune 2000').replace('MOD_ID', 'd2k').replace('FAQ_URL', 'http://wiki.openra.net/FAQ') | Set-Content "${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs"
- ps: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /platform:x64 /reference:System.dll /reference:System.Core.dll /reference:System.Drawing.dll /reference:System.Windows.Forms.dll /reference:"${env:APPVEYOR_BUILD_FOLDER}\OpenRA.Game.exe" /out:"${env:APPVEYOR_BUILD_FOLDER}\Dune2000.exe" /win32icon:"${env:APPVEYOR_BUILD_FOLDER}\d2k.ico" /target:winexe ${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs
- ps: C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /platform:x64 /reference:System.dll /reference:System.Core.dll /reference:System.Drawing.dll /reference:System.Windows.Forms.dll /reference:"${env:APPVEYOR_BUILD_FOLDER}\OpenRA.Game.dll" /out:"${env:APPVEYOR_BUILD_FOLDER}\Dune2000.exe" /win32icon:"${env:APPVEYOR_BUILD_FOLDER}\d2k.ico" /target:winexe ${env:APPVEYOR_BUILD_FOLDER}\packaging\windows\WindowsLauncher.cs
- if defined APPVEYOR_REPO_TAG_NAME set VERSION=%APPVEYOR_REPO_TAG_NAME%
- if not defined APPVEYOR_REPO_TAG_NAME set VERSION=%APPVEYOR_REPO_COMMIT:~0,7%
- '"C:\Program Files (x86)\NSIS\makensis.exe" /DSRCDIR="%APPVEYOR_BUILD_FOLDER%" /DTAG="git-%VERSION%" /DSUFFIX=" (dev)" /V3 packaging/windows/OpenRA.nsi'

View File

@@ -17,10 +17,10 @@ echo.
goto choosemod
:launchmod
bin\OpenRA.Game.exe Engine.EngineDir=".." Game.Mod=%mod% %*
bin\OpenRA.exe Engine.EngineDir=".." Game.Mod=%mod% %*
goto end
:launch
bin\OpenRA.Game.exe Engine.EngineDir=".." %*
bin\OpenRA.exe Engine.EngineDir=".." %*
:end
if %errorlevel% neq 0 goto crashdialog

View File

@@ -25,7 +25,7 @@ then
fi
# Launch the engine with the appropriate arguments
mono bin/OpenRA.Game.exe Engine.EngineDir=".." Engine.LaunchPath="$MODLAUNCHER" $MODARG "$@"
mono bin/OpenRA.exe Engine.EngineDir=".." Engine.LaunchPath="$MODLAUNCHER" $MODARG "$@"
# Show a crash dialog if something went wrong
if [ $? != 0 ] && [ $? != 1 ]; then

View File

@@ -10,8 +10,8 @@
# openra_user="<run server as this user>" (default: openra)
# openra_chdir="<home directory of openra_user>"
# (default: /usr/home/${openra_user})
# openra_path="<path to OpenRA.Game.exe>"
# (default: ${openra_chdir}/OpenRA/OpenRA.Game.exe)
# openra_path="<path to OpenRA.exe>"
# (default: ${openra_chdir}/OpenRA/OpenRA.exe)
# openra_ServerName="<ServerName>" (default: "Dedicated Server")
# openra_Mod="<Mod>" (default: ra)
# openra_ListenPort="<number>" (default: 1234)

View File

@@ -35,7 +35,7 @@ fi
# Run the game
export SDL_VIDEO_X11_WMCLASS="openra-{MODID}-{TAG}"
mono --debug OpenRA.Game.exe Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" Engine.LaunchWrapper="${HERE}/restore-environment.sh" "${JOIN_SERVER}" "$@"
mono --debug OpenRA.exe Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" Engine.LaunchWrapper="${HERE}/restore-environment.sh" "${JOIN_SERVER}" "$@"
# Show a crash dialog if something went wrong
if [ $? != 0 ] && [ $? != 1 ]; then

View File

@@ -9,7 +9,7 @@ if [ "${1#${PROTOCOL_PREFIX}}" != "${1}" ]; then
fi
# Run the game
mono {DEBUG} OpenRA.Game.exe Game.Mod={MODID} Engine.LaunchPath="{BIN_DIR}/openra-{MODID}" "${JOIN_SERVER}" "$@"
mono {DEBUG} OpenRA.exe Game.Mod={MODID} Engine.LaunchPath="{BIN_DIR}/openra-{MODID}" "${JOIN_SERVER}" "$@"
# Show a crash dialog if something went wrong
if [ $? != 0 ] && [ $? != 1 ]; then

View File

@@ -238,7 +238,7 @@ static int check_mono_version(const char *version, const char *req_version)
[self exitWithMonoPrompt];
// Default values - can be overriden by setting certain keys Info.plist
NSString *gameName = @"OpenRA.Game.exe";
NSString *gameName = @"OpenRA.exe";
NSString *modId = nil;
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];

View File

@@ -131,7 +131,7 @@ NSTask *gameTask;
launched = YES;
// Default values - can be overriden by setting certain keys Info.plist
NSString *gameName = @"OpenRA.Game.exe";
NSString *gameName = @"OpenRA.exe";
NSString *modId = nil;
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];

View File

@@ -18,7 +18,7 @@ SRCDIR="$(pwd)/../.."
BUILTDIR="$(pwd)/build"
ARTWORK_DIR="$(pwd)/../artwork/"
LAUNCHER_LIBS="-r:System.dll -r:System.Drawing.dll -r:System.Windows.Forms.dll -r:${BUILTDIR}/OpenRA.Game.exe"
LAUNCHER_LIBS="-r:System.dll -r:System.Drawing.dll -r:System.Windows.Forms.dll -r:${BUILTDIR}/OpenRA.Game.dll"
FAQ_URL="http://wiki.openra.net/FAQ"
SUFFIX=" (dev)"
@@ -44,7 +44,7 @@ function makelauncher()
# We need to set the loadFromRemoteSources flag for the launcher, but only for the "portable" zip package.
# Windows automatically un-trusts executables that are extracted from a downloaded zip file
cp "${BUILTDIR}/OpenRA.Game.exe.config" "${BUILTDIR}/${LAUNCHER_NAME}.config"
cp "${BUILTDIR}/OpenRA.exe.config" "${BUILTDIR}/${LAUNCHER_NAME}.config"
if [ "${PLATFORM}" = "x86" ]; then
# Enable the full 4GB address space for the 32 bit game executable
@@ -80,7 +80,7 @@ function build_platform()
make install-dependencies "${TARGETPLATFORM}" gameinstalldir="" DESTDIR="${BUILTDIR}"
popd > /dev/null || exit 1
cp "${SRCDIR}/bin/OpenRA.Game.exe.config" "${BUILTDIR}"
cp "${SRCDIR}/bin/OpenRA.exe.config" "${BUILTDIR}"
echo "Compiling Windows launchers (${PLATFORM})"
makelauncher "RedAlert.exe" "Red Alert" "ra" ${PLATFORM}