コード例 #1
0
 public JobTaskService(IBuildTask buildTask,
                       IPullTask cloneTask,
                       IDeployTask deployTask,
                       IDeployDbTask deployDbTask,
                       IGenerateTask generateTask,
                       IMergeTask mergeTask,
                       IPublishArtifactTask publishArtifactTask,
                       IPushTask pushTask,
                       ITestTask testTask,
                       IDeleteRepositoryTask deleteRepositoryTask,
                       IDeleteHostingTask deleteHostingTask,
                       ICustomTask customTask)
 {
     BuildTask            = buildTask;
     CloneTask            = cloneTask;
     DeployTask           = deployTask;
     DeployDbTask         = deployDbTask;
     GenerateTask         = generateTask;
     MergeTask            = mergeTask;
     PublishArtifactTask  = publishArtifactTask;
     PushTask             = pushTask;
     TestTask             = testTask;
     DeleteRepositoryTask = deleteRepositoryTask;
     DeleteHostingTask    = deleteHostingTask;
     CustomTask           = customTask;
 }
コード例 #2
0
ファイル: TaskBatchingImpl.cs プロジェクト: pmq20/mono_forked
 // Parse task attributes to get list of referenced metadata and items
 // to determine batching
 //
 void ParseTaskAttributes(IBuildTask buildTask)
 {
     foreach (var attr in buildTask.GetAttributes())
     {
         ParseAttribute(attr);
     }
 }
コード例 #3
0
ファイル: CabwizBuildContext.cs プロジェクト: adbre/cab42
        /// <inheritdoc />
        protected override bool BuildTask(IBuildTask task, IBuildFeedback feedback)
        {
            if (this.cabwizTextWriter != null)
            {
                this.cabwizTextWriter.SetActiveTask(task);
            }

            try
            {
                var cabwizTask = task as ICabwizBuildTask;
                if (cabwizTask != null)
                {
                    return(cabwizTask.Build(this.Cabwiz, feedback));
                }
                else
                {
                    return(base.BuildTask(task, feedback));
                }
            }
            finally
            {
                if (this.cabwizTextWriter != null)
                {
                    this.cabwizTextWriter.SetActiveTask(null);
                }
            }
        }
コード例 #4
0
ファイル: TaskBatchingImpl.cs プロジェクト: pmq20/mono_forked
        public bool Build(IBuildTask buildTask, out bool executeOnErrors)
        {
            executeOnErrors = false;
            try {
                Init();

                // populate list of referenced items and metadata
                ParseTaskAttributes(buildTask);
                if (consumedMetadataReferences.Count == 0)
                {
                    // No batching required
                    if (ConditionParser.ParseAndEvaluate(buildTask.Condition, project))
                    {
                        return(buildTask.Execute());
                    }
                    else                     // skipped, it should be logged
                    {
                        return(true);
                    }
                }

                BatchAndPrepareBuckets();
                return(Run(buildTask, out executeOnErrors));
            } finally {
                consumedItemsByName          = null;
                consumedMetadataReferences   = null;
                consumedQMetadataReferences  = null;
                consumedUQMetadataReferences = null;
                batchedItemsByName           = null;
                commonItemsByName            = null;
            }
        }
コード例 #5
0
ファイル: TaskBatchingImpl.cs プロジェクト: nlhepler/mono
		bool Run (IBuildTask buildTask, TaskExecutionMode taskExecutionMode, out bool executeOnErrors)
		{
			executeOnErrors = false;

			// Run the task in batches
			bool retval = true;
			if (buckets.Count == 0) {
				// batched mode, but no values in the corresponding items!
				retval = Execute (buildTask, taskExecutionMode);
				if (!retval && !buildTask.ContinueOnError)
					executeOnErrors = true;

				return retval;
			}

			// batched
			foreach (Dictionary<string, BuildItemGroup> bucket in buckets) {
				project.PushBatch (bucket, commonItemsByName);
				try {
					retval = Execute (buildTask, taskExecutionMode);
					 if (!retval && !buildTask.ContinueOnError) {
						executeOnErrors = true;
						break;
					}
				} finally {
					project.PopBatch ();
				}
			}

			return retval;
		}
