2023-05-04 16:23:07 +08:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
using System;
|
|
|
|
using UnityEditor.Build;
|
|
|
|
using UnityEditor.Build.Reporting;
|
|
|
|
|
2023-10-09 15:39:32 +08:00
|
|
|
namespace HybridCLR.Editor.BuildProcessors
|
2023-05-04 16:23:07 +08:00
|
|
|
{
|
|
|
|
|
2023-10-09 15:39:32 +08:00
|
|
|
public class MsvcStdextWorkaround : IPreprocessBuildWithReport
|
2023-05-04 16:23:07 +08:00
|
|
|
{
|
2023-10-09 15:39:32 +08:00
|
|
|
const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
|
2023-05-04 16:23:07 +08:00
|
|
|
|
2023-10-09 15:39:32 +08:00
|
|
|
public int callbackOrder => 0;
|
|
|
|
|
|
|
|
public void OnPreprocessBuild(BuildReport report)
|
2023-05-04 16:23:07 +08:00
|
|
|
{
|
2023-10-09 15:39:32 +08:00
|
|
|
var clEnv = Environment.GetEnvironmentVariable("_CL_");
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(clEnv))
|
|
|
|
{
|
|
|
|
Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
|
|
|
|
}
|
|
|
|
else if (!clEnv.Contains(kWorkaroundFlag))
|
|
|
|
{
|
|
|
|
clEnv += " " + kWorkaroundFlag;
|
|
|
|
Environment.SetEnvironmentVariable("_CL_", clEnv);
|
|
|
|
}
|
2023-05-04 16:23:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // UNITY_EDITOR
|