| Index: visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClLink.cs
|
| diff --git a/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClLink.cs b/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClLink.cs
|
| index 768051e501fb8aa4a34cc26b42d35f66a75c243b..cb8f50f9ee134035dece8382d4276a07abf5c292 100644
|
| --- a/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClLink.cs
|
| +++ b/visual_studio/NativeClientVSAddIn/NaCl.Build.CPPTasks/NaClLink.cs
|
| @@ -6,12 +6,13 @@ using System.Reflection;
|
| using System.Text;
|
| using Microsoft.Build.Framework;
|
| using Microsoft.Build.CPPTasks;
|
| +using Microsoft.Build.Utilities;
|
|
|
|
|
| namespace NaCl.Build.CPPTasks
|
| {
|
| - public class NaClLink : TrackedVCToolTask
|
| - {
|
| + public class NaClLink : NaClToolTask
|
| + {
|
| private XamlParser m_XamlParser;
|
|
|
| public bool BuildingInIDE { get; set; }
|
| @@ -23,51 +24,87 @@ namespace NaCl.Build.CPPTasks
|
| public string NaClLinkerPath { get; set; }
|
|
|
| [Required]
|
| - public virtual string OutputFile { get; set; }
|
| + public string Platform { get; set; }
|
|
|
| [Required]
|
| - public string PropertiesFile { get; set; }
|
| + public virtual string OutputFile { get; set; }
|
|
|
| [Required]
|
| - public virtual ITaskItem[] Sources { get; set; }
|
| + public string PropertiesFile { get; set; }
|
|
|
| [Required]
|
| public string ConfigurationType { get; set; }
|
|
|
| - public NaClLink()
|
| - : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources", Assembly.GetExecutingAssembly()))
|
| + protected override CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem[] inputs)
|
| {
|
| - this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning", "LC_CTYPE=C" };
|
| - }
|
| + string path = Path.Combine(TlogDirectory, WriteTLogFilename);
|
| + TaskItem item = new TaskItem(path);
|
| + CanonicalTrackedOutputFiles trackedFiles = new CanonicalTrackedOutputFiles(new TaskItem[] { item });
|
|
|
| - protected override string CommandTLogName
|
| - {
|
| - get
|
| + foreach (ITaskItem sourceItem in Sources)
|
| {
|
| - return "default.link.command.tlog";
|
| + //remove this entry associated with compiled source which is about to be recomputed
|
| + trackedFiles.RemoveEntriesForSource(sourceItem);
|
| +
|
| + //add entry with updated information
|
| + trackedFiles.AddComputedOutputForSourceRoot(Path.GetFullPath(sourceItem.ItemSpec).ToUpperInvariant(),
|
| + OutputFile);
|
| }
|
| +
|
| + //output tlog
|
| + trackedFiles.SaveTlog();
|
| +
|
| + return trackedFiles;
|
| }
|
|
|
| - protected override string[] ReadTLogNames
|
| + protected override void OutputReadTLog(ITaskItem[] compiledSources, CanonicalTrackedOutputFiles outputs)
|
| {
|
| - get
|
| + string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilenames[0]);
|
| +
|
| + using (StreamWriter writer = new StreamWriter(trackerPath, false, Encoding.Unicode))
|
| {
|
| - return new string[] {
|
| - "default.link.read.tlog"
|
| - };
|
| + 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 override string[] WriteTLogNames
|
| + protected override void OutputCommandTLog(ITaskItem[] compiledSources)
|
| {
|
| - get
|
| + //write tlog
|
| + using (StreamWriter writer = new StreamWriter(TLogCommandFile.GetMetadata("FullPath"), false, Encoding.Unicode))
|
| {
|
| - return new string[] {
|
| - "default.link.write.tlog"
|
| - };
|
| + 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 NaClLink()
|
| + : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources", Assembly.GetExecutingAssembly()))
|
| + {
|
| + this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning", "LC_CTYPE=C" };
|
| + }
|
| +
|
| protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance)
|
| {
|
| base.LogEventsFromTextOutput(GCCUtilities.ConvertGCCOutput(singleLine), messageImportance);
|
| @@ -95,12 +132,22 @@ namespace NaCl.Build.CPPTasks
|
|
|
| public override bool Execute()
|
| {
|
| + if (Platform.Equals("pnacl", StringComparison.OrdinalIgnoreCase))
|
| + {
|
| + if (!GCCUtilities.FindPython())
|
| + {
|
| + Log.LogError("PNaCl linking requires python in your executable path.");
|
| + return false;
|
| + }
|
| + }
|
| +
|
| bool returnResult = false;
|
|
|
| try
|
| {
|
| m_XamlParser = new XamlParser(PropertiesFile);
|
| -
|
| + if (!Setup())
|
| + return false;
|
| returnResult = base.Execute();
|
| }
|
| finally
|
| @@ -121,29 +168,11 @@ namespace NaCl.Build.CPPTasks
|
| return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
|
| }
|
|
|
| - protected override void PostProcessSwitchList()
|
| - {
|
| - //skip default behavior
|
| - }
|
| -
|
| protected override string GenerateFullPathToTool()
|
| {
|
| return this.ToolName;
|
| }
|
|
|
| - protected override string TrackerIntermediateDirectory
|
| - {
|
| - get
|
| - {
|
| - if (this.TrackerLogDirectory != null)
|
| - {
|
| - return this.TrackerLogDirectory;
|
| - }
|
| -
|
| - return string.Empty;
|
| - }
|
| - }
|
| -
|
| protected override Encoding ResponseFileEncoding
|
| {
|
| get
|
| @@ -152,38 +181,37 @@ namespace NaCl.Build.CPPTasks
|
| }
|
| }
|
|
|
| - protected override ITaskItem[] TrackedInputFiles
|
| + protected override string ToolName
|
| {
|
| get
|
| {
|
| - return this.Sources;
|
| + return NaClLinkerPath;
|
| }
|
| }
|
|
|
| - protected override bool MaintainCompositeRootingMarkers
|
| + protected override string CommandTLogFilename
|
| {
|
| get
|
| {
|
| - return true;
|
| + return BaseTool() + ".link.command.1.tlog";
|
| }
|
| -
|
| }
|
|
|
| - protected override string ToolName
|
| + protected override string[] ReadTLogFilenames
|
| {
|
| get
|
| {
|
| - return NaClLinkerPath;
|
| + return new string[] { BaseTool() + ".link.read.1.tlog" };
|
| }
|
| }
|
|
|
| - public override bool AttributeFileTracking
|
| + protected override string WriteTLogFilename
|
| {
|
| get
|
| {
|
| - return true;
|
| + return BaseTool() + ".link.write.1.tlog";
|
| }
|
| - }
|
| + }
|
|
|
| public virtual string PlatformToolset
|
| {
|
| @@ -193,8 +221,6 @@ namespace NaCl.Build.CPPTasks
|
| }
|
| set
|
| {}
|
| - }
|
| -
|
| - public string TrackerLogDirectory { get; set; }
|
| - }
|
| + }
|
| + }
|
| }
|
|
|