void InstallEntry (ProgressMonitor monitor, DeployContext ctx, SolutionFolderItem entry, ConfigurationSelector configuration) { foreach (DeployFile df in DeployService.GetDeployFiles (ctx, new SolutionFolderItem[] { entry }, configuration)) { string targetPath = df.ResolvedTargetFile; if (targetPath == null) { monitor.ReportWarning ("Could not copy file '" + df.RelativeTargetPath + "': Unknown target directory."); continue; } CopyFile (monitor, df.SourcePath, df.ResolvedTargetFile, df.FileAttributes); } SolutionFolder c = entry as SolutionFolder; if (c != null) { monitor.BeginTask ("Installing solution '" + c.Name + "'", c.Items.Count); foreach (SolutionFolderItem ce in c.Items) { InstallEntry (monitor, ctx, ce, configuration); monitor.Step (1); } monitor.EndTask (); } }
public object ReadFile (FilePath fileName, bool hasParentSolution, ProgressMonitor monitor) { FilePath basePath = fileName.ParentDirectory; MonoMakefile mkfile = new MonoMakefile (fileName); string aname = mkfile.GetVariable ("LIBRARY"); if (aname == null) aname = mkfile.GetVariable ("PROGRAM"); if (!string.IsNullOrEmpty (aname)) { monitor.BeginTask ("Loading '" + fileName + "'", 0); var project = Services.ProjectService.CreateProject ("C#"); project.FileName = fileName; var ext = new MonoMakefileProjectExtension (); project.AttachExtension (ext); ext.Read (mkfile); monitor.EndTask (); return project; } string subdirs; StringBuilder subdirsBuilder = new StringBuilder (); subdirsBuilder.Append (mkfile.GetVariable ("common_dirs")); if (subdirsBuilder.Length != 0) { subdirsBuilder.Append ("\t"); subdirsBuilder.Append (mkfile.GetVariable ("net_2_0_dirs")); } if (subdirsBuilder.Length == 0) subdirsBuilder.Append (mkfile.GetVariable ("SUBDIRS")); subdirs = subdirsBuilder.ToString (); if (subdirs != null && (subdirs = subdirs.Trim (' ', '\t')) != "") { object retObject; SolutionFolder folder; if (!hasParentSolution) { Solution sol = new Solution (); sol.AttachExtension (new MonoMakefileSolutionExtension ()); sol.FileName = fileName; folder = sol.RootFolder; retObject = sol; foreach (string conf in MonoMakefile.MonoConfigurations) { SolutionConfiguration sc = new SolutionConfiguration (conf); sol.Configurations.Add (sc); } } else { folder = new SolutionFolder (); folder.Name = Path.GetFileName (Path.GetDirectoryName (fileName)); retObject = folder; } subdirs = subdirs.Replace ('\t', ' '); string[] dirs = subdirs.Split (' '); monitor.BeginTask ("Loading '" + fileName + "'", dirs.Length); HashSet<string> added = new HashSet<string> (); foreach (string dir in dirs) { if (!added.Add (dir)) continue; monitor.Step (1); if (dir == null) continue; string tdir = dir.Trim (); if (tdir == "") continue; string mfile = Path.Combine (Path.Combine (basePath, tdir), "Makefile"); if (File.Exists (mfile) && CanRead (mfile, typeof(SolutionItem))) { SolutionFolderItem it = (SolutionFolderItem) ReadFile (mfile, true, monitor); folder.Items.Add (it); } } monitor.EndTask (); return retObject; } return null; }
public Makefile Deploy (AutotoolsContext ctx, SolutionFolderItem entry, ProgressMonitor monitor) { generateAutotools = ctx.MakefileType == MakefileType.AutotoolsMakefile; monitor.BeginTask ( GettextCatalog.GetString ( "Creating {0} for Solution {1}", generateAutotools ? "Makefile.am" : "Makefile", entry.Name), 1 ); Makefile solutionMakefile = new Makefile (); StringBuilder solutionTop = new StringBuilder (); try { SolutionFolder solutionFolder = (SolutionFolder) entry; string targetDirectory = solutionFolder.BaseDirectory; StringBuilder subdirs = new StringBuilder(); subdirs.Append ("#Warning: This is an automatically generated file, do not edit!\n"); if (!generateAutotools) { solutionTop.AppendFormat ("top_srcdir={0}\n", FileService.AbsoluteToRelativePath ( entry.BaseDirectory, ctx.TargetSolution.BaseDirectory)); solutionTop.Append ("include $(top_srcdir)/config.make\n"); solutionTop.Append ("include $(top_srcdir)/Makefile.include\n"); solutionTop.Append ("include $(top_srcdir)/rules.make\n\n"); solutionTop.Append ("#include $(top_srcdir)/custom-hooks.make\n\n"); } ArrayList children = new ArrayList (); foreach ( SolutionConfiguration config in solutionFolder.ParentSolution.Configurations ) { if ( !ctx.IsSupportedConfiguration ( config.Id ) ) continue; if (generateAutotools) subdirs.AppendFormat ( "if {0}\n", "ENABLE_" + ctx.EscapeAndUpperConfigName (config.Id)); else subdirs.AppendFormat ( "ifeq ($(CONFIG),{0})\n", ctx.EscapeAndUpperConfigName (config.Id)); subdirs.Append (" SUBDIRS = "); foreach (SolutionFolderItem ce in CalculateSubDirOrder (ctx, solutionFolder, config)) { string baseDirectory; if (!(ce is SolutionItem) && !(ce is SolutionFolder)) continue; // Ignore projects which can't be deployed IMakefileHandler handler = AutotoolsContext.GetMakefileHandler (ce, ctx.MakefileType); if (handler == null) continue; baseDirectory = ce.BaseDirectory; if (solutionFolder.BaseDirectory == baseDirectory) { subdirs.Append (" . "); } else { if (!baseDirectory.StartsWith (solutionFolder.BaseDirectory) ) throw new Exception ( GettextCatalog.GetString ( "Child projects must be in sub-directories of their parent") ); // add the subdirectory to the list string path = FileService.AbsoluteToRelativePath (targetDirectory, baseDirectory); if (path.StartsWith ("." + Path.DirectorySeparatorChar) ) path = path.Substring (2); AutotoolsContext.CheckSpaces (path); subdirs.Append (" "); subdirs.Append ( AutotoolsContext.EscapeStringForAutomake (path) ); } if (!children.Contains (ce)) children.Add ( ce ); } subdirs.Append ( "\nendif\n" ); } solutionTop.Append ( subdirs.ToString () ); string includedProject = null; // deploy recursively foreach (SolutionFolderItem ce in children) { IMakefileHandler handler = AutotoolsContext.GetMakefileHandler ( ce, ctx.MakefileType ); Makefile makefile; string outpath; if ( handler != null && handler.CanDeploy ( ce, ctx.MakefileType ) ) { ctx.RegisterBuiltProject (ce); makefile = handler.Deploy ( ctx, ce, monitor ); if (targetDirectory == ce.BaseDirectory) { if (includedProject != null) throw new Exception ( GettextCatalog.GetString ( "More than 1 project in the same directory as the top-level solution is not supported.")); // project is in the solution directory string projectMakefileName = ce.Name + ".make"; includedProject = String.Format ("include {0}", projectMakefileName); outpath = Path.Combine (targetDirectory, projectMakefileName); ctx.AddGeneratedFile (outpath); if (!generateAutotools) solutionMakefile.SetVariable ("EXTRA_DIST", projectMakefileName); } else { makefile.AppendToVariable ("EXTRA_DIST", generateAutotools ? String.Empty : "Makefile"); outpath = Path.Combine (ce.BaseDirectory, "Makefile"); if (generateAutotools) { ctx.AddAutoconfFile (outpath); outpath = outpath + ".am"; } else { makefile.Append ("install: install-local\nuninstall: uninstall-local\nclean: clean-local\n"); if (ce is SolutionFolder) //non TargetCombine makefile.Append ("dist-local: dist-local-recursive\n"); else makefile.Append ("include $(top_srcdir)/rules.make\n"); } ctx.AddGeneratedFile (outpath); } StreamWriter writer = new StreamWriter (outpath); makefile.Write ( writer ); writer.Close (); } else { monitor.Log .WriteLine("Project '{0}' skipped.", ce.Name); } } if (includedProject != null) { solutionTop.Append (GettextCatalog.GetString ("\n# Include project specific makefile\n")); solutionTop.Append (includedProject); } if (generateAutotools) { solutionMakefile.Append (solutionTop.ToString ()); } else { TemplateEngine templateEngine = new TemplateEngine (); templateEngine.Variables ["MAKEFILE_SOLUTION_TOP"] = solutionTop.ToString (); Stream stream = ctx.GetTemplateStream ("Makefile.solution.template"); StreamReader reader = new StreamReader (stream); StringWriter sw = new StringWriter (); templateEngine.Process (reader, sw); reader.Close (); solutionMakefile.Append (sw.ToString ()); if (solutionFolder.IsRoot) { // Emit dist and distcheck targets only for TargetCombine reader = new StreamReader (Path.Combine (ctx.TemplateDir, "make-dist.targets")); solutionMakefile.Append (reader.ReadToEnd ()); reader.Close (); } } monitor.Step (1); } finally { monitor.EndTask (); } return solutionMakefile; }
public static Task WaitForRunningTools (ProgressMonitor monitor) { TaskInfo[] operations; lock (runningTasks) { operations = runningTasks.Values.ToArray (); } if (operations.Length == 0) return Task.FromResult (true); monitor.BeginTask ("Waiting for custom tools...", operations.Length); List<Task> tasks = new List<Task> (); foreach (var t in operations) { tasks.Add (t.Task.ContinueWith (ta => { if (!monitor.CancellationToken.IsCancellationRequested) monitor.Step (1); })); } var cancelTask = new TaskCompletionSource<bool> (); var allDone = Task.WhenAll (tasks); var cancelReg = monitor.CancellationToken.Register (() => { cancelTask.SetResult (true); }); return Task.WhenAny (allDone, cancelTask.Task).ContinueWith (t => { monitor.EndTask (); cancelReg.Dispose (); }); }
bool CommonPreMergeRebase (GitUpdateOptions options, ProgressMonitor monitor, out int stashIndex) { stashIndex = -1; monitor.Step (1); if ((options & GitUpdateOptions.SaveLocalChanges) != GitUpdateOptions.SaveLocalChanges) { const VersionStatus unclean = VersionStatus.Modified | VersionStatus.ScheduledAdd | VersionStatus.ScheduledDelete; bool modified = false; if (GetDirectoryVersionInfo (RootPath, false, true).Any (v => (v.Status & unclean) != VersionStatus.Unversioned)) modified = true; if (modified) { if (MessageService.GenericAlert ( MonoDevelop.Ide.Gui.Stock.Question, GettextCatalog.GetString ("You have uncommitted changes"), GettextCatalog.GetString ("What do you want to do?"), AlertButton.Cancel, new AlertButton ("Stash")) == AlertButton.Cancel) return false; options |= GitUpdateOptions.SaveLocalChanges; } } if ((options & GitUpdateOptions.SaveLocalChanges) == GitUpdateOptions.SaveLocalChanges) { monitor.Log.WriteLine (GettextCatalog.GetString ("Saving local changes")); Stash stash; if (!TryCreateStash (monitor, GetStashName ("_tmp_"), out stash)) return false; if (stash != null) stashIndex = 0; monitor.Step (1); } return true; }
protected override void OnUpdate (FilePath[] localPaths, bool recurse, ProgressMonitor monitor) { // TODO: Make it work differently for submodules. monitor.BeginTask (GettextCatalog.GetString ("Updating"), 5); if (RootRepository.Head.IsTracking) { Fetch (monitor, RootRepository.Head.Remote.Name); GitUpdateOptions options = GitService.StashUnstashWhenUpdating ? GitUpdateOptions.NormalUpdate : GitUpdateOptions.UpdateSubmodules; if (GitService.UseRebaseOptionWhenPulling) Rebase (RootRepository.Head.TrackedBranch.FriendlyName, options, monitor); else Merge (RootRepository.Head.TrackedBranch.FriendlyName, options, monitor); monitor.Step (1); } monitor.EndTask (); }
static bool OnTransferProgress (TransferProgress tp, ProgressMonitor monitor, ref int progress) { if (progress == 0 && tp.ReceivedObjects == 0) { monitor.BeginTask ("Receiving and indexing objects", 2 * tp.TotalObjects); throttleWatch.Restart (); } int currentProgress = tp.ReceivedObjects + tp.IndexedObjects; int steps = currentProgress - progress; if (throttleWatch.ElapsedMilliseconds > progressThrottle) { monitor.Step (steps); throttleWatch.Restart (); } progress = currentProgress; if (tp.IndexedObjects >= tp.TotalObjects) { monitor.EndTask (); throttleWatch.Stop (); } return !monitor.CancellationToken.IsCancellationRequested; }
void NotifyFileChanges (ProgressMonitor monitor, TreeChanges statusList) { // Files added to source branch not present to target branch. var removed = statusList.Where (c => c.Status == ChangeKind.Added).Select (c => GetRepository (c.Path).FromGitPath (c.Path)).ToList (); var modified = statusList.Where (c => c.Status != ChangeKind.Added).Select (c => GetRepository (c.Path).FromGitPath (c.Path)).ToList (); monitor.BeginTask (GettextCatalog.GetString ("Updating solution"), removed.Count + modified.Count); FileService.NotifyFilesChanged (modified, true); monitor.Step (modified.Count); FileService.NotifyFilesRemoved (removed); monitor.Step (removed.Count); monitor.EndTask (); }
async Task AddXwtFromGithubAsync (Solution solution, string newProjectName, bool createSubmodule, ProgressMonitor monitor) { try { var gitUrl = "https://github.com/" + (string.IsNullOrEmpty (Parameters ["XwtGithubRepository"]) ? Parameters ["XwtGithubRepository"] : "mono/xwt") + ".git"; var gitBranch = Parameters ["XwtGithubBranch"]; if (gitBranch == String.Empty) gitBranch = "master"; var gitRepo = VersionControlService.GetRepository (solution) as GitRepository; var xwt_proj = solution.FindProjectByName ("Xwt") as DotNetProject; if (xwt_proj != null && xwt_proj.ItemId.ToUpper () != "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") { xwt_proj = null; foreach (var item in solution.GetAllProjectsWithFlavor<DotNetProjectExtension>()) { if (item.ItemId.ToUpper () == "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") { xwt_proj = item as DotNetProject; break; } } } var xwt_path = xwt_proj == null ? solution.BaseDirectory.Combine ("Xwt") : xwt_proj.BaseDirectory.ParentDirectory; monitor.BeginTask ("Configuring Xwt References...", 3); if (xwt_proj == null && !Directory.Exists (xwt_path)) { monitor.BeginTask ("Cloning Xwt into " + xwt_path + "...", 1); if (createSubmodule && gitRepo != null) { monitor.BeginTask ("Initializing Xwt submodule in " + xwt_path + "...", 1); var repo = new FileRepository (gitRepo.RootPath.Combine (".git")); var git = new Git (repo); try { using (var gm = new GitMonitor (monitor)) { var add_submodule = git.SubmoduleAdd (); add_submodule.SetPath ("Xwt"); add_submodule.SetURI (gitUrl); add_submodule.SetProgressMonitor (gm); add_submodule.Call (); var submodule = new GitRepository (VersionControlService.GetVersionControlSystems ().First (id => id.Name == "Git"), gitRepo.RootPath.Combine ("Xwt"), gitUrl); var submoduleRemote = submodule.GetCurrentRemote (); submodule.Fetch (monitor, submoduleRemote); if (submodule.GetCurrentBranch () != gitBranch) { submodule.CreateBranch (gitBranch, submoduleRemote + "/" + gitBranch, "refs/remotes/" + submoduleRemote + "/" + gitBranch); submodule.SwitchToBranch (monitor, gitBranch); } } } catch { Directory.Delete (xwt_path, true); throw; } monitor.EndTask (); } else { var repo = new GitRepository (); repo.Url = gitUrl; repo.Checkout (xwt_path, true, monitor); var remote = repo.GetCurrentRemote (); repo.Fetch (monitor, remote); if (repo.GetCurrentBranch () != gitBranch) { repo.CreateBranch (gitBranch, remote + "/" + gitBranch, "refs/remotes/" + remote + "/" + gitBranch); repo.SwitchToBranch (monitor, gitBranch); } } monitor.EndTask (); } SolutionFolder xwt_folder; if (xwt_proj != null) xwt_folder = xwt_proj.ParentFolder; else { xwt_folder = new SolutionFolder (); xwt_folder.Name = "Xwt"; } solution.RootFolder.Items.Add (xwt_folder); monitor.Step (1); monitor.BeginTask ("Adding Xwt Projects to Solution...", 7); if (xwt_proj == null && File.Exists (xwt_path.Combine ("Xwt", "Xwt.csproj"))) { xwt_proj = await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt", "Xwt.csproj") ) as DotNetProject; } if (xwt_proj == null) throw new InvalidOperationException ("Xwt project not found"); monitor.Step (1); var xwt_gtk_proj = solution.FindProjectByName ("Xwt.Gtk") ?? await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk.csproj") ) as DotNetProject; monitor.Step (1); var xwt_gtk_win_proj = solution.FindProjectByName ("Xwt.Gtk.Windows") ?? await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt.Gtk.Windows", "Xwt.Gtk.Windows.csproj") ) as DotNetProject; monitor.Step (1); var xwt_gtk_mac_proj = solution.FindProjectByName ("Xwt.Gtk.Mac") ?? await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt.Gtk.Mac", "Xwt.Gtk.Mac.csproj") ) as DotNetProject; monitor.Step (1); var xwt_gtk3_proj = solution.FindProjectByName ("Xwt.Gtk3") ?? await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk3.csproj") ) as DotNetProject; monitor.Step (1); var xwt_wpf_proj = solution.FindProjectByName ("Xwt.WPF") ?? await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt.WPF", "Xwt.WPF.csproj") ) as DotNetProject; monitor.Step (1); var xwt_mac_proj = solution.FindProjectByName ("Xwt.Mac") ?? await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt.Mac", "Xwt.Mac.csproj") ) as DotNetProject; monitor.Step (1); var xwt_xammac_proj = solution.FindProjectByName ("Xwt.XamMac") ?? await IdeApp.ProjectOperations.AddSolutionItem ( xwt_folder, xwt_path.Combine ("Xwt.XamMac", "Xwt.XamMac.csproj") ) as DotNetProject; monitor.EndTask (); monitor.Step (1); monitor.BeginTask ("Adding Xwt References...", solution.Items.Count); foreach (var item in solution.Items) { var project = item as DotNetProject; if (project != null) { if (project.Name == newProjectName || project.Name.StartsWith (newProjectName + ".", StringComparison.Ordinal)) project.References.Add (ProjectReference.CreateProjectReference (xwt_proj)); if (project.Name == newProjectName + ".Desktop") { if (Platform.IsWindows) { project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj)); project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj)); project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj)); } else if (Platform.IsLinux) { project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj)); project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj)); } else if (Platform.IsMac) { project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj)); project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj)); project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj)); } } if (project.Name == newProjectName + ".Gtk2") { project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj)); if (Platform.IsWindows) { project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj)); } else if (Platform.IsMac) { project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj)); } } if (project.Name == newProjectName + ".Wpf") { project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj)); } if (project.Name == newProjectName + ".Gtk3") { project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj)); } if (project.Name == newProjectName + ".Mac") { project.References.Add (ProjectReference.CreateProjectReference (xwt_mac_proj)); } if (project.Name == newProjectName + ".XamMac") { project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj)); } } monitor.Step (1); } monitor.EndTask (); monitor.EndTask (); monitor.ReportSuccess ("Xwt Repository initialized successfully"); await IdeApp.Workspace.SaveAsync (monitor); } catch (Exception e) { string msg = GettextCatalog.GetString ("Adding Xwt reference failed: "); monitor.ReportError (msg, e); MessageService.ShowError (msg, e); } finally { monitor.Dispose (); } }
void RunActionsWithProgressMonitor (ProgressMonitor monitor, IList<IPackageAction> packageActions) { foreach (IPackageAction action in packageActions) { action.Execute (monitor.CancellationToken); instrumentationService.InstrumentPackageAction (action); monitor.Step (1); } }
public override BuildResult Compile ( Project project, ProjectFileCollection projectFiles, ProjectPackageCollection packages, CProjectConfiguration configuration, ProgressMonitor monitor) { if (!appsChecked) { appsChecked = true; compilerFound = CheckApp (compilerCommand); linkerFound = CheckApp (linkerCommand); } if (!compilerFound) { BuildResult cres = new BuildResult (); cres.AddError ("Compiler not found: " + compilerCommand); return cres; } if (!linkerFound) { BuildResult cres = new BuildResult (); cres.AddError ("Linker not found: " + linkerCommand); return cres; } CompilerResults cr = new CompilerResults (new TempFileCollection ()); bool success = true; string compilerArgs = GetCompilerFlags (project, configuration) + " " + GeneratePkgCompilerArgs (packages); string outputName = Path.Combine (configuration.OutputDirectory, configuration.CompiledOutputName); // Precompile header files and place them in prec/<config_name>/ if (configuration.PrecompileHeaders) { string precDir = Path.Combine (configuration.IntermediateOutputDirectory, "prec"); string precConfigDir = Path.Combine (precDir, configuration.Id); if (!Directory.Exists (precDir)) Directory.CreateDirectory (precDir); if (!Directory.Exists (precConfigDir)) Directory.CreateDirectory (precConfigDir); if (!PrecompileHeaders (projectFiles, configuration, compilerArgs, monitor, cr)) success = false; } else { //old headers could interfere with the build CleanPrecompiledHeaders (configuration); } //compile source to object files monitor.BeginTask (GettextCatalog.GetString ("Compiling source to object files"), 1); foreach (ProjectFile f in projectFiles) { if (!success) break; if (f.Subtype == Subtype.Directory || f.BuildAction != BuildAction.Compile || CProject.IsHeaderFile (f.FilePath)) continue; if (configuration.UseCcache || NeedsCompiling (f, configuration)) success = DoCompilation (f, configuration, compilerArgs, monitor, cr, configuration.UseCcache); } if (success) monitor.Step (1); monitor.EndTask (); if (success) { switch (configuration.CompileTarget) { case CBinding.CompileTarget.Bin: MakeBin (project, projectFiles, configuration, packages, cr, monitor, outputName); break; case CBinding.CompileTarget.StaticLibrary: MakeStaticLibrary (project, projectFiles, configuration, packages, cr, monitor, outputName); break; case CBinding.CompileTarget.SharedLibrary: MakeSharedLibrary (project, projectFiles, configuration, packages, cr, monitor, outputName); break; } } return new BuildResult (cr, ""); }
private void MakeSharedLibrary(Project project, ProjectFileCollection projectFiles, CProjectConfiguration configuration, ProjectPackageCollection packages, CompilerResults cr, ProgressMonitor monitor, string outputName) { if (!NeedsUpdate (projectFiles, configuration, outputName)) return; string objectFiles = string.Join (" ", ObjectFiles (projectFiles, configuration, true)); string pkgargs = GeneratePkgLinkerArgs (packages); StringBuilder args = new StringBuilder (); if (configuration.ExtraLinkerArguments != null && configuration.ExtraLinkerArguments.Length > 0) { string extraLinkerArgs = ExpandBacktickedParameters(configuration.ExtraLinkerArguments.Replace ('\n', ' ')); args.Append (extraLinkerArgs + " "); } if (configuration.LibPaths != null) foreach (string libpath in configuration.LibPaths) args.Append ("-L\"" + StringParserService.Parse (libpath, GetStringTags (project)) + "\" "); if (configuration.Libs != null) { foreach (string lib in configuration.Libs) { string directory = Path.GetDirectoryName(lib); string library = Path.GetFileName(lib); // Is this a 'standard' (as in, uses an orthodox naming convention) library..? string link_lib = String.Empty; if(IsStandardLibrary(configuration, directory, library, ref link_lib)) args.Append ("-l\"" + link_lib + "\" "); // If not, reference the library by it's full pathname. else args.Append ("\"" + lib + "\" "); } } string linker_args = string.Format ("-shared -o \"{0}\" {1} {2} {3}", outputName, objectFiles, pkgargs, args.ToString ()); monitor.BeginTask (GettextCatalog.GetString ("Generating shared object \"{0}\" from object files", Path.GetFileName (outputName)), 1); string errorOutput; int exitCode = ExecuteCommand (linkerCommand , linker_args, Path.GetDirectoryName (outputName), monitor, out errorOutput); if (exitCode == 0) monitor.Step (1); monitor.EndTask (); ParseCompilerOutput (errorOutput, cr); ParseLinkerOutput (errorOutput, cr); CheckReturnCode (exitCode, cr); }
private void MakeStaticLibrary (Project project, ProjectFileCollection projectFiles, CProjectConfiguration configuration, ProjectPackageCollection packages, CompilerResults cr, ProgressMonitor monitor, string outputName) { if (!NeedsUpdate (projectFiles, configuration, outputName)) return; string objectFiles = string.Join (" ", ObjectFiles (projectFiles, configuration, true)); string args = string.Format ("rcs \"{0}\" {1}", outputName, objectFiles); monitor.BeginTask (GettextCatalog.GetString ("Generating static library {0} from object files", Path.GetFileName (outputName)), 1); string errorOutput; int exitCode = ExecuteCommand ("ar", args, Path.GetDirectoryName (outputName), monitor, out errorOutput); if (exitCode == 0) monitor.Step (1); monitor.EndTask (); ParseCompilerOutput (errorOutput, cr); ParseLinkerOutput (errorOutput, cr); CheckReturnCode (exitCode, cr); }
private bool PrecompileHeaders (ProjectFileCollection projectFiles, CProjectConfiguration configuration, string args, ProgressMonitor monitor, CompilerResults cr) { monitor.BeginTask (GettextCatalog.GetString ("Precompiling headers"), 1); bool success = true; foreach (ProjectFile file in projectFiles) { if (file.Subtype == Subtype.Code && CProject.IsHeaderFile (file.Name)) { string precomp = Path.Combine (configuration.IntermediateOutputDirectory, "prec"); precomp = Path.Combine (precomp, configuration.Id); precomp = Path.Combine (precomp, Path.GetFileName (file.Name) + ".ghc"); if (file.BuildAction == BuildAction.Compile) { if (!File.Exists (precomp) || configuration.UseCcache || File.GetLastWriteTime (file.Name) > File.GetLastWriteTime (precomp)) { if (DoPrecompileHeader (file, precomp, args, monitor, cr) == false) { success = false; break; } } } else { //remove old files or they'll interfere with the build if (File.Exists (precomp)) File.Delete (precomp); } } } if (success) monitor.Step (1); monitor.EndTask (); return success; }
public static void Initialize (ProgressMonitor monitor) { // Already done in IdeSetup, but called again since unit tests don't use IdeSetup. DispatchService.Initialize (); Counters.Initialization.Trace ("Creating Workbench"); workbench = new Workbench (); Counters.Initialization.Trace ("Creating Root Workspace"); workspace = new RootWorkspace (); Counters.Initialization.Trace ("Creating Services"); projectOperations = new ProjectOperations (); helpOperations = new HelpOperations (); commandService = new CommandManager (); ideServices = new IdeServices (); CustomToolService.Init (); commandService.CommandTargetScanStarted += CommandServiceCommandTargetScanStarted; commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished; commandService.KeyBindingFailed += KeyBindingFailed; KeyBindingService.LoadBindingsFromExtensionPath ("/MonoDevelop/Ide/KeyBindingSchemes"); KeyBindingService.LoadCurrentBindings ("MD2"); commandService.CommandError += delegate (object sender, CommandErrorArgs args) { LoggingService.LogInternalError (args.ErrorMessage, args.Exception); }; FileService.ErrorHandler = FileServiceErrorHandler; monitor.BeginTask (GettextCatalog.GetString("Loading Workbench"), 5); Counters.Initialization.Trace ("Loading Commands"); commandService.LoadCommands ("/MonoDevelop/Ide/Commands"); monitor.Step (1); Counters.Initialization.Trace ("Initializing Workbench"); workbench.Initialize (monitor); monitor.Step (1); MonoDevelop.Ide.WelcomePage.WelcomePageService.Initialize (); MonoDevelop.Ide.WelcomePage.WelcomePageService.ShowWelcomePage (); monitor.Step (1); Counters.Initialization.Trace ("Restoring Workbench State"); workbench.Show ("SharpDevelop.Workbench.WorkbenchMemento"); monitor.Step (1); Counters.Initialization.Trace ("Flushing GUI events"); DispatchService.RunPendingEvents (); Counters.Initialization.Trace ("Flushed GUI events"); MessageService.RootWindow = workbench.RootWindow; commandService.EnableIdleUpdate = true; // Perser service initialization TypeSystemService.TrackFileChanges = true; if (Customizer != null) Customizer.OnIdeInitialized (); // Startup commands Counters.Initialization.Trace ("Running Startup Commands"); AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged); monitor.Step (1); monitor.EndTask (); // Set initial run flags Counters.Initialization.Trace ("Upgrading Settings"); if (PropertyService.Get("MonoDevelop.Core.FirstRun", false)) { isInitialRun = true; PropertyService.Set ("MonoDevelop.Core.FirstRun", false); PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildInfo.Version); PropertyService.Set ("MonoDevelop.Core.LastRunRevision", CurrentRevision); PropertyService.SaveProperties (); } string lastVersion = PropertyService.Get ("MonoDevelop.Core.LastRunVersion", "1.9.1"); int lastRevision = PropertyService.Get ("MonoDevelop.Core.LastRunRevision", 0); if (lastRevision != CurrentRevision && !isInitialRun) { isInitialRunAfterUpgrade = true; if (lastRevision == 0) { switch (lastVersion) { case "1.0": lastRevision = 1; break; case "2.0": lastRevision = 2; break; case "2.2": lastRevision = 3; break; case "2.2.1": lastRevision = 4; break; } } upgradedFromRevision = lastRevision; PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildInfo.Version); PropertyService.Set ("MonoDevelop.Core.LastRunRevision", CurrentRevision); PropertyService.SaveProperties (); } // The ide is now initialized isInitialized = true; if (isInitialRun) { try { OnInitialRun (); } catch (Exception e) { LoggingService.LogError ("Error found while initializing the IDE", e); } } if (isInitialRunAfterUpgrade) { try { OnUpgraded (upgradedFromRevision); } catch (Exception e) { LoggingService.LogError ("Error found while initializing the IDE", e); } } if (initializedEvent != null) { initializedEvent (null, EventArgs.Empty); initializedEvent = null; } //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS MonoDevelop.Projects.HelpService.AsyncInitialize (); UpdateInstrumentationIcon (); IdeApp.Preferences.EnableInstrumentation.Changed += delegate { UpdateInstrumentationIcon (); }; AutoTestService.Start (commandService, Preferences.EnableAutomatedTesting); AutoTestService.NotifyEvent ("MonoDevelop.Ide.IdeStart"); Gtk.LinkButton.SetUriHook ((button, uri) => Xwt.Desktop.OpenUrl (uri)); }
internal ComponentIndex GetComponentIndex (ProgressMonitor monitor) { // Returns an index of all components that can be added to the toolbox. ComponentIndex index = ComponentIndex.Load (); // Get the list of assemblies that need to be updated HashSet<string> files = new HashSet<string> (); List<ComponentIndexFile> toupdate = new List<ComponentIndexFile> (); List<ComponentIndexFile> todelete = new List<ComponentIndexFile> (); foreach (ComponentIndexFile ia in index.Files) { files.Add (ia.FileName); if (!File.Exists (ia.FileName)) todelete.Add (ia); if (ia.NeedsUpdate) toupdate.Add (ia); if (monitor.CancellationToken.IsCancellationRequested) return index; } // Look for new assemblies foreach (TargetRuntime runtime in Runtime.SystemAssemblyService.GetTargetRuntimes ()) { foreach (SystemAssembly asm in runtime.AssemblyContext.GetAssemblies ()) { if (files.Add (asm.Location)) { ComponentIndexFile c = new ComponentIndexFile (asm.Location); index.Files.Add (c); toupdate.Add (c); } if (monitor.CancellationToken.IsCancellationRequested) return index; } } foreach (ComponentIndexFile ia in todelete) { index.Files.Remove (ia); } if (toupdate.Count > 0) { monitor.BeginTask (GettextCatalog.GetString ("Looking for components..."), toupdate.Count); LoaderContext ctx = new LoaderContext (); try { foreach (ComponentIndexFile ia in toupdate) { ia.Update (ctx); monitor.Step (1); if (monitor.CancellationToken.IsCancellationRequested) return index; } } finally { ctx.Dispose (); monitor.EndTask (); } } if (toupdate.Count > 0 || todelete.Count > 0) index.Save (); return index; }
public bool SwitchToBranch (ProgressMonitor monitor, string branch) { Signature sig = GetSignature (); Stash stash; int stashIndex = -1; if (sig == null) return false; monitor.BeginTask (GettextCatalog.GetString ("Switching to branch {0}", branch), GitService.StashUnstashWhenSwitchingBranches ? 4 : 2); // Get a list of files that are different in the target branch var statusList = GitUtil.GetChangedFiles (RootRepository, branch); if (GitService.StashUnstashWhenSwitchingBranches) { // Remove the stash for this branch, if exists string currentBranch = GetCurrentBranch (); stashIndex = GetStashForBranch (RootRepository.Stashes, currentBranch); if (stashIndex != -1) RootRepository.Stashes.Remove (stashIndex); if (!TryCreateStash (monitor, GetStashName (currentBranch), out stash)) return false; monitor.Step (1); } try { int progress = 0; RootRepository.Checkout (branch, new CheckoutOptions { OnCheckoutProgress = (path, completedSteps, totalSteps) => OnCheckoutProgress (completedSteps, totalSteps, monitor, ref progress), OnCheckoutNotify = RefreshFile, CheckoutNotifyFlags = refreshFlags, }); } finally { // Restore the branch stash if (GitService.StashUnstashWhenSwitchingBranches) { stashIndex = GetStashForBranch (RootRepository.Stashes, branch); if (stashIndex != -1) PopStash (monitor, stashIndex); monitor.Step (1); } } // Notify file changes NotifyFileChanges (monitor, statusList); BranchSelectionChanged?.Invoke (this, EventArgs.Empty); monitor.EndTask (); return true; }
public IEnumerable<SearchResult> FindAll (Scope scope, ProgressMonitor monitor, string pattern, string replacePattern, FilterOptions filter) { if (filter.RegexSearch) { RegexOptions regexOptions = RegexOptions.Compiled; if (!filter.CaseSensitive) regexOptions |= RegexOptions.IgnoreCase; regex = new Regex (pattern, regexOptions); } IsRunning = true; FoundMatchesCount = SearchedFilesCount = 0; monitor.BeginTask (scope.GetDescription (filter, pattern, replacePattern), 150); try { int totalWork = scope.GetTotalWork (filter); int step = Math.Max (1, totalWork / 50); var contents = new List<Tuple<FileProvider, string, List<SearchResult>>>(); foreach (var provider in scope.GetFiles (monitor, filter)) { try { searchedFilesCount++; contents.Add(Tuple.Create (provider, provider.ReadString (), new List<SearchResult> ())); if (searchedFilesCount % step == 0) monitor.Step (2); } catch (FileNotFoundException) { MessageService.ShowError (string.Format (GettextCatalog.GetString ("File {0} not found.")), provider.FileName); } } var results = new List<SearchResult>(); if (filter.RegexSearch && replacePattern != null) { foreach (var content in contents) { results.AddRange (RegexSearch (monitor, content.Item1, content.Item2, replacePattern, filter)); } } else { Parallel.ForEach (contents, content => { if (monitor.CancellationToken.IsCancellationRequested) return; try { Interlocked.Increment (ref searchedFilesCount); content.Item3.AddRange(FindAll (monitor, content.Item1, content.Item2, pattern, replacePattern, filter)); lock (results) { results.AddRange (content.Item3); } FoundMatchesCount += content.Item3.Count; if (searchedFilesCount % step == 0) monitor.Step (1); } catch (Exception e) { LoggingService.LogError("Exception during search.", e); } }); if (replacePattern != null) { foreach (var content in contents) { if (content.Item3.Count == 0) continue; try { content.Item1.BeginReplace (content.Item2); Replace (content.Item1, content.Item3, replacePattern); content.Item1.EndReplace (); } catch (Exception e) { LoggingService.LogError("Exception during replace.", e); } } } } return results; } finally { monitor.EndTask (); IsRunning = false; } }
protected override void OnMoveDirectory (FilePath localSrcPath, FilePath localDestPath, bool force, ProgressMonitor monitor) { VersionInfo[] versionedFiles = GetDirectoryVersionInfo (localSrcPath, false, true); base.OnMoveDirectory (localSrcPath, localDestPath, force, monitor); monitor.BeginTask ("Moving files", versionedFiles.Length); foreach (VersionInfo vif in versionedFiles) { if (vif.IsDirectory) continue; FilePath newDestPath = vif.LocalPath.ToRelative (localSrcPath).ToAbsolute (localDestPath); Add (newDestPath, false, monitor); monitor.Step (1); } monitor.EndTask (); }
internal void InternalCopyFiles (ProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context, string realPrefix) { string targetDirectory = ((LocalFileCopyConfiguration) copyConfig).TargetDirectory; if (string.IsNullOrEmpty (copyConfig.FriendlyLocation) || string.IsNullOrEmpty (targetDirectory)) throw new InvalidOperationException ("Cannot deploy to unconfigured location."); List<DeployFileConf> files = new List<DeployFileConf> (); long totalFileSize = 0; //pre-scan: ask all copy/replace questions first so user doesn't have to wait, and get foreach (DeployFile df in deployFiles) { if (!context.IncludeFile (df)) continue; DeployFileConf dfc = new DeployFileConf (); files.Add (dfc); dfc.SourceFile = df.SourcePath; dfc.FileSize = FileSize (dfc.SourceFile); totalFileSize += dfc.FileSize; string relativeTarget = context.GetResolvedPath (df.TargetDirectoryID, df.RelativeTargetPath); if (relativeTarget == null) throw new InvalidOperationException (GettextCatalog.GetString ("Could not resolve target directory ID \"{0}\"", df.TargetDirectoryID)); dfc.TargetFile = Path.Combine (targetDirectory, relativeTarget); //this is a bit hacky; it's an internal hook to the BaseFuseFileCopyHandler implementation a level up the inheritance heirarchy //Essentailly we are aliasing the path so that BaseFuseFileCopyHandler can use LocalFileCopyHandler to do the local copying //after the temp FUSE directory is mounted if (!string.IsNullOrEmpty (realPrefix)) { dfc.InternalTargetFile = Path.Combine (realPrefix, context.GetResolvedPath (df.TargetDirectoryID, df.RelativeTargetPath)); } else { dfc.InternalTargetFile = dfc.TargetFile; } if (FileExists (dfc.InternalTargetFile)) { dfc.SourceModified = File.GetLastWriteTime (dfc.SourceFile); dfc.TargetModified = GetTargetModificationTime (dfc.InternalTargetFile); dfc.ReplaceMode = replacePolicy.GetReplaceAction (dfc.SourceFile, dfc.SourceModified, dfc.TargetFile, dfc.TargetModified); if (dfc.ReplaceMode == FileReplaceMode.Abort) { monitor.Log.WriteLine (GettextCatalog.GetString ("Deployment aborted: target file {0} already exists.", dfc.TargetFile)); throw new OperationCanceledException (); } } } //PROBLEM: monitor takes ints, file sizes are longs //HOWEVER: longs are excessively long for a progress bar //SOLUTION: assume total task has a length of 1000 (longer than this is probably unnecessary for a progress bar), // and set up a callback system for translating the actual long number of bytes into a portion of this const int progressBarLength = 1000; long stepSize = totalFileSize / progressBarLength; long carry = 0; monitor.BeginTask (copyConfig.FriendlyLocation, progressBarLength); CopyReportCallback copyCallback = delegate (long bytes) { if (monitor.CancellationToken.IsCancellationRequested) return false; int steps = (int) (bytes / stepSize); carry += bytes % stepSize; if (carry > stepSize) { steps += 1; carry -= stepSize; } if (steps > 0) monitor.Step (steps); return true; }; //now the actual copy foreach (DeployFileConf file in files) { //abort the copy if cancelling if (monitor.CancellationToken.IsCancellationRequested) break; EnsureDirectoryExists (Path.GetDirectoryName (file.InternalTargetFile)); if (file.ReplaceMode != FileReplaceMode.NotSet) { switch (file.ReplaceMode) { case FileReplaceMode.Skip: monitor.Log.WriteLine (GettextCatalog.GetString ("Skipped {0}: file exists.", file.TargetFile)); copyCallback (file.FileSize); continue; //next file case FileReplaceMode.Replace: monitor.Log.WriteLine (GettextCatalog.GetString ("Replaced {0}.", file.TargetFile)); break; case FileReplaceMode.ReplaceOlder: if (file.SourceModified > file.TargetModified) { monitor.Log.WriteLine (GettextCatalog.GetString ("Replacing {0}: existing file is older.", file.TargetFile)); } else { if (file.SourceModified == file.TargetModified) monitor.Log.WriteLine (GettextCatalog.GetString ("Skipped {0}: existing file is the same age.", file.TargetFile)); else monitor.Log.WriteLine (GettextCatalog.GetString ("Skipped {0}: existing file is newer.", file.TargetFile)); copyCallback (file.FileSize); continue; //next file } break; } } else { monitor.Log.WriteLine (GettextCatalog.GetString ("Deployed file {0}.", file.TargetFile)); } CopyFile (file.SourceFile, file.InternalTargetFile, copyCallback); } monitor.EndTask (); }
static void OnCheckoutProgress (int completedSteps, int totalSteps, ProgressMonitor monitor, ref int progress) { if (progress == 0 && completedSteps == 0) { monitor.BeginTask ("Checking out files", totalSteps); throttleWatch.Restart (); } int steps = completedSteps - progress; if (throttleWatch.ElapsedMilliseconds > progressThrottle) { monitor.Step (steps); throttleWatch.Restart (); } progress = completedSteps; if (completedSteps >= totalSteps) { monitor.EndTask (); throttleWatch.Stop (); } }
//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 void Fetch (ProgressMonitor monitor, string remote) { monitor.Log.WriteLine (GettextCatalog.GetString ("Fetching from '{0}'", remote)); int progress = 0; RetryUntilSuccess (monitor, credType => RootRepository.Fetch (remote, new FetchOptions { CredentialsProvider = (url, userFromUrl, types) => GitCredentials.TryGet (url, userFromUrl, types, credType), OnTransferProgress = tp => OnTransferProgress (tp, monitor, ref progress), })); monitor.Step (1); }
protected async override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.CleanTargetName)) { return await base.OnClean (monitor, configuration, operationContext); } monitor.BeginTask ( GettextCatalog.GetString( "Cleaning project"), 1); try { string baseDir = Project.BaseDirectory; ProcessWrapper process = Runtime.ProcessService.StartProcess ( "make", data.CleanTargetName, baseDir, monitor.Log, monitor.Log, null ); await process.Task; if ( process.ExitCode > 0 ) throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0}'", "make " + data.CleanTargetName) ); monitor.Step ( 1 ); } catch ( Exception e ) { monitor.ReportError ( GettextCatalog.GetString ("Project could not be cleaned: "), e ); var res = new BuildResult (); res.AddError (GettextCatalog.GetString ("Project could not be cleaned: ") + e.Message); return res; } finally { monitor.EndTask (); } monitor.ReportSuccess ( GettextCatalog.GetString ( "Project successfully cleaned")); return BuildResult.CreateSuccess (); }
void CommonPostMergeRebase(int stashIndex, GitUpdateOptions options, ProgressMonitor monitor, Commit oldHead) { if ((options & GitUpdateOptions.SaveLocalChanges) == GitUpdateOptions.SaveLocalChanges) { monitor.Step (1); // Restore local changes if (stashIndex != -1) { monitor.Log.WriteLine (GettextCatalog.GetString ("Restoring local changes")); ApplyStash (monitor, stashIndex); // FIXME: No StashApplyStatus.Conflicts here. if (RootRepository.Index.Conflicts.Any () && !ConflictResolver (monitor, oldHead, string.Empty)) PopStash (monitor, stashIndex); else RootRepository.Stashes.Remove (stashIndex); monitor.Step (1); } } monitor.EndTask (); }
protected async override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.ExecuteTargetName)) { await base.OnExecute (monitor, context, configuration); return; } OperationConsole console = context.ConsoleFactory.CreateConsole (); monitor.BeginTask (GettextCatalog.GetString ("Executing {0}", Project.Name), 1); try { ProcessWrapper process = Runtime.ProcessService.StartProcess ("make", data.ExecuteTargetName, Project.BaseDirectory, console.Out, console.Error, null); await process.Task; monitor.Log.WriteLine (GettextCatalog.GetString ("The application exited with code: {0}", process.ExitCode)); monitor.Step (1); } catch (Exception e) { monitor.ReportError (GettextCatalog.GetString ("Project could not be executed: "), e); return; } finally { monitor.EndTask (); console.Dispose (); } }
internal void LoadSolution (Solution sol, SlnFile sln, ProgressMonitor monitor, SolutionLoadContext ctx) { var version = sln.FormatVersion; //Parse the .sln file var folder = sol.RootFolder; sol.Version = "0.1"; //FIXME: monitor.BeginTask("Loading projects ..", sln.Projects.Count + 1); Dictionary<string, SolutionFolderItem> items = new Dictionary<string, SolutionFolderItem> (); List<string> sortedList = new List<string> (); List<Task> loadTasks = new List<Task> (); foreach (SlnProject sec in sln.Projects) { try { // Valid guid? new Guid (sec.TypeGuid); } catch (FormatException) { monitor.Step (1); //Use default guid as projectGuid LoggingService.LogDebug (GettextCatalog.GetString ( "Invalid Project type guid '{0}' on line #{1}. Ignoring.", sec.Id, sec.Line)); continue; } string projTypeGuid = sec.TypeGuid.ToUpper (); string projectName = sec.Name; string projectPath = sec.FilePath; string projectGuid = sec.Id; lock (items) sortedList.Add (projectGuid); if (projTypeGuid == MSBuildProjectService.FolderTypeGuid) { //Solution folder SolutionFolder sfolder = new SolutionFolder (); sfolder.Name = projectName; sfolder.ItemId = projectGuid; DeserializeSolutionItem (monitor, sol, sfolder, sec); foreach (string f in ReadFolderFiles (sec)) sfolder.Files.Add (MSBuildProjectService.FromMSBuildPath (Path.GetDirectoryName (sol.FileName), f)); lock (items) items.Add (projectGuid, sfolder); monitor.Step (1); continue; } if (projectPath.StartsWith("http://")) { monitor.ReportWarning (GettextCatalog.GetString ( "{0}({1}): Projects with non-local source (http://...) not supported. '{2}'.", sol.FileName, sec.Line, projectPath)); monitor.Step (1); continue; } string path = MSBuildProjectService.FromMSBuildPath (Path.GetDirectoryName (sol.FileName), projectPath); if (String.IsNullOrEmpty (path)) { monitor.ReportWarning (GettextCatalog.GetString ( "Invalid project path found in {0} : {1}", sol.FileName, projectPath)); LoggingService.LogWarning (GettextCatalog.GetString ( "Invalid project path found in {0} : {1}", sol.FileName, projectPath)); monitor.Step (1); continue; } projectPath = Path.GetFullPath (path); SolutionItem item = null; Task<SolutionItem> loadTask; DateTime ti = DateTime.Now; if (sol.IsSolutionItemEnabled (projectPath)) { loadTask = Services.ProjectService.ReadSolutionItem (monitor, projectPath, format, projTypeGuid, projectGuid, ctx); } else { loadTask = Task.FromResult<SolutionItem> (new UnloadedSolutionItem () { FileName = projectPath }); } var ft = loadTask.ContinueWith (ta => { try { item = ta.Result; if (item == null) throw new UnknownSolutionItemTypeException (projTypeGuid); } catch (Exception cex) { var e = UnwrapException (cex).First (); string unsupportedMessage = e.Message; if (e is UserException) { var ex = (UserException) e; LoggingService.LogError ("{0}: {1}", ex.Message, ex.Details); monitor.ReportError (string.Format ("{0}{1}{1}{2}", ex.Message, Environment.NewLine, ex.Details), null); } else { LoggingService.LogError (string.Format ("Error while trying to load the project {0}", projectPath), e); monitor.ReportWarning (GettextCatalog.GetString ( "Error while trying to load the project '{0}': {1}", projectPath, e.Message)); } SolutionItem uitem; uitem = new UnknownSolutionItem () { FileName = projectPath, LoadError = unsupportedMessage, }; item = uitem; item.ItemId = projectGuid; item.TypeGuid = projTypeGuid; } item.UnresolvedProjectDependencies = ReadSolutionItemDependencies (sec); // Deserialize the object DeserializeSolutionItem (monitor, sol, item, sec); lock (items) { if (!items.ContainsKey (projectGuid)) { items.Add (projectGuid, item); } else { monitor.ReportError (GettextCatalog.GetString ("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null); } } monitor.Step (1); }); loadTasks.Add (ft); } Task.WaitAll (loadTasks.ToArray ()); sol.LoadedProjects = new HashSet<string> (items.Keys); var nested = sln.Sections.GetSection ("NestedProjects"); if (nested != null) LoadNestedProjects (nested, items, monitor); // Resolve project dependencies foreach (var it in items.Values.OfType<SolutionItem> ()) { if (it.UnresolvedProjectDependencies != null) { foreach (var id in it.UnresolvedProjectDependencies.ToArray ()) { SolutionFolderItem dep; if (items.TryGetValue (id, out dep) && dep is SolutionItem) { it.UnresolvedProjectDependencies.Remove (id); it.ItemDependencies.Add ((SolutionItem)dep); } } if (it.UnresolvedProjectDependencies.Count == 0) it.UnresolvedProjectDependencies = null; } } //Add top level folders and projects to the main folder foreach (string id in sortedList) { SolutionFolderItem ce; if (items.TryGetValue (id, out ce) && ce.ParentFolder == null) folder.Items.Add (ce); } //FIXME: This can be just SolutionConfiguration also! LoadSolutionConfigurations (sln.SolutionConfigurationsSection, sol, monitor); LoadProjectConfigurationMappings (sln.ProjectConfigurationsSection, sol, items, monitor); foreach (var e in sln.Sections) { string name = e.Id; if (name.StartsWith ("MonoDevelopProperties.")) { int i = name.IndexOf ('.'); LoadMonoDevelopConfigurationProperties (name.Substring (i+1), e, sol, monitor); } } monitor.EndTask (); }
protected override void OnReadProject (ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.MSBuildProject msproject) { base.OnReadProject (monitor, msproject); var ext = msproject.GetMonoDevelopProjectExtension ("MonoDevelop.Autotools.MakefileInfo"); if (ext == null) return; data = MakefileData.Read (ext); if (data == null) return; 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 ( "\tError loading Makefile for project {0}", Project.Name), e); } finally { monitor.EndTask (); } }
internal static void TransferFilesInternal (ProgressMonitor monitor, Project sourceProject, FilePath sourcePath, Project targetProject, FilePath targetPath, bool removeFromSource, bool copyOnlyProjectFiles) { // When transfering directories, targetPath is the directory where the source // directory will be transfered, including the destination directory or file name. // For example, if sourcePath is /a1/a2/a3 and targetPath is /b1/b2, the // new folder or file will be /b1/b2 if (targetProject == null) throw new ArgumentNullException ("targetProject"); if (!targetPath.IsChildPathOf (targetProject.BaseDirectory)) throw new ArgumentException ("Invalid project folder: " + targetPath); if (sourceProject != null && !sourcePath.IsChildPathOf (sourceProject.BaseDirectory)) throw new ArgumentException ("Invalid project folder: " + sourcePath); if (copyOnlyProjectFiles && sourceProject == null) throw new ArgumentException ("A source project must be specified if copyOnlyProjectFiles is True"); bool sourceIsFolder = Directory.Exists (sourcePath); bool movingFolder = removeFromSource && sourceIsFolder && ( !copyOnlyProjectFiles || ContainsOnlyProjectFiles (sourcePath, sourceProject)); // We need to remove all files + directories from the source project // but when dealing with the VCS addins we need to process only the // files so we do not create a 'file' in the VCS which corresponds // to a directory in the project and blow things up. List<ProjectFile> filesToRemove = null; List<ProjectFile> filesToMove = null; try { //get the real ProjectFiles if (sourceProject != null) { if (sourceIsFolder) { var virtualPath = sourcePath.ToRelative (sourceProject.BaseDirectory); // Grab all the child nodes of the folder we just dragged/dropped filesToRemove = sourceProject.Files.GetFilesInVirtualPath (virtualPath).ToList (); // Add the folder itself so we can remove it from the source project if its a Move operation var folder = sourceProject.Files.FirstOrDefault (f => f.ProjectVirtualPath == virtualPath); if (folder != null) filesToRemove.Add (folder); } else { filesToRemove = new List<ProjectFile> (); var pf = sourceProject.Files.GetFileWithVirtualPath (sourceProject.GetRelativeChildPath (sourcePath)); if (pf != null) filesToRemove.Add (pf); } } //get all the non-project files and create fake ProjectFiles if (!copyOnlyProjectFiles || sourceProject == null) { var col = new List<ProjectFile> (); GetAllFilesRecursive (sourcePath, col); if (sourceProject != null) { var names = new HashSet<string> (filesToRemove.Select (f => sourceProject.BaseDirectory.Combine (f.ProjectVirtualPath).ToString ())); foreach (var f in col) if (names.Add (f.Name)) filesToRemove.Add (f); } else { filesToRemove = col; } } } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Could not get any file from '{0}'.", sourcePath), ex); return; } // Strip out all the directories to leave us with just the files. filesToMove = filesToRemove.Where (f => f.Subtype != Subtype.Directory).ToList (); // If copying a single file, bring any grouped children along ProjectFile sourceParent = null; if (filesToMove.Count == 1 && sourceProject != null) { var pf = filesToMove[0]; if (pf != null && pf.HasChildren) { foreach (ProjectFile child in pf.DependentChildren) { filesToRemove.Add (child); filesToMove.Add (child); } } sourceParent = pf; } // Ensure that the destination folder is created, even if no files // are copied try { if (sourceIsFolder && !Directory.Exists (targetPath) && !movingFolder) FileService.CreateDirectory (targetPath); } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Could not create directory '{0}'.", targetPath), ex); return; } // Transfer files // If moving a folder, do it all at once if (movingFolder) { try { FileService.MoveDirectory (sourcePath, targetPath); } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Directory '{0}' could not be moved.", sourcePath), ex); return; } } if (removeFromSource) monitor.BeginTask (GettextCatalog.GetString ("Moving files..."), filesToMove.Count); else monitor.BeginTask (GettextCatalog.GetString ("Copying files..."), filesToMove.Count); ProjectFile targetParent = null; foreach (ProjectFile file in filesToMove) { bool fileIsLink = file.Project != null && file.IsLink; var sourceFile = fileIsLink ? file.Project.BaseDirectory.Combine (file.ProjectVirtualPath) : file.FilePath; FilePath newFile; if (sourceIsFolder) newFile = targetPath.Combine (sourceFile.ToRelative (sourcePath)); else if (sourceFile == sourcePath) newFile = targetPath; else if (sourceFile.ParentDirectory != targetPath.ParentDirectory) newFile = targetPath.ParentDirectory.Combine (sourceFile.ToRelative (sourcePath.ParentDirectory)); else newFile = GetTargetCopyName (sourceFile, false); if (!movingFolder && !fileIsLink) { try { FilePath fileDir = newFile.ParentDirectory; if (!Directory.Exists (fileDir) && !file.IsLink) FileService.CreateDirectory (fileDir); if (removeFromSource) { // File.Move() does not have an overwrite argument and will fail if the destFile path exists, however, the user // has already chosen to overwrite the destination file. if (File.Exists (newFile)) File.Delete (newFile); FileService.MoveFile (sourceFile, newFile); } else FileService.CopyFile (sourceFile, newFile); } catch (Exception ex) { if (removeFromSource) monitor.ReportError (GettextCatalog.GetString ("File '{0}' could not be moved.", sourceFile), ex); else monitor.ReportError (GettextCatalog.GetString ("File '{0}' could not be copied.", sourceFile), ex); monitor.Step (1); continue; } } if (sourceProject != null) { if (fileIsLink) { var linkFile = (ProjectFile) file.Clone (); if (movingFolder) { var abs = linkFile.Link.ToAbsolute (sourceProject.BaseDirectory); var relSrc = abs.ToRelative (sourcePath); var absTarg = relSrc.ToAbsolute (targetPath); linkFile.Link = absTarg.ToRelative (targetProject.BaseDirectory); } else { linkFile.Link = newFile.ToRelative (targetProject.BaseDirectory); } targetProject.Files.Add (linkFile); } else if (targetProject.Files.GetFile (newFile) == null) { ProjectFile projectFile = (ProjectFile) file.Clone (); projectFile.Name = newFile; targetProject.Files.Add (projectFile); if (targetParent == null) { if (file == sourceParent) targetParent = projectFile; } else if (sourceParent != null) { if (projectFile.DependsOn == sourceParent.Name) projectFile.DependsOn = targetParent.Name; } } } monitor.Step (1); } if (removeFromSource) { // Remove all files and directories under 'sourcePath' foreach (var v in filesToRemove) sourceProject.Files.Remove (v); } // Moving or copying an empty folder. A new folder object has to be added to the project. if (sourceIsFolder && !targetProject.Files.GetFilesInVirtualPath (targetPath).Any ()) { var folderFile = new ProjectFile (targetPath) { Subtype = Subtype.Directory }; targetProject.Files.Add (folderFile); } var pfolder = sourcePath.ParentDirectory; // If this was the last item in the folder, make sure we keep // a reference to the folder, so it is not deleted from the tree. if (removeFromSource && sourceProject != null && pfolder.CanonicalPath != sourceProject.BaseDirectory.CanonicalPath && pfolder.IsChildPathOf (sourceProject.BaseDirectory)) { pfolder = pfolder.ToRelative (sourceProject.BaseDirectory); if (!sourceProject.Files.GetFilesInVirtualPath (pfolder).Any () && sourceProject.Files.GetFileWithVirtualPath (pfolder) == null) { var folderFile = new ProjectFile (sourceProject.BaseDirectory.Combine (pfolder)); folderFile.Subtype = Subtype.Directory; sourceProject.Files.Add (folderFile); } } monitor.EndTask (); }
void RunActionsWithProgressMonitor (ProgressMonitor monitor, IList<IPackageAction> packageActions) { foreach (IPackageAction action in packageActions) { action.Execute (); InstrumentPackageAction (action); monitor.Step (1); } }