Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
OutputEnumerationBuildStep.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.ComponentModel;
6 using System.Linq;
7 using System.Threading.Tasks;
8 
9 namespace SiliconStudio.BuildEngine
10 {
11  [Description("Output enumeration")]
12  [Obsolete("This class is not maintained.")]
14  {
15  public BuildStep Template { get { return template; } set { template = value; if (template != null) template.Parent = this; } }
16  private BuildStep template;
17 
18  public List<string> SearchTags { get; set; }
19 
20  public IEnumerable<string> Urls { get; protected set; }
21 
23  {
24  SearchTags = new List<string>();
25  Urls = Enumerable.Empty<string>();
26  }
27 
28  public override string ToString()
29  {
30  lock (Urls)
31  {
32  return "Output enumeration" + (Urls.FirstOrDefault() != null ? " (" + Urls.Count() + " urls)" : "");
33  }
34  }
35 
36  public override BuildStep Clone()
37  {
38  var clone = new OutputEnumerationBuildStep();
39  if (template != null)
40  clone.Template = template.Clone();
41  clone.SearchTags = SearchTags.ToList();
42  return clone;
43  }
44 
45  public override async Task<ResultStatus> Execute(IExecuteContext executeContext, BuilderContext builderContext)
46  {
47  Steps = new List<BuildStep>();
48 
49  var urls = Enumerable.Empty<string>();
50 
51  BuildStep parentList = Parent;
52  while (!(parentList is ListBuildStep))
53  {
54  parentList = parentList.Parent;
55  }
56 
57  var parentListBuildStep = (ListBuildStep)parentList;
58 
59 
60  foreach (string tag in SearchTags)
61  {
62  urls = urls.Concat(parentListBuildStep.OutputObjects.Where(x => x.Value.Tags.Contains(tag)).Select(x => x.Key.ToString()));
63  }
64 
65  var buildStepToWait = new List<BuildStep>();
66 
67  lock (Urls)
68  {
69  Urls = urls;
70  foreach (string url in Urls)
71  {
72  executeContext.Variables["URL"] = url;
73  var fileBuildStep = Template.Clone();
74  ((List<BuildStep>)Steps).Add(fileBuildStep);
75  buildStepToWait.Add(fileBuildStep);
76  executeContext.ScheduleBuildStep(fileBuildStep);
77  }
78  }
79 
80  await CompleteCommands(executeContext, buildStepToWait);
81 
82  return ResultStatus.Successful;
83  }
84  }
85 }
A BuildStep that can spawn multiple BuildStep. Input and output tracking and merging will be performe...
override async Task< ResultStatus > Execute(IExecuteContext executeContext, BuilderContext builderContext)
Execute the BuildStep, usually resulting in scheduling tasks in the scheduler
override BuildStep Clone()
Clone this Build Step.