コード例 #1
0
        protected override SolutionEntityItem LoadSolutionItem(IProgressMonitor monitor, string fileName)
        {
            SolutionEntityItem entry = base.LoadSolutionItem(monitor, fileName);

            if (entry == null)
            {
                return(null);
            }

            Project project = entry as Project;

            if (project == null)
            {
                return(entry);
            }

            //Project
            MakefileData data = entry.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;

            if (data == null)
            {
                return(entry);
            }

            monitor.BeginTask(GettextCatalog.GetString("Updating project from Makefile"), 1);
            try
            {
                data.OwnerProject = project;
                if (data.SupportsIntegration)
                {
                    data.UpdateProject(monitor, false);
                }
                monitor.Step(1);
            }
            catch (Exception e)
            {
                monitor.ReportError(GettextCatalog.GetString(
                                        "Error loading Makefile for project {0}", project.Name), e);
            }
            finally
            {
                monitor.EndTask();
            }

            entry.SetNeedsBuilding(false);
            return(entry);
        }
コード例 #2
0
		//FIXME: Check whether autogen.sh is required or not
		protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
		{
			Project project = entry as Project;
			if (project == null)
				return base.Build (monitor, entry, configuration);

			MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
			if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.BuildTargetName))
				return base.Build (monitor, entry, configuration);

			//FIXME: Gen autofoo ? autoreconf?

			string output = String.Empty;
			int exitCode = 0;
			monitor.BeginTask (GettextCatalog.GetString ("Building {0}", project.Name), 1);
			try {
				string baseDir = project.BaseDirectory;
				StringBuilder args = new StringBuilder ();
				
				if (data.RelativeMakeCommand.EndsWith ("make", StringComparison.OrdinalIgnoreCase))
					args.AppendFormat (" -j {0}", data.ParallelProcesses, data.BuildTargetName);
				args.AppendFormat (" {0}", data.BuildTargetName);
	
				StringWriter swOutput = new StringWriter ();
				LogTextWriter chainedOutput = new LogTextWriter ();
				chainedOutput.ChainWriter (monitor.Log);
				chainedOutput.ChainWriter (swOutput);
				
				ProcessWrapper process = Runtime.ProcessService.StartProcess (data.AbsoluteMakeCommand, 
						args.ToString (), 
						baseDir, 
						chainedOutput, 
						chainedOutput, 
						null);
				process.WaitForOutput ();

				exitCode = process.ExitCode;
				output = swOutput.ToString ();
				chainedOutput.Close ();
				swOutput.Close ();
				monitor.Step (1);
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString ("Project could not be built: "), e);
				return null;
			} finally {
				monitor.EndTask ();
			}

			TempFileCollection tf = new TempFileCollection ();
			Regex regexError = data.GetErrorRegex (false);
			Regex regexWarning = data.GetWarningRegex (false);

			BuildResult cr = ParseOutput (tf, output, project.BaseDirectory, regexError, regexWarning);
			if (exitCode != 0 && cr.FailedBuildCount == 0)
				cr.AddError (GettextCatalog.GetString ("Build failed. See Build Output panel."));
			else
				entry.SetNeedsBuilding (false, configuration);

			return cr;
		}
コード例 #3
0
        //FIXME: Check whether autogen.sh is required or not
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            Project project = entry as Project;

            if (project == null)
            {
                return(base.Build(monitor, entry, configuration));
            }

            MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;

            if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.BuildTargetName))
            {
                return(base.Build(monitor, entry, configuration));
            }

            //FIXME: Gen autofoo ? autoreconf?

            string output   = String.Empty;
            int    exitCode = 0;

            monitor.BeginTask(GettextCatalog.GetString("Building {0}", project.Name), 1);
            try
            {
                string baseDir = project.BaseDirectory;
                string args    = string.Format("-j {0} {1}", data.ParallelProcesses, data.BuildTargetName);

                StringWriter  swOutput      = new StringWriter();
                LogTextWriter chainedOutput = new LogTextWriter();
                chainedOutput.ChainWriter(monitor.Log);
                chainedOutput.ChainWriter(swOutput);

                ProcessWrapper process = Runtime.ProcessService.StartProcess("make",
                                                                             args,
                                                                             baseDir,
                                                                             chainedOutput,
                                                                             chainedOutput,
                                                                             null);
                process.WaitForOutput();

                exitCode = process.ExitCode;
                output   = swOutput.ToString();
                chainedOutput.Close();
                swOutput.Close();
                monitor.Step(1);
            }
            catch (Exception e)
            {
                monitor.ReportError(GettextCatalog.GetString("Project could not be built: "), e);
                return(null);
            }
            finally
            {
                monitor.EndTask();
            }

            TempFileCollection tf = new TempFileCollection();
            Regex regexError      = data.GetErrorRegex(false);
            Regex regexWarning    = data.GetWarningRegex(false);

            BuildResult cr = ParseOutput(tf, output, project.BaseDirectory, regexError, regexWarning);

            if (exitCode != 0 && cr.FailedBuildCount == 0)
            {
                cr.AddError(GettextCatalog.GetString("Build failed. See Build Output panel."));
            }
            else
            {
                entry.SetNeedsBuilding(false, configuration);
            }

            return(cr);
        }