コード例 #1
0
 public CodeGenerator()
 {
     codeManager = CodeManager.Create(this);
     Settings    = new CodeGeneratorSettings();
     Settings.IsGeneratingCode = true;
     Settings.Load();
 }
コード例 #2
0
 public CodeGenerator(bool timeSliced)
 {
     TimeSliced  = TimeSliced;
     codeManager = CodeManager.Create(this);
     Settings    = new CodeGeneratorSettings();
     Settings.IsGeneratingCode = true;
     Settings.Load();
 }
コード例 #3
0
        internal static bool CompileGeneratedCode()
        {
            CodeGeneratorSettings settings = new CodeGeneratorSettings();
            string slnPath  = Path.GetFullPath(Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.sln"));
            string projPath = Path.GetFullPath(Path.Combine(settings.GetManagedModulesDir(), "UnrealEngine.csproj"));

            return(CompileCode(slnPath, projPath));
        }
コード例 #4
0
        private void GenerateInternal()
        {
            CodeGeneratorSettings settings = new CodeGeneratorSettings();

            string projectFileName = FPaths.ProjectFilePath;

            if (string.IsNullOrEmpty(projectFileName))
            {
                return;
            }

            projectName = Path.GetFileNameWithoutExtension(projectFileName);
            string gameSlnPath = Path.Combine(settings.GetManagedDir(), projectName + ".Managed.sln");

            if (File.Exists(gameSlnPath))
            {
                // Probably not a good idea to wipe over the existing code
                return;
            }

            string managedDir = settings.GetManagedDir();

            if (!Directory.Exists(managedDir))
            {
                Directory.CreateDirectory(managedDir);
            }

            templateName = defaultTemplateName;
            string templateDir        = Path.Combine(settings.GetUSharpBaseDir(), "Templates", templateName);
            string templateManagedDir = Path.Combine(templateDir, "Managed");
            string templateSlnFile    = Path.Combine(templateManagedDir, templateName + ".Managed.sln");

            if (Directory.Exists(templateDir) && File.Exists(templateSlnFile))
            {
                CopyFilesRecursive(new DirectoryInfo(templateManagedDir), new DirectoryInfo(managedDir), false);
            }

            // Update the props file (as it will be mostly empty from the template)
            ProjectProps.Update();
        }
コード例 #5
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);
        }
コード例 #6
0
        private static void CompileGeneratedCode()
        {
            CodeGeneratorSettings _settings = new CodeGeneratorSettings();
            string _slnPath             = Path.GetFullPath(Path.Combine(_settings.GetManagedModulesDir(), "UnrealEngine.sln"));
            string _projPath            = Path.GetFullPath(Path.Combine(_settings.GetManagedModulesDir(), "UnrealEngine.csproj"));
            string _pluginInstallerPath = Path.GetFullPath(Path.Combine(_settings.GetManagedModulesDir(), "../", "../", "../", "Binaries", "Managed", "PluginInstaller", "PluginInstaller.exe"));

            if (!File.Exists(_slnPath))
            {
                Log(ELogVerbosity.Error, "Can't Compile: The Solution " + _slnPath + " doesn't exist");
                return;
            }
            if (!File.Exists(_projPath))
            {
                Log(ELogVerbosity.Error, "Can't Compile: The Project " + _projPath + " doesn't exist");
                return;
            }
            if (!File.Exists(_pluginInstallerPath))
            {
                Log(ELogVerbosity.Error, "Can't Compile: Can't Find Plugin Installer At Path: " + _pluginInstallerPath);
                return;
            }

            Log(ELogVerbosity.Log, "Attempting To Build Generated Solution at " + _slnPath);

            int    timeout    = 60000;
            bool   built      = false;
            int    _exitCode  = 0;
            string _arguments = "buildcustomsln" + @" """ + _slnPath + @""" """ + _projPath + @""" """ + "command" + @"""";

            using (System.Diagnostics.Process process = new System.Diagnostics.Process())
            {
                process.StartInfo = new System.Diagnostics.ProcessStartInfo()
                {
                    WindowStyle     = System.Diagnostics.ProcessWindowStyle.Normal,
                    FileName        = _pluginInstallerPath,
                    Arguments       = _arguments,
                    UseShellExecute = false
                };
                process.Start();

                built     = process.WaitForExit(timeout) && process.ExitCode == 0;
                _exitCode = process.ExitCode;
            }

            if (built)
            {
                Log(ELogVerbosity.Log, "Solution Was Compiled Successfully.");
            }
            else if (_exitCode == 1)
            {
                Log(ELogVerbosity.Error, "There was an error building the Solution, Please Try Compiling Manually At " + _slnPath);
            }
            else if (_exitCode == 2)
            {
                Log(ELogVerbosity.Error, "Couldn't Build Custom Solution Because Files Provided were Invalid. Arguments: " + _arguments);
            }
            else if (_exitCode == 3)
            {
                Log(ELogVerbosity.Error, "Didn't provide the correct number of arguments for buildcustomsln command. Arguments: " + _arguments);
            }
            else
            {
                Log(ELogVerbosity.Error, "Couldn't Compile Solution, Please Try Compiling Manually At " + _slnPath);
            }
        }