Example #1
0
        private void GenerateCodeForModule(UnrealModuleInfo module, UStruct[] structs, UEnum[] enums, UFunction[] globalFunctions)
        {
            if (structs.Length == 0 && enums.Length == 0 && globalFunctions.Length == 0)
            {
                return;
            }

            if (slowTaskModuleCount > 1)
            {
                System.Diagnostics.Debug.Assert(subSlowTask == null);
                subSlowTask            = new FScopedSlowTask(currentSlowTaskTarget, "SubTask");
                subSlowTask.Visibility = ESlowTaskVisibility.ForceVisible;// Required otherwise the UI is very delayed
                subSlowTask.MakeDialog();
            }

            BeginGenerateModule(module);

            GenerateCodeForGlobalFunctions(module, globalFunctions);

            foreach (UStruct unrealStruct in structs)
            {
                SlowTaskStep(unrealStruct);
                GenerateCodeForStruct(module, unrealStruct);
            }

            GenerateCodeForEnums(module, enums, Settings.MergeEnumFiles);

            EndGenerateModule(module);

            if (subSlowTask != null)
            {
                subSlowTask.Dispose();
                subSlowTask = null;
            }
        }
Example #2
0
 private void SlowTaskSetModuleCount(int moduleCount)
 {
     if (slowTask == null)
     {
         slowTask = new FScopedSlowTask(moduleCount * 100, GetSlowTaskTitle());
         slowTask.MakeDialog();
     }
     slowTaskModuleCount = moduleCount;
 }
Example #3
0
        private void OnEndGenerateModules()
        {
            if (codeManager != null)
            {
                codeManager.OnEndGenerateModules();
            }

            if (slowTask != null)
            {
                slowTask.Dispose();
                slowTask = null;
            }
            if (subSlowTask != null)
            {
                subSlowTask.Dispose();
                subSlowTask = null;
            }
            slowTaskModuleCount   = 0;
            currentSlowTaskStep   = 0;
            currentSlowTaskTarget = 0;
            currentSlowTaskName   = null;
        }
Example #4
0
        internal static bool CompileCode(string slnPath, string projPath)
        {
            CodeGeneratorSettings settings = new CodeGeneratorSettings();
            string pluginInstallerPath     = Path.GetFullPath(Path.Combine(settings.GetManagedBinDir(), "PluginInstaller", "PluginInstaller.exe"));

            if (!File.Exists(slnPath))
            {
                CommandLog(ELogVerbosity.Error, "The solution '" + slnPath + "' doesn't exist");
                return(false);
            }
            if (!string.IsNullOrEmpty(projPath) && !File.Exists(projPath))
            {
                CommandLog(ELogVerbosity.Error, "The project '" + projPath + "' doesn't exist");
                return(false);
            }
            if (!File.Exists(pluginInstallerPath))
            {
                CommandLog(ELogVerbosity.Error, "Plugin installer not found at '" + pluginInstallerPath + "'");
                return(false);
            }

            const string typeName   = "PluginInstaller.Program";
            const string methodName = "BuildCustomSolution";

            if (pluginInstallerBuildSlnMethod == null)
            {
                if (!pluginInstallerLoaded)
                {
                    pluginInstallerLoaded = true;

                    Assembly assembly = CurrentAssemblyContext.LoadFrom(pluginInstallerPath);
                    if (assembly == null)
                    {
                        CommandLog(ELogVerbosity.Error, "Failed to load the plugin installer at '" + pluginInstallerPath + "'.");
                        return(false);
                    }

                    Type type = assembly.GetType(typeName);
                    if (type == null)
                    {
                        CommandLog(ELogVerbosity.Error, "Failed to resolve the plugin installer type '" + typeName + "'.");
                        return(false);
                    }

                    // Set the AppDirectory path so that it can resolve the local msbuild path (if a local msbuild exists)
                    type.GetField("AppDirectory", BindingFlags.Public | BindingFlags.Static).SetValue(
                        null, Path.GetDirectoryName(pluginInstallerPath));

                    pluginInstallerBuildSlnMethod = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static);
                }

                if (pluginInstallerBuildSlnMethod == null)
                {
                    CommandLog(ELogVerbosity.Error, "Failed to resolve the '" + methodName + "' function in plugin installer.");
                    return(false);
                }
            }

            CommandLog(ELogVerbosity.Log, "Attempting to build generated solution at " + slnPath);

            bool built = false;

            using (FScopedSlowTask slowTask = new FScopedSlowTask(100, "Compiling..."))
            {
                slowTask.MakeDialog();

                try
                {
                    built = (bool)pluginInstallerBuildSlnMethod.Invoke(null, new object[] { slnPath, projPath });
                    if (built)
                    {
                        CommandLog(ELogVerbosity.Log, "Solution was compiled successfully.");
                    }
                    else
                    {
                        CommandLog(ELogVerbosity.Error, "There was an error building the solution. Try compiling manually at " + slnPath);
                    }
                }
                catch (Exception e)
                {
                    CommandLog(ELogVerbosity.Error, "'" + methodName + "' throw an exception whilst compiling: " + e);
                }

                // This will give us one frame of 100% rather than always showing 0% (is there an alternative dialog for unknown task lengths?)
                slowTask.EnterProgressFrame(99.9f);
                slowTask.EnterProgressFrame(0.1f);
            }
            return(built);
        }