예제 #1
0
 public override bool CanExecute(IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration)
 {
     if (item is SolutionEntityItem)
     {
         SolutionEntityItem        entry = (SolutionEntityItem)item;
         SolutionItemConfiguration conf  = entry.GetConfiguration(configuration) as SolutionItemConfiguration;
         if (conf != null && conf.CustomCommands.HasCommands(CustomCommandType.Execute))
         {
             return(conf.CustomCommands.CanExecute(entry, CustomCommandType.Execute, context, configuration));
         }
         return(entry.OnGetCanExecute(context, configuration));
     }
     else if (item is WorkspaceItem)
     {
         return(((WorkspaceItem)item).OnGetCanExecute(context, configuration));
     }
     else if (item is SolutionItem)
     {
         return(((SolutionItem)item).OnGetCanExecute(context, configuration));
     }
     else
     {
         throw new InvalidOperationException("Unknown item type: " + item);
     }
 }
예제 #2
0
        protected override void Execute(IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration)
        {
            SolutionItemConfiguration conf = entry.GetConfiguration(configuration) as SolutionItemConfiguration;

            if (conf != null)
            {
                ExecutionContext localContext = new ExecutionContext(Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory, context.ExecutionTarget);

                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.BeforeExecute, localContext, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.BeforeExecute, localContext, configuration);
                }

                if (monitor.IsCancelRequested)
                {
                    return;
                }
            }

            base.Execute(monitor, entry, context, configuration);

            if (conf != null && !monitor.IsCancelRequested)
            {
                ExecutionContext localContext = new ExecutionContext(Runtime.ProcessService.DefaultExecutionHandler, context.ConsoleFactory, context.ExecutionTarget);

                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.AfterExecute, localContext, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.AfterExecute, localContext, configuration);
                }
            }
        }
예제 #3
0
 public override void Execute(IProgressMonitor monitor, IBuildTarget item, ExecutionContext context, ConfigurationSelector configuration)
 {
     if (item is SolutionEntityItem)
     {
         SolutionEntityItem        entry = (SolutionEntityItem)item;
         SolutionItemConfiguration conf  = entry.GetConfiguration(configuration) as SolutionItemConfiguration;
         if (conf != null && conf.CustomCommands.HasCommands(CustomCommandType.Execute))
         {
             conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.Execute, context, configuration);
             return;
         }
         entry.OnExecute(monitor, context, configuration);
     }
     else if (item is WorkspaceItem)
     {
         ((WorkspaceItem)item).OnExecute(monitor, context, configuration);
     }
     else if (item is SolutionItem)
     {
         ((SolutionItem)item).OnExecute(monitor, context, configuration);
     }
     else
     {
         throw new InvalidOperationException("Unknown item type: " + item);
     }
 }
예제 #4
0
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            SolutionItemConfiguration conf = entry.GetConfiguration(configuration) as SolutionItemConfiguration;

            if (conf != null)
            {
                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.BeforeBuild, null, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.BeforeBuild, configuration);
                }

                if (monitor.IsCancelRequested)
                {
                    return(new BuildResult(new CompilerResults(null), ""));
                }
            }

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

            if (conf != null && !monitor.IsCancelRequested && !res.Failed)
            {
                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.AfterBuild, null, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.AfterBuild, configuration);
                }
            }

            return(res);
        }
