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 if (ExecuteTool(finalize, cmd, string.Empty) != 0) | |
binji
2013/11/19 21:57:16
You could do just
return ExecuteTool(...) == 0;
Sam Clegg
2013/11/19 23:21:24
Done.
| |
105 return false; | |
106 | |
107 return true; | |
108 } | |
109 | |
91 private bool Translate(string arch, string pnacl_arch=null) | 110 private bool Translate(string arch, string pnacl_arch=null) |
92 { | 111 { |
93 if (pnacl_arch == null) | 112 if (pnacl_arch == null) |
94 pnacl_arch = arch; | 113 pnacl_arch = arch; |
95 string outfile = PexeToNexe(OutputFile, arch); | 114 string outfile = PexeToNexe(OutputFile, arch); |
96 string cmd = String.Format("-arch {0} \"{1}\" -o \"{2}\"", | 115 string cmd = String.Format("-arch {0} \"{1}\" -o \"{2}\"", |
97 pnacl_arch, OutputFile, outfile); | 116 pnacl_arch, OutputFile, outfile); |
98 | 117 |
99 string dirname = Path.GetDirectoryName(GenerateFullPathToTool()); | 118 string dirname = Path.GetDirectoryName(GenerateFullPathToTool()); |
100 string translateTool = Path.Combine(dirname, "pnacl-translate.bat"); | 119 string translateTool = Path.Combine(dirname, "pnacl-translate.bat"); |
101 if (!OutputCommandLine) | 120 if (!OutputCommandLine) |
102 Log.LogMessage("pnacl-translate -> {0}", Path.GetFileName(outfil e)); | 121 Log.LogMessage("pnacl-translate -> {0}", Path.GetFileName(outfil e)); |
103 | 122 |
104 if (ExecuteTool(translateTool, cmd, string.Empty) != 0) | 123 if (ExecuteTool(translateTool, cmd, string.Empty) != 0) |
105 { | |
106 return false; | 124 return false; |
107 } | |
108 | 125 |
109 return true; | 126 return true; |
110 } | 127 } |
111 | 128 |
112 public override bool Execute() | 129 public override bool Execute() |
113 { | 130 { |
114 if (!OutputCommandLine) | 131 if (!OutputCommandLine) { |
115 Log.LogMessage("Linking: {0}", Path.GetFileName(OutputFile)); | 132 string filename = OutputFile; |
133 if (IsPNaCl()) | |
134 filename = PexeToBC(OutputFile); | |
135 Log.LogMessage("Linking: {0}", filename); | |
136 } | |
116 | 137 |
117 if (!base.Execute()) | 138 if (!base.Execute()) |
118 return false; | 139 return false; |
119 | 140 |
120 if (!SkippedExecution) | 141 if (!SkippedExecution) |
121 if (!PostLink()) | 142 if (!PostLink()) |
122 return false; | 143 return false; |
123 | 144 |
124 return true; | 145 return true; |
125 } | 146 } |
126 | 147 |
127 protected bool PostLink() | 148 protected bool PostLink() |
128 { | 149 { |
129 if (IsPNaCl()) | 150 if (IsPNaCl()) |
130 { | 151 { |
152 if (!Finalize()) | |
153 return false; | |
154 | |
131 if (TranslateX64 && !Translate("64", "x86-64")) | 155 if (TranslateX64 && !Translate("64", "x86-64")) |
132 return false; | 156 return false; |
133 | 157 |
134 if (TranslateX86 && !Translate("32", "i686")) | 158 if (TranslateX86 && !Translate("32", "i686")) |
135 return false; | 159 return false; |
136 | 160 |
137 if (TranslateARM && !Translate("arm")) | 161 if (TranslateARM && !Translate("arm")) |
138 return false; | 162 return false; |
139 } | 163 } |
140 | 164 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 | 197 |
174 foreach (var arch in new string []{ "arm", "32", "64" }) | 198 foreach (var arch in new string []{ "arm", "32", "64" }) |
175 { | 199 { |
176 string nexe = PexeToNexe(OutputFile, arch); | 200 string nexe = PexeToNexe(OutputFile, arch); |
177 if (File.Exists(nexe)) | 201 if (File.Exists(nexe)) |
178 cmd += " \"" + nexe + "\""; | 202 cmd += " \"" + nexe + "\""; |
179 } | 203 } |
180 } | 204 } |
181 else | 205 else |
182 { | 206 { |
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 + "\""; | 207 cmd += " \"" + OutputFile + "\""; |
192 } | 208 } |
193 | 209 |
194 if (!OutputCommandLine) | 210 if (!OutputCommandLine) |
195 Log.LogMessage("CreateNMF -> {0}", Path.GetFileName(nmfPath) ); | 211 Log.LogMessage("CreateNMF -> {0}", Path.GetFileName(nmfPath) ); |
196 | 212 |
197 if (ExecuteTool("python", string.Empty, cmd) != 0) | 213 if (ExecuteTool("python", string.Empty, cmd) != 0) |
198 { | |
199 return false; | 214 return false; |
200 } | |
201 } | 215 } |
202 | 216 |
203 return true; | 217 return true; |
204 } | 218 } |
205 | 219 |
206 protected override int ExecuteTool(string pathToTool, string responseFil eCommands, string commandLineCommands) | 220 protected override int ExecuteTool(string pathToTool, string responseFil eCommands, string commandLineCommands) |
207 { | 221 { |
208 if (OutputCommandLine) | 222 if (OutputCommandLine) |
209 { | |
210 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo nseFileCommands + " " + commandLineCommands); | 223 Log.LogMessage(MessageImportance.High, pathToTool + " " + respo nseFileCommands + " " + commandLineCommands); |
211 } | |
212 | 224 |
213 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin eCommands); | 225 return base.ExecuteTool(pathToTool, responseFileCommands, commandLin eCommands); |
214 } | 226 } |
215 | 227 |
216 protected override Encoding ResponseFileEncoding | 228 protected override Encoding ResponseFileEncoding |
217 { | 229 { |
218 get | 230 get |
219 { | 231 { |
220 return Encoding.ASCII; | 232 return Encoding.ASCII; |
221 } | 233 } |
(...skipping 25 matching lines...) Expand all Loading... | |
247 | 259 |
248 protected override string WriteTLogFilename | 260 protected override string WriteTLogFilename |
249 { | 261 { |
250 get | 262 get |
251 { | 263 { |
252 return BaseTool() + ".link.write.1.tlog"; | 264 return BaseTool() + ".link.write.1.tlog"; |
253 } | 265 } |
254 } | 266 } |
255 } | 267 } |
256 } | 268 } |
OLD | NEW |