Skip to content

Commit

Permalink
fix: Prevent Compiler Paradox (#1145)
Browse files Browse the repository at this point in the history
* Prevent Compiler Paradox

* Change platform to Editor Only

* added new line at EOF
  • Loading branch information
MrGadget authored and paulpach committed Oct 14, 2019
1 parent ae2f5cb commit fd43c67
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 28 deletions.
8 changes: 8 additions & 0 deletions Assets/Mirror/CompilerSymbols.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Assets/Mirror/CompilerSymbols/Mirror.CompilerSymbols.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Mirror.CompilerSymbols",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using UnityEditor;

namespace Mirror
{
static class PreprocessorDefine
{
/// <summary>
/// Add define symbols as soon as Unity gets done compiling.
/// </summary>
[InitializeOnLoadMethod]
static void AddDefineSymbols()
{
HashSet<string> defines = new HashSet<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup).Split(';'))
{
"MIRROR",
"MIRROR_1726_OR_NEWER",
"MIRROR_3_0_OR_NEWER",
"MIRROR_3_12_OR_NEWER",
"MIRROR_4_0_OR_NEWER"
};
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", defines));
}
}
}
11 changes: 11 additions & 0 deletions Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 4 additions & 25 deletions Assets/Mirror/Editor/PreprocessorDefine.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
using System.Collections.Generic;
using UnityEditor;

namespace Mirror
{
static class PreprocessorDefine
{
/// <summary>
/// Add define symbols as soon as Unity gets done compiling.
/// </summary>
[InitializeOnLoadMethod]
static void AddDefineSymbols()
{
HashSet<string> defines = new HashSet<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup).Split(';'))
{
"MIRROR",
"MIRROR_1726_OR_NEWER",
"MIRROR_3_0_OR_NEWER",
"MIRROR_3_12_OR_NEWER",
"MIRROR_4_0_OR_NEWER"
};
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, string.Join(";", defines));
}
}
}
// This file was moved to Mirror/CompilerSymbols in Mirror 4.0
// The purpose of this file is to get the old file overwritten
// when users update from the asset store to prevent a flood of errors
// from having the old file still in the project as a straggler.
2 changes: 1 addition & 1 deletion Assets/Mirror/Editor/PreprocessorDefine.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions Assets/Mirror/Runtime/Mirror.asmdef
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"name": "Mirror",
"references": [],
"references": [
"Mirror.CompilerSymbols"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

0 comments on commit fd43c67

Please sign in to comment.