Ejemplo n.º 1
0
        /// <summary>
        /// Gathers all Unreal types (native and managed types) in all loaded assemblies.
        /// </summary>
        public static void Load()
        {
            Assembly thisAssembly = Assembly.GetExecutingAssembly();

            foreach (Assembly assembly in CurrentAssemblyContext.GetAssemblies())
            {
                LoadInternal(thisAssembly, assembly);
            }

            gatheredUnrealTypes = true;
        }
Ejemplo n.º 2
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);
        }