private static void WarnCompileFailed(CodeGeneratorSettings settings, string slnPath, string dialogTitle) { string logPath = Path.GetFullPath(Path.Combine(settings.GetManagedBinDir(), "PluginInstaller", "build.log")); if (string.IsNullOrEmpty(slnPath)) { slnPath = Path.GetFullPath(Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.sln")); } FMessage.OpenDialog("Compile failed.\nBuild log: '" + logPath + "'\nsln: '" + slnPath + "'"); }
private static void GenerateAndCompileMissingAssemblies() { string projectFileName = FPaths.ProjectFilePath; if (!FBuild.WithEditor || string.IsNullOrEmpty(projectFileName)) { return; } // NOTE: This is called before ManagedUnrealModuleInfo.Load / ManagedUnrealTypes.Load so some things may not be accessible. // Maybe call load then unload after this is finished? // NOTE: Most of the functions called here use FSlowTask but the UI isn't available until the engine is fully initialized. // Instead use FFeedbackContext to display a progress bar (FDesktopPlatformModule::Get()->GetNativeFeedbackContext()) // TODO: Redirect some of the FSlowTask messages to the log, so that the "show log" button displays useful info? codeGenContext = FFeedbackContext.GetGetDesktopFeedbackContext(); string dialogTitle = "USharp"; CodeGeneratorSettings settings = new CodeGeneratorSettings(); string engineWrapperDllPath = Path.Combine(settings.GetManagedModulesDir(), "bin", "Debug", "UnrealEngine.dll"); string engineWrapperSlnPath = Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.sln"); bool compileEngineWrapperCode = false; if (!File.Exists(engineWrapperSlnPath)) { if (FMessage.OpenDialog(EAppMsgType.YesNo, "C# engine wrapper code not found. Generate it now?", dialogTitle) == EAppReturnType.Yes) { codeGenContext.BeginSlowTask("Generating C# engine wrapper code (this might take a while...)", true); CodeGenerator.GenerateCode(new string[] { "modules" }); codeGenContext.EndSlowTask(); compileEngineWrapperCode = true; } } if (compileEngineWrapperCode || (!File.Exists(engineWrapperDllPath) && File.Exists(engineWrapperSlnPath))) { if (compileEngineWrapperCode || FMessage.OpenDialog(EAppMsgType.YesNo, "C# engine wrapper code isn't compiled. Compile it now?", dialogTitle) == EAppReturnType.Yes) { codeGenContext.BeginSlowTask("Compiling C# engine wrapper code (this might take a while...)", true); bool compiled = CodeGenerator.CompileGeneratedCode(); codeGenContext.EndSlowTask(); if (!compiled) { WarnCompileFailed(settings, null, dialogTitle); } } } string projectName = Path.GetFileNameWithoutExtension(projectFileName); string gameSlnPath = Path.Combine(settings.GetManagedDir(), projectName + ".Managed.sln"); string gameDllPath = Path.Combine(FPaths.ProjectDir, "Binaries", "Managed", projectName + ".Managed.dll"); if (!File.Exists(gameSlnPath) && FMessage.OpenDialog(EAppMsgType.YesNo, "USharp is enabled but the C# game project files weren't found. Generate them now?", dialogTitle) == EAppReturnType.Yes) { TemplateProjectGenerator.Generate(); } if (File.Exists(gameSlnPath) && !File.Exists(gameDllPath) && FMessage.OpenDialog(EAppMsgType.YesNo, "C# game project code isn't compiled. Compile it now?", dialogTitle) == EAppReturnType.Yes) { codeGenContext.BeginSlowTask("Compiling C# game project code (this might take a while...)", true); bool compiled = CodeGenerator.CompileCode(gameSlnPath, null); codeGenContext.EndSlowTask(); if (!compiled) { WarnCompileFailed(settings, null, dialogTitle); } } codeGenContext = null; }