コード例 #6
0
ファイル: BuildRunner.cs プロジェクト: mrcece/MotionFramework
        /// <summary>
        /// 执行构建流程
        /// </summary>
        /// <returns>如果成功返回TRUE,否则返回FALSE</returns>
        public static bool Run(List <IBuildTask> pipeline, BuildContext context)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException("pipeline");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            bool succeed = true;

            for (int i = 0; i < pipeline.Count; i++)
            {
                IBuildTask task = pipeline[i];
                try
                {
                    var taskAttribute = task.GetType().GetCustomAttribute <TaskAttribute>();
                    Log($"---------------------------------------->{taskAttribute.Desc}");
                    task.Run(context);
                }
                catch (Exception e)
                {
                    Debug.LogError($"Build task {task.GetType().Name} failed !");
                    Debug.LogError($"Build error : {e}");
                    succeed = false;
                    break;
                }
            }

            // 返回运行结果
            return(succeed);
        }
コード例 #7
0
ファイル: TaskBatchingImpl.cs プロジェクト: frje/SharpLang
		public bool Build (IBuildTask buildTask, out bool executeOnErrors)
		{
			executeOnErrors = false;
			try {
				Init ();

				// populate list of referenced items and metadata
				ParseTaskAttributes (buildTask);
				if (consumedMetadataReferences.Count == 0) {
					// No batching required
					if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project))
						return buildTask.Execute ();
					else // skipped, it should be logged
						return true;
				}

				BatchAndPrepareBuckets ();
				return Run (buildTask, out executeOnErrors);
			} finally {
				consumedItemsByName = null;
				consumedMetadataReferences = null;
				consumedQMetadataReferences = null;
				consumedUQMetadataReferences = null;
				batchedItemsByName = null;
				commonItemsByName = null;
			}
		}
コード例 #8
0
        public void CanInjectAndExtractWithStructs()
        {
            IInjectionContext injection = new InjectionStruct();

            injection.State = 1;

            IBuildContext context = new BuildContext();

            context.SetContextObject(injection);

            TaskStruct task = new TaskStruct(2);

            Assert.IsNull(task.InjectedObject);

            // Still need to box / unbox the struct task
            IBuildTask boxed = task;

            ContextInjector.Inject(context, boxed);
            task = (TaskStruct)boxed;

            Assert.IsNotNull(task.InjectedObject);
            Assert.AreEqual(1, task.InjectedObject.State);

            ReturnCode result = task.Run();

            Assert.AreEqual(ReturnCode.Success, result);

            ContextInjector.Extract(context, task);

            IInjectionContext modifiedInjection = context.GetContextObject <IInjectionContext>();

            Assert.AreEqual(task.NewState, modifiedInjection.State);
        }
コード例 #9
0
 /// <summary>
 ///   Initializes an instance of the build task result.
 /// </summary>
 public BuildTaskResult(IBuildTask buildTask, string taskSignature, string taskOutputDir,
                        ImmutableArray <BuildTaskResult> dependenciesResults)
 {
     BuildTask           = buildTask;
     TaskSignature       = taskSignature;
     TaskOutputDir       = taskOutputDir;
     DependenciesResults = dependenciesResults;
 }
コード例 #10
0
ファイル: Builder.cs プロジェクト: TerrificNet/TerrificNet
        public void AddTask(IBuildTask task)
        {
            _tasks.Add(task);

            //foreach (var item in _project.GetItems().ToList())
            {
                PushTask(Proceed(task, _project.GetItems().ToList()));
            }
        }
コード例 #11
0
        private void AssertUniqueSignature(IBuildTask buildTask, string taskSignature)
        {
            var storedTask = signatureToBuildTask.GetOrAdd(taskSignature, buildTask);

            if (storedTask != buildTask)
            {
                throw new BuildTaskClashException(storedTask, buildTask, taskSignature);
            }
        }
コード例 #12
0
        static void ExtractTestData(IBuildTask task, out CustomAssets customAssets, out TestContent content, out TestDependencyData dependencyData)
        {
            IBuildContext context = new BuildContext();

            ContextInjector.Extract(context, task);
            customAssets   = (CustomAssets)context.GetContextObject <ICustomAssets>();
            content        = (TestContent)context.GetContextObject <IBundleBuildContent>();
            dependencyData = (TestDependencyData)context.GetContextObject <IDependencyData>();
        }
