| 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; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // so we wrap all the inputs (libraries and object) into one group s
o they are | 70 // so we wrap all the inputs (libraries and object) into one group s
o they are |
| 71 // searched iteratively. | 71 // searched iteratively. |
| 72 responseFileCmds.Append("-Wl,--start-group "); | 72 responseFileCmds.Append("-Wl,--start-group "); |
| 73 foreach (ITaskItem sourceFile in Sources) | 73 foreach (ITaskItem sourceFile in Sources) |
| 74 { | 74 { |
| 75 responseFileCmds.Append(GCCUtilities.ConvertPathWindowsToPosix(s
ourceFile.GetMetadata("Identity"))); | 75 responseFileCmds.Append(GCCUtilities.ConvertPathWindowsToPosix(s
ourceFile.GetMetadata("Identity"))); |
| 76 responseFileCmds.Append(" "); | 76 responseFileCmds.Append(" "); |
| 77 } | 77 } |
| 78 responseFileCmds.Append("-Wl,--end-group "); | 78 responseFileCmds.Append("-Wl,--end-group "); |
| 79 | 79 |
| 80 responseFileCmds.Append(xamlParser.Parse(Sources[0], false)); | 80 responseFileCmds.Append(xamlParser.Parse(Sources[0], false, IsPNaCl(
) ? ".bc" : null)); |
| 81 | 81 |
| 82 return responseFileCmds.ToString(); | 82 return responseFileCmds.ToString(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 private static string PexeToBC(string pexe) |
| 86 { |
| 87 return Path.ChangeExtension(pexe, ".bc"); |
| 88 } |
| 89 |
| 85 private static string PexeToNexe(string pexe, string arch) | 90 private static string PexeToNexe(string pexe, string arch) |
| 86 { | 91 { |
| 87 string basename = Path.GetFileNameWithoutExtension(pexe) + "_" + arc
h + ".nexe"; | 92 string basename = Path.GetFileNameWithoutExtension(pexe) + "_" + arc
h + ".nexe"; |
| 88 return Path.Combine(Path.GetDirectoryName(pexe), basename); | 93 return Path.Combine(Path.GetDirectoryName(pexe), basename); |
| 89 } | 94 } |
| 90 | 95 |
| 96 private bool Finalize() |
| 97 { |
| 98 string dirname = Path.GetDirectoryName(GenerateFullPathToTool()); |
| 99 string finalize = Path.Combine(dirname, "pnacl-finalize.bat"); |
| 100 string cmd = String.Format("\"{0}\" -o \"{1}\"", PexeToBC(OutputFile
), OutputFile); |
| 101 if (!OutputCommandLine) |
| 102 Log.LogMessage("pnacl-finalize -> {0}", Path.GetFileName(OutputF
ile)); |
| 103 |
| 104 return ExecuteTool(finalize, cmd, string.Empty) == 0; |
| 105 } |
| 106 |
| 91 private bool Translate(string arch, string pnacl_arch=null) | 107 private bool Translate(string arch, string pnacl_arch=null) |
| 92 { | 108 { |
| 93 if (pnacl_arch == null) | 109 if (pnacl_arch == null) |
| 94 pnacl_arch = arch; | 110 pnacl_arch = arch; |
| 95 string outfile = PexeToNexe(OutputFile, arch); | 111 string outfile = PexeToNexe(OutputFile, arch); |
| 96 string cmd = String.Format("-arch {0} \"{1}\" -o \"{2}\"", | 112 string cmd = String.Format("-arch {0} \"{1}\" -o \"{2}\"", |
| 97 pnacl_arch, OutputFile, outfile); | 113 pnacl_arch, OutputFile, outfile); |
| 98 | 114 |
| 99 string dirname = Path.GetDirectoryName(GenerateFullPathToTool()); | 115 string dirname = Path.GetDirectoryName(GenerateFullPathToTool()); |
| 100 string translateTool = Path.Combine(dirname, "pnacl-translate.bat"); | 116 string translateTool = Path.Combine(dirname, "pnacl-translate.bat"); |
| 101 if (!OutputCommandLine) | 117 if (!OutputCommandLine) |
| 102 Log.LogMessage("pnacl-translate -> {0}", Path.GetFileName(outfil
e)); | 118 Log.LogMessage("pnacl-translate -> {0}", Path.GetFileName(outfil
e)); |
| 103 | 119 |
| 104 if (ExecuteTool(translateTool, cmd, string.Empty) != 0) | 120 return ExecuteTool(translateTool, cmd, string.Empty) == 0; |
| 105 { | |
| 106 return false; | |
| 107 } | |
| 108 | |
| 109 return true; | |
| 110 } | 121 } |
| 111 | 122 |
| 112 public override bool Execute() | 123 public override bool Execute() |
| 113 { | 124 { |
| 114 if (!OutputCommandLine) | 125 if (!OutputCommandLine) { |
| 115 Log.LogMessage("Linking: {0}", Path.GetFileName(OutputFile)); | 126 string filename = OutputFile; |
| 127 if (IsPNaCl()) |
| 128 filename = PexeToBC(OutputFile); |
| 129 Log.LogMessage("Linking: {0}", filename); |
| 130 } |
| 116 | 131 |
| 117 if (!base.Execute()) | 132 if (!base.Execute()) |
| 118 return false; | 133 return false; |
| 119 | 134 |
| 120 if (!SkippedExecution) | 135 if (!SkippedExecution) |
| 121 if (!PostLink()) | 136 if (!PostLink()) |
| 122 return false; | 137 return false; |
| 123 | 138 |
| 124 return true; | 139 return true; |
| 125 } | 140 } |
| 126 | 141 |
| 127 protected bool PostLink() | 142 protected bool PostLink() |
| 128 { | 143 { |
| 129 if (IsPNaCl()) | 144 if (IsPNaCl()) |
| 130 { | 145 { |
| 146 if (!Finalize()) |
| 147 return false; |
| 148 |
| 131 if (TranslateX64 && !Translate("64", "x86-64")) | 149 if (TranslateX64 && !Translate("64", "x86-64")) |
| 132 return false; | 150 return false; |
| 133 | 151 |
| 134 if (TranslateX86 && !Translate("32", "i686")) | 152 if (TranslateX86 && !Translate("32", "i686")) |
| 135 return false; | 153 return false; |
| 136 | 154 |
| 137 if (TranslateARM && !Translate("arm")) | 155 if (TranslateARM && !Translate("arm")) |
| 138 return false; | 156 return false; |
| 139 } | 157 } |
| 140 | 158 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 191 |
| 174 foreach (var arch in new string []{ "arm", "32", "64" }) | 192 foreach (var arch in new string []{ "arm", "32", "64" }) |
| 175 { | 193 { |
| 176 string nexe = PexeToNexe(OutputFile, arch); | 194 string nexe = PexeToNexe(OutputFile, arch); |
| 177 if (File.Exists(nexe)) | 195 if (File.Exists(nexe)) |
| 178 cmd += " \"" + nexe + "\""; | 196 cmd += " \"" + nexe + "\""; |
| 179 } | 197 } |
| 180 } | 198 } |
| 181 else | 199 else |
| 182 { | 200 { |
| 183 if (ToolchainName == "glibc") | |
| 184 { | |
| 185 string bindir = Path.GetDirectoryName(NaClLinkerPath); | |
| 186 string tcroot = Path.GetDirectoryName(bindir); | |
| 187 cmd += " -D \"" + Path.Combine(bindir, "x86_64-nacl-objd
ump.exe") + "\""; | |
| 188 cmd += " -L \"" + Path.Combine(tcroot, "x86_64-nacl", "l
ib") + "\""; | |
| 189 cmd += " -L \"" + Path.Combine(tcroot, "x86_64-nacl", "l
ib32") + "\""; | |
| 190 } | |
| 191 cmd += " \"" + OutputFile + "\""; | 201 cmd += " \"" + OutputFile + "\""; |
| 192 } | 202 } |
| 193 | 203 |
| 194 if (!OutputCommandLine) | 204 if (!OutputCommandLine) |
| 195 Log.LogMessage("CreateNMF -> {0}", Path.GetFileName(nmfPath)
); | 205 Log.LogMessage("CreateNMF -> {0}", Path.GetFileName(nmfPath)
); |
| 196 | 206 |
| 197 if (ExecuteTool("python", string.Empty, cmd) != 0) | 207 if (ExecuteTool("python", string.Empty, cmd) != 0) |
| 198 { | |
| 199 return false; | 208 return false; |
| 200 } | |
| 201 } | 209 } |
| 202 | 210 |
| 203 return true; | 211 return true; |
| 204 } | 212 } |
| 205 | 213 |
| 206 protected override int ExecuteTool(string pathToTool, string responseFil
eCommands, string commandLineCommands) | 214 protected override int ExecuteTool(string pathToTool, string responseFil
eCommands, string commandLineCommands) |
| 207 { | 215 { |
| 208 if (OutputCommandLine) | 216 if (OutputCommandLine) |
| 209 { | |
| 210 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo
nseFileCommands + " " + commandLineCommands); | 217 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo
nseFileCommands + " " + commandLineCommands); |
| 211 } | |
| 212 | 218 |
| 213 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin
eCommands); | 219 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin
eCommands); |
| 214 } | 220 } |
| 215 | 221 |
| 216 protected override Encoding ResponseFileEncoding | 222 protected override Encoding ResponseFileEncoding |
| 217 { | 223 { |
| 218 get | 224 get |
| 219 { | 225 { |
| 220 return Encoding.ASCII; | 226 return Encoding.ASCII; |
| 221 } | 227 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 247 | 253 |
| 248 protected override string WriteTLogFilename | 254 protected override string WriteTLogFilename |
| 249 { | 255 { |
| 250 get | 256 get |
| 251 { | 257 { |
| 252 return BaseTool() + ".link.write.1.tlog"; | 258 return BaseTool() + ".link.write.1.tlog"; |
| 253 } | 259 } |
| 254 } | 260 } |
| 255 } | 261 } |
| 256 } | 262 } |
| OLD | NEW |