Use precompiled headers for libopenrct2 with MSVC (#15997)

* Use precompiled headers for libopenrct2 with MSVC

* Exclude PCH from duktape

duktape needs all the warnings turned off and forcing PCH also enables
warnings. As there is nothing duktape would consume from our header,
remove forcing inclusion of that header into duktape.

* Provide msbuild parameter for using PCH only in CI
This commit is contained in:
Michał Janiszewski 2023-05-07 21:53:50 +02:00 committed by GitHub
parent 4afa56e373
commit 0871525850
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 12 deletions

View File

@ -26,7 +26,7 @@ if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then
# Build everything
echo -e "\033[0;36mBuilding OpenRCT2 for Windows $CONFIGURATION|$PLATFORM...\033[0m"
vstool msbuild openrct2.proj -t:build -p:Breakpad=true
vstool msbuild openrct2.proj -t:build -p:Breakpad=true -p:UsePCH=true
# Create openrct2.exe and openrct2.com with correct subsystem
cp bin/openrct2.exe bin/openrct2.com

View File

@ -1175,7 +1175,7 @@ namespace OpenRCT2
// TODO: This variable has been never "variable" in time, some code expects
// this to be 40Hz (25 ms). Refactor this once the UI is decoupled.
gCurrentDeltaTime = static_cast<uint32_t>(GAME_UPDATE_TIME_MS * 1000.0f);
gCurrentDeltaTime = static_cast<uint16_t>(GAME_UPDATE_TIME_MS * 1000.0f);
if (GameIsNotPaused())
{

View File

@ -11,6 +11,11 @@
#undef M_PI
// Ignore isatty warning on WIN32
#ifndef _CRT_NONSTDC_NO_WARNINGS
# define _CRT_NONSTDC_NO_WARNINGS
#endif
#ifdef _MSC_VER
# include <ctime>
#endif

View File

@ -381,11 +381,11 @@ void LightFXPrepareLightList()
continue;
}
entry->LightIntensity = std::min<uint32_t>(
0xFF, (entry->LightIntensity * lightIntensityOccluded) / (totalSamplePoints * 100));
entry->LightIntensity = static_cast<uint8_t>(
std::min<uint32_t>(0xFF, (entry->LightIntensity * lightIntensityOccluded) / (totalSamplePoints * 100)));
}
entry->LightIntensity = std::max<uint32_t>(
0x00, entry->LightIntensity - static_cast<int8_t>(_current_view_zoom_front) * 5);
entry->LightIntensity = static_cast<uint8_t>(
std::max<uint32_t>(0x00, entry->LightIntensity - static_cast<int8_t>(_current_view_zoom_front) * 5));
if (_current_view_zoom_front > ZoomLevel{ 0 })
{
@ -1012,7 +1012,7 @@ static uint8_t MixLight(uint32_t a, uint32_t b, uint32_t intensity)
intensity = intensity * 6;
uint32_t bMul = (b * intensity) >> 8;
uint32_t ab = a + bMul;
uint8_t result = std::min<uint32_t>(255, ab);
uint8_t result = static_cast<uint8_t>(std::min<uint32_t>(255, ab));
return result;
}

View File

@ -7,11 +7,6 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
// Ignore isatty warning on WIN32
#ifndef _CRT_NONSTDC_NO_WARNINGS
# define _CRT_NONSTDC_NO_WARNINGS
#endif
#include "../Context.h"
#include "../OpenRCT2.h"
#include "../platform/Platform.h"

View File

@ -54,6 +54,9 @@
<PreprocessorDefinitions>__ENABLE_DISCORD__;USE_BENCHMARK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Breakpad)'=='true' and ('$(Platform)'=='Win32' or '$(Platform)'=='x64')">USE_BREAKPAD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='Win32' or '$(Platform)'=='x64'">USE_FRIBIDI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader Condition="'$(UsePCH)'=='true'">Use</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(UsePCH)'=='true'">openrct2_pch.h</PrecompiledHeaderFile>
<ForcedIncludeFiles Condition="'$(UsePCH)'=='true'">openrct2_pch.h</ForcedIncludeFiles>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
@ -348,6 +351,7 @@
<ClInclude Include="object\WaterEntry.h" />
<ClInclude Include="object\WaterObject.h" />
<ClInclude Include="OpenRCT2.h" />
<ClInclude Include="openrct2_pch.h" Condition="'$(UsePCH)'=='true'"/>
<ClInclude Include="paint\Boundbox.h" />
<ClInclude Include="paint\Paint.Entity.h" />
<ClInclude Include="paint\Paint.h" />
@ -840,6 +844,9 @@
<ClCompile Include="object\WallObject.cpp" />
<ClCompile Include="object\WaterObject.cpp" />
<ClCompile Include="OpenRCT2.cpp" />
<ClCompile Include="openrct2_pch.cpp" Condition="'$(UsePCH)'=='true'">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="paint\Paint.cpp" />
<ClCompile Include="paint\Paint.Entity.cpp" />
<ClCompile Include="paint\Painter.cpp" />
@ -1039,6 +1046,8 @@
<ClCompile Include="world\TileInspector.cpp" />
<ClCompile Include="world\Wall.cpp" />
<ClCompile Include="..\thirdparty\duktape\duktape.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<ForcedIncludeFiles></ForcedIncludeFiles>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemGroup>

View File

@ -0,0 +1,2 @@
// Empty file for MSVC's PCH
// Do not include the header file - it is set up with MSVC solution

View File

@ -0,0 +1,9 @@
#pragma once
// Include some expensive headers here to improve compilation speed
#include "common.h"
#include "core/FileSystem.hpp"
#include "object/Object.h"
#include "rct2/RCT2.h"
#include "ride/Ride.h"