コード例 #13
0
        bool RunTargetWithBucket(Dictionary <string, BuildItemGroup> bucket, Target target, out bool executeOnErrors)
        {
            bool target_result = true;

            executeOnErrors = false;

            LogTargetStarted(target);
            if (bucket != null)
            {
                project.PushBatch(bucket, commonItemsByName);
            }
            try {
                string reason;
                if (!BuildTargetNeeded(out reason))
                {
                    LogTargetSkipped(target, reason);
                    return(true);
                }

                if (!String.IsNullOrEmpty(reason))
                {
                    target.Engine.LogMessage(MessageImportance.Low, reason);
                }

                for (int i = 0; i < target.BuildTasks.Count; i++)
                {
                    //FIXME: parsing attributes repeatedly
                    IBuildTask bt = target.BuildTasks [i];

                    TaskBatchingImpl batchingImpl = new TaskBatchingImpl(project);
                    bool             task_result  = batchingImpl.Build(bt, out executeOnErrors);
                    if (task_result)
                    {
                        continue;
                    }

                    // task failed, if ContinueOnError,
                    // ignore failed state for target
                    target_result = bt.ContinueOnError;

                    if (!bt.ContinueOnError)
                    {
                        executeOnErrors = true;
                        return(false);
                    }
                }
            } finally {
                if (bucket != null)
                {
                    project.PopBatch();
                }
                LogTargetFinished(target, target_result);
            }

            return(target_result);
        }
コード例 #14
0
ファイル: CabwizBuildContext.cs プロジェクト: adbre/cab42
        /// <inheritdoc />
        public override IBuildResult Build(IBuildTask[] tasks, IBuildFeedback feedback)
        {
            // Wrap the feedback object to a textwriter instance so we may channel
            // the output from the cabwiz.exe application to the feedback object.
            this.cabwizTextWriter = new CabwizTextWriter(feedback);

            this.Cabwiz.StandardOutput = this.cabwizTextWriter;
            this.Cabwiz.StandardError = this.cabwizTextWriter;

            return base.Build(tasks, feedback);
        }
コード例 #15
0
        private void GraphNodeAction(IBuildTask buildTask)
        {
            // At this point all dependencies will have been evaluated.
            var dependenciesResults = GetResults(buildTask.Dependencies);
            var taskSignature       = buildTask.Signature(SourceDir, dependenciesResults);

            AssertUniqueSignature(buildTask, taskSignature);
            var buildTaskResult = ExecuteBuildTask(buildTask, taskSignature, dependenciesResults);

            buildTasksToResults.TryAdd(buildTask, buildTaskResult);
        }
コード例 #16
0
        static ReturnCode RunTask <T>(params IContextObject[] args) where T : IBuildTask
        {
            IBuildContext context  = new BuildContext(args);
            IBuildTask    instance = Activator.CreateInstance <T>();

            ContextInjector.Inject(context, instance);
            var result = instance.Run();

            ContextInjector.Extract(context, instance);
            return(result);
        }
コード例 #17
0
        /// <summary>
        /// 向任务管线中增加任务
        /// </summary>
        /// <param name="task"></param>
        public ATBuildPipline AddBuildTask(IBuildTask task)
        {
            if (Tasks == null)
            {
                Tasks = new Queue <IBuildTask>();
            }

            Tasks.Enqueue(task);

            return(_instance);
        }
コード例 #18
0
            public void Run()
            {
                while (!mAbort)
                {
                    IBuildTask task = null;

                    lock (mSemaphore)
                    {
                        if (mTask != null && mTask.TaskState == BuildTaskState.Inactive)
                        {
                            task  = mTask;
                            mTask = null;
                        }
                    }

                    if (task == null)
                    {
                        Thread.Sleep(100);
                    }
                    else
                    {
                        // Have to re-check.  State may have changed.
                        if (task.TaskState == BuildTaskState.Inactive)
                        {
                            /*
                             * Design note:
                             *
                             * This is a trade-off to deal with poorly written tasks. Technically,
                             * the task is responsible for catching and reporting its own
                             * exceptions.  But if it doesn't it can bring down the processor
                             * thread.
                             *
                             * This method forces the task to abort so the main manager can detect
                             * and discard it.  But if the task is so poorly written that the
                             * abort doesn't work, or throws another exception, then the processor
                             * will become a zombie, unresponsive to new requests from the manager.
                             */
                            try
                            {
                                task.Run();
                            }
                            catch (Exception ex)
                            {
                                task.Abort("Exception detected by processor: " + ex.Message);
                            }
                        }
                    }
                }
            }
