Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(828)

Side by Side Diff: visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClToolTask.cs

Issue 11266051: Add PNaCl support for VS addin. (Closed) Base URL: http://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5 using System;
6 using System.Collections.Generic;
7 using System.Text;
8 using System.Collections;
9 using System.IO;
10 using System.Reflection;
11 using System.Resources;
12 using System.Windows.Forms;
13 using Microsoft.Build.Framework;
14 using Microsoft.Win32;
15 using Microsoft.Build.Utilities;
16 using System.Collections.Specialized;
17
18 using System.Diagnostics;
19
20 namespace NaCl.Build.CPPTasks
21 {
22 public abstract class NaClToolTask : ToolTask
23 {
24 protected NaClToolTask(ResourceManager taskResources) : base(taskResourc es) { }
25 protected ITaskItem[] excludedInputPaths;
26 private ITaskItem[] tlogReadFiles;
27 private ITaskItem tlogCommandFile;
28 private ITaskItem[] tlogWriteFiles;
29 private CanonicalTrackedInputFiles trackedInputFiles;
30 private bool skippedExecution;
31 private bool minimalRebuildFromTracking;
32 private bool trackFileAccess;
33 protected ITaskItem[] compileSourceList;
34
35 protected abstract CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem [] compiledSources);
36 protected abstract void OutputReadTLog(ITaskItem[] compiledSources, Cano nicalTrackedOutputFiles outputs);
37 protected abstract void OutputCommandTLog(ITaskItem[] compiledSources);
38
39 [Required]
40 public string TrackerLogDirectory { get; set; }
41
42 [Required]
43 public virtual ITaskItem[] Sources { get; set; }
44
45 protected bool ForcedRebuildRequired()
46 {
47 string tlogCommandPath = null;
48
49 try
50 {
51 tlogCommandPath = this.TLogCommandFile.GetMetadata("FullPath");
52 }
53 catch (Exception exception)
54 {
55 if (exception is InvalidOperationException || exception is NullR eferenceException)
56 return true;
57 else
58 throw;
59 }
60
61 //if command tlog file does not exist then force rebuild is required
62 if (File.Exists(tlogCommandPath) == false)
63 {
64 return true;
65 }
66 else
67 {
68 return false;
69 }
70 }
71
72 protected override bool SkipTaskExecution()
73 {
74 return this.skippedExecution;
75 }
76
77 protected string BaseTool()
78 {
79 return Path.GetFileNameWithoutExtension(ToolName);
80 }
81
82 protected bool Setup()
83 {
84 this.SkippedExecution = false;
85
86 if (!ValidateParameters())
87 {
88 return false;
89 }
90
91 if (this.TrackFileAccess || this.MinimalRebuildFromTracking)
92 {
93 this.SetTrackerLogPaths();
94 }
95
96 if (this.ForcedRebuildRequired() || this.MinimalRebuildFromTracking == false)
97 {
98 if (this.Sources == null || this.Sources.Length == 0)
99 {
100 this.SkippedExecution = true;
101 }
102 }
103
104 return true;
105 }
106
107 public override bool Execute()
108 {
109 bool returnResult = base.Execute();
110
111 // Update tracker log files if execution occurred
112 //if (this.skippedExecution == false)
113 {
114 CanonicalTrackedOutputFiles outputs = OutputWriteTLog(compileSou rceList);
115 OutputReadTLog(compileSourceList, outputs);
116 OutputCommandTLog(compileSourceList);
117 }
118
119 return returnResult;
120 }
121
122 protected override Encoding ResponseFileEncoding
123 {
124 get
125 {
126 return Encoding.ASCII;
127 }
128 }
129
130 protected virtual void SetTrackerLogPaths()
131 {
132 if (this.TLogCommandFile == null)
133 {
134 string commandFile = Path.Combine(this.TlogDirectory, this.Comma ndTLogFilename);
135 this.TLogCommandFile = new TaskItem(commandFile);
136 }
137
138 if (this.TLogReadFiles == null)
139 {
140 this.TLogReadFiles = new ITaskItem[this.ReadTLogFilenames.Length ];
141 for (int n = 0; n < this.ReadTLogFilenames.Length; n++)
142 {
143 string readFile = Path.Combine(this.TlogDirectory, this.Read TLogFilenames[n]);
144 this.TLogReadFiles[n] = new TaskItem(readFile);
145 }
146 }
147
148 if (this.TLogWriteFiles == null)
149 {
150 this.TLogWriteFiles = new ITaskItem[1];
151 string writeFile = Path.Combine(this.TlogDirectory, this.WriteTL ogFilename);
152 this.TLogWriteFiles[0] = new TaskItem(writeFile);
153 }
154 }
155
156 [Output]
157 public bool SkippedExecution
158 {
159 get
160 {
161 return this.skippedExecution;
162 }
163 set
164 {
165 this.skippedExecution = value;
166 }
167 }
168
169 public ITaskItem TLogCommandFile
170 {
171 get
172 {
173 return this.tlogCommandFile;
174 }
175 set
176 {
177 this.tlogCommandFile = value;
178 }
179 }
180
181 protected string TlogDirectory
182 {
183 get
184 {
185 if (this.TrackerLogDirectory != null)
186 {
187 return this.TrackerLogDirectory;
188 }
189 return string.Empty;
190 }
191 }
192
193 public bool MinimalRebuildFromTracking
194 {
195 get
196 {
197 return this.minimalRebuildFromTracking;
198 }
199 set
200 {
201 this.minimalRebuildFromTracking = value;
202 }
203 }
204
205
206 public ITaskItem[] TLogReadFiles
207 {
208 get
209 {
210 return this.tlogReadFiles;
211 }
212 set
213 {
214 this.tlogReadFiles = value;
215 }
216 }
217
218 public ITaskItem[] TLogWriteFiles
219 {
220 get
221 {
222 return this.tlogWriteFiles;
223 }
224 set
225 {
226 this.tlogWriteFiles = value;
227 }
228 }
229
230 public bool TrackFileAccess
231 {
232 get
233 {
234 return this.trackFileAccess;
235 }
236 set
237 {
238 this.trackFileAccess = value;
239 }
240 }
241
242 protected CanonicalTrackedInputFiles TrackedInputFiles
243 {
244 get
245 {
246 return this.trackedInputFiles;
247 }
248 set
249 {
250 this.trackedInputFiles = value;
251 }
252 }
253
254 public ITaskItem[] ExcludedInputPaths
255 {
256 get
257 {
258 return this.excludedInputPaths;
259 }
260 set
261 {
262 this.excludedInputPaths = value;
263 }
264 }
265
266 protected virtual string CommandTLogFilename
267 {
268 get
269 {
270 return BaseTool() + ".compile.command.1.tlog";
271 }
272 }
273
274 protected virtual string[] ReadTLogFilenames
275 {
276 get
277 {
278 return new string[] { BaseTool() + ".compile.read.1.tlog" };
279 }
280 }
281
282 protected virtual string WriteTLogFilename
283 {
284 get
285 {
286 return BaseTool() + ".compile.write.1.tlog";
287 }
288 }
289 }
290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698