public async Task<BuildResult> Build (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { var res = new BuildResult { BuildCount = 0 }; foreach (var bt in Items.OfType<IBuildTarget> ()) res.Append (await bt.Build (monitor, configuration, operationContext:operationContext)); return res; }
/// <summary> /// Builds the specified solution item. /// </summary> /// <param name = "monitor">The monitor.</param> /// <param name = "item">The item.</param> /// <param name = "configuration">The configuration.</param> /// <returns>The build result.</returns> protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration) { BuildResult result = new BuildResult (); // Pre-build monitor.BeginTask (GettextCatalog.GetString ("Pre-Building..."), 1); this.PreBuild (result, monitor, item, configuration); monitor.EndTask(); if (result.ErrorCount > 0) { return result; } // Build monitor.BeginTask (GettextCatalog.GetString ("Building"), 1); result.Append (base.Build (monitor, item, configuration)); monitor.EndTask(); if (result.ErrorCount > 0) { return result; } // Post-build monitor.BeginTask (GettextCatalog.GetString ("Post-Building..."), 1); this.PostBuild (result, monitor, item, configuration); monitor.EndTask(); return result; }
public static BuildResult UpdateDesignerFile ( CodeBehindWriter writer, AspNetAppProject project, ProjectFile file, ProjectFile designerFile ) { var result = new BuildResult (); //parse the ASP.NET file var parsedDocument = TypeSystemService.ParseFile (project, file.FilePath) as WebFormsParsedDocument; if (parsedDocument == null) { result.AddError (string.Format ("Failed to parse file '{0}'", file.Name)); return result; } //TODO: ensure type system is up to date CodeCompileUnit ccu; result.Append (GenerateCodeBehind (project, designerFile.FilePath, parsedDocument, out ccu)); if (ccu != null) { writer.WriteFile (designerFile.FilePath, ccu); } return result; }
protected internal override BuildResult OnRunTarget(IProgressMonitor monitor, string target, ConfigurationSelector configuration) { if (target == ProjectService.BuildTarget) { return(OnBuild(monitor, configuration)); } else if (target == ProjectService.CleanTarget) { OnClean(monitor, configuration); return(new BuildResult()); } ReadOnlyCollection <SolutionItem> allProjects; try { allProjects = GetAllBuildableEntries(configuration, true, true); } catch (CyclicDependencyException) { monitor.ReportError(GettextCatalog.GetString("Cyclic dependencies are not supported."), null); return(new BuildResult("", 1, 1)); } try { monitor.BeginTask(GettextCatalog.GetString("Building Solution: {0} ({1})", Name, configuration.ToString()), allProjects.Count); BuildResult cres = new BuildResult(); cres.BuildCount = 0; HashSet <SolutionItem> failedItems = new HashSet <SolutionItem> (); foreach (SolutionItem item in allProjects) { if (monitor.IsCancelRequested) { break; } if (!item.ContainsReferences(failedItems, configuration)) { BuildResult res = item.RunTarget(monitor, target, configuration); if (res != null) { cres.Append(res); if (res.ErrorCount > 0) { failedItems.Add(item); } } } else { failedItems.Add(item); } monitor.Step(1); } return(cres); } finally { monitor.EndTask(); } }
protected override BuildResult OnBuild(IProgressMonitor monitor, ConfigurationSelector configuration) { ReadOnlyCollection <SolutionItem> allProjects; try { allProjects = GetAllBuildableEntries(configuration, true, true); } catch (CyclicDependencyException) { monitor.ReportError(GettextCatalog.GetString("Cyclic dependencies are not supported."), null); return(new BuildResult("", 1, 1)); } try { List <SolutionItem> toBuild = new List <SolutionItem> (allProjects.Where(p => p.NeedsBuilding(configuration))); monitor.BeginTask(GettextCatalog.GetString("Building Solution: {0} ({1})", Name, configuration.ToString()), toBuild.Count); BuildResult cres = new BuildResult(); cres.BuildCount = 0; HashSet <SolutionItem> failedItems = new HashSet <SolutionItem> (); foreach (SolutionItem item in toBuild) { if (monitor.IsCancelRequested) { break; } if (!item.ContainsReferences(failedItems, configuration)) { BuildResult res = item.Build(monitor, configuration, false); if (res != null) { cres.Append(res); if (res.ErrorCount > 0) { failedItems.Add(item); } } } else { failedItems.Add(item); } monitor.Step(1); } return(cres); } finally { monitor.EndTask(); } }
public async Task <BuildResult> Build(ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { var res = new BuildResult { BuildCount = 0 }; foreach (var bt in Items.OfType <IBuildTarget> ()) { res.Append(await bt.Build(monitor, configuration, operationContext: operationContext)); } return(res); }
public async Task <BuildResult> Clean(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext = null) { AssertMainThread(); var res = new BuildResult { BuildCount = 0 }; foreach (var bt in Items.OfType <IBuildTarget> ()) { res.Append(await bt.Clean(monitor, configuration, operationContext)); } return(res); }
async Task<BuildResult> Pack (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets, OperationContext operationContext) { var result = new BuildResult (); // Build the project and any dependencies first. if (buildReferencedTargets && project.GetReferencedItems (configuration).Any ()) { result = await project.Build (monitor, configuration, buildReferencedTargets, operationContext); if (result.Failed) return result; } // Generate the NuGet package by calling the Pack target. var packResult = (await project.RunTarget (monitor, "Pack", configuration, new TargetEvaluationContext (operationContext))).BuildResult; return result.Append (packResult); }
protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem project, ConfigurationSelector configuration) { var aspProject = project as AspNetAppProject; //get the config object and validate AspNetAppProjectConfiguration config = (AspNetAppProjectConfiguration)aspProject.GetConfiguration (configuration); if (config == null || config.DisableCodeBehindGeneration) { return base.Build (monitor, project, configuration); } var writer = CodeBehindWriter.CreateForProject (monitor, aspProject); if (!writer.SupportsPartialTypes) { return base.Build (monitor, project, configuration); } var result = new BuildResult (); monitor.BeginTask ("Updating CodeBehind designer files", 0); foreach (var file in aspProject.Files) { ProjectFile designerFile = CodeBehind.GetDesignerFile (file); if (designerFile == null) continue; if (File.GetLastWriteTimeUtc (designerFile.FilePath) > File.GetLastWriteTimeUtc (file.FilePath)) continue; monitor.Log.WriteLine ("Updating CodeBehind for file '{0}'", file); result.Append (CodeBehind.UpdateDesignerFile (writer, aspProject, file, designerFile)); } writer.WriteOpenFiles (); monitor.EndTask (); if (writer.WrittenCount > 0) monitor.Log.WriteLine ("{0} CodeBehind designer classes updated.", writer.WrittenCount); else monitor.Log.WriteLine ("No changes made to CodeBehind classes."); if (result.Failed) return result; return result.Append (base.Build (monitor, project, configuration)); }
private void HandleOptLinkOutput(BuildResult br, string linkerOutput) { var matches = optlinkRegex.Matches (linkerOutput); var ctxt = ResolutionContext.Create(Project == null ? ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache) : Project.ParseCache, null, null); ctxt.ContextIndependentOptions = ResolutionOptions.IgnoreAllProtectionAttributes | ResolutionOptions.DontResolveBaseTypes | ResolutionOptions.DontResolveBaseClasses | ResolutionOptions.DontResolveAliases; foreach (Match match in matches) { var error = new BuildError (); // Get associated D source file if (match.Groups ["obj"].Success) { var obj = Project.GetAbsoluteChildPath (new FilePath (match.Groups ["obj"].Value)).ChangeExtension (".d"); foreach (var pf in Project.Files) if (pf.FilePath == obj) { error.FileName = pf.FilePath; break; } } var msg = match.Groups ["message"].Value; var symUndefMatch = symbolUndefRegex.Match(msg); if(symUndefMatch.Success && symUndefMatch.Groups["mangle"].Success) { var mangledSymbol = symUndefMatch.Groups["mangle"].Value; ITypeDeclaration qualifier; try{ var resSym = D_Parser.Misc.Mangling.Demangler.DemangleAndResolve(mangledSymbol, ctxt, out qualifier); if(resSym is DSymbol) { var ds = resSym as DSymbol; var ast = ds.Definition.NodeRoot as DModule; if(ast!=null) error.FileName = ast.FileName; error.Line = ds.Definition.Location.Line; error.Column = ds.Definition.Location.Column; msg = ds.Definition.ToString(false, true); } else msg = qualifier.ToString(); }catch(Exception ex) { msg = "<log analysis error> "+ex.Message; } error.ErrorText = msg + " could not be resolved - library reference missing?"; } else error.ErrorText = "Linker error " + match.Groups ["code"].Value + " - " + msg; br.Append (error); } }
/// <summary> /// Scans errorString line-wise for filename-line-message patterns (e.g. "myModule(1): Something's wrong here") and add these error locations to the CompilerResults cr. /// </summary> protected void HandleCompilerOutput(BuildResult br, string errorString) { var reader = new StringReader (errorString); string next; while ((next = reader.ReadLine()) != null) { var error = ErrorExtracting.FindError (next, reader); if (error != null) { if (!Path.IsPathRooted (error.FileName)) error.FileName = Project.GetAbsoluteChildPath (error.FileName); br.Append (error); } } reader.Close (); }
/// <summary> /// Builds the solution item /// </summary> /// <param name='monitor'> /// A progress monitor /// </param> /// <param name='solutionConfiguration'> /// Configuration to use to build the project /// </param> /// <param name='buildReferences'> /// When set to <c>true</c>, the referenced items will be built before building this item /// </param> public BuildResult Build(IProgressMonitor monitor, ConfigurationSelector solutionConfiguration, bool buildReferences) { if (!buildReferences) { //SolutionFolder's OnRunTarget handles the begin/end task itself, don't duplicate if (this is SolutionFolder) { return(RunTarget(monitor, ProjectService.BuildTarget, solutionConfiguration)); } try { SolutionEntityItem it = this as SolutionEntityItem; SolutionItemConfiguration iconf = it != null?it.GetConfiguration(solutionConfiguration) : null; string confName = iconf != null ? iconf.Id : solutionConfiguration.ToString(); monitor.BeginTask(GettextCatalog.GetString("Building: {0} ({1})", Name, confName), 1); using (Counters.BuildProjectTimer.BeginTiming("Building " + Name, GetProjectEventMetadata(solutionConfiguration))) { // This will end calling OnBuild () return(RunTarget(monitor, ProjectService.BuildTarget, solutionConfiguration)); } } finally { monitor.EndTask(); } } ITimeTracker tt = Counters.BuildProjectAndReferencesTimer.BeginTiming("Building " + Name, GetProjectEventMetadata(solutionConfiguration)); try { // Get a list of all items that need to be built (including this), // and build them in the correct order List <SolutionItem> referenced = new List <SolutionItem> (); Set <SolutionItem> visited = new Set <SolutionItem> (); GetBuildableReferencedItems(visited, referenced, this, solutionConfiguration); ReadOnlyCollection <SolutionItem> sortedReferenced = SolutionFolder.TopologicalSort(referenced, solutionConfiguration); BuildResult cres = new BuildResult(); cres.BuildCount = 0; HashSet <SolutionItem> failedItems = new HashSet <SolutionItem> (); monitor.BeginTask(null, sortedReferenced.Count); foreach (SolutionItem p in sortedReferenced) { if (!p.ContainsReferences(failedItems, solutionConfiguration)) { BuildResult res = p.Build(monitor, solutionConfiguration, false); cres.Append(res); if (res.ErrorCount > 0) { failedItems.Add(p); } } else { failedItems.Add(p); } monitor.Step(1); if (monitor.IsCancelRequested) { break; } } monitor.EndTask(); return(cres); } finally { tt.End(); } }
/// <summary> /// Scans errorString line-wise for filename-line-message patterns (e.g. "myModule(1): Something's wrong here") and add these error locations to the CompilerResults cr. /// </summary> public static void HandleCompilerOutput(AbstractDProject Project, BuildResult br, string errorString) { var reader = new StringReader(errorString); string next; while ((next = reader.ReadLine()) != null) { var error = ErrorExtracting.FindError(next, reader); if (error != null) { if (error.ErrorText != null && error.ErrorText.Length > MaxErrorMsgLength) error.ErrorText = error.ErrorText.Substring (0, MaxErrorMsgLength) + "..."; // dmd's error filenames may contain mixin location info var m = mixinInlineRegex.Match (error.FileName); if (m.Success) { error.FileName = error.FileName.Substring (0, m.Index); int line; int.TryParse (m.Groups ["line"].Value, out line); error.Line = line; } if (!Path.IsPathRooted(error.FileName)) error.FileName = Project.GetAbsoluteChildPath(error.FileName); br.Append(error); } } reader.Close(); }
public static void HandleLdOutput(AbstractDProject prj, BuildResult br, string linkerOutput) { var ctxt = ResolutionContext.Create(DResolverWrapper.CreateParseCacheView(prj), null, null); ctxt.ContextIndependentOptions = ResolutionOptions.IgnoreAllProtectionAttributes | ResolutionOptions.DontResolveBaseTypes | ResolutionOptions.DontResolveBaseClasses | ResolutionOptions.DontResolveAliases; foreach (Match m in ldErrorRegex.Matches(linkerOutput)) { var error = new BuildError(); var firstSymbolOccurring = ldMangleRegex.Match(m.Groups["err"].Value); if(firstSymbolOccurring.Success) { var mangledString = "_D" + firstSymbolOccurring.Groups["mangle"].Value; var associatedSymbol = DResolver.GetResultMember(Demangler.DemangleAndResolve(mangledString, ctxt)); if(associatedSymbol != null) { error.FileName = (associatedSymbol.NodeRoot as DModule).FileName; error.Line = associatedSymbol.Location.Line; error.Column = associatedSymbol.Location.Column; } } error.ErrorText = m.Groups["msg"].Value; if (string.IsNullOrWhiteSpace(error.ErrorText)) error.ErrorText = m.Groups["err"].Value; error.ErrorText = DemangleLdOutput(error.ErrorText); br.Append(error); } }
static BuildResult ParseOutput(string stdout, string stderr) { BuildResult result = new BuildResult (); StringBuilder compilerOutput = new StringBuilder (); bool typeLoadException = false; foreach (string s in new string[] { stdout, stderr }) { StreamReader sr = File.OpenText (s); while (true) { if (typeLoadException) { compilerOutput.Append (sr.ReadToEnd ()); break; } string curLine = sr.ReadLine(); compilerOutput.AppendLine (curLine); if (curLine == null) break; curLine = curLine.Trim(); if (curLine.Length == 0) continue; if (curLine.StartsWith ("Unhandled Exception: System.TypeLoadException") || curLine.StartsWith ("Unhandled Exception: System.IO.FileNotFoundException")) { result.ClearErrors (); typeLoadException = true; } BuildError error = CreateErrorFromString (curLine); if (error != null) result.Append (error); } sr.Close(); } if (typeLoadException) { Regex reg = new Regex (@".*WARNING.*used in (mscorlib|System),.*", RegexOptions.Multiline); if (reg.Match (compilerOutput.ToString ()).Success) result.AddError ("", 0, 0, "", "Error: A referenced assembly may be built with an incompatible CLR version. See the compilation output for more details."); else result.AddError ("", 0, 0, "", "Error: A dependency of a referenced assembly may be missing, or you may be referencing an assembly created with a newer CLR version. See the compilation output for more details."); } result.CompilerOutput = compilerOutput.ToString (); return result; }
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); var result = new BuildResult (output.ToString (), 1, 0); string[] lines = result.CompilerOutput.Split ('\n'); foreach (string line in lines) { var err = CreateErrorFromString (line); if (err != null) result.Append (err); } return result; } } }
BuildResult ParseOutput(TempFileCollection tf, string output) { var result = new BuildResult (output, 1, 0); using (var sr = new StringReader (output)) { while (true) { string curLine = sr.ReadLine(); if (curLine == null) { break; } curLine = curLine.Trim(); if (curLine.Length == 0) { continue; } var error = CreateErrorFromString (curLine); if (error != null) result.Append (error); } } return result; }
protected override BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration) { BuildResult results = new BuildResult ("", 1, 0); string outputDirectory = GetOutputDirectory (configuration); if (!string.IsNullOrEmpty (outputDirectory)) { foreach (Translation translation in this.Translations) { if (translation.NeedsBuilding (configuration)) { BuildResult res = translation.Build (monitor, configuration); results.Append (res); } } isDirty = false; } return results; }
static BuildResult CreateMergedPlist (IProgressMonitor monitor, IPhoneProjectConfiguration conf, ProjectFile template, string outPath, Func<IPhoneProjectConfiguration, PlistDocument,BuildResult> merge) { var result = new BuildResult (); var doc = new PlistDocument (); if (template != null) { try { doc.LoadFromXmlFile (template.FilePath); } catch (Exception ex) { if (ex is XmlException) result.AddError (template.FilePath, ((XmlException)ex).LineNumber, ((XmlException)ex).LinePosition, null, ex.Message); else result.AddError (template.FilePath, 0, 0, null, ex.Message); monitor.ReportError (GettextCatalog.GetString ("Could not load file '{0}': {1}", template.FilePath, ex.Message), null); return result; } } if (result.Append (merge (conf, doc)).ErrorCount > 0) return result; try { EnsureDirectoryForFile (outPath); using (XmlTextWriter writer = new XmlTextWriter (outPath, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; doc.Write (writer); } } catch (Exception ex) { result.AddError (outPath, 0, 0, null, ex.Message); monitor.ReportError (GettextCatalog.GetString ("Could not write file '{0}'", outPath), ex); } return result; }
protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem item, ConfigurationSelector configuration) { IPhoneProject proj = item as IPhoneProject; if (proj == null || proj.CompileTarget != CompileTarget.Exe) return base.Build (monitor, item, configuration); IPhoneFramework.CheckInfoCaches (); //prebuild var conf = (IPhoneProjectConfiguration) proj.GetConfiguration (configuration); bool isDevice = conf.Platform == IPhoneProject.PLAT_IPHONE; if (IPhoneFramework.SimOnly && isDevice) { //if in the GUI, show a dialog too if (MonoDevelop.Ide.IdeApp.IsInitialized) Gtk.Application.Invoke (delegate { IPhoneFramework.ShowSimOnlyDialog (); } ); return IPhoneFramework.GetSimOnlyError (); } var result = new BuildResult (); var sdkVersion = conf.MtouchSdkVersion.ResolveIfDefault (); if (!IPhoneFramework.SdkIsInstalled (sdkVersion)) { sdkVersion = IPhoneFramework.GetClosestInstalledSdk (sdkVersion); if (sdkVersion.IsUseDefault || !IPhoneFramework.SdkIsInstalled (sdkVersion)) { if (conf.MtouchSdkVersion.IsUseDefault) result.AddError ( string.Format ("The Apple iPhone SDK is not installed.")); else result.AddError ( string.Format ("Apple iPhone SDK version '{0}' is not installed, and no newer version was found.", conf.MtouchSdkVersion)); return result; } result.AddWarning ( string.Format ("Apple iPhone SDK version '{0}' is not installed. Using newer version '{1}' instead'.", conf.MtouchSdkVersion, sdkVersion)); } IPhoneAppIdentity identity = null; if (isDevice) { monitor.BeginTask (GettextCatalog.GetString ("Detecting signing identity..."), 0); if ((result = GetIdentity (monitor, proj, conf, out identity).Append (result)).ErrorCount > 0) return result; monitor.Log.WriteLine ("Provisioning profile: \"{0}\" ({1})", identity.Profile.Name, identity.Profile.Uuid); monitor.Log.WriteLine ("Signing Identity: \"{0}\"", Keychain.GetCertificateCommonName (identity.SigningKey)); monitor.Log.WriteLine ("App ID: \"{0}\"", identity.AppID); monitor.EndTask (); } else { identity = new IPhoneAppIdentity () { BundleID = !string.IsNullOrEmpty (proj.BundleIdentifier)? proj.BundleIdentifier : GetDefaultBundleID (proj, null) }; } result = base.Build (monitor, item, configuration).Append (result); if (result.ErrorCount > 0) return result; if (!Directory.Exists (conf.AppDirectory)) Directory.CreateDirectory (conf.AppDirectory); var assemblyRefs = proj.GetReferencedAssemblies (configuration).Distinct ().ToList (); FilePath mtouchOutput = conf.NativeExe; if (new FilePair (conf.CompiledOutputName, mtouchOutput).NeedsBuilding ()) { BuildResult error; var mtouch = GetMTouch (proj, monitor, out error); if (error != null) return error.Append (result); var args = new ProcessArgumentBuilder (); //FIXME: make verbosity configurable? args.Add ("-v"); args.Add ("--nomanifest", "--nosign"); //FIXME: should we error out if the platform is invalid? if (conf.Platform == IPhoneProject.PLAT_IPHONE) { args.Add ("-dev"); args.AddQuoted (conf.AppDirectory); } else { args.Add ("-sim"); args.AddQuoted (conf.AppDirectory); } foreach (string asm in assemblyRefs) args.AddQuotedFormat ("-r={0}", asm); IPhoneSdkVersion osVersion = IPhoneSdkVersion.V3_0; try { osVersion = IPhoneSdkVersion.Parse (conf.MtouchMinimumOSVersion); } catch { result.AddWarning ("Could not parse minimum OS version '" + conf.MtouchMinimumOSVersion + "'"); } if (osVersion < IPhoneSdkVersion.V3_0 && conf.MtouchArch == MtouchArch.ARMv7) { result.AddError ("Apps with a minimum OS older than 3.1 cannot be ARMv7 only"); return result; } AppendExtrasMtouchArgs (args, sdkVersion, proj, conf); args.AddQuoted (conf.CompiledOutputName); mtouch.WorkingDirectory = conf.OutputDirectory; mtouch.Arguments = args.ToString (); monitor.BeginTask (GettextCatalog.GetString ("Compiling to native code"), 0); string output; int code; monitor.Log.WriteLine ("{0} {1}", mtouch.FileName, mtouch.Arguments); if ((code = MacBuildUtilities.ExecuteCommand (monitor, mtouch, out output)) != 0) { if (String.IsNullOrEmpty (output)) { result.AddError (null, 0, 0, code.ToString (), "mtouch failed with no output"); } else { result.AddError (null, 0, 0, code.ToString (), "mtouch failed with the following message:\n" + output); } return result; } monitor.EndTask (); } //unpack nibs and content from dll resources (MT 4+ only) if (IPhoneFramework.MonoTouchVersion >= new IPhoneSdkVersion (3, 99)) if (result.Append (UnpackContent (monitor, conf, assemblyRefs)).ErrorCount > 0) return result; //create the info.plist, merging in the template if it exists var plistOut = conf.AppDirectory.Combine ("Info.plist"); ProjectFile appInfoIn = proj.Files.GetFile (proj.BaseDirectory.Combine ("Info.plist")); if (new FilePair (proj.FileName, plistOut).NeedsBuilding () || (appInfoIn != null && new FilePair (appInfoIn.FilePath, plistOut).NeedsBuilding ())) { try { monitor.BeginTask (GettextCatalog.GetString ("Updating application manifest"), 0); if (result.Append (UpdateInfoPlist (monitor, sdkVersion, proj, conf, identity, appInfoIn, plistOut)).ErrorCount > 0) return result; } finally { monitor.EndTask (); } } //create the Setting.bundle plist for debug settings, merging in the template if it exists try { monitor.BeginTask (GettextCatalog.GetString ("Updating debug settings manifest"), 0); var sbRootRel = Path.Combine ("Settings.bundle", "Root.plist"); var sbRootOut = conf.AppDirectory.Combine (sbRootRel); var sbRootIn = proj.Files.GetFile (proj.BaseDirectory.Combine (sbRootRel)); if (result.Append (UpdateDebugSettingsPlist (monitor, conf, sbRootIn, sbRootOut)).ErrorCount > 0) return result; } finally { monitor.EndTask (); } try { if (result.Append (ProcessPackaging (monitor, sdkVersion, proj, conf, identity)).ErrorCount > 0) return result; } finally { //if packaging failed, make sure that it's marked as needing building if (result.ErrorCount > 0 && File.Exists (conf.AppDirectory.Combine ("PkgInfo"))) File.Delete (conf.AppDirectory.Combine ("PkgInfo")); } //TODO: create/update the xcode project return result; }
protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { var toBuild = Translations.Where (t => t.NeedsBuilding(configuration)).ToArray (); BuildResult results = new BuildResult ("", 1, 0); string outputDirectory = GetOutputDirectory (configuration); if (!string.IsNullOrEmpty (outputDirectory)) { await Task.Run (delegate { foreach (Translation translation in toBuild) { if (translation.NeedsBuilding (configuration)) { BuildResult res = translation.Build (monitor, configuration); results.Append (res); } } isDirty = false; }); } return results; }
static BuildResult ProcessPackaging (IProgressMonitor monitor, IPhoneSdkVersion sdkVersion, IPhoneProject proj, IPhoneProjectConfiguration conf, IPhoneAppIdentity identity) { //don't bother signing in the sim bool isDevice = conf.Platform == IPhoneProject.PLAT_IPHONE; if (!isDevice) return null; BuildResult result = new BuildResult (); var pkgInfo = conf.AppDirectory.Combine ("PkgInfo"); if (!File.Exists (pkgInfo)) using (var f = File.OpenWrite (pkgInfo)) f.Write (new byte [] { 0X41, 0X50, 0X50, 0X4C, 0x3f, 0x3f, 0x3f, 0x3f}, 0, 8); if (result.Append (CompressResources (monitor, conf)).ErrorCount > 0) return result; if (result.Append (EmbedProvisioningProfile (monitor, conf, identity.Profile)).ErrorCount > 0) return result; string xcent; if (result.Append (GenXcent (monitor, sdkVersion, proj, conf, identity, out xcent)).ErrorCount > 0) return result; string resRules; if (result.Append (PrepareResourceRules (monitor, sdkVersion, conf, out resRules)).ErrorCount > 0) return result; if (result.Append (SignAppBundle (monitor, proj, conf, identity.SigningKey, resRules, xcent)).ErrorCount > 0) return result; return result; }
public async Task<BuildResult> Clean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext = null) { AssertMainThread (); var res = new BuildResult { BuildCount = 0 }; foreach (var bt in Items.OfType<IBuildTarget> ()) res.Append (await bt.Clean (monitor, configuration, operationContext)); return res; }
public static BuildResult CreateMergedPlist (IProgressMonitor monitor, ProjectFile template, string outPath, Func<PlistDocument,BuildResult> merge) { var result = new BuildResult (); var doc = new PlistDocument (); if (template != null) { try { doc.LoadFromXmlFile (template.FilePath); } catch (Exception ex) { if (ex is XmlException) result.AddError (template.FilePath, ((XmlException)ex).LineNumber, ((XmlException)ex).LinePosition, null, ex.Message); else result.AddError (template.FilePath, 0, 0, null, ex.Message); monitor.ReportError (GettextCatalog.GetString ("Could not load file '{0}': {1}", template.FilePath, ex.Message), null); return result; } } try { if (result.Append (merge (doc)).ErrorCount > 0) return result; } catch (Exception ex) { result.AddError ("Error merging Info.plist: " + ex.Message); LoggingService.LogError ("Error merging Info.plist", ex); return result; } try { EnsureDirectoryForFile (outPath); doc.WriteToFile (outPath); } catch (Exception ex) { result.AddError (outPath, 0, 0, null, ex.Message); monitor.ReportError (GettextCatalog.GetString ("Could not write file '{0}'", outPath), ex); } return result; }
internal static async Task <BuildResult> RunParallelBuildOperation(ProgressMonitor monitor, ConfigurationSelector configuration, IEnumerable <SolutionItem> sortedItems, Func <ProgressMonitor, SolutionItem, Task <BuildResult> > buildAction, bool ignoreFailed) { List <SolutionItem> toBuild = new List <SolutionItem> (sortedItems); BuildResult cres = new BuildResult(); cres.BuildCount = 0; // Limit the number of concurrent builders to processors / 2 var slotScheduler = new TaskSlotScheduler(Environment.ProcessorCount / 2); // Create a dictionary with the status objects of all items var buildStatus = new Dictionary <SolutionItem, BuildStatus> (); foreach (var it in toBuild) { buildStatus.Add(it, new BuildStatus()); } // Start the build tasks for all itemsw foreach (var itemToBuild in toBuild) { if (monitor.CancellationToken.IsCancellationRequested) { break; } var item = itemToBuild; var myStatus = buildStatus [item]; var myMonitor = monitor.BeginAsyncStep(1); // Get a list of the status objects for all items on which this one depends var refStatus = item.GetReferencedItems(configuration).Select(it => { BuildStatus bs; buildStatus.TryGetValue(it, out bs); return(bs); }).Where(t => t != null).ToArray(); // Build the item when all its dependencies have been built var refTasks = refStatus.Select(bs => bs.Task); myStatus.Task = Task.WhenAll(refTasks).ContinueWith(async t => { if (!ignoreFailed && (refStatus.Any(bs => bs.Failed) || t.IsFaulted)) { myStatus.Failed = true; } else { using (await slotScheduler.GetTaskSlot()) myStatus.Result = await buildAction(myMonitor, item); myStatus.Failed = myStatus.Result != null && myStatus.Result.ErrorCount > 0; } myMonitor.Dispose(); }, Runtime.MainTaskScheduler).Unwrap(); if (!Runtime.Preferences.ParallelBuild.Value) { await myStatus.Task; } } // Wait for all tasks to end await Task.WhenAll(buildStatus.Values.Select(bs => bs.Task)); // Generate the errors in the order they were supposed to build foreach (var it in toBuild) { BuildStatus bs; if (buildStatus.TryGetValue(it, out bs) && bs.Result != null) { cres.Append(bs.Result); } } return(cres); }
BuildResult ParseOutput(TypeScriptProject project, string stdOutAndErr) { BuildResult result = new BuildResult (); StringBuilder output = new StringBuilder (); bool enteredStackTrace = false; string next = string.Empty; foreach (var l in stdOutAndErr.Split ('\n').Select (l => l.Trim ()).Concat (new string [] {""})) { var line = next; next = l; output.AppendLine (line); if (next == "throw err;") { result.Append (new BuildError () { ErrorText = "Internal compiler error occured. Check build output for details."}); enteredStackTrace = true; } if (enteredStackTrace || line.Length == 0 || line.StartsWith ("\t")) continue; var error = new BuildError (); var match = error_rex.Match (line); if (match.Length > 0) { error.FileName = match.Groups [1].ToString ().TrimEnd (' '); error.Line = int.Parse (match.Groups [2].ToString ()); error.Column = int.Parse (match.Groups [3].ToString ()); error.ErrorText = match.Groups [4].ToString (); } else error.ErrorText = line; result.Append (error); } result.CompilerOutput = output.ToString (); return result; }
static void ParserOutputFile(HaxeProject project, BuildResult result, StringBuilder output, string filename) { StreamReader reader = File.OpenText (filename); string line; while ((line = reader.ReadLine()) != null) { output.AppendLine (line); line = line.Trim (); if (line.Length == 0 || line.StartsWith ("\t")) continue; BuildError error = CreateErrorFromString (project, line); if (error != null) result.Append (error); } reader.Close (); }
private void HandleOptLinkOutput(BuildResult br, string linkerOutput) { var matches = optlinkRegex.Matches (linkerOutput); foreach (Match match in matches) { var error = new BuildError (); // Get associated D source file if (match.Groups ["obj"].Success) { var obj = Project.GetAbsoluteChildPath (new FilePath (match.Groups ["obj"].Value)).ChangeExtension (".d"); foreach (var pf in Project.Files) if (pf.FilePath == obj) { error.FileName = pf.FilePath; break; } } error.ErrorText = "Linker error " + match.Groups ["code"].Value + " - " + match.Groups ["message"].Value; br.Append (error); } }