コード例 #19
0
        private BuildTaskResult ExecuteBuildTask(IBuildTask buildTask,
                                                 string taskSignature,
                                                 ImmutableArray <BuildTaskResult> dependenciesResults)
        {
            var taskOutputDir = Combine(PerTaskOutputDir, taskSignature);

            if (!Exists(taskOutputDir))
            {
                var partialTaskOutputDir = Combine(PerTaskPartialOutputDir, taskSignature);
                CreateDirectory(partialTaskOutputDir);
                buildTask.Execute(SourceDir, partialTaskOutputDir, dependenciesResults);
                Move(partialTaskOutputDir, taskOutputDir);
            }
            return(new BuildTaskResult(buildTask, taskSignature, taskOutputDir, dependenciesResults));
        }
コード例 #20
0
ファイル: TaskBatchingImpl.cs プロジェクト: pmq20/mono_forked
        bool Run(IBuildTask buildTask, out bool executeOnErrors)
        {
            executeOnErrors = false;

            // Run the task in batches
            bool retval = true;

            if (buckets.Count == 0)
            {
                // batched mode, but no values in the corresponding items!
                if (ConditionParser.ParseAndEvaluate(buildTask.Condition, project))
                {
                    retval = buildTask.Execute();
                    if (!retval && !buildTask.ContinueOnError)
                    {
                        executeOnErrors = true;
                    }
                }

                return(retval);
            }

            // batched
            foreach (Dictionary <string, BuildItemGroup> bucket in buckets)
            {
                project.PushBatch(bucket, commonItemsByName);
                try {
                    if (ConditionParser.ParseAndEvaluate(buildTask.Condition, project))
                    {
                        retval = buildTask.Execute();
                        if (!retval && !buildTask.ContinueOnError)
                        {
                            executeOnErrors = true;
                            break;
                        }
                    }
                } finally {
                    project.PopBatch();
                }
            }

            return(retval);
        }
コード例 #21
0
ファイル: Builder.cs プロジェクト: TerrificNet/TerrificNet
        private async Task Proceed(IBuildTask task, IList<ProjectItem> items)
        {
            if (!task.DependsOn.IsMatch(items))
                return;

            var querySets = task.DependsOn.Select(_project.GetItems(), items).ToList();
            foreach (var querySet in querySets)
            {
                var sources = task.Proceed(querySet.GetItems());
                if (sources == null)
                    throw new InvalidOperationException("The proceed method has to return a value.");

                foreach (var source in sources)
                {
                    ProjectItem existing;
                    if (_project.TryGetItemById(source.Identifier, out existing))
                    {
                        var defferred = existing as DefferedProjectItem;
                        defferred?.SetDirty(source.Content);

                        var inMemory = existing as InMemoryProjectItem;
                        inMemory?.SetContent((await CopyToStream(source)).GetBuffer());

                        _project.Touch(existing);
                    }
                    else
                    {
                        ProjectItem item2;
                        if (task.Options == BuildOptions.BuildInBackground)
                        {
                            item2 = await BuildInMemoryItem(source);
                        }
                        else
                            item2 = new DefferedProjectItem(source.Identifier, source.Content);

                        _project.AddItem(item2);

                        foreach (var linkedItem in querySet.GetItems())
                            _project.AddLink(linkedItem, new ProjectItemLinkDescriptionFromBuilder(task.Name, this, linkedItem), item2);
                    }
                }
            }
        }
コード例 #22
0
        bool Execute(IBuildTask buildTask, TaskExecutionMode taskExecutionMode)
        {
            if (ConditionParser.ParseAndEvaluate(buildTask.Condition, project))
            {
                switch (taskExecutionMode)
                {
                case TaskExecutionMode.Complete:
                    return(buildTask.Execute());

                case TaskExecutionMode.SkipAndSetOutput:
                    return(buildTask.ResolveOutputItems());

                default:
                    throw new NotImplementedException();
                }
            }

            return(true);
        }
コード例 #23
0
ファイル: JobTaskService.cs プロジェクト: frandi/OpenCatapult
 public JobTaskService(IBuildTask buildTask,
                       ICloneTask cloneTask,
                       IDeployTask deployTask,
                       IDeployDbTask deployDbTask,
                       IGenerateTask generateTask,
                       IMergeTask mergeTask,
                       IPublishArtifactTask publishArtifactTask,
                       IPushTask pushTask,
                       ITestTask testTask)
 {
     BuildTask           = buildTask;
     CloneTask           = cloneTask;
     DeployTask          = deployTask;
     DeployDbTask        = deployDbTask;
     GenerateTask        = generateTask;
     MergeTask           = mergeTask;
     PublishArtifactTask = publishArtifactTask;
     PushTask            = pushTask;
     TestTask            = testTask;
 }
