Chromium Code Reviews| Index: visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClToolTask.cs |
| diff --git a/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClToolTask.cs b/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClToolTask.cs |
| index 2c471366d0e68a82c39003471546d52484fa9fdd..a72386f4e20b2e9b7772a6847aedd589f50ed7cb 100644 |
| --- a/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClToolTask.cs |
| +++ b/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClToolTask.cs |
| @@ -21,6 +21,7 @@ namespace NaCl.Build.CPPTasks |
| public abstract class NaClToolTask : ToolTask |
| { |
|
Sam Clegg
2012/11/12 20:10:36
Almost all the changes to this file come from the
|
| protected NaClToolTask(ResourceManager taskResources) : base(taskResources) { } |
| + public bool BuildingInIDE { get; set; } |
| protected ITaskItem[] excludedInputPaths; |
| private ITaskItem[] tlogReadFiles; |
| private ITaskItem tlogCommandFile; |
| @@ -32,16 +33,19 @@ namespace NaCl.Build.CPPTasks |
| protected ITaskItem[] compileSourceList; |
| protected XamlParser xamlParser; |
| - protected abstract CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem[] compiledSources); |
| - protected abstract void OutputReadTLog(ITaskItem[] compiledSources, CanonicalTrackedOutputFiles outputs); |
| - protected abstract void OutputCommandTLog(ITaskItem[] compiledSources); |
| - |
| [Required] |
| public string TrackerLogDirectory { get; set; } |
| [Required] |
| public virtual ITaskItem[] Sources { get; set; } |
| + [Required] |
| + public bool OutputCommandLine { get; set; } |
| + |
| + [Required] |
| + public string Platform { get; set; } |
| + |
| + public virtual string OutputFile { get; set; } |
| // Override default StandardOutputLoggingImportance so that we see the stdout from the |
| // toolchain from within visual studio. |
| @@ -87,6 +91,11 @@ namespace NaCl.Build.CPPTasks |
| return Path.GetFileNameWithoutExtension(ToolName); |
| } |
| + protected bool IsPNaCl() |
| + { |
| + return Platform.Equals("pnacl", StringComparison.OrdinalIgnoreCase); |
| + } |
| + |
| protected bool Setup() |
| { |
| this.SkippedExecution = false; |
| @@ -96,6 +105,15 @@ namespace NaCl.Build.CPPTasks |
| return false; |
| } |
| + if (IsPNaCl()) |
| + { |
| + if (!SDKUtilities.FindPython()) |
| + { |
| + Log.LogError("PNaCl linking requires python in your executable path."); |
| + return false; |
| + } |
| + } |
| + |
| if (this.TrackFileAccess || this.MinimalRebuildFromTracking) |
| { |
| this.SetTrackerLogPaths(); |
| @@ -112,6 +130,70 @@ namespace NaCl.Build.CPPTasks |
| return true; |
| } |
| + protected virtual CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem[] inputs) |
| + { |
| + string path = Path.Combine(TlogDirectory, WriteTLogFilename); |
| + TaskItem item = new TaskItem(path); |
| + CanonicalTrackedOutputFiles trackedFiles = |
| + new CanonicalTrackedOutputFiles(new TaskItem[] { item }); |
| + |
| + foreach (ITaskItem sourceItem in Sources) |
| + { |
| + //remove this entry associated with compiled source which is about to be recomputed |
| + trackedFiles.RemoveEntriesForSource(sourceItem); |
| + |
| + //add entry with updated information |
| + string upper = Path.GetFullPath(sourceItem.ItemSpec).ToUpperInvariant(); |
| + trackedFiles.AddComputedOutputForSourceRoot(upper, OutputFile); |
| + } |
| + |
| + //output tlog |
| + trackedFiles.SaveTlog(); |
| + |
| + return trackedFiles; |
| + } |
| + |
| + protected virtual void OutputReadTLog(ITaskItem[] compiledSources, CanonicalTrackedOutputFiles outputs) |
|
binji
2012/11/12 21:27:02
nit: wrap at 100
Sam Clegg
2012/11/12 21:56:22
Done.
|
| + { |
| + string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilenames[0]); |
| + |
| + using (StreamWriter writer = new StreamWriter(trackerPath, false, Encoding.Unicode)) |
| + { |
| + string sourcePath = ""; |
| + foreach (ITaskItem source in Sources) |
| + { |
| + if (sourcePath != "") |
| + sourcePath += "|"; |
| + sourcePath += Path.GetFullPath(source.ItemSpec).ToUpperInvariant(); |
| + } |
| + |
| + writer.WriteLine("^" + sourcePath); |
| + foreach (ITaskItem source in Sources) |
| + { |
| + writer.WriteLine(Path.GetFullPath(source.ItemSpec).ToUpperInvariant()); |
| + } |
| + writer.WriteLine(Path.GetFullPath(OutputFile).ToUpperInvariant()); |
| + } |
| + } |
| + |
| + protected virtual void OutputCommandTLog(ITaskItem[] compiledSources) |
| + { |
| + using (StreamWriter writer = new StreamWriter(TLogCommandFile.GetMetadata("FullPath"), false, Encoding.Unicode)) |
|
binji
2012/11/12 21:27:02
nit: wrap at 100
Sam Clegg
2012/11/12 21:56:22
Done.
|
| + { |
| + string cmds = GenerateResponseFileCommands(); |
| + string sourcePath = ""; |
| + foreach (ITaskItem source in Sources) |
| + { |
| + if (sourcePath != "") |
| + sourcePath += "|"; |
| + sourcePath += Path.GetFullPath(source.ItemSpec).ToUpperInvariant(); |
| + } |
| + |
| + writer.WriteLine("^" + sourcePath); |
| + writer.WriteLine(cmds); |
| + } |
| + } |
| + |
| public override bool Execute() |
| { |
| bool returnResult = base.Execute(); |
| @@ -294,5 +376,18 @@ namespace NaCl.Build.CPPTasks |
| return BaseTool() + ".compile.write.1.tlog"; |
| } |
| } |
| + |
| + public virtual string PlatformToolset |
| + { |
| + get |
| + { |
| + return "GCC"; |
| + } |
| + } |
| + |
| + protected override string GenerateFullPathToTool() |
| + { |
| + return this.ToolName; |
| + } |
| } |
| } |