| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 " + |
| 318 if (File.Exists(testPath)) | 282 "be available in the visual studio executabl
e path.\n" + |
| 319 { | 283 "Please disable Multi-processor Compilation
in the project " + |
| 320 pythonExe = testPath; | 284 "properties or add python to the your execut
able path.\n" + |
| 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 " + | |
| 335 "to the your 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 Loading... |
| 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", cmd, "\"" + pythonSc
ript + "\""); |
| 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 Loading... |
| 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> outOfDateSourcesFromCommandLine = GetOutOfDateSource
sFromCmdLineChanges(); |
| 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, |
| 424 this.TLogRea
dFiles, |
| 425 this.Sources
, |
| 426 this.Exclude
dInputPaths, |
| 427 trackedOutpu
tFiles, |
| 428 true, |
| 429 false); |
| 430 ITaskItem[] outOfDateSourcesFromTracking = this.TrackedInputFiles.Co
mputeSourcesNeedingCompilation(); |
| 431 |
| 432 //merge out of date lists |
| 433 CompileSourceList = MergeOutOfDateSources(outOfDateSourcesFromTracki
ng, outOfDateSourcesFromCommandLine); |
| 434 |
| 435 if (this.CompileSourceList.Length == 0) |
| 484 { | 436 { |
| 485 //retrieve list of sources out of date due to command line chang
es | 437 this.SkippedExecution = true; |
| 486 List<ITaskItem> outOfDateSourcesFromCommandLineChanges = this.Ge
tOutOfDateSourcesFromCommandLineChanges(); | 438 return; |
| 439 } |
| 487 | 440 |
| 488 //retrieve sources out of date due to tracking | 441 //remove sources to compile from tracked file list |
| 489 CanonicalTrackedOutputFiles trackedOutputFiles = new CanonicalTr
ackedOutputFiles(this, this.TLogWriteFiles); | 442 this.TrackedInputFiles.RemoveEntriesForSource(this.CompileSourceList
); |
| 490 this.TrackedInputFiles = new CanonicalTrackedInputFiles(this, th
is.TLogReadFiles, this.Sources, this.ExcludedInputPaths, trackedOutputFiles, tru
e, false); | 443 trackedOutputFiles.RemoveEntriesForSource(this.CompileSourceList); |
| 491 ITaskItem[] outOfDateSourcesFromTracking = this.TrackedInputFile
s.ComputeSourcesNeedingCompilation(); | 444 this.TrackedInputFiles.SaveTlog(); |
| 492 | 445 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 } | 446 } |
| 512 | 447 |
| 513 protected bool SourceIsC(string sourceFilename) | 448 protected bool SourceIsC(string sourceFilename) |
| 514 { | 449 { |
| 515 string fileExt = Path.GetExtension(sourceFilename.ToString()); | 450 string fileExt = Path.GetExtension(sourceFilename.ToString()); |
| 516 | 451 |
| 517 if (fileExt == ".c") | 452 if (fileExt == ".c") |
| 518 return true; | 453 return true; |
| 519 else | 454 else |
| 520 return false; | 455 return false; |
| 521 } | 456 } |
| 522 | 457 |
| 523 public override bool Execute() | 458 public override bool Execute() |
| 524 { | 459 { |
| 525 bool returnResult = false; | 460 bool returnResult = false; |
| 526 | 461 |
| 527 try | 462 try |
| 528 { | 463 { |
| 529 m_XamlParser = new XamlParser(PropertiesFile); | 464 xamlParser = new XamlParser(PropertiesFile); |
| 530 m_toolname = Path.GetFileNameWithoutExtension(ToolName); | 465 if (!Setup()) |
| 531 ValidateParameters(); | 466 return false; |
| 532 CalcSourcesToCompile(); | 467 CalcSourcesToCompile(); |
| 533 | |
| 534 returnResult = base.Execute(); | 468 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 } | 469 } |
| 544 finally | 470 finally |
| 545 { | 471 { |
| 546 | 472 |
| 547 } | 473 } |
| 548 | 474 |
| 549 return returnResult; | 475 return returnResult; |
| 550 } | 476 } |
| 551 | 477 |
| 552 protected List<ITaskItem> GetOutOfDateSourcesFromCommandLineChanges() | 478 protected List<ITaskItem> GetOutOfDateSourcesFromCmdLineChanges() |
| 553 { | 479 { |
| 554 //get dictionary of source + command lines | 480 //get dictionary of source + command lines |
| 555 IDictionary<string, string> dictionary = this.GenerateCommandLinesFr
omTlog(); | 481 IDictionary<string, string> dictionary = this.GenerateCommandLinesFr
omTlog(); |
| 556 List<ITaskItem> outOfDateSources = new List<ITaskItem>(); | 482 List<ITaskItem> outOfDateSources = new List<ITaskItem>(); |
| 557 | 483 |
| 558 //add sources to out of date list if the tlog dictionary string do n
ot match the generated command line string | 484 //add sources to out of date list if the tlog dictionary string do n
ot match the generated command line string |
| 559 StringBuilder currentCommandLine = new StringBuilder(GCCUtilities.s_
CommandLineLength); | 485 StringBuilder currentCommandLine = new StringBuilder(GCCUtilities.s_
CommandLineLength); |
| 560 foreach (ITaskItem sourceItem in Sources) | 486 foreach (ITaskItem sourceItem in Sources) |
| 561 { | 487 { |
| 562 currentCommandLine.Length = 0; | 488 currentCommandLine.Length = 0; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 574 } | 500 } |
| 575 } | 501 } |
| 576 else | 502 else |
| 577 { | 503 { |
| 578 outOfDateSources.Add(sourceItem); | 504 outOfDateSources.Add(sourceItem); |
| 579 } | 505 } |
| 580 } | 506 } |
| 581 return outOfDateSources; | 507 return outOfDateSources; |
| 582 } | 508 } |
| 583 | 509 |
| 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] | 510 [Output] |
| 748 public ITaskItem[] CompileSourceList | 511 public ITaskItem[] CompileSourceList |
| 749 { | 512 { |
| 750 get | 513 get |
| 751 { | 514 { |
| 752 return this.compileSourceList; | 515 return this.compileSourceList; |
| 753 } | 516 } |
| 754 set | 517 set |
| 755 { | 518 { |
| 756 this.compileSourceList = value; | 519 this.compileSourceList = value; |
| 757 } | 520 } |
| 758 } | 521 } |
| 759 | 522 |
| 760 protected override string ToolName | 523 protected override string ToolName |
| 761 { | 524 { |
| 762 get | 525 get |
| 763 { | 526 { |
| 764 return NaCLCompilerPath; | 527 return NaCLCompilerPath; |
| 765 } | 528 } |
| 766 } | 529 } |
| 767 | 530 |
| 768 protected override Encoding ResponseFileEncoding | |
| 769 { | |
| 770 get | |
| 771 { | |
| 772 return Encoding.ASCII; | |
| 773 } | |
| 774 } | |
| 775 } | 531 } |
| 776 } | 532 } |
| OLD | NEW |