コード例 #24
0
        /// <summary>
        /// Queues a task to be run.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The processor will only queue inactive tasks that are threadsafe.
        /// </para>
        /// </remarks>
        /// <param name="task">The task to queue.</param>
        /// <returns>True if the task was accepted.</returns>
        public bool QueueTask(IBuildTask task)
        {
            if (task == null || task.TaskState != BuildTaskState.Inactive || !task.IsThreadSafe)
            {
                return(false);
            }

            lock (mTaskQueue)
            {
                if (mAbort)
                {
                    return(false);
                }

                if (mProcessors[0] == null)
                {
                    for (int i = 0; i < mProcessors.Length; i++)
                    {
                        mProcessors[i] = new Processor();
                        Thread t = new Thread(new ThreadStart(mProcessors[i].Run));
                        t.Start();
                    }
                }

                mTaskQueue.Add(task);

                mTaskCount = mTaskQueue.Count;
                foreach (IBuildTask item in mActiveTasks)
                {
                    if (item != null)
                    {
                        mTaskCount++;
                    }
                }

                return(true);
            }
        }
コード例 #25
0
ファイル: TaskBatchingImpl.cs プロジェクト: nlhepler/mono
		public bool Build (IBuildTask buildTask, TaskExecutionMode taskExecutionMode, out bool executeOnErrors)
		{
			executeOnErrors = false;
			try {
				Init ();

				// populate list of referenced items and metadata
				ParseTaskAttributes (buildTask);
				if (consumedMetadataReferences.Count == 0) {
					return Execute (buildTask, taskExecutionMode);
				}

				BatchAndPrepareBuckets ();
				return Run (buildTask, taskExecutionMode, out executeOnErrors);
			} finally {
				consumedItemsByName = null;
				consumedMetadataReferences = null;
				consumedQMetadataReferences = null;
				consumedUQMetadataReferences = null;
				batchedItemsByName = null;
				commonItemsByName = null;
			}
		}
コード例 #26
0
        public bool Build(IBuildTask buildTask, TaskExecutionMode taskExecutionMode, out bool executeOnErrors)
        {
            executeOnErrors = false;
            try {
                Init();

                // populate list of referenced items and metadata
                ParseTaskAttributes(buildTask);
                if (consumedMetadataReferences.Count == 0)
                {
                    return(Execute(buildTask, taskExecutionMode));
                }

                BatchAndPrepareBuckets();
                return(Run(buildTask, taskExecutionMode, out executeOnErrors));
            } finally {
                consumedItemsByName          = null;
                consumedMetadataReferences   = null;
                consumedQMetadataReferences  = null;
                consumedUQMetadataReferences = null;
                batchedItemsByName           = null;
                commonItemsByName            = null;
            }
        }
