protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            DotNetProject project = (DotNetProject)entry;
            GtkDesignInfo info    = GtkDesignInfo.FromProject(project);

            // The code generator must run in the GUI thread since it needs to
            // access to Gtk classes
            Generator gen = new Generator();

            lock (gen) {
                Gtk.Application.Invoke(delegate { gen.Run(monitor, project, configuration); });
                Monitor.Wait(gen);
            }

            BuildResult res = base.Build(monitor, entry, configuration);

            if (gen.Messages != null)
            {
                foreach (string s in gen.Messages)
                {
                    res.AddWarning(info.GuiBuilderProject.File, 0, 0, null, s);
                }

                if (gen.Messages.Length > 0)
                {
                    info.ForceCodeGenerationOnBuild();
                }
            }
            return(res);
        }
        public override void LogWarning(string helpLink, Microsoft.Xna.Framework.Content.Pipeline.ContentIdentity contentIdentity, string message, params object[] messageArgs)
        {
            var msg      = string.Format(message, messageArgs);
            var fileName = GetCurrentFilename(contentIdentity);

            monitor.Log.WriteLine(string.Format("{0}: {1}", fileName, msg));
            if (result != null)
            {
                result.AddWarning(string.Format("{0}: {1}", fileName, msg));
            }
        }
Example #3
0
 static void AddErrorsToResult(BuildResult result, string filename, IEnumerable <Error> errors)
 {
     foreach (var err in errors)
     {
         if (err.ErrorType == ErrorType.Warning)
         {
             result.AddWarning(filename, err.Region.BeginLine, err.Region.BeginColumn, null, err.Message);
         }
         else
         {
             result.AddError(filename, err.Region.BeginLine, err.Region.BeginColumn, null, err.Message);
         }
     }
 }
        protected async override Task <BuildResult> OnBuild(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
        {
            if (Project.References.Count == 0 || !GtkDesignInfo.HasDesignedObjects(Project))
            {
                return(await base.OnBuild(monitor, configuration, operationContext));
            }

            Generator gen = new Generator();

            if (!await gen.Run(monitor, Project, configuration))
            {
                BuildResult gr = new BuildResult();
                foreach (string s in gen.Messages)
                {
                    gr.AddError(DesignInfo.GuiBuilderProject.File, 0, 0, null, s);
                }
                return(gr);
            }

            BuildResult res = await base.OnBuild(monitor, configuration, operationContext);

            if (gen.Messages != null)
            {
                foreach (string s in gen.Messages)
                {
                    res.AddWarning(DesignInfo.GuiBuilderProject.File, 0, 0, null, s);
                }

                if (gen.Messages.Length > 0)
                {
                    DesignInfo.ForceCodeGenerationOnBuild();
                }
            }

            if (res.Failed && !Platform.IsWindows && !Platform.IsMac)
            {
                // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel
                if (Project.AssemblyContext.GetPackage("gtk-sharp-2.0") == null)
                {
                    string msg = GettextCatalog.GetString(
                        "ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " +
                        "Compilation of projects depending on Gtk# libraries will fail. " +
                        "You may need to install development packages for gtk-sharp-2.0.");
                    monitor.Log.WriteLine();
                    monitor.Log.WriteLine(BrandingService.BrandApplicationName(msg));
                }
            }

            return(res);
        }
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            DotNetProject project = (DotNetProject)entry;
            GtkDesignInfo info    = GtkDesignInfo.FromProject(project);

            // The code generator must run in the GUI thread since it needs to
            // access to Gtk classes
            Generator gen = new Generator();

            lock (gen)
            {
                Gtk.Application.Invoke(delegate
                {
                    gen.Run(monitor, project, configuration);
                });
                Monitor.Wait(gen);
            }

            BuildResult res = base.Build(monitor, entry, configuration);

            if (gen.Messages != null)
            {
                foreach (string s in gen.Messages)
                {
                    res.AddWarning(info.GuiBuilderProject.File, 0, 0, null, s);
                }

                if (gen.Messages.Length > 0)
                {
                    info.ForceCodeGenerationOnBuild();
                }
            }

            if (res.Failed && !Platform.IsWindows && !Platform.IsMac)
            {
                // Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel
                if (project.AssemblyContext.GetPackage("gtk-sharp-2.0") == null)
                {
                    string msg = GettextCatalog.GetString(
                        "ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " +
                        "Compilation of projects depending on Gtk# libraries will fail. " +
                        "You may need to install development packages for gtk-sharp-2.0.");
                    monitor.Log.WriteLine();
                    monitor.Log.WriteLine(msg);
                }
            }

            return(res);
        }
