MsvcStdextWorkaround.cs 865 B

1234567891011121314151617181920212223242526272829303132
  1. #if UNITY_EDITOR
  2. using System;
  3. using UnityEditor.Build;
  4. using UnityEditor.Build.Reporting;
  5. namespace HybridCLR.Editor.BuildProcessors
  6. {
  7. public class MsvcStdextWorkaround : IPreprocessBuildWithReport
  8. {
  9. const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
  10. public int callbackOrder => 0;
  11. public void OnPreprocessBuild(BuildReport report)
  12. {
  13. var clEnv = Environment.GetEnvironmentVariable("_CL_");
  14. if (string.IsNullOrEmpty(clEnv))
  15. {
  16. Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
  17. }
  18. else if (!clEnv.Contains(kWorkaroundFlag))
  19. {
  20. clEnv += " " + kWorkaroundFlag;
  21. Environment.SetEnvironmentVariable("_CL_", clEnv);
  22. }
  23. }
  24. }
  25. }
  26. #endif // UNITY_EDITOR