예제 #5
0
        protected override void Clean(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            SolutionItemConfiguration conf = entry.GetConfiguration(configuration) as SolutionItemConfiguration;

            if (conf != null)
            {
                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.BeforeClean, null, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.BeforeClean, configuration);
                }

                if (monitor.IsCancelRequested)
                {
                    return;
                }
            }

            base.Clean(monitor, entry, configuration);

            if (conf != null && !monitor.IsCancelRequested)
            {
                if (conf.CustomCommands.CanExecute(entry, CustomCommandType.AfterClean, null, configuration))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.AfterClean, configuration);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Cleans the files produced by this solution item
        /// </summary>
        /// <param name='monitor'>
        /// A progress monitor
        /// </param>
        /// <param name='configuration'>
        /// Configuration to use to clean the project
        /// </param>
        public void Clean(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            ITimeTracker tt = Counters.CleanProjectTimer.BeginTiming("Cleaning " + Name, GetProjectEventMetadata(configuration));

            try {
                //SolutionFolder handles the begin/end task itself, don't duplicate
                if (this is SolutionFolder)
                {
                    RunTarget(monitor, ProjectService.CleanTarget, configuration);
                    return;
                }

                try {
                    SolutionEntityItem        it    = this as SolutionEntityItem;
                    SolutionItemConfiguration iconf = it != null?it.GetConfiguration(configuration) : null;

                    string confName = iconf != null ? iconf.Id : configuration.ToString();
                    monitor.BeginTask(GettextCatalog.GetString("Cleaning: {0} ({1})", Name, confName), 1);
                    RunTarget(monitor, ProjectService.CleanTarget, configuration);
                } finally {
                    monitor.EndTask();
                }
            }
            finally {
                tt.End();
            }
        }
예제 #7
0
 protected override void Clean(IProgressMonitor monitor, IBuildTarget item, ConfigurationSelector configuration)
 {
     if (item is SolutionEntityItem)
     {
         SolutionEntityItem        entry  = (SolutionEntityItem)item;
         SolutionItemConfiguration config = entry.GetConfiguration(configuration) as SolutionItemConfiguration;
         if (config != null && config.CustomCommands.HasCommands(CustomCommandType.Clean))
         {
             config.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.Clean, configuration);
             return;
         }
         entry.OnClean(monitor, configuration);
     }
     else if (item is WorkspaceItem)
     {
         ((WorkspaceItem)item).OnRunTarget(monitor, ProjectService.CleanTarget, configuration);
     }
     else if (item is SolutionItem)
     {
         ((SolutionItem)item).OnClean(monitor, configuration);
     }
     else
     {
         throw new InvalidOperationException("Unknown item type: " + item);
     }
 }
예제 #8
0
        /// <summary>
        /// Cleans the files produced by this solution item
        /// </summary>
        /// <param name='monitor'>
        /// A progress monitor
        /// </param>
        /// <param name='configuration'>
        /// Configuration to use to clean the project
        /// </param>
        public void Clean(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            ITimeTracker tt = Counters.BuildProjectTimer.BeginTiming("Cleaning " + Name);

            try {
                try {
                    SolutionEntityItem        it    = this as SolutionEntityItem;
                    SolutionItemConfiguration iconf = it != null?it.GetConfiguration(configuration) : null;

                    string confName = iconf != null ? iconf.Id : configuration.ToString();
                    monitor.BeginTask(GettextCatalog.GetString("Cleaning: {0} ({1})", Name, confName), 1);
                    RunTarget(monitor, ProjectService.CleanTarget, configuration);
                    monitor.Step(1);
                } finally {
                    monitor.EndTask();
                }
            }
            finally {
                tt.End();
            }
        }
예제 #9
0
        protected override BuildResult Build(IProgressMonitor monitor, IBuildTarget item, ConfigurationSelector configuration)
        {
            BuildResult res;

            if (item is SolutionEntityItem)
            {
                SolutionEntityItem        entry = (SolutionEntityItem)item;
                SolutionItemConfiguration conf  = entry.GetConfiguration(configuration) as SolutionItemConfiguration;
                if (conf != null && conf.CustomCommands.HasCommands(CustomCommandType.Build))
                {
                    conf.CustomCommands.ExecuteCommand(monitor, entry, CustomCommandType.Build, configuration);
                    res = new BuildResult();
                }
                else
                {
                    res = entry.OnBuild(monitor, configuration);
                }
            }
            else if (item is WorkspaceItem)
            {
                res = ((WorkspaceItem)item).OnRunTarget(monitor, ProjectService.BuildTarget, configuration);
            }
            else if (item is SolutionItem)
            {
                res = ((SolutionItem)item).OnBuild(monitor, configuration);
            }
            else
            {
                throw new InvalidOperationException("Unknown item type: " + item);
            }

            if (res != null)
            {
                res.SourceTarget = item;
            }
            return(res);
        }
예제 #10
0
        /// <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();
            }
        }