Example #6
0
        public async Task <BuildResult> RunBuildTasks(GroupedTaskRunnerInformation tasks, TaskRunnerBindEvent bindEvent)
        {
            var buildResult = new BuildResult();

            foreach (TaskRunnerWithOptions node in tasks.GetTasks(bindEvent))
            {
                ITaskRunnerCommandResult result = await TaskRunnerServices.Workspace.RunTask(node);

                if (result.ExitCode != 0)
                {
                    buildResult.AddWarning(node.TaskRunner, result);
                }
            }

            return(buildResult);
        }
Example #7
0
 private void executeProgramErrorCallback(object sender, DataReceivedEventArgs e)
 {
     lock (this)
     {
         if (!String.IsNullOrEmpty(e.Data))
         {
             if (Regex.Match(e.Data.ToLower(), ".*error:|error", RegexOptions.Singleline).Success)
             {
                 buildingResult.AddError(e.Data);
             }
             else
             {
                 buildingResult.AddWarning(e.Data);
             }
         }
     }
 }
        protected override BuildResult OnBuild(MonoDevelop.Core.IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            var restResult = RestClient.CompileScripts();
            var result     = new BuildResult();

            foreach (var message in restResult.Messages)
            {
                var file     = BaseDirectory + "/" + message.File;
                var msg      = message.Message;
                var errorNum = "";

                var messageStrings = message.Message.Split(':');

                if (messageStrings.Length == 3)
                {
                    var errorNumStrings = messageStrings[1].Split(' ');

                    if (errorNumStrings.Length > 1)
                    {
                        errorNum = errorNumStrings[errorNumStrings.Length - 1];
                    }

                    msg = messageStrings[2];
                }

                if (message.Type == "warning")
                {
                    result.AddWarning(file, message.Line, message.Column, errorNum, msg);
                }
                else
                {
                    result.AddError(file, message.Line, message.Column, errorNum, msg);
                }
            }

            return(result);
        }
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem project, ConfigurationSelector configuration)
        {
            AspNetAppProject aspProject = project as AspNetAppProject;

            //get the config object and validate
            AspNetAppProjectConfiguration config = (AspNetAppProjectConfiguration)aspProject.GetConfiguration(configuration);

            if (config == null)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("Project configuration is invalid. Skipping CodeBehind member generation."));
                return(base.Build(monitor, project, configuration));
            }

            if (config.DisableCodeBehindGeneration)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("Skipping updating of CodeBehind partial classes, because this feature is disabled."));
                return(base.Build(monitor, project, configuration));
            }

            CodeBehindWriter writer = CodeBehindWriter.CreateForProject(monitor, aspProject);

            if (!writer.SupportsPartialTypes)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString
                                          ("The code generator for {0} does not support partial classes. Skipping CodeBehind member generation.",
                                          aspProject.LanguageBinding.Language));
                ;
                return(base.Build(monitor, project, configuration));
            }

            //get the extension used for codebehind files
            string langExt = aspProject.LanguageBinding.GetFileName("a");

            langExt = langExt.Substring(1, langExt.Length - 1);

            List <CodeBehindWarning> errors = new List <CodeBehindWarning> ();

            monitor.Log.WriteLine(GettextCatalog.GetString("Generating CodeBehind members..."));

            bool updatedParseDb = false;

            //go over all the files generating members where necessary
            foreach (ProjectFile file in aspProject.Files)
            {
                WebSubtype type = AspNetAppProject.DetermineWebSubtype(file.FilePath);
                if (type != WebSubtype.WebForm && type != WebSubtype.WebControl && type != WebSubtype.MasterPage)
                {
                    continue;
                }

                //find the designer file
                ProjectFile designerFile = aspProject.Files.GetFile(file.Name + ".designer" + langExt);
                if (designerFile == null)
                {
                    aspProject.Files.GetFile(file.Name + ".Designer" + langExt);
                }
                if (designerFile == null)
                {
                    continue;
                }

                //only regenerate the designer class if it's older than the aspx (etc) file
                if (System.IO.File.GetLastWriteTimeUtc(designerFile.FilePath)
                    > System.IO.File.GetLastWriteTimeUtc(file.FilePath))
                {
                    continue;
                }

                //need parse DB to be up to date
                if (!updatedParseDb)
                {
                    updatedParseDb = true;
                    monitor.Log.Write(GettextCatalog.GetString("Waiting for project type database to finish updating..."));
                    //var dom = TypeSystemService.GetContext (aspProject);
                    //TypeSystemService.ForceUpdate (dom);
                    monitor.Log.WriteLine(GettextCatalog.GetString(" complete."));
                }

                //parse the ASP.NET file
                var parsedDocument = TypeSystemService.ParseFile(aspProject, file.FilePath) as AspNetParsedDocument;
                if (parsedDocument == null)
                {
                    continue;
                }

                var ccu = CodeBehind.GenerateCodeBehind(aspProject, designerFile.FilePath, parsedDocument, errors);
                if (ccu == null)
                {
                    continue;
                }

                writer.WriteFile(designerFile.FilePath, ccu);
            }

            writer.WriteOpenFiles();

            //write out a friendly message aout what we did
            if (writer.WrittenCount > 0)
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("{0} CodeBehind designer classes updated.", writer.WrittenCount));
            }
            else
            {
                monitor.Log.WriteLine(GettextCatalog.GetString("No changes made to CodeBehind classes."));
            }

            //and construct and return a build result
            BuildResult baseResult = base.Build(monitor, project, configuration);

            foreach (CodeBehindWarning cbw in errors)
            {
                if (cbw.FileName != null)
                {
                    baseResult.AddWarning(cbw.FileName, cbw.Line, cbw.Column, null, cbw.WarningText);
                }
                else
                {
                    baseResult.AddWarning(cbw.WarningText);
                }
            }
            return(baseResult);
        }
