From 73b21b5880f5087242737eb91ef0fe3c23b132c8 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 4 Jan 2017 22:50:35 +0000 Subject: [PATCH] Convert openrct2 to static library --- openrct2.sln | 46 ++++--------------- src/openrct2-win/openrct2-win.cpp | 5 +- src/openrct2-win/openrct2-win.vcxproj | 21 ++------- src/openrct2/OpenRCT2.h | 4 ++ ...{openrct2.vcxproj => openrct2-lib.vcxproj} | 30 ++---------- src/openrct2/platform/windows.c | 32 +------------ test/tests/tests.vcxproj | 20 ++++---- 7 files changed, 36 insertions(+), 122 deletions(-) rename src/openrct2/{openrct2.vcxproj => openrct2-lib.vcxproj} (95%) diff --git a/openrct2.sln b/openrct2.sln index c161447964..7933d2540c 100644 --- a/openrct2.sln +++ b/openrct2.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "src\openrct2\openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-lib", "src\openrct2\openrct2-lib.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpaint", "test\testpaint\testpaint.vcxproj", "{57E60BA1-FB76-4316-909E-C1449C142327}" EndProject @@ -25,67 +25,39 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - DebugTests|Win32 = DebugTests|Win32 - DebugTests|x64 = DebugTests|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 - ReleaseTests|Win32 = ReleaseTests|Win32 - ReleaseTests|x64 = ReleaseTests|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.ActiveCfg = Debug|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|x64.Build.0 = Debug|x64 - {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|Win32.ActiveCfg = DebugTests|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|Win32.Build.0 = DebugTests|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|x64.ActiveCfg = DebugTests|x64 - {D24D94F6-2A74-480C-B512-629C306CE92F}.DebugTests|x64.Build.0 = DebugTests|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.ActiveCfg = Release|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.Build.0 = Release|x64 - {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|Win32.ActiveCfg = ReleaseTests|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|Win32.Build.0 = ReleaseTests|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|x64.ActiveCfg = ReleaseTests|x64 - {D24D94F6-2A74-480C-B512-629C306CE92F}.ReleaseTests|x64.Build.0 = ReleaseTests|x64 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.ActiveCfg = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.Build.0 = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|x64.ActiveCfg = Debug|Win32 - {57E60BA1-FB76-4316-909E-C1449C142327}.DebugTests|Win32.ActiveCfg = Debug|Win32 - {57E60BA1-FB76-4316-909E-C1449C142327}.DebugTests|x64.ActiveCfg = Debug|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Release|Win32.ActiveCfg = Release|Win32 {57E60BA1-FB76-4316-909E-C1449C142327}.Release|x64.ActiveCfg = Release|Win32 - {57E60BA1-FB76-4316-909E-C1449C142327}.ReleaseTests|Win32.ActiveCfg = Release|Win32 - {57E60BA1-FB76-4316-909E-C1449C142327}.ReleaseTests|x64.ActiveCfg = Release|Win32 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|Win32.ActiveCfg = DebugTests|Win32 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|x64.ActiveCfg = DebugTests|x64 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|Win32.ActiveCfg = DebugTests|Win32 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|Win32.Build.0 = DebugTests|Win32 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|x64.ActiveCfg = DebugTests|x64 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.DebugTests|x64.Build.0 = DebugTests|x64 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|Win32.ActiveCfg = ReleaseTests|Win32 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|x64.ActiveCfg = ReleaseTests|x64 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|Win32.ActiveCfg = ReleaseTests|Win32 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|Win32.Build.0 = ReleaseTests|Win32 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|x64.ActiveCfg = ReleaseTests|x64 - {62B020FA-E4FB-4C6E-B32A-DC999470F155}.ReleaseTests|x64.Build.0 = ReleaseTests|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|Win32.ActiveCfg = Debug|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|Win32.Build.0 = Debug|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|x64.ActiveCfg = Debug|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Debug|x64.Build.0 = Debug|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|Win32.ActiveCfg = Release|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|Win32.Build.0 = Release|Win32 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|x64.ActiveCfg = Release|x64 + {62B020FA-E4FB-4C6E-B32A-DC999470F155}.Release|x64.Build.0 = Release|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|Win32.ActiveCfg = Debug|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|Win32.Build.0 = Debug|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|x64.ActiveCfg = Debug|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Debug|x64.Build.0 = Debug|x64 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.DebugTests|Win32.ActiveCfg = DebugTests|Win32 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.DebugTests|Win32.Build.0 = DebugTests|Win32 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.DebugTests|x64.ActiveCfg = DebugTests|x64 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.DebugTests|x64.Build.0 = DebugTests|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|Win32.ActiveCfg = Release|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|Win32.Build.0 = Release|Win32 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|x64.ActiveCfg = Release|x64 {7A9A57D5-7006-4208-A290-5491BA3C8808}.Release|x64.Build.0 = Release|x64 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.ReleaseTests|Win32.ActiveCfg = ReleaseTests|Win32 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.ReleaseTests|Win32.Build.0 = ReleaseTests|Win32 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.ReleaseTests|x64.ActiveCfg = ReleaseTests|x64 - {7A9A57D5-7006-4208-A290-5491BA3C8808}.ReleaseTests|x64.Build.0 = ReleaseTests|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/openrct2-win/openrct2-win.cpp b/src/openrct2-win/openrct2-win.cpp index 433607d313..29736969cf 100644 --- a/src/openrct2-win/openrct2-win.cpp +++ b/src/openrct2-win/openrct2-win.cpp @@ -20,6 +20,7 @@ #include #include #include +#include // Enable visual styles #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") @@ -39,7 +40,7 @@ int main(int argc, char * * argv) return -1; } - int exitCode = 0; // RunOpenRCT2 + int exitCode = RunOpenRCT2(argc, argv); FreeCommandLineArgs(argc, argv); return exitCode; @@ -58,7 +59,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine return -1; } - int exitCode = 0; // RunOpenRCT2 + int exitCode = RunOpenRCT2(argc, argv); FreeCommandLineArgs(argc, argv); return exitCode; diff --git a/src/openrct2-win/openrct2-win.vcxproj b/src/openrct2-win/openrct2-win.vcxproj index 33c89c907c..67c40a3a0d 100644 --- a/src/openrct2-win/openrct2-win.vcxproj +++ b/src/openrct2-win/openrct2-win.vcxproj @@ -12,14 +12,6 @@ Debug x64 - - DebugTests - Win32 - - - DebugTests - x64 - Release Win32 @@ -28,14 +20,6 @@ Release x64 - - ReleaseTests - Win32 - - - ReleaseTests - x64 - {7A9A57D5-7006-4208-A290-5491BA3C8808} @@ -46,6 +30,10 @@ Application + + openrct2 + $(SolutionDir)bin;$(LibraryPath) + __NOENTRYPOINT__;%(PreprocessorDefinitions) @@ -57,6 +45,7 @@ $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) + openrct2-lib.lib;%(AdditionalDependencies) Console Windows diff --git a/src/openrct2/OpenRCT2.h b/src/openrct2/OpenRCT2.h index a601dd6798..e7d814f1d1 100644 --- a/src/openrct2/OpenRCT2.h +++ b/src/openrct2/OpenRCT2.h @@ -87,6 +87,10 @@ extern "C" int cmdline_run(const char * * argv, int argc); +#ifdef _MSC_VER + int RunOpenRCT2(int argc, char * *); +#endif + #ifdef __cplusplus } #endif diff --git a/src/openrct2/openrct2.vcxproj b/src/openrct2/openrct2-lib.vcxproj similarity index 95% rename from src/openrct2/openrct2.vcxproj rename to src/openrct2/openrct2-lib.vcxproj index 2cd5814180..4a50422ff2 100644 --- a/src/openrct2/openrct2.vcxproj +++ b/src/openrct2/openrct2-lib.vcxproj @@ -12,14 +12,6 @@ Debug x64 - - DebugTests - Win32 - - - DebugTests - x64 - Release Win32 @@ -28,35 +20,23 @@ Release x64 - - ReleaseTests - Win32 - - - ReleaseTests - x64 - {D24D94F6-2A74-480C-B512-629C306CE92F} - openrct2 - openrct2 + openrct2-lib + openrct2-lib - Application + StaticLibrary DynamicLibrary - - StaticLibrary - USE_BREAKPAD;%(PreprocessorDefinitions) - __NOENTRYPOINT__;%(PreprocessorDefinitions) @@ -64,10 +44,6 @@ $(IntDir)\%(RelativeDir) $(OPENRCT2_CL_ADDITIONALOPTIONS) %(AdditionalOptions) - - Console - Windows - MachineX86 MachineX64 diff --git a/src/openrct2/platform/windows.c b/src/openrct2/platform/windows.c index 4c90cb9b64..bf4a85b5bc 100644 --- a/src/openrct2/platform/windows.c +++ b/src/openrct2/platform/windows.c @@ -55,38 +55,10 @@ utf8 **windows_get_command_line_args(int *outNumArgs); static HMODULE _dllModule = NULL; -#if defined(NO_RCT2) && !defined(__NOENTRYPOINT__) - -/** - * Windows entry point to OpenRCT2 without a console window. - */ -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - _dllModule = hInstance; - - core_init(); - - int argc; - char ** argv = (char**)windows_get_command_line_args(&argc); - int runGame = cmdline_run((const char **)argv, argc); - - // Free argv - for (int i = 0; i < argc; i++) { - free(argv[i]); - } - free(argv); - - if (runGame == 1) { - openrct2_launch(); - } - - return gExitCode; -} - /** * Windows entry point to OpenRCT2 with a console window using a traditional C main function. */ -int main(int argc, char *argv[]) +int RunOpenRCT2(int argc, char * * argv) { HINSTANCE hInstance = GetModuleHandle(NULL); _dllModule = hInstance; @@ -101,7 +73,7 @@ int main(int argc, char *argv[]) return gExitCode; } -#else +#ifndef NO_RCT2 /* DllMain is already defined in one of static libraries we implicitly depend * on (libcrypto), which is their bug really, but since we don't do anything in diff --git a/test/tests/tests.vcxproj b/test/tests/tests.vcxproj index d10bc48bf3..8b7bca2f9f 100644 --- a/test/tests/tests.vcxproj +++ b/test/tests/tests.vcxproj @@ -5,20 +5,20 @@ $(SolutionDir)lib\googletest\googletest - - DebugTests + + Debug Win32 - - ReleaseTests + + Release Win32 - - DebugTests + + Debug x64 - - ReleaseTests + + Release x64 @@ -33,7 +33,7 @@ $(SolutionDir)bin\tests\ - $(GtestDir);$(GtestDir)\include;$(SolutionDir)src\openrct2;$(IncludePath) + $(GtestDir);$(GtestDir)\include;$(IncludePath) $(SolutionDir)bin;$(LibraryPath) @@ -41,7 +41,7 @@ GTEST_LANG_CXX11;%(PreprocessorDefinitions) - openrct2.lib;%(AdditionalDependencies) + openrct2-lib.lib;%(AdditionalDependencies) Console