コード例 #27
0
        public static void Run(List <IBuildTask> pipeline, BuildContext context)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException("pipeline");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            for (int i = 0; i < pipeline.Count; i++)
            {
                IBuildTask task = pipeline[i];
                try
                {
                    task.Run(context);
                }
                catch (Exception e)
                {
                    throw new Exception($"Build task {task.GetType().Name} failed : {e}");
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// 任务管线的执行函数
        /// </summary>
        public void Run()
        {
            //任务管线中无任务队列
            if (Tasks.Count == 0)
            {
                //EditorUtility.DisplayDialog("提示", "任务管线中无任务队列!", "OK");
                EndATBuildPipline();//重置相关属性
                return;
            }

            //上次执行任务如果失败,直接返回,管线终止
            if (LastTask == TaskStatus.Failure)
            {
                //EndATBuildPipline();//重置相关属性
                OnReverseTasks();
                return;
            }

            PiplineStatus = ATBuildPiplineStatus.Occupied;
            if (Tasks.Count > 0)
            {
                IBuildTask currentTask = Tasks.Peek();

                switch (currentTask.Status)
                {
                case TaskStatus.None:
                {        //只执行一次
                    currentTask.Status = TaskStatus.Start;
                    _currentTask       = currentTask;
                    currentTask.OnStatusChanged(currentTask.Status);
                    _lastTime = DateTime.Now;
                }
                break;

                case TaskStatus.Start:
                {        //开始任务
                    if (OnRePaintWindow())
                    {    //此处为了Repaint
                        currentTask.Status = TaskStatus.Running;
                        currentTask.OnReady();
                        currentTask.DoTask();
                    }
                }
                break;

                case TaskStatus.Running:
                {        //和刷新的帧数一样
                }
                break;

                case TaskStatus.Success:
                {
                    //TODO
                    currentTask.OnFinal();
                    currentTask = null;

                    IBuildTask task = Tasks.Dequeue();
                    ExcutedTasks.Add(task);
                    _currentTask = null;
                    _currentTime = new DateTime();
                    _lastTime    = new DateTime();
                }
                break;

                case TaskStatus.Failure:
                {
                    //TODO
                    //任务失败
                    currentTask.OnFinal();
                    currentTask = null;

                    LastTask     = TaskStatus.Failure;
                    _currentTime = new DateTime();
                    _lastTime    = new DateTime();
                }
                break;
                }
            }
        }
コード例 #29
0
 /// <summary>
 /// Add IBuildTask object to build pipeline as a task
 /// </summary>
 /// <param name="buildTask">Build task</param>
 public static void RegisterScenePostprocessTask(IBuildTask buildTask)
 {
     s_Tasks.Add(buildTask);
 }
コード例 #30
0
ファイル: TaskBatchingImpl.cs プロジェクト: nlhepler/mono
		bool Execute (IBuildTask buildTask, TaskExecutionMode taskExecutionMode)
		{
			if (ConditionParser.ParseAndEvaluate (buildTask.Condition, project)) {
				switch (taskExecutionMode) {
				case TaskExecutionMode.Complete:
					return buildTask.Execute ();
				case TaskExecutionMode.SkipAndSetOutput:
					return buildTask.ResolveOutputItems ();
				default:
					throw new NotImplementedException ();
				}
			}

			return true;
		}
コード例 #31
0
ファイル: TaskBatchingImpl.cs プロジェクト: nlhepler/mono
		// Parse task attributes to get list of referenced metadata and items
		// to determine batching
		//
		void ParseTaskAttributes (IBuildTask buildTask)
		{
			foreach (var attr in buildTask.GetAttributes ()) {
				ParseAttribute (attr);
			}
		}
コード例 #32
0
ファイル: SiteBuilder.cs プロジェクト: threax/EdityMcEditface
 public void AddPreBuildTask(IBuildTask task)
 {
     preBuildTasks.Add(task);
 }
コード例 #33
0
ファイル: BuildTaskContext.cs プロジェクト: adbre/cab42
        /// <summary>
        /// Executes a collection of build tasks using the specified feedback object.
        /// </summary>
        /// <param name="tasks">An array of build tasks to execute.</param>
        /// <returns>The build result for all tasks.</returns>
        public virtual IBuildResult Build(IBuildTask[] tasks, IBuildFeedback feedback)
        {
            if (tasks == null)
            {
                throw new ArgumentNullException("tasks");
            }

            if (feedback == null)
            {
                throw new ArgumentNullException("feedback");
            }

            var result = new BuildResult()
            {
                Success = true,
                TotalSteps = tasks.Length
            };

            foreach (var task in tasks)
            {
                try
                {
                    feedback.WriteLine("------ Build started: {0} ------", task.ToString());

                    result.Success = this.BuildTask(task, feedback);

                    feedback.WriteLine();
                }
                catch (Exception x)
                {
                    var message = new BuildMessage(x)
                    {
                        Project = task.ProjectName,
                        Configuration = task.Configuration
                    };

                    feedback.AddMessage(message);

                    result.Success = false;
                }

                if (result.Success)
                {
                    result.TasksSuccesful++;
                }
                else
                {
                    feedback.Write("aborting build... ");

                    result.TasksAborted++;

                    break;
                }
            }

            if (!result.Success)
            {
                feedback.WriteLine("aborted!");
                feedback.WriteLine();
            }

            feedback.WriteLine(
                "========== Build: {1} succeeded, {2} failed, {3} skipped ==========",
                result.Success ? "succeeded" : "failed",
                result.TasksSuccesful,
                result.TasksAborted,
                result.TasksSkipped,
                result.TotalSteps);

            return result;
        }
コード例 #34
0
 /// <summary>
 /// Stores the given exception parameters into properties.
 /// </summary>
 public BuildTaskClashException(IBuildTask buildTask1, IBuildTask buildTask2, string clashingSignature)
 {
     BuildTask1        = buildTask1;
     BuildTask2        = buildTask2;
     ClashingSignature = clashingSignature;
 }
コード例 #35
0
 public void RunTask(IBuildTask task)
 {
     lock (mSemaphore) { mTask = task; }
 }
コード例 #36
0
        /// <summary>
        /// Runs the processor.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method will block until the processor is aborted.  So the expected use
        /// case is that this method will be run on its own thread.
        /// </para>
        /// <para>
        /// Processors are single use.  They cannot be run again after they are aborted.
        /// </para>
        /// </remarks>
        public void Run()
        {
            lock (mTaskQueue)
            {
                if (mAbort || mIsRunning)
                {
                    return;
                }

                mIsRunning = true;
            }

            while (!mAbort)
            {
                int activeCount = 0;

                lock (mTaskQueue)
                {
                    mTaskQueue.Sort(mComparer);

                    for (int i = 0; i < mActiveTasks.Length; i++)
                    {
                        IBuildTask task = mActiveTasks[i];

                        if (task == null || task.IsFinished)
                        {
                            // Task complete.  Clear it out.
                            mActiveTasks[i] = null;
                            task            = null;
                        }
                        else
                        {
                            // Task still being processed.
                            activeCount++;
                            continue;
                        }

                        // Need to assign a new task to this slot.
                        while (task == null && mTaskQueue.Count > 0)
                        {
                            task = mTaskQueue[mTaskQueue.Count - 1];
                            mTaskQueue.RemoveAt(mTaskQueue.Count - 1);

                            if (task.TaskState != BuildTaskState.Inactive)
                            {
                                task = null;
                            }
                        }

                        if (task != null)
                        {
                            // Found a task to run.
                            activeCount++;
                            mActiveTasks[i] = task;
                            mProcessors[i].RunTask(task);
                        }
                    }

                    mTaskCount = mTaskQueue.Count + activeCount;
                }

                // Pause longer if there are no active tasks.
                if (activeCount > 0)
                {
                    Thread.Sleep(10);
                }
                else
                {
                    Thread.Sleep(100);
                }
            }

            mTaskCount = 0;

            foreach (Processor processor in mProcessors)
            {
                if (processor == null)
                {
                    // The processors were never started.
                    break;
                }

                processor.Abort();
            }

            mIsRunning = false;
        }
コード例 #37
0
        /// <summary>
        /// Queues a task to be run.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The processor will only queue inactive tasks that are threadsafe.
        /// </para>
        /// </remarks>
        /// <param name="task">The task to queue.</param>
        /// <returns>True if the task was accepted.</returns>
        public bool QueueTask(IBuildTask task)
        {
            if (task == null || task.TaskState != BuildTaskState.Inactive || !task.IsThreadSafe)
                return false;

            lock (mTaskQueue)
            {
                if (mAbort)
                    return false;

                if (mProcessors[0] == null)
                {
                    for (int i = 0; i < mProcessors.Length; i++)
                    {
                        mProcessors[i] = new Processor();
                        Thread t = new Thread(new ThreadStart(mProcessors[i].Run));
                        t.Start();
                    }
                }

                mTaskQueue.Add(task);

                mTaskCount = mTaskQueue.Count;
                foreach (IBuildTask item in mActiveTasks)
                {
                    if (item != null)
                        mTaskCount++;
                }

                return true;
            }
        }
コード例 #38
0
ファイル: CabwizTextWriter.cs プロジェクト: adbre/cab42
 public void SetActiveTask(IBuildTask task)
 {
     this.activeTask = task;
 }
コード例 #39
0
ファイル: CabwizBuildContext.cs プロジェクト: adbre/cab42
        /// <inheritdoc />
        protected override bool BuildTask(IBuildTask task, IBuildFeedback feedback)
        {
            if (this.cabwizTextWriter != null)
            {
                this.cabwizTextWriter.SetActiveTask(task);
            }

            try
            {
                var cabwizTask = task as ICabwizBuildTask;
                if (cabwizTask != null)
                {
                    return cabwizTask.Build(this.Cabwiz, feedback);
                }
                else
                {
                    return base.BuildTask(task, feedback);
                }
            }
            finally
            {
                if (this.cabwizTextWriter != null)
                {
                    this.cabwizTextWriter.SetActiveTask(null);
                }
            }
        }
コード例 #40
0
 public void RunTask(IBuildTask task)
 {
     lock (mSemaphore) { mTask = task; }
 }
コード例 #41
0
            public void Run()
            {
                while (!mAbort)
                {
                    IBuildTask task = null;

                    lock (mSemaphore)
                    {
                        if (mTask != null && mTask.TaskState == BuildTaskState.Inactive)
                        {
                            task = mTask;
                            mTask = null;
                        }
                    }

                    if (task == null)
                        Thread.Sleep(100);
                    else
                    {
                        // Have to re-check.  State may have changed.
                        if (task.TaskState == BuildTaskState.Inactive)
                        {
                            /*
                             * Design note: 
                             * 
                             * This is a trade-off to deal with poorly written tasks. Technically, 
                             * the task is responsible for catching and reporting its own 
                             * exceptions.  But if it doesn't it can bring down the processor 
                             * thread.  
                             * 
                             * This method forces the task to abort so the main manager can detect 
                             * and discard it.  But if the task is so poorly written that the 
                             * abort doesn't work, or throws another exception, then the processor 
                             * will become a zombie, unresponsive to new requests from the manager.
                             */
                            try
                            {
                                task.Run();
                            }
                            catch (Exception ex)
                            {
                                task.Abort("Exception detected by processor: " + ex.Message);
                            }
                        }
                    }
                }
            }
コード例 #42
0
        bool RunTargetWithBucket(Dictionary <string, BuildItemGroup> bucket, Target target, out bool executeOnErrors)
        {
            bool target_result = true;

            executeOnErrors = false;

            LogTargetStarted(target);

            if (bucket != null)
            {
                project.PushBatch(bucket, commonItemsByName);
            }

            try {
                TaskExecutionMode taskExecutionMode;
                string            reason;
                bool skip_completely;
                if (!BuildTargetNeeded(out reason, out skip_completely))
                {
                    LogTargetSkipped(target, reason);
                    if (skip_completely)
                    {
                        return(true);
                    }

                    taskExecutionMode = TaskExecutionMode.SkipAndSetOutput;
                }
                else
                {
                    taskExecutionMode = TaskExecutionMode.Complete;

                    if (!String.IsNullOrEmpty(reason))
                    {
                        target.Engine.LogMessage(MessageImportance.Low, reason);
                    }
                }

                for (int i = 0; i < target.BuildTasks.Count; i++)
                {
                    //FIXME: parsing attributes repeatedly
                    IBuildTask bt = target.BuildTasks [i];

                    // HACK: need some form of cross references checks
                    var tem = taskExecutionMode;
                    if (tem == TaskExecutionMode.SkipAndSetOutput)
                    {
                        var bti = bt as BuildTask;

                        //
                        // BuildTargetNeeded checks only files timestamps but ignores any metadata dependencies
                        // that way we can end up in the situation when output metadata are populated but from
                        // incomplete dependencies.
                        //
                        // E.g.
                        // <CreateItem Include="$(IntermediateOutputPath)%(_PngImage.LogicalName)" AdditionalMetadata="LogicalName=%(_PngImage.LogicalName)">
                        //		<Output TaskParameter="Include" />
                        // </CreateItem>
                        //
                        if (bti != null && bti.Name == "CreateItem")
                        {
                            tem = TaskExecutionMode.Complete;
                        }
                    }

                    TaskBatchingImpl batchingImpl = new TaskBatchingImpl(project);
                    bool             task_result  = batchingImpl.Build(bt, tem, out executeOnErrors);
                    if (task_result)
                    {
                        continue;
                    }

                    // task failed, if ContinueOnError,
                    // ignore failed state for target
                    target_result = bt.ContinueOnError;

                    if (!bt.ContinueOnError)
                    {
                        executeOnErrors = true;
                        return(false);
                    }
                }
            } finally {
                if (bucket != null)
                {
                    project.PopBatch();
                }

                LogTargetFinished(target, target_result);
            }

            return(target_result);
        }
コード例 #43
0
ファイル: SiteBuilder.cs プロジェクト: threax/EdityMcEditface
 public void AddPostPublishTask(IBuildTask task)
 {
     postPublishTasks.Add(task);
 }
コード例 #44
0
 public void SetActiveTask(IBuildTask task)
 {
     this.activeTask = task;
 }
コード例 #45
0
ファイル: BuildTaskContext.cs プロジェクト: adbre/cab42
 /// <summary>
 /// Executes the Build method of the specified task.
 /// </summary>
 /// <param name="task">The build task to execute.</param>
 /// <param name="feedback">The feedback object.</param>
 /// <returns>The value returned by the task's Build method.</returns>
 protected virtual bool BuildTask(IBuildTask task, IBuildFeedback feedback)
 {
     return task.Build(feedback);
 }