hxhb / HotPatcher

Unreal Engine hot update manage and package plugin.
https://imzlp.com/posts/17590/
MIT License
1.23k stars 333 forks source link

Fix Linux DS build for "Plugins\HotPatcher\Source\HotPatcherRuntime\Private\FlibPakHelper.cpp(6,10): error: non-portable path to file '"HAL/PlatformFileManager.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]" #102

Closed TroutZhang closed 6 months ago

TroutZhang commented 6 months ago

This is due to the change introduced from engine-side from UE5 start: https://github.com/EpicGames/UnrealEngine/commit/99be00dcdb26416cd7305119e0f144b3fdb9a565

TroutZhang commented 6 months ago

因为我只管我们用的新引擎版本(目前为5.2, 之后可能是5.4,5.5),所以我本地是这么改的。

但是看了作者文章后,为了尊重作者“坚持同一份代码做版本兼容”的理念,我也做下补充。

1 (验证过)在 (YourGame)Server.target.cs 里面加入如下代码,也是可以的 if (Target.Platform == UnrealTargetPlatform.Linux) { AdditionalCompilerArguments += " -Wno-nonportable-include-path"; //for case change in UE4->UE5, that "HAL/PlatformFilemanager.h"->"HAL/PlatformFileManager.h" bOverrideBuildEnvironment = true; // needed due to global definitions changed above }

2 (未验证)或者单独的cpp里加入这个也多半行的。

#ifdef __clang__ #pragma clang diagnostic ignored "-Wnonportable-include-path" #endif

TroutZhang commented 6 months ago

刚看到新版本里的 HotPatcher\Source\HotPatcherRuntime\Public\BaseTypes\AssetRegistry.h 那么可能

3 (不用验证)更符合作者的用法的改动 #if WITH_UE5 #include "HAL/PlatformFileManager.h" #else #include "HAL/PlatformFilemanager.h" #endif

TroutZhang commented 6 months ago

已经按照3更新了提交。

同时我搜项目发现其他用到的插件,有类似的改动,比如 https://github.com/getsentry/sentry-unreal/pull/499
PS: sentry 类似于 bugly

WWise的插件里,也有很多: #if UE_5_0_OR_LATER #include "HAL/PlatformFileManager.h" #else #include "HAL/PlatformFilemanager.h" #endif

hxhb commented 6 months ago

可以使用UE_VERSION_OLDER_THAN(5,0,0)来进行控制,更通用些。

TroutZhang commented 6 months ago

@hxhb 改用UE_VERSION_OLDER_THAN(5,0,0)了,我看了下,这个宏所在的文件是4.19加入的,确实可以满足你的支持范围”目前支持的引擎版本为 UE4.21-UE5“

TroutZhang commented 6 months ago

@hxhb 顺便说个问题:

不知道你们项目用不用Dedicated Server。 我今天刚集成新版v82,服务器那边就通知我崩了,还好我自己本地Win64打DS也能重现。

UFlibPakHelper::LoadShaderLibrary 的277行 EShaderPlatform ShaderPlatform = FShaderCodeLibrary::GetRuntimeShaderPlatform(); 在DS下返回的是 SP_NumPlatforms. 然后278行的 RHISupportsNativeShaderLibraries 调用,一路inline下去,就在

Engine\Source\Runtime\RHI\Public\DataDrivenShaderPlatformInfo.h line 170 数组越界挂了

因为我这方面API不熟悉, 我就本地简单return了, 你有空看下有没更好的改法,这个我就不PR了。

if (ShaderPlatform == SP_NumPlatforms)
{
    return;
}
hxhb commented 6 months ago

LoadShaderLibrary里未考虑ShaderPlatform无效的情况,在DS下确实会有这个问题,可以按照你的改法直接return;