//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); using (var swOutput = new StringWriter ()) { using (var chainedOutput = new LogTextWriter ()) { chainedOutput.ChainWriter (monitor.Log); chainedOutput.ChainWriter (swOutput); using (ProcessWrapper process = Runtime.ProcessService.StartProcess ("make", args, baseDir, chainedOutput, chainedOutput, null)) { process.WaitForOutput (); chainedOutput.UnchainWriter (monitor.Log); chainedOutput.UnchainWriter (swOutput); exitCode = process.ExitCode; output = swOutput.ToString (); 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.")); return cr; }
//FIXME: Check whether autogen.sh is required or not protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.BuildTargetName)) return await base.OnBuild (monitor, configuration, operationContext); //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); using (var swOutput = new StringWriter ()) { using (var chainedOutput = new LogTextWriter ()) { chainedOutput.ChainWriter (monitor.Log); chainedOutput.ChainWriter (swOutput); using (ProcessWrapper process = Runtime.ProcessService.StartProcess ("make", args, baseDir, chainedOutput, chainedOutput, null)) { await process.Task; chainedOutput.UnchainWriter (monitor.Log); chainedOutput.UnchainWriter (swOutput); exitCode = process.ExitCode; output = swOutput.ToString (); 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.")); return cr; }
public bool Deploy ( DeployContext ctx, Solution solution, string defaultConf, string targetDir, bool generateFiles, IProgressMonitor monitor ) { if (generateFiles) { if ( !GenerateFiles ( ctx, solution, defaultConf, monitor ) ) return false; } monitor.BeginTask ( GettextCatalog.GetString( "Deploying Solution to Tarball" ) , 3 ); try { string baseDir = Path.GetDirectoryName ( solution.FileName); ProcessWrapper ag_process = Runtime.ProcessService.StartProcess ( "sh", generateAutotools ? "autogen.sh" : "configure", baseDir, monitor.Log, monitor.Log, null ); ag_process.WaitForOutput (); if ( ag_process.ExitCode > 0 ) throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", generateAutotools ? "autogen.sh" : "configure") ); monitor.Step ( 1 ); using (var sw = new StringWriter ()) { using (var chainedOutput = new LogTextWriter ()) { chainedOutput.ChainWriter (monitor.Log); chainedOutput.ChainWriter (sw); using (ProcessWrapper process = Runtime.ProcessService.StartProcess ("make", "dist", baseDir, chainedOutput, monitor.Log, null)) { process.WaitForOutput (); chainedOutput.UnchainWriter (monitor.Log); chainedOutput.UnchainWriter (sw); if ( process.ExitCode > 0 ) throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", "make dist") ); } monitor.Step ( 1 ); // FIXME: hackish way to get the created tarball's filename string output = sw.ToString(); int targz = output.LastIndexOf ( "tar.gz" ); int begin = output.LastIndexOf ( '>', targz ); string filename = output.Substring ( begin + 1, (targz - begin) + 5 ).Trim (); FileService.CopyFile (Path.Combine (baseDir, filename), Path.Combine (targetDir, filename)); monitor.Step ( 1 ); } } } catch ( Exception e ) { monitor.ReportError ( GettextCatalog.GetString ("Solution could not be deployed: "), e ); return false; } finally { monitor.EndTask (); } monitor.ReportSuccess (GettextCatalog.GetString ("Solution was successfully deployed.")); return true; }
int ExecuteCommand (string command, string args, string baseDirectory, ProgressMonitor monitor, out string errorOutput) { errorOutput = string.Empty; int exitCode = -1; using (var swError = new StringWriter ()) { using (var chainedError = new LogTextWriter ()) { chainedError.ChainWriter (monitor.Log); chainedError.ChainWriter (swError); monitor.Log.WriteLine ("{0} {1}", command, args); using (ProcessWrapper p = Runtime.ProcessService.StartProcess (command, args, baseDirectory, monitor.Log, chainedError, null)) using (monitor.CancellationToken.Register (p.Cancel)) { p.WaitForOutput (); chainedError.UnchainWriter (monitor.Log); chainedError.UnchainWriter (swError); errorOutput = swError.ToString (); exitCode = p.ExitCode; if (monitor.CancellationToken.IsCancellationRequested) { monitor.Log.WriteLine (GettextCatalog.GetString ("Build cancelled")); monitor.ReportError (GettextCatalog.GetString ("Build cancelled"), null); if (exitCode == 0) exitCode = -1; } } } } return exitCode; }
public BuildResult RunTarget (MonoDevelop.Core.IProgressMonitor monitor, string target, ConfigurationSelector configuration) { if (target == ProjectService.BuildTarget) target = "all"; else if (target == ProjectService.CleanTarget) target = "clean"; DotNetProjectConfiguration conf = (DotNetProjectConfiguration) project.GetConfiguration (configuration); using (var output = new StringWriter ()) { using (var tw = new LogTextWriter ()) { tw.ChainWriter (output); tw.ChainWriter (monitor.Log); using (ProcessWrapper proc = Runtime.ProcessService.StartProcess ("make", "PROFILE=" + conf.Id + " " + target, conf.OutputDirectory, monitor.Log, tw, null)) proc.WaitForOutput (); tw.UnchainWriter (output); tw.UnchainWriter (monitor.Log); CompilerResults cr = new CompilerResults (null); string[] lines = output.ToString().Split ('\n'); foreach (string line in lines) { CompilerError err = CreateErrorFromString (line); if (err != null) cr.Errors.Add (err); } return new BuildResult (cr, output.ToString()); } } }