private static Compiler FindSuitableCompiler(Logger logger, Platform platform, string monoProfile, string projectDir, string[] compilationOptions, string unityEditorDataDir) { Compiler compiler = null; // Looking for Incremental C# 6.0 compiler var icscDirectory = Path.Combine(projectDir, LANGUAGE_SUPPORT_DIR); if (Incremental60Compiler.IsAvailable(icscDirectory)) { compiler = new Incremental60Compiler(logger, icscDirectory); } // Looking for Roslyn C# 6.0 compiler var roslynDirectory = Path.Combine(Path.Combine(projectDir, LANGUAGE_SUPPORT_DIR), "Roslyn"); if (compiler == null && Microsoft60Compiler.IsAvailable(roslynDirectory)) { compiler = new Microsoft60Compiler(logger, roslynDirectory); if (platform != Platform.Windows) { compiler = null; logger?.Append("Microsoft C# 6.0 compiler found, but it is not supported on the current platform. Looking for another compiler..."); } } if (compiler == null) { // Looking for Mono C# 6.0 compiler var mcsDirectory = Path.Combine(projectDir, LANGUAGE_SUPPORT_DIR); if (Mono60Compiler.IsAvailable(mcsDirectory)) { compiler = new Mono60Compiler(logger, mcsDirectory); } } if (compiler == null && compilationOptions.Any(line => line.Contains("AsyncBridge.Net35.dll"))) { // Using Mono C# 5.0 compiler var bleedingEdgeCompilerPath = Path.Combine(unityEditorDataDir, @"MonoBleedingEdge/lib/mono/4.5/mcs.exe"); compiler = new Mono50Compiler(logger, bleedingEdgeCompilerPath); } if (compiler == null) { // Using stock Mono C# 3.0 compiler var stockCompilerPath = monoProfile == "2.0" ? Path.Combine(unityEditorDataDir, @"Mono/lib/mono/2.0/gmcs.exe") : Path.Combine(unityEditorDataDir, @"Mono/lib/mono/" + monoProfile + "/smcs.exe"); compiler = new Mono30Compiler(logger, stockCompilerPath); } return(compiler); }
private static Compiler CreateCompiler(CompilerType compilerType, Logger logger, Platform platform, string monoProfile, string projectDir, string[] compilationOptions, string unityEditorDataDir) { var compilerDirectory = Path.Combine(projectDir, LANGUAGE_SUPPORT_DIR); switch (compilerType) { case CompilerType.Auto: return(FindSuitableCompiler(logger, platform, monoProfile, projectDir, compilationOptions, unityEditorDataDir)); case CompilerType.Mono3: var stockCompilerPath = monoProfile == "2.0" ? Path.Combine(unityEditorDataDir, @"Mono/lib/mono/2.0/gmcs.exe") : Path.Combine(unityEditorDataDir, @"Mono/lib/mono/" + monoProfile + "/smcs.exe"); return(new Mono30Compiler(logger, stockCompilerPath)); case CompilerType.Mono5: var bleedingEdgeCompilerPath = Path.Combine(unityEditorDataDir, @"MonoBleedingEdge/lib/mono/4.5/mcs.exe"); return(new Mono50Compiler(logger, bleedingEdgeCompilerPath)); case CompilerType.Mono6: if (Mono60Compiler.IsAvailable(compilerDirectory)) { return(new Mono60Compiler(logger, compilerDirectory)); } break; case CompilerType.Microsoft6: var roslynDirectory = Path.Combine(compilerDirectory, "Roslyn"); if (Microsoft60Compiler.IsAvailable(roslynDirectory)) { return(new Microsoft60Compiler(logger, roslynDirectory)); } break; case CompilerType.Incremental6: if (Incremental60Compiler.IsAvailable(compilerDirectory)) { return(new Incremental60Compiler(logger, compilerDirectory)); } break; } return(null); }