Example #10
0
        BuildResult ParseGenerationResult(Stream result, ProgressMonitor monitor)
        {
            var results = new BuildResult();

            result.Position = 0;
            var    sr = new StreamReader(result);
            var    sb = new StringBuilder();
            string line;
            string fileName   = "";
            int    lineNumber = 0;
            bool   isWarning  = false;

            while ((line = sr.ReadLine()) != null)
            {
                //e.g.	CMake Warning in/at CMakeLists.txt:10 (COMMAND):
                //or:	CMake Warning:
                if (line.StartsWith("CMake Warning", StringComparison.OrdinalIgnoreCase))
                {
                    //reset everything and add last error or warning.
                    if (sb.Length > 0)
                    {
                        if (isWarning)
                        {
                            results.AddWarning(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                        else
                        {
                            results.AddError(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                    }

                    sb.Clear();
                    fileName   = "";
                    lineNumber = 0;
                    isWarning  = true;

                    // in/at CMakeLists.txt:10 (COMMAND):
                    if (line.Contains(" in "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " in ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else if (line.Contains(" at "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " at ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else
                    {
                        string [] warning = line.Split(':');
                        if (!string.IsNullOrEmpty(warning.ElementAtOrDefault(1)))
                        {
                            sb.Append(warning [1]);
                        }
                    }
                }
                else if (line.StartsWith("CMake Error", StringComparison.OrdinalIgnoreCase))
                {
                    //reset everything and add last error or warning.
                    if (sb.Length > 0)
                    {
                        if (isWarning)
                        {
                            results.AddWarning(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                        else
                        {
                            results.AddError(BaseDirectory.Combine(fileName), lineNumber, 0, "", sb.ToString());
                        }
                    }

                    sb.Clear();
                    fileName   = "";
                    lineNumber = 0;
                    isWarning  = false;

                    // in/at CMakeLists.txt:10 (COMMAND):
                    if (line.Contains(" in "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " in ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else if (line.Contains(" at "))
                    {
                        Tuple <int, string> t = GetFileAndLine(line, " at ");
                        lineNumber = t.Item1;
                        fileName   = t.Item2;
                    }
                    else
                    {
                        string [] error = line.Split(':');
                        if (!string.IsNullOrEmpty(error.ElementAtOrDefault(1)))
                        {
                            sb.Append(error [1]);
                        }
                    }
                }
                else
                {
                    sb.Append(line);
                }
            }

            return(results);
        }
Example #11
0
        public void Compile(PythonProject project,
                            FilePath fileName,
                            PythonConfiguration config,
                            BuildResult result)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }
            else if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            else if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            else if (Runtime == null)
            {
                throw new InvalidOperationException("No supported runtime!");
            }

            // Get our relative path within the project
            if (!fileName.IsChildPathOf(project.BaseDirectory))
            {
                Console.WriteLine("File is not within our project!");
                return;
            }

            FilePath relName = fileName.ToRelative(project.BaseDirectory);
            string   outFile = relName.ToAbsolute(config.OutputDirectory);

            if (!outFile.EndsWith(".py"))
            {
                return;
            }

            // Create the destination directory
            FileInfo fileInfo = new FileInfo(outFile);

            if (!fileInfo.Directory.Exists)
            {
                fileInfo.Directory.Create();
            }

            // Create and start our process to generate the byte code
            Process process = BuildCompileProcess(fileName, outFile, config.Optimize);

            process.Start();
            process.WaitForExit();

            // Parse errors and warnings
            string output = process.StandardError.ReadToEnd();

            // Extract potential Warnings
            foreach (Match m in m_WarningRegex.Matches(output))
            {
                string lineNum = m.Groups[m_WarningRegex.GroupNumberFromName("line")].Value;
                string message = m.Groups[m_WarningRegex.GroupNumberFromName("message")].Value;

                result.AddWarning(fileName, Int32.Parse(lineNum), 0, String.Empty, message);
            }

            // Extract potential SyntaxError
            foreach (Match m in m_ErrorRegex.Matches(output))
            {
                string lineNum = m.Groups[m_ErrorRegex.GroupNumberFromName("line")].Value;
                result.AddError(fileName, Int32.Parse(lineNum), 0, String.Empty, "SyntaxError");
            }
        }
        protected override BuildResult Compile(MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
        {
#if DEBUG
            monitor.Log.WriteLine("MonoGame Extension Compile Called");
#endif
            try
            {
                var cfg  = buildData.Configuration as MonoGameContentProjectConfiguration;
                var proj = item as MonoGameContentProject;
                if (proj == null || cfg == null)
                {
                    monitor.Log.WriteLine("Compiling for Unknown MonoGame Project");
                    return(base.Compile(monitor, item, buildData));
                }
                monitor.Log.WriteLine("Detected {0} MonoGame Platform", cfg.MonoGamePlatform);
                var result  = new BuildResult();
                var manager = new PipelineManager(proj.BaseDirectory.FullPath,
                                                  Path.Combine(buildData.Configuration.OutputDirectory, cfg.MonoGamePlatform),
                                                  buildData.Configuration.IntermediateOutputDirectory);

                manager.Logger   = new MonitorBuilder(monitor, result);
                manager.Platform = (TargetPlatform)Enum.Parse(typeof(TargetPlatform), cfg.MonoGamePlatform);
                try {
                    foreach (var pr in proj.ParentSolution.GetAllProjects())
                    {
                        if (pr is DotNetAssemblyProject)
                        {
                            var dot = pr as DotNetAssemblyProject;
                            foreach (var r in dot.References)
                            {
                                if (r.Package.Name == "monogame-contentpipeline")
                                {
                                    var output = dot.GetOutputFileName(buildData.ConfigurationSelector).FullPath;
                                    monitor.Log.WriteLine("Adding {0} to Content Pipeline Assembly List", output);
                                    manager.AddAssembly(output);
                                    proj.Manager.AddAssembly(output);
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    result.AddWarning(string.Format("Problem processing Content Extensions {0}", ex.Message));
                }

                var dict = new Microsoft.Xna.Framework.Content.Pipeline.OpaqueDataDictionary();
                if (cfg != null)
                {
                    if (cfg.XnaCompressContent.ToLowerInvariant() == "true")
                    {
                        // tell the manager to compress the output
                    }
                }
                foreach (var file in proj.Files)
                {
                    if (file.BuildAction == "Compile")
                    {
                        try
                        {
                            dict.Clear();
                            foreach (object key in file.ExtendedProperties.Keys)
                            {
                                string k = key as string;
                                if (k != null && k.StartsWith("ProcessorParameters_"))
                                {
                                    if (!dict.ContainsKey(k.Replace("ProcessorParameters_", String.Empty)))
                                    {
                                        dict.Add(k.Replace("ProcessorParameters_", String.Empty), file.ExtendedProperties[k]);
                                    }
                                    else
                                    {
                                        dict[k.Replace("ProcessorParameters_", String.Empty)] = file.ExtendedProperties[k];
                                    }
                                }
                            }

                            // check if the file has changed and rebuild if required.
                            manager.BuildContent(file.FilePath.FullPath,
                                                 null,
                                                 file.ExtendedProperties.Contains("Importer") ? (string)file.ExtendedProperties["Importer"] : null,
                                                 file.ExtendedProperties.Contains("Processor") ? (string)file.ExtendedProperties["Processor"] : null,
                                                 dict);
                        }
                        catch (Exception ex)
                        {
                            monitor.Log.WriteLine(ex.ToString());
                            result.AddError(ex.Message);
                        }
                    }
                }
                return(result);
            }
            finally
            {
#if DEBUG
                monitor.Log.WriteLine("MonoGame Extension Compile Ended");
#endif
            }
        }
Example #13
0
 public static void AddWarning(this BuildResult buildResult, ITaskRunnerNode task, ITaskRunnerCommandResult result)
 {
     buildResult.AddWarning(GetBuildWarning(task, result));
 }