OLD | NEW |
---|---|
1 | 1 |
2 using System; | 2 using System; |
3 using System.Collections.Generic; | 3 using System.Collections.Generic; |
4 using System.Text; | 4 using System.Text; |
5 using System.Collections; | 5 using System.Collections; |
6 using System.IO; | 6 using System.IO; |
7 using System.Reflection; | 7 using System.Reflection; |
8 using System.Resources; | 8 using System.Resources; |
9 using System.Windows.Forms; | 9 using System.Windows.Forms; |
10 using Microsoft.Build.Framework; | 10 using Microsoft.Build.Framework; |
11 using Microsoft.Win32; | 11 using Microsoft.Win32; |
12 using Microsoft.Build.Utilities; | 12 using Microsoft.Build.Utilities; |
13 using System.Collections.Specialized; | 13 using System.Collections.Specialized; |
14 | 14 |
15 using System.Diagnostics; | 15 using System.Diagnostics; |
16 | 16 |
17 namespace NaCl.Build.CPPTasks | 17 namespace NaCl.Build.CPPTasks |
18 { | 18 { |
19 public class NaClCompile : ToolTask | 19 public class NaClCompile : NaClToolTask |
20 { | 20 { |
21 private XamlParser m_XamlParser; | |
22 private ITaskItem[] excludedInputPaths; | |
23 private ITaskItem[] tlogReadFiles; | |
24 private ITaskItem tlogCommandFile; | |
25 private ITaskItem[] tlogWriteFiles; | |
26 private CanonicalTrackedInputFiles trackedInputFiles; | |
27 private bool skippedExecution; | |
28 private ITaskItem[] compileSourceList; | |
29 public bool BuildingInIDE { get; set; } | 21 public bool BuildingInIDE { get; set; } |
30 private string m_toolname; | |
31 private bool trackFileAccess; | |
32 private bool minimalRebuildFromTracking; | |
33 private string pathToLog; | |
34 | 22 |
35 [Required] | 23 [Required] |
36 public string PropertiesFile { get; set; } | 24 public string PropertiesFile { get; set; } |
37 | 25 |
38 [Required] | 26 [Required] |
39 public ITaskItem[] Sources { get; set; } | |
40 | |
41 [Required] | |
42 public string NaCLCompilerPath { get; set; } | 27 public string NaCLCompilerPath { get; set; } |
43 | 28 |
44 [Required] | 29 [Required] |
45 public bool OutputCommandLine { get; set; } | 30 public bool OutputCommandLine { get; set; } |
46 | 31 |
32 [Required] | |
33 public string Platform { get; set; } | |
34 | |
47 public int ProcessorNumber { get; set; } | 35 public int ProcessorNumber { get; set; } |
48 | 36 |
49 public bool MultiProcessorCompilation { get; set; } | 37 public bool MultiProcessorCompilation { get; set; } |
50 | 38 |
51 [Required] | 39 [Obsolete] |
52 public string TrackerLogDirectory { get; set; } | |
53 | |
54 protected override StringDictionary EnvironmentOverride | 40 protected override StringDictionary EnvironmentOverride |
55 { | 41 { |
56 get { | 42 get { |
57 string show = OutputCommandLine ? "1" : "0"; | 43 string show = OutputCommandLine ? "1" : "0"; |
58 string cores = Convert.ToString(ProcessorNumber); | 44 string cores = Convert.ToString(ProcessorNumber); |
59 return new StringDictionary() { | 45 return new StringDictionary() { |
60 {"NACL_GCC_CORES", cores}, | 46 {"NACL_GCC_CORES", cores}, |
61 {"NACL_GCC_SHOW_COMMANDS", show } | 47 {"NACL_GCC_SHOW_COMMANDS", show } |
62 }; | 48 }; |
63 } | 49 } |
64 } | 50 } |
65 | 51 |
66 protected override string GenerateFullPathToTool() { return ToolName; } | 52 protected override string GenerateFullPathToTool() |
53 { | |
54 return ToolName; | |
55 } | |
67 | 56 |
68 public NaClCompile() | 57 public NaClCompile() |
69 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources ", Assembly.GetExecutingAssembly())) | 58 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources ", Assembly.GetExecutingAssembly())) |
70 { | 59 { |
71 this.pathToLog = string.Empty; | |
72 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning" , "LC_CTYPE=C" }; | 60 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning" , "LC_CTYPE=C" }; |
73 } | 61 } |
74 | 62 |
75 protected IDictionary<string, string> GenerateCommandLinesFromTlog() | 63 protected IDictionary<string, string> GenerateCommandLinesFromTlog() |
76 { | 64 { |
77 IDictionary<string, string> cmdLineDictionary = new Dictionary<strin g, string>(StringComparer.OrdinalIgnoreCase); | 65 IDictionary<string, string> cmdLineDictionary = new Dictionary<strin g, string>(StringComparer.OrdinalIgnoreCase); |
78 string tlogFilename = this.TLogCommandFile.GetMetadata("FullPath"); | 66 string tlogFilename = this.TLogCommandFile.GetMetadata("FullPath"); |
79 if (File.Exists(tlogFilename)) | 67 if (File.Exists(tlogFilename)) |
80 { | 68 { |
81 using (StreamReader reader = File.OpenText(tlogFilename)) | 69 using (StreamReader reader = File.OpenText(tlogFilename)) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 // the objectfile is created as <ObjectFileName>/<basename>.obj. He re | 103 // the objectfile is created as <ObjectFileName>/<basename>.obj. He re |
116 // we mimic this behaviour. | 104 // we mimic this behaviour. |
117 if ((File.GetAttributes(objectFilePath) & FileAttributes.Directory) != 0) | 105 if ((File.GetAttributes(objectFilePath) & FileAttributes.Directory) != 0) |
118 { | 106 { |
119 objectFilePath = Path.Combine(objectFilePath, Path.GetFileName(s ource.ItemSpec)); | 107 objectFilePath = Path.Combine(objectFilePath, Path.GetFileName(s ource.ItemSpec)); |
120 objectFilePath = Path.ChangeExtension(objectFilePath, ".obj"); | 108 objectFilePath = Path.ChangeExtension(objectFilePath, ".obj"); |
121 } | 109 } |
122 return objectFilePath; | 110 return objectFilePath; |
123 } | 111 } |
124 | 112 |
125 private void ConstructReadTLog(ITaskItem[] compiledSources, CanonicalTra ckedOutputFiles outputs) | 113 protected override void OutputReadTLog(ITaskItem[] compiledSources, Cano nicalTrackedOutputFiles outputs) |
126 { | 114 { |
127 string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilena mes[0]); | 115 string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilena mes[0]); |
128 | 116 |
129 //save tlog for sources not compiled during this execution | 117 //save tlog for sources not compiled during this execution |
130 TaskItem readTrackerItem = new TaskItem(trackerPath); | 118 TaskItem readTrackerItem = new TaskItem(trackerPath); |
131 CanonicalTrackedInputFiles files = new CanonicalTrackedInputFiles(ne w TaskItem[] { readTrackerItem }, Sources, outputs, false, false); | 119 CanonicalTrackedInputFiles files = new CanonicalTrackedInputFiles(ne w TaskItem[] { readTrackerItem }, Sources, outputs, false, false); |
132 files.RemoveEntriesForSource(compiledSources); | 120 files.RemoveEntriesForSource(compiledSources); |
133 files.SaveTlog(); | 121 files.SaveTlog(); |
134 | 122 |
135 //add tlog information for compiled sources | 123 //add tlog information for compiled sources |
(...skipping 26 matching lines...) Expand all Loading... | |
162 { | 150 { |
163 Log.LogMessage(MessageImportance.High, "File " + sourcePath + " is missing dependency " + filename); | 151 Log.LogMessage(MessageImportance.High, "File " + sourcePath + " is missing dependency " + filename); |
164 } | 152 } |
165 | 153 |
166 writer.WriteLine(filename); | 154 writer.WriteLine(filename); |
167 } | 155 } |
168 | 156 |
169 //remove d file | 157 //remove d file |
170 try | 158 try |
171 { | 159 { |
172 File.Delete(depFilePath); | 160 //File.Delete(depFilePath); |
binji
2012/10/29 18:08:59
Why is this removed?
Sam Clegg
2012/10/29 22:42:51
Done.
| |
173 } | 161 } |
174 finally | 162 finally |
175 { | 163 { |
176 | 164 |
177 } | 165 } |
178 } | 166 } |
179 | 167 |
180 } | 168 } |
181 catch (Exception) | 169 catch (Exception) |
182 { | 170 { |
183 Log.LogError("Failed to update " + readTrackerItem + " f or " + sourcePath); | 171 Log.LogError("Failed to update " + readTrackerItem + " f or " + sourcePath); |
184 } | 172 } |
185 } | 173 } |
186 } | 174 } |
187 } | 175 } |
188 | 176 |
189 private CanonicalTrackedOutputFiles OutputWriteTrackerLog(ITaskItem[] co mpiledSources) | 177 protected override CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem [] compiledSources) |
190 { | 178 { |
191 string path = Path.Combine(TlogDirectory, WriteTLogFilename); | 179 string path = Path.Combine(TlogDirectory, WriteTLogFilename); |
192 TaskItem item = new TaskItem(path); | 180 TaskItem item = new TaskItem(path); |
193 CanonicalTrackedOutputFiles trackedFiles = new CanonicalTrackedOutpu tFiles(new TaskItem[] { item }); | 181 CanonicalTrackedOutputFiles trackedFiles = new CanonicalTrackedOutpu tFiles(new TaskItem[] { item }); |
194 | 182 |
195 foreach (ITaskItem sourceItem in compiledSources) | 183 foreach (ITaskItem sourceItem in compiledSources) |
196 { | 184 { |
197 //remove this entry associated with compiled source which is abo ut to be recomputed | 185 //remove this entry associated with compiled source which is abo ut to be recomputed |
198 trackedFiles.RemoveEntriesForSource(sourceItem); | 186 trackedFiles.RemoveEntriesForSource(sourceItem); |
199 | 187 |
200 //add entry with updated information | 188 //add entry with updated information |
201 trackedFiles.AddComputedOutputForSourceRoot(Path.GetFullPath(sou rceItem.ItemSpec).ToUpperInvariant(), | 189 trackedFiles.AddComputedOutputForSourceRoot(Path.GetFullPath(sou rceItem.ItemSpec).ToUpperInvariant(), |
202 Path.GetFullPath(Get ObjectFile(sourceItem)).ToUpperInvariant()); | 190 Path.GetFullPath(Get ObjectFile(sourceItem)).ToUpperInvariant()); |
203 } | 191 } |
204 | 192 |
205 //output tlog | 193 //output tlog |
206 trackedFiles.SaveTlog(); | 194 trackedFiles.SaveTlog(); |
207 | 195 |
208 return trackedFiles; | 196 return trackedFiles; |
209 } | 197 } |
210 | 198 |
211 private void OutputCommandTrackerLog(ITaskItem[] compiledSources) | 199 protected override void OutputCommandTLog(ITaskItem[] compiledSources) |
212 { | 200 { |
213 IDictionary<string, string> commandLines = GenerateCommandLinesFromT log(); | 201 IDictionary<string, string> commandLines = GenerateCommandLinesFromT log(); |
214 | 202 |
215 // | 203 // |
216 if (compiledSources != null) | 204 if (compiledSources != null) |
217 { | 205 { |
218 foreach (ITaskItem source in compiledSources) | 206 foreach (ITaskItem source in compiledSources) |
219 { | 207 { |
220 string rmSource = FileTracker.FormatRootingMarker(source); | 208 string rmSource = FileTracker.FormatRootingMarker(source); |
221 commandLines[rmSource] = GenerateCommandLineFromProps(source ) + " " + source.GetMetadata("FullPath").ToUpperInvariant(); | 209 commandLines[rmSource] = GenerateCommandLineFromProps(source ) + " " + source.GetMetadata("FullPath").ToUpperInvariant(); |
(...skipping 19 matching lines...) Expand all Loading... | |
241 if (sourceFile != null) | 229 if (sourceFile != null) |
242 { | 230 { |
243 // Remove rtti items as they are not relevant in C compilation a nd will produce warnings | 231 // Remove rtti items as they are not relevant in C compilation a nd will produce warnings |
244 if (SourceIsC(sourceFile.ToString())) | 232 if (SourceIsC(sourceFile.ToString())) |
245 { | 233 { |
246 commandLine.Replace("-fno-rtti", ""); | 234 commandLine.Replace("-fno-rtti", ""); |
247 commandLine.Replace("-frtti", ""); | 235 commandLine.Replace("-frtti", ""); |
248 } | 236 } |
249 | 237 |
250 //build command line from components and add required switches | 238 //build command line from components and add required switches |
251 string props = m_XamlParser.Parse(sourceFile, fullOutputName); | 239 string props = xamlParser.Parse(sourceFile, fullOutputName); |
252 commandLine.Append(props); | 240 commandLine.Append(props); |
253 commandLine.Append(" -MD -c "); | 241 commandLine.Append(" -c "); |
254 } | 242 } |
255 | 243 |
256 return commandLine.ToString(); | 244 return commandLine.ToString(); |
257 } | 245 } |
258 | 246 |
259 protected ITaskItem[] MergeOutOfDateSources(ITaskItem[] outOfDateSources FromTracking, List<ITaskItem> outOfDateSourcesFromCommandLineChanges) | 247 protected ITaskItem[] MergeOutOfDateSources(ITaskItem[] outOfDateSources FromTracking, List<ITaskItem> outOfDateSourcesFromCommandLineChanges) |
260 { | 248 { |
261 List<ITaskItem> mergedSources = new List<ITaskItem>(outOfDateSources FromTracking); | 249 List<ITaskItem> mergedSources = new List<ITaskItem>(outOfDateSources FromTracking); |
262 | 250 |
263 foreach (ITaskItem item in outOfDateSourcesFromCommandLineChanges) | 251 foreach (ITaskItem item in outOfDateSourcesFromCommandLineChanges) |
264 { | 252 { |
265 if (!mergedSources.Contains(item)) | 253 if (!mergedSources.Contains(item)) |
266 { | 254 { |
267 mergedSources.Add(item); | 255 mergedSources.Add(item); |
268 } | 256 } |
269 } | 257 } |
270 | 258 |
271 return mergedSources.ToArray(); | 259 return mergedSources.ToArray(); |
272 } | 260 } |
273 | 261 |
274 protected bool ForcedRebuildRequired() | |
275 { | |
276 string tlogCommandPath = null; | |
277 | |
278 try | |
279 { | |
280 tlogCommandPath = this.TLogCommandFile.GetMetadata("FullPath"); | |
281 } | |
282 catch (Exception exception) | |
283 { | |
284 if (exception is InvalidOperationException || exception is NullR eferenceException) | |
285 return true; | |
286 else | |
287 throw; | |
288 } | |
289 | |
290 //if command tlog file does not exist then force rebuild is required | |
291 if (File.Exists(tlogCommandPath) == false) | |
292 { | |
293 return true; | |
294 } | |
295 else | |
296 { | |
297 return false; | |
298 } | |
299 } | |
300 | |
301 private int Compile(string pathToTool) | 262 private int Compile(string pathToTool) |
302 { | 263 { |
264 if (Platform.Equals("pnacl", StringComparison.OrdinalIgnoreCase)) | |
265 { | |
266 if (!GCCUtilities.FindPython()) | |
267 { | |
268 Log.LogError("PNaCl compilation requires python in your exec utable path."); | |
269 return -1; | |
270 } | |
271 } | |
272 | |
303 // If multiprocess complication is enabled (not the VS default) | 273 // If multiprocess complication is enabled (not the VS default) |
304 // and the number of processors to use is not 1, then use the | 274 // and the number of processors to use is not 1, then use the |
305 // compiler_wrapper python script to run multiple instances of | 275 // compiler_wrapper python script to run multiple instances of |
306 // gcc | 276 // gcc |
307 if (MultiProcessorCompilation && ProcessorNumber != 1) | 277 if (MultiProcessorCompilation && ProcessorNumber != 1) |
308 { | 278 { |
309 | 279 if (!GCCUtilities.FindPython()) |
310 string envvar = (string)Registry.GetValue("HKEY_CURRENT_USER\\En vironment", "PATH", ""); | |
311 List<string> pathList = new List<string>(envvar.Split(';')); | |
312 envvar = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\ CurrentControlSet\\Control\\Session Manager\\Environment", "PATH", ""); | |
313 pathList.AddRange(new List<string>(envvar.Split(';'))); | |
314 string pythonExe = null; | |
315 foreach (string path in pathList) | |
316 { | 280 { |
317 string testPath = Path.Combine(path, "python.bat"); | 281 MessageBox.Show("Multi-processor Compilation with NaCl requi res that python available in the visual stduio executable path.\n" + |
binji
2012/10/29 18:08:59
sp: visual studio
binji
2012/10/29 18:08:59
Also, "requires that python be available"
Sam Clegg
2012/10/29 22:42:51
Done.
Sam Clegg
2012/10/29 22:42:51
Done.
| |
318 if (File.Exists(testPath)) | |
319 { | |
320 pythonExe = testPath; | |
321 break; | |
322 } | |
323 testPath = Path.Combine(path, "python.exe"); | |
324 if (File.Exists(testPath)) | |
325 { | |
326 pythonExe = testPath; | |
327 break; | |
328 } | |
329 } | |
330 | |
331 if (pythonExe == null) | |
332 { | |
333 MessageBox.Show("Multi-processor Compilation with NaCl requi res that python available in the PATH.\n" + | |
334 "Please disable Multi-processor Compilation in the project properties or add python " + | 282 "Please disable Multi-processor Compilation in the project properties or add python " + |
335 "to the your PATH\n" + | 283 "to the your executable path.\n" + |
336 "Falling back to serial compilation.\n"); | 284 "Falling back to serial compilation.\n"); |
337 } | 285 } |
338 else | 286 else |
339 { | 287 { |
340 return CompileParallel(pathToTool, pythonExe); | 288 return CompileParallel(pathToTool); |
341 } | 289 } |
342 } | 290 } |
343 return CompileSerial(pathToTool); | 291 return CompileSerial(pathToTool); |
344 } | 292 } |
345 | 293 |
346 private int CompileSerial(string pathToTool) | 294 private int CompileSerial(string pathToTool) |
347 { | 295 { |
348 int returnCode = 0; | 296 int returnCode = 0; |
349 | |
350 foreach (ITaskItem sourceItem in CompileSourceList) | 297 foreach (ITaskItem sourceItem in CompileSourceList) |
351 { | 298 { |
352 try | 299 try |
353 { | 300 { |
354 string commandLine = GenerateCommandLineFromProps(sourceItem , true); | 301 string commandLine = GenerateCommandLineFromProps(sourceItem , true); |
355 commandLine += "\"" + GCCUtilities.ConvertPathWindowsToPosix (sourceItem.ToString()) + "\""; | 302 commandLine += "\"" + GCCUtilities.ConvertPathWindowsToPosix (sourceItem.ToString()) + "\""; |
356 | 303 |
357 if (OutputCommandLine) | 304 if (OutputCommandLine) |
358 { | 305 { |
359 string logMessage = pathToTool + " " + commandLine; | 306 string logMessage = pathToTool + " " + commandLine; |
360 Log.LogMessage(logMessage); | 307 Log.LogMessage(logMessage); |
361 } | 308 } |
362 else | 309 else |
363 { | 310 { |
364 base.Log.LogMessage(Path.GetFileName(sourceItem.ToString ())); | 311 base.Log.LogMessage(Path.GetFileName(sourceItem.ToString ())); |
365 } | 312 } |
366 | 313 |
367 | |
368 // compile | 314 // compile |
369 returnCode = base.ExecuteTool(pathToTool, commandLine, strin g.Empty); | 315 returnCode = base.ExecuteTool(pathToTool, commandLine, strin g.Empty); |
370 } | 316 } |
371 catch (Exception) | 317 catch (Exception) |
372 { | 318 { |
373 returnCode = base.ExitCode; | 319 returnCode = base.ExitCode; |
374 } | 320 } |
375 | 321 |
376 //abort if an error was encountered | 322 //abort if an error was encountered |
377 if (returnCode != 0) | 323 if (returnCode != 0) |
378 { | 324 { |
379 return returnCode; | 325 return returnCode; |
380 } | 326 } |
381 } | 327 } |
382 return returnCode; | 328 return returnCode; |
383 } | 329 } |
384 | 330 |
385 private int CompileParallel(string pathToTool, string pythonExe) | 331 private int CompileParallel(string pathToTool) |
386 { | 332 { |
387 int returnCode = 0; | 333 int returnCode = 0; |
388 | 334 |
389 // Compute sources that can be compiled together. | 335 // Compute sources that can be compiled together. |
390 Dictionary<string, List<ITaskItem>> srcGroups = | 336 Dictionary<string, List<ITaskItem>> srcGroups = |
391 new Dictionary<string, List<ITaskItem>>(); | 337 new Dictionary<string, List<ITaskItem>>(); |
392 | 338 |
393 foreach (ITaskItem sourceItem in CompileSourceList) | 339 foreach (ITaskItem sourceItem in CompileSourceList) |
394 { | 340 { |
395 string commandLine = GenerateCommandLineFromProps(sourceItem); | 341 string commandLine = GenerateCommandLineFromProps(sourceItem); |
(...skipping 18 matching lines...) Expand all Loading... | |
414 | 360 |
415 foreach (ITaskItem sourceItem in sources) | 361 foreach (ITaskItem sourceItem in sources) |
416 { | 362 { |
417 string src = GCCUtilities.ConvertPathWindowsToPosix(sourceIt em.ToString()); | 363 string src = GCCUtilities.ConvertPathWindowsToPosix(sourceIt em.ToString()); |
418 cmd += " \"" + src + "\""; | 364 cmd += " \"" + src + "\""; |
419 } | 365 } |
420 | 366 |
421 try | 367 try |
422 { | 368 { |
423 // compile this group of sources | 369 // compile this group of sources |
424 returnCode = base.ExecuteTool(pythonExe, cmd, "\"" + pythonS cript + "\""); | 370 returnCode = base.ExecuteTool("python.exe", cmd, "\"" + pyth onScript + "\""); |
binji
2012/10/29 18:08:59
what if we found python.bat instead?
Sam Clegg
2012/10/29 22:42:51
Done.
| |
425 } | 371 } |
426 catch (Exception e) | 372 catch (Exception e) |
427 { | 373 { |
428 Log.LogMessage("compiler exception: {0}", e); | 374 Log.LogMessage("compiler exception: {0}", e); |
429 returnCode = base.ExitCode; | 375 returnCode = base.ExitCode; |
430 } | 376 } |
431 | 377 |
432 //abort if an error was encountered | 378 //abort if an error was encountered |
433 if (returnCode != 0) | 379 if (returnCode != 0) |
434 break; | 380 break; |
(...skipping 17 matching lines...) Expand all Loading... | |
452 { | 398 { |
453 returnCode = Compile(pathToTool); | 399 returnCode = Compile(pathToTool); |
454 } | 400 } |
455 finally | 401 finally |
456 { | 402 { |
457 | 403 |
458 } | 404 } |
459 return returnCode; | 405 return returnCode; |
460 } | 406 } |
461 | 407 |
462 protected override bool SkipTaskExecution() | |
463 { | |
464 return this.skippedExecution; | |
465 } | |
466 | |
467 protected void CalcSourcesToCompile() | 408 protected void CalcSourcesToCompile() |
468 { | 409 { |
469 if (this.TrackFileAccess || this.MinimalRebuildFromTracking) | |
470 { | |
471 this.SetTrackerLogPaths(); | |
472 } | |
473 | |
474 //check if full recompile is required otherwise perform incremental | 410 //check if full recompile is required otherwise perform incremental |
475 if (this.ForcedRebuildRequired() || this.MinimalRebuildFromTracking == false) | 411 if (this.ForcedRebuildRequired() || this.MinimalRebuildFromTracking == false) |
476 { | 412 { |
477 this.CompileSourceList = this.Sources; | 413 this.CompileSourceList = this.Sources; |
478 if (this.CompileSourceList == null || this.CompileSourceList.Len gth == 0) | 414 return; |
479 { | |
480 this.SkippedExecution = true; | |
481 } | |
482 } | 415 } |
483 else | 416 |
417 //retrieve list of sources out of date due to command line changes | |
418 List<ITaskItem> outOfDateSourcesFromCommandLineChanges = this.GetOut OfDateSourcesFromCommandLineChanges(); | |
binji
2012/10/29 18:08:59
nit: wrap these lines at 100
Sam Clegg
2012/10/29 22:42:51
Done.
| |
419 | |
420 //retrieve sources out of date due to tracking | |
421 CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTracke dOutputFiles(this, this.TLogWriteFiles); | |
422 this.TrackedInputFiles = new CanonicalTrackedInputFiles(this, this.T LogReadFiles, this.Sources, this.ExcludedInputPaths, trackedOutputFiles, true, f alse); | |
binji
2012/10/29 18:08:59
nit: specify what true/false are here?
| |
423 ITaskItem[] outOfDateSourcesFromTracking = this.TrackedInputFiles.Co mputeSourcesNeedingCompilation(); | |
424 | |
425 //merge out of date lists | |
426 this.CompileSourceList = this.MergeOutOfDateSources(outOfDateSources FromTracking, outOfDateSourcesFromCommandLineChanges); | |
427 | |
428 if (this.CompileSourceList.Length == 0) | |
484 { | 429 { |
485 //retrieve list of sources out of date due to command line chang es | 430 this.SkippedExecution = true; |
486 List<ITaskItem> outOfDateSourcesFromCommandLineChanges = this.Ge tOutOfDateSourcesFromCommandLineChanges(); | 431 return; |
432 } | |
487 | 433 |
488 //retrieve sources out of date due to tracking | 434 //remove sources to compile from tracked file list |
489 CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTr ackedOutputFiles(this, this.TLogWriteFiles); | 435 this.TrackedInputFiles.RemoveEntriesForSource(this.CompileSourceList ); |
490 this.TrackedInputFiles = new CanonicalTrackedInputFiles(this, th is.TLogReadFiles, this.Sources, this.ExcludedInputPaths, trackedOutputFiles, tru e, false); | 436 trackedOutputFiles.RemoveEntriesForSource(this.CompileSourceList); |
491 ITaskItem[] outOfDateSourcesFromTracking = this.TrackedInputFile s.ComputeSourcesNeedingCompilation(); | 437 this.TrackedInputFiles.SaveTlog(); |
492 | 438 trackedOutputFiles.SaveTlog(); |
binji
2012/10/29 18:08:59
not necessary to set SkippedExecution to false any
Sam Clegg
2012/10/29 22:42:51
I set it to false at the start of each compile in
| |
493 //merge out of date lists | |
494 this.CompileSourceList = this.MergeOutOfDateSources(outOfDateSou rcesFromTracking, outOfDateSourcesFromCommandLineChanges); | |
495 | |
496 if (this.CompileSourceList.Length == 0) | |
497 { | |
498 this.SkippedExecution = true; | |
499 } | |
500 else | |
501 { | |
502 //remove sources to compile from tracked file list | |
503 this.TrackedInputFiles.RemoveEntriesForSource(this.CompileSo urceList); | |
504 trackedOutputFiles.RemoveEntriesForSource(this.CompileSource List); | |
505 this.TrackedInputFiles.SaveTlog(); | |
506 trackedOutputFiles.SaveTlog(); | |
507 | |
508 this.SkippedExecution = false; | |
509 } | |
510 } | |
511 } | 439 } |
512 | 440 |
513 protected bool SourceIsC(string sourceFilename) | 441 protected bool SourceIsC(string sourceFilename) |
514 { | 442 { |
515 string fileExt = Path.GetExtension(sourceFilename.ToString()); | 443 string fileExt = Path.GetExtension(sourceFilename.ToString()); |
516 | 444 |
517 if (fileExt == ".c") | 445 if (fileExt == ".c") |
518 return true; | 446 return true; |
519 else | 447 else |
520 return false; | 448 return false; |
521 } | 449 } |
522 | 450 |
523 public override bool Execute() | 451 public override bool Execute() |
524 { | 452 { |
525 bool returnResult = false; | 453 bool returnResult = false; |
526 | 454 |
527 try | 455 try |
528 { | 456 { |
529 m_XamlParser = new XamlParser(PropertiesFile); | 457 xamlParser = new XamlParser(PropertiesFile); |
530 m_toolname = Path.GetFileNameWithoutExtension(ToolName); | 458 if (!Setup()) |
531 ValidateParameters(); | 459 return false; |
532 CalcSourcesToCompile(); | 460 CalcSourcesToCompile(); |
533 | |
534 returnResult = base.Execute(); | 461 returnResult = base.Execute(); |
535 | |
536 // Update tracker log files if execution occurred | |
537 //if (this.skippedExecution == false) | |
538 { | |
539 CanonicalTrackedOutputFiles outputs = OutputWriteTrackerLog( CompileSourceList); | |
540 ConstructReadTLog(CompileSourceList, outputs); | |
541 OutputCommandTrackerLog(CompileSourceList); | |
542 } | |
543 } | 462 } |
544 finally | 463 finally |
545 { | 464 { |
546 | 465 |
547 } | 466 } |
548 | 467 |
549 return returnResult; | 468 return returnResult; |
550 } | 469 } |
551 | 470 |
552 protected List<ITaskItem> GetOutOfDateSourcesFromCommandLineChanges() | 471 protected List<ITaskItem> GetOutOfDateSourcesFromCommandLineChanges() |
(...skipping 21 matching lines...) Expand all Loading... | |
574 } | 493 } |
575 } | 494 } |
576 else | 495 else |
577 { | 496 { |
578 outOfDateSources.Add(sourceItem); | 497 outOfDateSources.Add(sourceItem); |
579 } | 498 } |
580 } | 499 } |
581 return outOfDateSources; | 500 return outOfDateSources; |
582 } | 501 } |
583 | 502 |
584 protected virtual void SetTrackerLogPaths() | |
585 { | |
586 if (this.TLogCommandFile == null) | |
587 { | |
588 string commandFile = Path.Combine(this.TlogDirectory, this.Comma ndTLogFilename); | |
589 this.TLogCommandFile = new TaskItem(commandFile); | |
590 } | |
591 | |
592 if (this.TLogReadFiles == null) | |
593 { | |
594 this.TLogReadFiles = new ITaskItem[this.ReadTLogFilenames.Length ]; | |
595 for (int n = 0; n < this.ReadTLogFilenames.Length; n++) | |
596 { | |
597 string readFile = Path.Combine(this.TlogDirectory, this.Read TLogFilenames[n]); | |
598 this.TLogReadFiles[n] = new TaskItem(readFile); | |
599 } | |
600 } | |
601 | |
602 if (this.TLogWriteFiles == null) | |
603 { | |
604 this.TLogWriteFiles = new ITaskItem[1]; | |
605 string writeFile = Path.Combine(this.TlogDirectory, this.WriteTL ogFilename); | |
606 this.TLogWriteFiles[0] = new TaskItem(writeFile); | |
607 } | |
608 } | |
609 | |
610 | |
611 //props | |
612 protected string CommandTLogFilename | |
613 { | |
614 get | |
615 { | |
616 return m_toolname + ".compile.command.1.tlog"; | |
617 } | |
618 } | |
619 | |
620 protected string[] ReadTLogFilenames | |
621 { | |
622 get | |
623 { | |
624 return new string[] { m_toolname + ".compile.read.1.tlog" }; | |
625 } | |
626 } | |
627 | |
628 [Output] | |
629 public bool SkippedExecution | |
630 { | |
631 get | |
632 { | |
633 return this.skippedExecution; | |
634 } | |
635 set | |
636 { | |
637 this.skippedExecution = value; | |
638 } | |
639 } | |
640 | |
641 public ITaskItem TLogCommandFile | |
642 { | |
643 get | |
644 { | |
645 return this.tlogCommandFile; | |
646 } | |
647 set | |
648 { | |
649 this.tlogCommandFile = value; | |
650 } | |
651 } | |
652 | |
653 protected string TlogDirectory | |
654 { | |
655 get | |
656 { | |
657 if (this.TrackerLogDirectory != null) | |
658 { | |
659 return this.TrackerLogDirectory; | |
660 } | |
661 return string.Empty; | |
662 } | |
663 } | |
664 | |
665 public bool MinimalRebuildFromTracking | |
666 { | |
667 get | |
668 { | |
669 return this.minimalRebuildFromTracking; | |
670 } | |
671 set | |
672 { | |
673 this.minimalRebuildFromTracking = value; | |
674 } | |
675 } | |
676 | |
677 | |
678 public ITaskItem[] TLogReadFiles | |
679 { | |
680 get | |
681 { | |
682 return this.tlogReadFiles; | |
683 } | |
684 set | |
685 { | |
686 this.tlogReadFiles = value; | |
687 } | |
688 } | |
689 | |
690 public ITaskItem[] ExcludedInputPaths | |
691 { | |
692 get | |
693 { | |
694 return this.excludedInputPaths; | |
695 } | |
696 set | |
697 { | |
698 this.excludedInputPaths = value; | |
699 } | |
700 } | |
701 | |
702 | |
703 public ITaskItem[] TLogWriteFiles | |
704 { | |
705 get | |
706 { | |
707 return this.tlogWriteFiles; | |
708 } | |
709 set | |
710 { | |
711 this.tlogWriteFiles = value; | |
712 } | |
713 } | |
714 | |
715 protected string WriteTLogFilename | |
716 { | |
717 get | |
718 { | |
719 return m_toolname + ".compile.write.1.tlog"; | |
720 } | |
721 } | |
722 | |
723 public bool TrackFileAccess | |
724 { | |
725 get | |
726 { | |
727 return this.trackFileAccess; | |
728 } | |
729 set | |
730 { | |
731 this.trackFileAccess = value; | |
732 } | |
733 } | |
734 | |
735 protected CanonicalTrackedInputFiles TrackedInputFiles | |
736 { | |
737 get | |
738 { | |
739 return this.trackedInputFiles; | |
740 } | |
741 set | |
742 { | |
743 this.trackedInputFiles = value; | |
744 } | |
745 } | |
746 | |
747 [Output] | 503 [Output] |
748 public ITaskItem[] CompileSourceList | 504 public ITaskItem[] CompileSourceList |
749 { | 505 { |
750 get | 506 get |
751 { | 507 { |
752 return this.compileSourceList; | 508 return this.compileSourceList; |
753 } | 509 } |
754 set | 510 set |
755 { | 511 { |
756 this.compileSourceList = value; | 512 this.compileSourceList = value; |
757 } | 513 } |
758 } | 514 } |
759 | 515 |
760 protected override string ToolName | 516 protected override string ToolName |
761 { | 517 { |
762 get | 518 get |
763 { | 519 { |
764 return NaCLCompilerPath; | 520 return NaCLCompilerPath; |
765 } | 521 } |
766 } | 522 } |
767 | 523 |
768 protected override Encoding ResponseFileEncoding | |
769 { | |
770 get | |
771 { | |
772 return Encoding.ASCII; | |
773 } | |
774 } | |
775 } | 524 } |
776 } | 525 } |
OLD | NEW |