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

Side by Side Diff: visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClCompile.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
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; 21 private XamlParser 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; } 22 public bool BuildingInIDE { get; set; }
30 private string m_toolname;
31 private bool trackFileAccess;
32 private bool minimalRebuildFromTracking;
33 private string pathToLog;
34 23
35 [Required] 24 [Required]
36 public string PropertiesFile { get; set; } 25 public string PropertiesFile { get; set; }
37 26
38 [Required] 27 [Required]
39 public ITaskItem[] Sources { get; set; }
40
41 [Required]
42 public string NaCLCompilerPath { get; set; } 28 public string NaCLCompilerPath { get; set; }
43 29
44 [Required] 30 [Required]
45 public bool OutputCommandLine { get; set; } 31 public bool OutputCommandLine { get; set; }
46 32
33 [Required]
34 public string Platform { get; set; }
35
47 public int ProcessorNumber { get; set; } 36 public int ProcessorNumber { get; set; }
48 37
49 public bool MultiProcessorCompilation { get; set; } 38 public bool MultiProcessorCompilation { get; set; }
50 39
51 [Required] 40 [Obsolete]
52 public string TrackerLogDirectory { get; set; }
53
54 protected override StringDictionary EnvironmentOverride 41 protected override StringDictionary EnvironmentOverride
55 { 42 {
56 get { 43 get {
57 string show = OutputCommandLine ? "1" : "0"; 44 string show = OutputCommandLine ? "1" : "0";
58 string cores = Convert.ToString(ProcessorNumber); 45 string cores = Convert.ToString(ProcessorNumber);
59 return new StringDictionary() { 46 return new StringDictionary() {
60 {"NACL_GCC_CORES", cores}, 47 {"NACL_GCC_CORES", cores},
61 {"NACL_GCC_SHOW_COMMANDS", show } 48 {"NACL_GCC_SHOW_COMMANDS", show }
62 }; 49 };
63 } 50 }
64 } 51 }
65 52
66 protected override string GenerateFullPathToTool() { return ToolName; } 53 protected override string GenerateFullPathToTool()
54 {
55 return ToolName;
56 }
67 57
68 public NaClCompile() 58 public NaClCompile()
69 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources ", Assembly.GetExecutingAssembly())) 59 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources ", Assembly.GetExecutingAssembly()))
70 { 60 {
71 this.pathToLog = string.Empty;
72 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning" , "LC_CTYPE=C" }; 61 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning" , "LC_CTYPE=C" };
73 } 62 }
74 63
75 protected IDictionary<string, string> GenerateCommandLinesFromTlog() 64 protected IDictionary<string, string> GenerateCommandLinesFromTlog()
76 { 65 {
77 IDictionary<string, string> cmdLineDictionary = new Dictionary<strin g, string>(StringComparer.OrdinalIgnoreCase); 66 IDictionary<string, string> cmdLineDictionary = new Dictionary<strin g, string>(StringComparer.OrdinalIgnoreCase);
78 string tlogFilename = this.TLogCommandFile.GetMetadata("FullPath"); 67 string tlogFilename = this.TLogCommandFile.GetMetadata("FullPath");
79 if (File.Exists(tlogFilename)) 68 if (File.Exists(tlogFilename))
80 { 69 {
81 using (StreamReader reader = File.OpenText(tlogFilename)) 70 using (StreamReader reader = File.OpenText(tlogFilename))
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // the objectfile is created as <ObjectFileName>/<basename>.obj. He re 104 // the objectfile is created as <ObjectFileName>/<basename>.obj. He re
116 // we mimic this behaviour. 105 // we mimic this behaviour.
117 if ((File.GetAttributes(objectFilePath) & FileAttributes.Directory) != 0) 106 if ((File.GetAttributes(objectFilePath) & FileAttributes.Directory) != 0)
118 { 107 {
119 objectFilePath = Path.Combine(objectFilePath, Path.GetFileName(s ource.ItemSpec)); 108 objectFilePath = Path.Combine(objectFilePath, Path.GetFileName(s ource.ItemSpec));
120 objectFilePath = Path.ChangeExtension(objectFilePath, ".obj"); 109 objectFilePath = Path.ChangeExtension(objectFilePath, ".obj");
121 } 110 }
122 return objectFilePath; 111 return objectFilePath;
123 } 112 }
124 113
125 private void ConstructReadTLog(ITaskItem[] compiledSources, CanonicalTra ckedOutputFiles outputs) 114 protected override void OutputReadTLog(ITaskItem[] compiledSources, Cano nicalTrackedOutputFiles outputs)
126 { 115 {
127 string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilena mes[0]); 116 string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilena mes[0]);
128 117
129 //save tlog for sources not compiled during this execution 118 //save tlog for sources not compiled during this execution
130 TaskItem readTrackerItem = new TaskItem(trackerPath); 119 TaskItem readTrackerItem = new TaskItem(trackerPath);
131 CanonicalTrackedInputFiles files = new CanonicalTrackedInputFiles(ne w TaskItem[] { readTrackerItem }, Sources, outputs, false, false); 120 CanonicalTrackedInputFiles files = new CanonicalTrackedInputFiles(ne w TaskItem[] { readTrackerItem }, Sources, outputs, false, false);
132 files.RemoveEntriesForSource(compiledSources); 121 files.RemoveEntriesForSource(compiledSources);
133 files.SaveTlog(); 122 files.SaveTlog();
134 123
135 //add tlog information for compiled sources 124 //add tlog information for compiled sources
(...skipping 26 matching lines...) Expand all
162 { 151 {
163 Log.LogMessage(MessageImportance.High, "File " + sourcePath + " is missing dependency " + filename); 152 Log.LogMessage(MessageImportance.High, "File " + sourcePath + " is missing dependency " + filename);
164 } 153 }
165 154
166 writer.WriteLine(filename); 155 writer.WriteLine(filename);
167 } 156 }
168 157
169 //remove d file 158 //remove d file
170 try 159 try
171 { 160 {
172 File.Delete(depFilePath); 161 //File.Delete(depFilePath);
173 } 162 }
174 finally 163 finally
175 { 164 {
176 165
177 } 166 }
178 } 167 }
179 168
180 } 169 }
181 catch (Exception) 170 catch (Exception)
182 { 171 {
183 Log.LogError("Failed to update " + readTrackerItem + " f or " + sourcePath); 172 Log.LogError("Failed to update " + readTrackerItem + " f or " + sourcePath);
184 } 173 }
185 } 174 }
186 } 175 }
187 } 176 }
188 177
189 private CanonicalTrackedOutputFiles OutputWriteTrackerLog(ITaskItem[] co mpiledSources) 178 protected override CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem [] compiledSources)
190 { 179 {
191 string path = Path.Combine(TlogDirectory, WriteTLogFilename); 180 string path = Path.Combine(TlogDirectory, WriteTLogFilename);
192 TaskItem item = new TaskItem(path); 181 TaskItem item = new TaskItem(path);
193 CanonicalTrackedOutputFiles trackedFiles = new CanonicalTrackedOutpu tFiles(new TaskItem[] { item }); 182 CanonicalTrackedOutputFiles trackedFiles = new CanonicalTrackedOutpu tFiles(new TaskItem[] { item });
194 183
195 foreach (ITaskItem sourceItem in compiledSources) 184 foreach (ITaskItem sourceItem in compiledSources)
196 { 185 {
197 //remove this entry associated with compiled source which is abo ut to be recomputed 186 //remove this entry associated with compiled source which is abo ut to be recomputed
198 trackedFiles.RemoveEntriesForSource(sourceItem); 187 trackedFiles.RemoveEntriesForSource(sourceItem);
199 188
200 //add entry with updated information 189 //add entry with updated information
201 trackedFiles.AddComputedOutputForSourceRoot(Path.GetFullPath(sou rceItem.ItemSpec).ToUpperInvariant(), 190 trackedFiles.AddComputedOutputForSourceRoot(Path.GetFullPath(sou rceItem.ItemSpec).ToUpperInvariant(),
202 Path.GetFullPath(Get ObjectFile(sourceItem)).ToUpperInvariant()); 191 Path.GetFullPath(Get ObjectFile(sourceItem)).ToUpperInvariant());
203 } 192 }
204 193
205 //output tlog 194 //output tlog
206 trackedFiles.SaveTlog(); 195 trackedFiles.SaveTlog();
207 196
208 return trackedFiles; 197 return trackedFiles;
209 } 198 }
210 199
211 private void OutputCommandTrackerLog(ITaskItem[] compiledSources) 200 protected override void OutputCommandTLog(ITaskItem[] compiledSources)
212 { 201 {
213 IDictionary<string, string> commandLines = GenerateCommandLinesFromT log(); 202 IDictionary<string, string> commandLines = GenerateCommandLinesFromT log();
214 203
215 // 204 //
216 if (compiledSources != null) 205 if (compiledSources != null)
217 { 206 {
218 foreach (ITaskItem source in compiledSources) 207 foreach (ITaskItem source in compiledSources)
219 { 208 {
220 string rmSource = FileTracker.FormatRootingMarker(source); 209 string rmSource = FileTracker.FormatRootingMarker(source);
221 commandLines[rmSource] = GenerateCommandLineFromProps(source ) + " " + source.GetMetadata("FullPath").ToUpperInvariant(); 210 commandLines[rmSource] = GenerateCommandLineFromProps(source ) + " " + source.GetMetadata("FullPath").ToUpperInvariant();
(...skipping 19 matching lines...) Expand all
241 if (sourceFile != null) 230 if (sourceFile != null)
242 { 231 {
243 // Remove rtti items as they are not relevant in C compilation a nd will produce warnings 232 // Remove rtti items as they are not relevant in C compilation a nd will produce warnings
244 if (SourceIsC(sourceFile.ToString())) 233 if (SourceIsC(sourceFile.ToString()))
245 { 234 {
246 commandLine.Replace("-fno-rtti", ""); 235 commandLine.Replace("-fno-rtti", "");
247 commandLine.Replace("-frtti", ""); 236 commandLine.Replace("-frtti", "");
248 } 237 }
249 238
250 //build command line from components and add required switches 239 //build command line from components and add required switches
251 string props = m_XamlParser.Parse(sourceFile, fullOutputName); 240 string props = xamlParser.Parse(sourceFile, fullOutputName);
252 commandLine.Append(props); 241 commandLine.Append(props);
253 commandLine.Append(" -MD -c "); 242 commandLine.Append(" -c ");
254 } 243 }
255 244
256 return commandLine.ToString(); 245 return commandLine.ToString();
257 } 246 }
258 247
259 protected ITaskItem[] MergeOutOfDateSources(ITaskItem[] outOfDateSources FromTracking, List<ITaskItem> outOfDateSourcesFromCommandLineChanges) 248 protected ITaskItem[] MergeOutOfDateSources(ITaskItem[] outOfDateSources FromTracking, List<ITaskItem> outOfDateSourcesFromCommandLineChanges)
260 { 249 {
261 List<ITaskItem> mergedSources = new List<ITaskItem>(outOfDateSources FromTracking); 250 List<ITaskItem> mergedSources = new List<ITaskItem>(outOfDateSources FromTracking);
262 251
263 foreach (ITaskItem item in outOfDateSourcesFromCommandLineChanges) 252 foreach (ITaskItem item in outOfDateSourcesFromCommandLineChanges)
264 { 253 {
265 if (!mergedSources.Contains(item)) 254 if (!mergedSources.Contains(item))
266 { 255 {
267 mergedSources.Add(item); 256 mergedSources.Add(item);
268 } 257 }
269 } 258 }
270 259
271 return mergedSources.ToArray(); 260 return mergedSources.ToArray();
272 } 261 }
273 262
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) 263 private int Compile(string pathToTool)
302 { 264 {
265 if (Platform.Equals("pnacl", StringComparison.OrdinalIgnoreCase))
266 {
267 if (!GCCUtilities.FindPython())
268 {
269 Log.LogError("PNaCl compilation requires python in your exec utable path.");
270 return -1;
271 }
272 }
273
303 // If multiprocess complication is enabled (not the VS default) 274 // If multiprocess complication is enabled (not the VS default)
304 // and the number of processors to use is not 1, then use the 275 // and the number of processors to use is not 1, then use the
305 // compiler_wrapper python script to run multiple instances of 276 // compiler_wrapper python script to run multiple instances of
306 // gcc 277 // gcc
307 if (MultiProcessorCompilation && ProcessorNumber != 1) 278 if (MultiProcessorCompilation && ProcessorNumber != 1)
308 { 279 {
309 280 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 { 281 {
317 string testPath = Path.Combine(path, "python.bat"); 282 MessageBox.Show("Multi-processor Compilation with NaCl requi res that python available in the visual stduio executable path.\n" +
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 " + 283 "Please disable Multi-processor Compilation in the project properties or add python " +
335 "to the your PATH\n" + 284 "to the your executable path.\n" +
336 "Falling back to serial compilation.\n"); 285 "Falling back to serial compilation.\n");
337 } 286 }
338 else 287 else
339 { 288 {
340 return CompileParallel(pathToTool, pythonExe); 289 return CompileParallel(pathToTool);
341 } 290 }
342 } 291 }
343 return CompileSerial(pathToTool); 292 return CompileSerial(pathToTool);
344 } 293 }
345 294
346 private int CompileSerial(string pathToTool) 295 private int CompileSerial(string pathToTool)
347 { 296 {
348 int returnCode = 0; 297 int returnCode = 0;
349
350 foreach (ITaskItem sourceItem in CompileSourceList) 298 foreach (ITaskItem sourceItem in CompileSourceList)
351 { 299 {
352 try 300 try
353 { 301 {
354 string commandLine = GenerateCommandLineFromProps(sourceItem , true); 302 string commandLine = GenerateCommandLineFromProps(sourceItem , true);
355 commandLine += "\"" + GCCUtilities.ConvertPathWindowsToPosix (sourceItem.ToString()) + "\""; 303 commandLine += "\"" + GCCUtilities.ConvertPathWindowsToPosix (sourceItem.ToString()) + "\"";
356 304
357 if (OutputCommandLine) 305 if (OutputCommandLine)
358 { 306 {
359 string logMessage = pathToTool + " " + commandLine; 307 string logMessage = pathToTool + " " + commandLine;
360 Log.LogMessage(logMessage); 308 Log.LogMessage(logMessage);
361 } 309 }
362 else 310 else
363 { 311 {
364 base.Log.LogMessage(Path.GetFileName(sourceItem.ToString ())); 312 base.Log.LogMessage(Path.GetFileName(sourceItem.ToString ()));
365 } 313 }
366 314
367
368 // compile 315 // compile
369 returnCode = base.ExecuteTool(pathToTool, commandLine, strin g.Empty); 316 returnCode = base.ExecuteTool(pathToTool, commandLine, strin g.Empty);
370 } 317 }
371 catch (Exception) 318 catch (Exception)
372 { 319 {
373 returnCode = base.ExitCode; 320 returnCode = base.ExitCode;
374 } 321 }
375 322
376 //abort if an error was encountered 323 //abort if an error was encountered
377 if (returnCode != 0) 324 if (returnCode != 0)
378 { 325 {
379 return returnCode; 326 return returnCode;
380 } 327 }
381 } 328 }
382 return returnCode; 329 return returnCode;
383 } 330 }
384 331
385 private int CompileParallel(string pathToTool, string pythonExe) 332 private int CompileParallel(string pathToTool)
386 { 333 {
387 int returnCode = 0; 334 int returnCode = 0;
388 335
389 // Compute sources that can be compiled together. 336 // Compute sources that can be compiled together.
390 Dictionary<string, List<ITaskItem>> srcGroups = 337 Dictionary<string, List<ITaskItem>> srcGroups =
391 new Dictionary<string, List<ITaskItem>>(); 338 new Dictionary<string, List<ITaskItem>>();
392 339
393 foreach (ITaskItem sourceItem in CompileSourceList) 340 foreach (ITaskItem sourceItem in CompileSourceList)
394 { 341 {
395 string commandLine = GenerateCommandLineFromProps(sourceItem); 342 string commandLine = GenerateCommandLineFromProps(sourceItem);
(...skipping 18 matching lines...) Expand all
414 361
415 foreach (ITaskItem sourceItem in sources) 362 foreach (ITaskItem sourceItem in sources)
416 { 363 {
417 string src = GCCUtilities.ConvertPathWindowsToPosix(sourceIt em.ToString()); 364 string src = GCCUtilities.ConvertPathWindowsToPosix(sourceIt em.ToString());
418 cmd += " \"" + src + "\""; 365 cmd += " \"" + src + "\"";
419 } 366 }
420 367
421 try 368 try
422 { 369 {
423 // compile this group of sources 370 // compile this group of sources
424 returnCode = base.ExecuteTool(pythonExe, cmd, "\"" + pythonS cript + "\""); 371 returnCode = base.ExecuteTool("python.exe", cmd, "\"" + pyth onScript + "\"");
425 } 372 }
426 catch (Exception e) 373 catch (Exception e)
427 { 374 {
428 Log.LogMessage("compiler exception: {0}", e); 375 Log.LogMessage("compiler exception: {0}", e);
429 returnCode = base.ExitCode; 376 returnCode = base.ExitCode;
430 } 377 }
431 378
432 //abort if an error was encountered 379 //abort if an error was encountered
433 if (returnCode != 0) 380 if (returnCode != 0)
434 break; 381 break;
(...skipping 17 matching lines...) Expand all
452 { 399 {
453 returnCode = Compile(pathToTool); 400 returnCode = Compile(pathToTool);
454 } 401 }
455 finally 402 finally
456 { 403 {
457 404
458 } 405 }
459 return returnCode; 406 return returnCode;
460 } 407 }
461 408
462 protected override bool SkipTaskExecution()
463 {
464 return this.skippedExecution;
465 }
466
467 protected void CalcSourcesToCompile() 409 protected void CalcSourcesToCompile()
468 { 410 {
469 if (this.TrackFileAccess || this.MinimalRebuildFromTracking)
470 {
471 this.SetTrackerLogPaths();
472 }
473
474 //check if full recompile is required otherwise perform incremental 411 //check if full recompile is required otherwise perform incremental
475 if (this.ForcedRebuildRequired() || this.MinimalRebuildFromTracking == false) 412 if (this.ForcedRebuildRequired() || this.MinimalRebuildFromTracking == false)
476 { 413 {
477 this.CompileSourceList = this.Sources; 414 this.CompileSourceList = this.Sources;
478 if (this.CompileSourceList == null || this.CompileSourceList.Len gth == 0) 415 return;
479 {
480 this.SkippedExecution = true;
481 }
482 } 416 }
483 else 417
418 //retrieve list of sources out of date due to command line changes
419 List<ITaskItem> outOfDateSourcesFromCommandLineChanges = this.GetOut OfDateSourcesFromCommandLineChanges();
420
421 //retrieve sources out of date due to tracking
422 CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTracke dOutputFiles(this, this.TLogWriteFiles);
423 this.TrackedInputFiles = new CanonicalTrackedInputFiles(this, this.T LogReadFiles, this.Sources, this.ExcludedInputPaths, trackedOutputFiles, true, f alse);
424 ITaskItem[] outOfDateSourcesFromTracking = this.TrackedInputFiles.Co mputeSourcesNeedingCompilation();
425
426 //merge out of date lists
427 this.CompileSourceList = this.MergeOutOfDateSources(outOfDateSources FromTracking, outOfDateSourcesFromCommandLineChanges);
428
429 if (this.CompileSourceList.Length == 0)
484 { 430 {
485 //retrieve list of sources out of date due to command line chang es 431 this.SkippedExecution = true;
486 List<ITaskItem> outOfDateSourcesFromCommandLineChanges = this.Ge tOutOfDateSourcesFromCommandLineChanges(); 432 return;
433 }
487 434
488 //retrieve sources out of date due to tracking 435 //remove sources to compile from tracked file list
489 CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTr ackedOutputFiles(this, this.TLogWriteFiles); 436 this.TrackedInputFiles.RemoveEntriesForSource(this.CompileSourceList );
490 this.TrackedInputFiles = new CanonicalTrackedInputFiles(this, th is.TLogReadFiles, this.Sources, this.ExcludedInputPaths, trackedOutputFiles, tru e, false); 437 trackedOutputFiles.RemoveEntriesForSource(this.CompileSourceList);
491 ITaskItem[] outOfDateSourcesFromTracking = this.TrackedInputFile s.ComputeSourcesNeedingCompilation(); 438 this.TrackedInputFiles.SaveTlog();
492 439 trackedOutputFiles.SaveTlog();
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 } 440 }
512 441
513 protected bool SourceIsC(string sourceFilename) 442 protected bool SourceIsC(string sourceFilename)
514 { 443 {
515 string fileExt = Path.GetExtension(sourceFilename.ToString()); 444 string fileExt = Path.GetExtension(sourceFilename.ToString());
516 445
517 if (fileExt == ".c") 446 if (fileExt == ".c")
518 return true; 447 return true;
519 else 448 else
520 return false; 449 return false;
521 } 450 }
522 451
523 public override bool Execute() 452 public override bool Execute()
524 { 453 {
525 bool returnResult = false; 454 bool returnResult = false;
526 455
527 try 456 try
528 { 457 {
529 m_XamlParser = new XamlParser(PropertiesFile); 458 xamlParser = new XamlParser(PropertiesFile);
530 m_toolname = Path.GetFileNameWithoutExtension(ToolName); 459 if (!Setup())
531 ValidateParameters(); 460 return false;
532 CalcSourcesToCompile(); 461 CalcSourcesToCompile();
533
534 returnResult = base.Execute(); 462 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 } 463 }
544 finally 464 finally
545 { 465 {
546 466
547 } 467 }
548 468
549 return returnResult; 469 return returnResult;
550 } 470 }
551 471
552 protected List<ITaskItem> GetOutOfDateSourcesFromCommandLineChanges() 472 protected List<ITaskItem> GetOutOfDateSourcesFromCommandLineChanges()
(...skipping 21 matching lines...) Expand all
574 } 494 }
575 } 495 }
576 else 496 else
577 { 497 {
578 outOfDateSources.Add(sourceItem); 498 outOfDateSources.Add(sourceItem);
579 } 499 }
580 } 500 }
581 return outOfDateSources; 501 return outOfDateSources;
582 } 502 }
583 503
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] 504 [Output]
748 public ITaskItem[] CompileSourceList 505 public ITaskItem[] CompileSourceList
749 { 506 {
750 get 507 get
751 { 508 {
752 return this.compileSourceList; 509 return this.compileSourceList;
753 } 510 }
754 set 511 set
755 { 512 {
756 this.compileSourceList = value; 513 this.compileSourceList = value;
757 } 514 }
758 } 515 }
759 516
760 protected override string ToolName 517 protected override string ToolName
761 { 518 {
762 get 519 get
763 { 520 {
764 return NaCLCompilerPath; 521 return NaCLCompilerPath;
765 } 522 }
766 } 523 }
767 524
768 protected override Encoding ResponseFileEncoding
769 {
770 get
771 {
772 return Encoding.ASCII;
773 }
774 }
775 } 525 }
776 } 526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698