| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 using System; | 4 using System; |
| 5 using System.IO; | 5 using System.IO; |
| 6 using System.Resources; | 6 using System.Resources; |
| 7 using System.Reflection; | 7 using System.Reflection; |
| 8 using System.Text; | 8 using System.Text; |
| 9 using Microsoft.Build.Framework; | 9 using Microsoft.Build.Framework; |
| 10 using Microsoft.Build.CPPTasks; | 10 using Microsoft.Build.CPPTasks; |
| 11 using Microsoft.Build.Utilities; | 11 using Microsoft.Build.Utilities; |
| 12 | 12 |
| 13 | 13 |
| 14 namespace NaCl.Build.CPPTasks | 14 namespace NaCl.Build.CPPTasks |
| 15 { | 15 { |
| 16 public class NaClLink : NaClToolTask | 16 public class NaClLink : NaClToolTask |
| 17 { | 17 { |
| 18 public bool BuildingInIDE { get; set; } | |
| 19 | |
| 20 /// <summary> | 18 /// <summary> |
| 21 /// Property set only in PNaCl builds to signal that the translator | 19 /// Property set only in PNaCl builds to signal that the translator |
| 22 /// should be run post-link. | 20 /// should be run post-link. |
| 23 /// </summary> | 21 /// </summary> |
| 24 public bool TranslateARM { get; set; } | 22 public bool TranslateARM { get; set; } |
| 25 | 23 |
| 26 /// <summary> | 24 /// <summary> |
| 27 /// Property set only in PNaCl builds to signal that the translator | 25 /// Property set only in PNaCl builds to signal that the translator |
| 28 /// should be run post-link. | 26 /// should be run post-link. |
| 29 /// </summary> | 27 /// </summary> |
| 30 public bool TranslateX86 { get; set; } | 28 public bool TranslateX86 { get; set; } |
| 31 | 29 |
| 32 /// <summary> | 30 /// <summary> |
| 33 /// Property set only in PNaCl builds to signal that the translator | 31 /// Property set only in PNaCl builds to signal that the translator |
| 34 /// should be run post-link. | 32 /// should be run post-link. |
| 35 /// </summary> | 33 /// </summary> |
| 36 public bool TranslateX64 { get; set; } | 34 public bool TranslateX64 { get; set; } |
| 37 | 35 |
| 38 [Required] | 36 [Required] |
| 39 public bool OutputCommandLine { get; set; } | |
| 40 | |
| 41 [Required] | |
| 42 public bool CreateNMF { get; set; } | 37 public bool CreateNMF { get; set; } |
| 43 | 38 |
| 44 [Required] | 39 [Required] |
| 45 public string NaClLinkerPath { get; set; } | 40 public string NaClLinkerPath { get; set; } |
| 46 | 41 |
| 47 [Required] | 42 [Required] |
| 48 public string ProjectName { get; set; } | 43 public string ProjectName { get; set; } |
| 49 | 44 |
| 50 [Required] | 45 [Required] |
| 51 public string ToolchainName { get; set; } | 46 public string ToolchainName { get; set; } |
| 52 | 47 |
| 53 [Required] | 48 [Required] |
| 54 public string Platform { get; set; } | |
| 55 | |
| 56 [Required] | |
| 57 public string CreateNMFPath { get; set; } | 49 public string CreateNMFPath { get; set; } |
| 58 | 50 |
| 59 [Required] | 51 [Required] |
| 60 public virtual string OutputFile { get; set; } | |
| 61 | |
| 62 [Required] | |
| 63 public string PropertiesFile { get; set; } | 52 public string PropertiesFile { get; set; } |
| 64 | 53 |
| 65 [Required] | 54 [Required] |
| 66 public string ConfigurationType { get; set; } | 55 public string ConfigurationType { get; set; } |
| 67 | 56 |
| 68 protected override CanonicalTrackedOutputFiles OutputWriteTLog(ITaskItem
[] inputs) | |
| 69 { | |
| 70 string path = Path.Combine(TlogDirectory, WriteTLogFilename); | |
| 71 TaskItem item = new TaskItem(path); | |
| 72 CanonicalTrackedOutputFiles trackedFiles = | |
| 73 new CanonicalTrackedOutputFiles(new TaskItem[] { item }); | |
| 74 | |
| 75 foreach (ITaskItem sourceItem in Sources) | |
| 76 { | |
| 77 //remove this entry associated with compiled source which is abo
ut to be recomputed | |
| 78 trackedFiles.RemoveEntriesForSource(sourceItem); | |
| 79 | |
| 80 //add entry with updated information | |
| 81 string upper = Path.GetFullPath(sourceItem.ItemSpec).ToUpperInva
riant(); | |
| 82 trackedFiles.AddComputedOutputForSourceRoot(upper, OutputFile); | |
| 83 } | |
| 84 | |
| 85 //output tlog | |
| 86 trackedFiles.SaveTlog(); | |
| 87 | |
| 88 return trackedFiles; | |
| 89 } | |
| 90 | |
| 91 protected override void OutputReadTLog(ITaskItem[] compiledSources, Cano
nicalTrackedOutputFiles outputs) | |
| 92 { | |
| 93 string trackerPath = Path.GetFullPath(TlogDirectory + ReadTLogFilena
mes[0]); | |
| 94 | |
| 95 using (StreamWriter writer = new StreamWriter(trackerPath, false, En
coding.Unicode)) | |
| 96 { | |
| 97 string sourcePath = ""; | |
| 98 foreach (ITaskItem source in Sources) | |
| 99 { | |
| 100 if (sourcePath != "") | |
| 101 sourcePath += "|"; | |
| 102 sourcePath += Path.GetFullPath(source.ItemSpec).ToUpperInvar
iant(); | |
| 103 } | |
| 104 | |
| 105 writer.WriteLine("^" + sourcePath); | |
| 106 foreach (ITaskItem source in Sources) | |
| 107 { | |
| 108 writer.WriteLine(Path.GetFullPath(source.ItemSpec).ToUpperIn
variant()); | |
| 109 } | |
| 110 writer.WriteLine(Path.GetFullPath(OutputFile).ToUpperInvariant()
); | |
| 111 } | |
| 112 } | |
| 113 | |
| 114 protected override void OutputCommandTLog(ITaskItem[] compiledSources) | |
| 115 { | |
| 116 using (StreamWriter writer = new StreamWriter(TLogCommandFile.GetMet
adata("FullPath"), false, Encoding.Unicode)) | |
| 117 { | |
| 118 string cmds = GenerateResponseFileCommands(); | |
| 119 string sourcePath = ""; | |
| 120 foreach (ITaskItem source in Sources) | |
| 121 { | |
| 122 if (sourcePath != "") | |
| 123 sourcePath += "|"; | |
| 124 sourcePath += Path.GetFullPath(source.ItemSpec).ToUpperInvar
iant(); | |
| 125 } | |
| 126 | |
| 127 writer.WriteLine("^" + sourcePath); | |
| 128 writer.WriteLine(cmds); | |
| 129 } | |
| 130 } | |
| 131 | |
| 132 public NaClLink() | 57 public NaClLink() |
| 133 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources
", Assembly.GetExecutingAssembly())) | 58 : base(new ResourceManager("NaCl.Build.CPPTasks.Properties.Resources
", Assembly.GetExecutingAssembly())) |
| 134 { | 59 { |
| 135 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning"
, "LC_CTYPE=C" }; | 60 this.EnvironmentVariables = new string[] { "CYGWIN=nodosfilewarning"
, "LC_CTYPE=C" }; |
| 136 } | 61 } |
| 137 | 62 |
| 138 protected override void LogEventsFromTextOutput(string singleLine, Messa
geImportance messageImportance) | 63 protected override void LogEventsFromTextOutput(string singleLine, Messa
geImportance messageImportance) |
| 139 { | 64 { |
| 140 base.LogEventsFromTextOutput(GCCUtilities.ConvertGCCOutput(singleLin
e), messageImportance); | 65 base.LogEventsFromTextOutput(GCCUtilities.ConvertGCCOutput(singleLin
e), messageImportance); |
| 141 } | 66 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 Log.LogMessage("pnacl-translate -> {0}", Path.GetFileName(outfil
e)); | 105 Log.LogMessage("pnacl-translate -> {0}", Path.GetFileName(outfil
e)); |
| 181 | 106 |
| 182 if (ExecuteTool(translateTool, cmd, string.Empty) != 0) | 107 if (ExecuteTool(translateTool, cmd, string.Empty) != 0) |
| 183 { | 108 { |
| 184 return false; | 109 return false; |
| 185 } | 110 } |
| 186 | 111 |
| 187 return true; | 112 return true; |
| 188 } | 113 } |
| 189 | 114 |
| 190 private bool IsPNaCl() | |
| 191 { | |
| 192 return Platform.Equals("pnacl", StringComparison.OrdinalIgnoreCase); | |
| 193 } | |
| 194 | |
| 195 public override bool Execute() | 115 public override bool Execute() |
| 196 { | 116 { |
| 197 if (IsPNaCl()) | |
| 198 { | |
| 199 if (!SDKUtilities.FindPython()) | |
| 200 { | |
| 201 Log.LogError("PNaCl linking requires python in your executab
le path."); | |
| 202 return false; | |
| 203 } | |
| 204 } | |
| 205 | |
| 206 xamlParser = new XamlParser(PropertiesFile); | 117 xamlParser = new XamlParser(PropertiesFile); |
| 207 if (!Setup()) | 118 if (!Setup()) |
| 208 return false; | 119 return false; |
| 209 | 120 |
| 210 if (!OutputCommandLine) | 121 if (!OutputCommandLine) |
| 211 Log.LogMessage("Linking: {0}", Path.GetFileName(OutputFile)); | 122 Log.LogMessage("Linking: {0}", Path.GetFileName(OutputFile)); |
| 212 | 123 |
| 213 if (!base.Execute()) | 124 if (!base.Execute()) |
| 214 return false; | 125 return false; |
| 215 | 126 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 protected override int ExecuteTool(string pathToTool, string responseFil
eCommands, string commandLineCommands) | 205 protected override int ExecuteTool(string pathToTool, string responseFil
eCommands, string commandLineCommands) |
| 295 { | 206 { |
| 296 if (OutputCommandLine) | 207 if (OutputCommandLine) |
| 297 { | 208 { |
| 298 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo
nseFileCommands + " " + commandLineCommands); | 209 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo
nseFileCommands + " " + commandLineCommands); |
| 299 } | 210 } |
| 300 | 211 |
| 301 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin
eCommands); | 212 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin
eCommands); |
| 302 } | 213 } |
| 303 | 214 |
| 304 protected override string GenerateFullPathToTool() | |
| 305 { | |
| 306 return this.ToolName; | |
| 307 } | |
| 308 | |
| 309 protected override Encoding ResponseFileEncoding | 215 protected override Encoding ResponseFileEncoding |
| 310 { | 216 { |
| 311 get | 217 get |
| 312 { | 218 { |
| 313 return Encoding.ASCII; | 219 return Encoding.ASCII; |
| 314 } | 220 } |
| 315 } | 221 } |
| 316 | 222 |
| 317 protected override string ToolName | 223 protected override string ToolName |
| 318 { | 224 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 338 } | 244 } |
| 339 } | 245 } |
| 340 | 246 |
| 341 protected override string WriteTLogFilename | 247 protected override string WriteTLogFilename |
| 342 { | 248 { |
| 343 get | 249 get |
| 344 { | 250 { |
| 345 return BaseTool() + ".link.write.1.tlog"; | 251 return BaseTool() + ".link.write.1.tlog"; |
| 346 } | 252 } |
| 347 } | 253 } |
| 348 | |
| 349 public virtual string PlatformToolset | |
| 350 { | |
| 351 get | |
| 352 { | |
| 353 return "GCC"; | |
| 354 } | |
| 355 set | |
| 356 {} | |
| 357 } | |
| 358 } | 254 } |
| 359 } | 255 } |
| OLD | NEW |