Mac M1 源码调试 Unreal Engine

1,353 阅读1分钟

可以先看官方文档:

生成 Xcode 项目

sh "源码路径/UnrealEngine/Engine/Build/BatchFiles/Mac/GenerateProjectFiles.sh" -project="工程路径/工程文件.uproject" -game -Engine

问题

Variable set but not used

开始编译 ShaderCompileWorker 时,可能会遇到下面的错误:

Showing All Errors Only

Variable 'MallocCrashOverhead' set but not used
Variable 'bDidStall' set but not used
Variable 'Result' set but not used
Variable 'MaxTaskThreads' set but not used
Variable 'TotalMemoryUsage' set but not used
Variable 'DeviceUtil' set but not used
Variable 'Memory' set but not used
Variable 'Cycles' set but not used
Variable 'HitRate' set but not used
Variable 'bDidSomething' set but not used
Variable 'bAnyImportArcsAdded' set but not used
Variable 'PkgCDO' set but not used
Variable 'PropagationFlags' set but not used
Variable 'bHandledWithCppStructOps' set but not used
Variable 'PreviousNonEditorOnly' set but not used
Variable 'Previous' set but not used

解决方案: 打开 UnrealEngine/Engine/Source/Programs/UnrealBuildTool/Platform/Mac/MacToolChain.cs文件:

image.png

        if (CompileEnvironment.bEnableUndefinedIdentifierWarnings)
        {
            Result += " -Wundef" + (CompileEnvironment.bUndefinedIdentifierWarningsAsErrors ? "" : " -Wno-error=undef");
        }

        // https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
        Result += " -Wno-deprecated";
        Result += " -Wno-deprecated-declarations";
        Result += " -Wno-int-to-void-pointer-cast";
        Result += " -Wno-non-literal-null-conversion";
        Result += " -Wno-overloaded-virtual";
        Result += " -Wno-pointer-to-int-cast";
        Result += " -Wno-pragma-once-outside-header";
        Result += " -Wno-unused-but-set-variable";
        Result += " -Wno-unused-function";
        Result += " -Wno-unused-result";
        Result += " -Wno-unused-variable";

        Result += " -c";

参考: