Beispiel #1
0
 internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
 {
     using (ManagedProgram managedProgram = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", exe, args))
     {
         managedProgram.GetProcessStartInfo().WorkingDirectory = workingDirectory;
         managedProgram.Start();
         managedProgram.WaitForExit();
         if (managedProgram.ExitCode != 0)
         {
             if (parser != null)
             {
                 string[] errorOutput    = managedProgram.GetErrorOutput();
                 string[] standardOutput = managedProgram.GetStandardOutput();
                 IEnumerable <CompilerMessage> enumerable = parser.Parse(errorOutput, standardOutput, true);
                 foreach (CompilerMessage current in enumerable)
                 {
                     Debug.LogPlayerBuildError(current.message, current.file, current.line, current.column);
                 }
             }
             Debug.LogError(string.Concat(new string[]
             {
                 "Failed running ",
                 exe,
                 " ",
                 args,
                 "\n\n",
                 managedProgram.GetAllOutput()
             }));
             throw new Exception(string.Format("{0} did not run properly!", exe));
         }
     }
 }
    private static bool StartManagedProgram(string exe, string arguments, CompilerOutputParserBase parser, ref IEnumerable <CompilerMessage> compilerMessages)
    {
        bool result;

        using (ManagedProgram managedProgram = GendarmeValidationRule.ManagedProgramFor(exe, arguments))
        {
            managedProgram.LogProcessStartInfo();
            try
            {
                managedProgram.Start();
            }
            catch
            {
                throw new Exception("Could not start " + exe);
            }
            managedProgram.WaitForExit();
            if (managedProgram.ExitCode == 0)
            {
                result = true;
                return(result);
            }
            compilerMessages = parser.Parse(managedProgram.GetErrorOutput(), managedProgram.GetStandardOutput(), true);
        }
        result = false;
        return(result);
    }
 private static void RunUpdatingProgram(string executable, string arguments)
 {
   ManagedProgram program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.5", EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable, arguments);
   program.LogProcessStartInfo();
   program.Start();
   program.WaitForExit();
   Console.WriteLine(string.Join(Environment.NewLine, program.GetStandardOutput()));
   APIUpdaterHelper.HandleUpdaterReturnValue(program);
 }
        protected ManagedProgram StartCompiler(BuildTarget target, string compiler, List <string> arguments, bool setMonoEnvironmentVariables, string monodistro)
        {
            string text = CommandLineFormatter.GenerateResponseFile(arguments);

            base.RunAPIUpdaterIfRequired(text);
            ManagedProgram managedProgram = new ManagedProgram(monodistro, BuildPipeline.CompatibilityProfileToClassLibFolder(this._island._api_compatibility_level), compiler, " @" + text, setMonoEnvironmentVariables, null);

            managedProgram.Start();
            return(managedProgram);
        }
 protected ManagedProgram StartCompiler(BuildTarget target, string compiler, List<string> arguments, bool setMonoEnvironmentVariables)
 {
   this.AddCustomResponseFileIfPresent(arguments, Path.GetFileNameWithoutExtension(compiler) + ".rsp");
   string responseFile = CommandLineFormatter.GenerateResponseFile((IEnumerable<string>) arguments);
   if (this.runUpdater)
     APIUpdaterHelper.UpdateScripts(responseFile, this._island.GetExtensionOfSourceFiles());
   ManagedProgram managedProgram = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation(), this._island._classlib_profile, compiler, " @" + responseFile, setMonoEnvironmentVariables);
   managedProgram.Start();
   return managedProgram;
 }
Beispiel #6
0
        private static void RunUpdatingProgram(string executable, string arguments)
        {
            ManagedProgram program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.5", EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable, arguments);

            program.LogProcessStartInfo();
            program.Start();
            program.WaitForExit();
            Console.WriteLine(string.Join(Environment.NewLine, program.GetStandardOutput()));
            APIUpdaterHelper.HandleUpdaterReturnValue(program);
        }
Beispiel #7
0
        protected ManagedProgram StartCompiler(BuildTarget target, string compiler, List <string> arguments, string profileDirectory, bool setMonoEnvironmentVariables, string monodistro, IList <string> pathMappings = null)
        {
            var responseFile = CommandLineFormatter.GenerateResponseFile(arguments);

            RunAPIUpdaterIfRequired(responseFile, pathMappings);

            var program = new ManagedProgram(monodistro, profileDirectory, compiler, " @" + responseFile, setMonoEnvironmentVariables, null);

            program.Start();

            return(program);
        }
        protected ManagedProgram StartCompiler(BuildTarget target, string compiler, List <string> arguments, bool setMonoEnvironmentVariables, string monodistro)
        {
            string text = CommandLineFormatter.GenerateResponseFile(arguments);

            if (this.runUpdater)
            {
                APIUpdaterHelper.UpdateScripts(text, this._island.GetExtensionOfSourceFiles());
            }
            ManagedProgram managedProgram = new ManagedProgram(monodistro, this._island._classlib_profile, compiler, " @" + text, setMonoEnvironmentVariables, null);

            managedProgram.Start();
            return(managedProgram);
        }
        static void RunUpdatingProgram(string executable, string arguments, string tempOutputPath)
        {
            var scriptUpdater = EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable;
            var program       = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), null, scriptUpdater, arguments, false, null);

            program.LogProcessStartInfo();
            program.Start();
            program.WaitForExit();

            Console.WriteLine(string.Join(Environment.NewLine, program.GetStandardOutput()));

            HandleUpdaterReturnValue(program, tempOutputPath);
        }
        protected ManagedProgram StartCompiler(BuildTarget target, string compiler, List <string> arguments, bool setMonoEnvironmentVariables)
        {
            base.AddCustomResponseFileIfPresent(arguments, Path.GetFileNameWithoutExtension(compiler) + ".rsp");
            string responseFile = CommandLineFormatter.GenerateResponseFile(arguments);

            if (this.runUpdater)
            {
                UnityEditor.Scripting.Compilers.APIUpdaterHelper.UpdateScripts(responseFile, this._island.GetExtensionOfSourceFiles());
            }
            ManagedProgram program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation(), this._island._classlib_profile, compiler, " @" + responseFile, setMonoEnvironmentVariables);

            program.Start();
            return(program);
        }
        static void RunUpdatingProgram(string executable, string arguments, string tempOutputPath, bool anyFileInAssetsFolder)
        {
            var scriptUpdaterPath = EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable; // ManagedProgram will quote this path for us.

            using (var program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), null, scriptUpdaterPath, arguments, false, null))
            {
                program.LogProcessStartInfo();
                program.Start();
                program.WaitForExit();

                Console.WriteLine(string.Join(Environment.NewLine, program.GetStandardOutput()));

                HandleUpdaterReturnValue(program, tempOutputPath, anyFileInAssetsFolder);
            }
        }
		private static void RunUpdatingProgram(string executable, string arguments)
		{
			string executable2 = EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable;
			ManagedProgram managedProgram = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.5", executable2, arguments);
			managedProgram.LogProcessStartInfo();
			managedProgram.Start();
			managedProgram.WaitForExit();
			Console.WriteLine(string.Join(Environment.NewLine, managedProgram.GetStandardOutput()));
			if (managedProgram.ExitCode == 0)
			{
				APIUpdaterHelper.UpdateFilesInVCIfNeeded();
			}
			else
			{
				APIUpdaterHelper.ReportAPIUpdaterFailure(managedProgram.GetErrorOutput());
			}
		}
        private static void RunUpdatingProgram(string executable, string arguments)
        {
            string         executable2    = EditorApplication.applicationContentsPath + "/Tools/ScriptUpdater/" + executable;
            ManagedProgram managedProgram = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.5", executable2, arguments);

            managedProgram.LogProcessStartInfo();
            managedProgram.Start();
            managedProgram.WaitForExit();
            Console.WriteLine(string.Join(Environment.NewLine, managedProgram.GetStandardOutput()));
            if (managedProgram.ExitCode == 0)
            {
                APIUpdaterHelper.UpdateFilesInVCIfNeeded();
            }
            else
            {
                APIUpdaterHelper.ReportAPIUpdaterFailure(managedProgram.GetErrorOutput());
            }
        }
Beispiel #14
0
        public static void WeaveInto(string assemblyPath, string destPath, string unityEngine, string playerPackage)
        {
            string arguments = Weaver.CommandLineArgsFor(assemblyPath, destPath, unityEngine);

            using (ManagedProgram managedProgram = Weaver.SerializationWeaverProgramWith(arguments, playerPackage))
            {
                try
                {
                    managedProgram.Start();
                }
                catch
                {
                    managedProgram.LogProcessStartInfo();
                    throw new Exception("Could not start SerializationWeaver.exe");
                }
                managedProgram.WaitForExit();
                if (managedProgram.ExitCode != 0)
                {
                    throw new Exception("Failed running SerializationWeaver. output was: " + managedProgram.GetAllOutput());
                }
            }
        }
        private Program StartCompilerImpl(List <string> arguments, string argsPrefix)
        {
            foreach (string dll in _island._references)
            {
                arguments.Add("/reference:" + PrepareFileName(dll));
            }

            foreach (string define in _island._defines.Distinct())
            {
                arguments.Add("/define:" + define);
            }

            var filePathMappings = new List <string>(_island._files.Length);

            foreach (var source in _island._files)
            {
                var f = PrepareFileName(source);
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    f = f.Replace('/', '\\');
                }
                else
                {
                    f = f.Replace('\\', '/');
                }

                arguments.Add(f);

                if (f != source)
                {
                    filePathMappings.Add(f + " => " + source);
                }
            }

            var useNetCore = true;
            var csc        = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "Roslyn", "csc.exe");

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                csc = csc.Replace('/', '\\');
            }
            else
            {
                if (UseNetCoreCompiler())
                {
                    csc = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "Roslyn", "csc").Replace('\\', '/');
                }
                else
                {
                    useNetCore = false;
                    csc        = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "RoslynNet46", "csc.exe").Replace('\\', '/');
                }
            }


            if (!File.Exists(csc))
            {
                ThrowCompilerNotFoundException(csc);
            }

            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(BuildTarget);

            if (!AddCustomResponseFileIfPresent(arguments, ReponseFilename) && PlayerSettings.GetScriptingBackend(buildTargetGroup) != ScriptingImplementation.WinRTDotNET)
            {
                if (AddCustomResponseFileIfPresent(arguments, "mcs.rsp"))
                {
                    UnityEngine.Debug.LogWarning(string.Format("Using obsolete custom response file 'mcs.rsp'. Please use '{0}' instead.", ReponseFilename));
                }
            }

            var responseFile = CommandLineFormatter.GenerateResponseFile(arguments);

            RunAPIUpdaterIfRequired(responseFile, filePathMappings);

            if (useNetCore)
            {
                var psi = new ProcessStartInfo()
                {
                    Arguments = argsPrefix + " /shared " + "@" + responseFile, FileName = csc, CreateNoWindow = true
                };
                var program = new Program(psi);
                program.Start();
                return(program);
            }
            else
            {
                var program = new ManagedProgram(
                    MonoInstallationFinder.GetMonoBleedingEdgeInstallation(),
                    "not needed",
                    csc,
                    argsPrefix + "@" + responseFile,
                    false,
                    null);
                program.Start();
                return(program);
            }
        }
Beispiel #16
0
        private Program StartCompilerImpl(List <string> arguments, string argsPrefix)
        {
            foreach (string dll in m_Island._references)
            {
                arguments.Add("/reference:" + PrepareFileName(dll));
            }

            foreach (string define in m_Island._defines.Distinct())
            {
                arguments.Add("/define:" + define);
            }

            var filePathMappings = new List <string>(m_Island._files.Length);

            foreach (var source in m_Island._files)
            {
                var f = PrepareFileName(source);
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    f = f.Replace('/', '\\');
                }
                else
                {
                    f = f.Replace('\\', '/');
                }

                arguments.Add(f);

                if (f != source)
                {
                    filePathMappings.Add(f + " => " + source);
                }
            }

            var useNetCore = true;
            var csc        = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "Roslyn", "csc.exe");

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                csc = csc.Replace('/', '\\');
            }
            else
            {
                if (UseNetCoreCompiler())
                {
                    csc = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "Roslyn", "csc").Replace('\\', '/');
                }
                else
                {
                    useNetCore = false;
                    csc        = Paths.Combine(EditorApplication.applicationContentsPath, "Tools", "RoslynNet46", "csc.exe").Replace('\\', '/');
                }
            }


            if (!File.Exists(csc))
            {
                ThrowCompilerNotFoundException(csc);
            }

            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(BuildTarget);

            var responseFiles = m_Island._responseFiles?.ToDictionary(Path.GetFileName) ?? new Dictionary <string, string>();
            KeyValuePair <string, string> obsoleteResponseFile = responseFiles
                                                                 .SingleOrDefault(x => CompilerSpecificResponseFiles.MicrosoftCSharpCompilerObsolete.Contains(x.Key));

            if (!string.IsNullOrEmpty(obsoleteResponseFile.Key))
            {
                if (!IsBuildingForDotNetScriptingBackend(buildTargetGroup, m_Island._editor))
                {
                    Debug.LogWarning($"Using obsolete custom response file '{obsoleteResponseFile.Key}'. Please use '{CompilerSpecificResponseFiles.MicrosoftCSharpCompiler}' instead.");
                }
                else
                {
                    responseFiles.Remove(obsoleteResponseFile.Key);
                }
            }

            foreach (var reposeFile in responseFiles)
            {
                AddResponseFileToArguments(arguments, reposeFile.Value);
            }

            var responseFile = CommandLineFormatter.GenerateResponseFile(arguments);

            RunAPIUpdaterIfRequired(responseFile, filePathMappings);

            if (useNetCore)
            {
                var psi = new ProcessStartInfo()
                {
                    Arguments = argsPrefix + " /shared " + "@" + responseFile, FileName = csc, CreateNoWindow = true
                };
                var program = new Program(psi);
                program.Start();
                return(program);
            }
            else
            {
                var program = new ManagedProgram(
                    MonoInstallationFinder.GetMonoBleedingEdgeInstallation(),
                    "not needed",
                    csc,
                    argsPrefix + "@" + responseFile,
                    false,
                    null);
                program.Start();
                return(program);
            }
        }
Beispiel #17
0
        public static bool WeaveUNetInto(string assemblyPath, string destPath, string unityEngine, string unityUNet)
        {
            string text = Weaver.CommandLineArgsFor(assemblyPath, destPath, unityEngine);

            text = text + " -unity-unet=" + unityUNet;
            string frameWorksFolder = MonoInstallationFinder.GetFrameWorksFolder();

            Console.Write(string.Concat(new string[]
            {
                "WeaveUNetInto ",
                assemblyPath,
                " using ",
                frameWorksFolder,
                "/UNetWeaver/UNetWeaver.exe ",
                text
            }));
            bool result;

            using (ManagedProgram managedProgram = Weaver.UNetWeaverProgramWith(text, frameWorksFolder))
            {
                try
                {
                    managedProgram.Start();
                }
                catch
                {
                    managedProgram.LogProcessStartInfo();
                    throw new Exception("Could not start UNetWeaver.exe");
                }
                managedProgram.WaitForExit();
                Console.Write(managedProgram.GetAllOutput());
                if (managedProgram.ExitCode == 0)
                {
                    string   allOutput = managedProgram.GetAllOutput();
                    string   text2     = "COMPILE_WARNING ";
                    string[] array     = allOutput.Split(new char[]
                    {
                        '\n'
                    });
                    string[] array2 = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string text3 = array2[i];
                        if (text3.Length >= text2.Length)
                        {
                            if (text3.Substring(0, text2.Length) == text2)
                            {
                                string msg = text3.Substring(text2.Length);
                                EditorApplication.ReportUNetWeaver("file", msg, false);
                            }
                        }
                    }
                    result = true;
                }
                else
                {
                    string   allOutput2 = managedProgram.GetAllOutput();
                    string   text4      = "COMPILE_ERROR ";
                    string   text5      = "COMPILE_WARNING ";
                    string[] array3     = allOutput2.Split(new char[]
                    {
                        '\n'
                    });
                    string[] array4 = array3;
                    for (int j = 0; j < array4.Length; j++)
                    {
                        string text6 = array4[j];
                        if (text6.Length >= text5.Length)
                        {
                            if (text6.Substring(0, text4.Length) == text4)
                            {
                                string msg2 = text6.Substring(text4.Length);
                                EditorApplication.ReportUNetWeaver("file", msg2, true);
                            }
                            if (text6.Substring(0, text5.Length) == text5)
                            {
                                string msg3 = text6.Substring(text5.Length);
                                EditorApplication.ReportUNetWeaver("file", msg3, false);
                            }
                        }
                    }
                    result = false;
                }
            }
            return(result);
        }