diff options
author | MW | 2007-05-26 13:40:19 +0000 |
---|---|---|
committer | MW | 2007-05-26 13:40:19 +0000 |
commit | 3436961bb5c01d659d09be134368f4f69460cef9 (patch) | |
tree | 3753ba4d7818df2a6bce0bbe863ff033cdfd568a /Prebuild/src/Core/Targets/VS2003Target.cs | |
download | opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.zip opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2 opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz |
Start of rewrite 5279!
Diffstat (limited to 'Prebuild/src/Core/Targets/VS2003Target.cs')
-rw-r--r-- | Prebuild/src/Core/Targets/VS2003Target.cs | 633 |
1 files changed, 633 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs new file mode 100644 index 0000000..b3236a8 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2003Target.cs | |||
@@ -0,0 +1,633 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-09-29 21:11:40 +0200 (fr, 29 sep 2006) $ | ||
31 | * $Revision: 177 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.IO; | ||
39 | |||
40 | using Prebuild.Core.Attributes; | ||
41 | using Prebuild.Core.Interfaces; | ||
42 | using Prebuild.Core.Nodes; | ||
43 | using Prebuild.Core.Utilities; | ||
44 | |||
45 | namespace Prebuild.Core.Targets | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | public enum VSVersion | ||
51 | { | ||
52 | /// <summary> | ||
53 | /// | ||
54 | /// </summary> | ||
55 | VS70, | ||
56 | /// <summary> | ||
57 | /// | ||
58 | /// </summary> | ||
59 | VS71, | ||
60 | /// <summary> | ||
61 | /// | ||
62 | /// </summary> | ||
63 | VS80 | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// | ||
68 | /// </summary> | ||
69 | [Target("vs2003")] | ||
70 | public class VS2003Target : ITarget | ||
71 | { | ||
72 | |||
73 | #region Fields | ||
74 | |||
75 | string solutionVersion = "8.00"; | ||
76 | string productVersion = "7.10.3077"; | ||
77 | string schemaVersion = "2.0"; | ||
78 | string versionName = "2003"; | ||
79 | VSVersion version = VSVersion.VS71; | ||
80 | |||
81 | Hashtable m_Tools; | ||
82 | Kernel m_Kernel; | ||
83 | |||
84 | /// <summary> | ||
85 | /// Gets or sets the solution version. | ||
86 | /// </summary> | ||
87 | /// <value>The solution version.</value> | ||
88 | protected string SolutionVersion | ||
89 | { | ||
90 | get | ||
91 | { | ||
92 | return this.solutionVersion; | ||
93 | } | ||
94 | set | ||
95 | { | ||
96 | this.solutionVersion = value; | ||
97 | } | ||
98 | } | ||
99 | /// <summary> | ||
100 | /// Gets or sets the product version. | ||
101 | /// </summary> | ||
102 | /// <value>The product version.</value> | ||
103 | protected string ProductVersion | ||
104 | { | ||
105 | get | ||
106 | { | ||
107 | return this.productVersion; | ||
108 | } | ||
109 | set | ||
110 | { | ||
111 | this.productVersion = value; | ||
112 | } | ||
113 | } | ||
114 | /// <summary> | ||
115 | /// Gets or sets the schema version. | ||
116 | /// </summary> | ||
117 | /// <value>The schema version.</value> | ||
118 | protected string SchemaVersion | ||
119 | { | ||
120 | get | ||
121 | { | ||
122 | return this.schemaVersion; | ||
123 | } | ||
124 | set | ||
125 | { | ||
126 | this.schemaVersion = value; | ||
127 | } | ||
128 | } | ||
129 | /// <summary> | ||
130 | /// Gets or sets the name of the version. | ||
131 | /// </summary> | ||
132 | /// <value>The name of the version.</value> | ||
133 | protected string VersionName | ||
134 | { | ||
135 | get | ||
136 | { | ||
137 | return this.versionName; | ||
138 | } | ||
139 | set | ||
140 | { | ||
141 | this.versionName = value; | ||
142 | } | ||
143 | } | ||
144 | /// <summary> | ||
145 | /// Gets or sets the version. | ||
146 | /// </summary> | ||
147 | /// <value>The version.</value> | ||
148 | protected VSVersion Version | ||
149 | { | ||
150 | get | ||
151 | { | ||
152 | return this.version; | ||
153 | } | ||
154 | set | ||
155 | { | ||
156 | this.version = value; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | #endregion | ||
161 | |||
162 | #region Constructors | ||
163 | |||
164 | /// <summary> | ||
165 | /// Initializes a new instance of the <see cref="VS2003Target"/> class. | ||
166 | /// </summary> | ||
167 | public VS2003Target() | ||
168 | { | ||
169 | m_Tools = new Hashtable(); | ||
170 | |||
171 | m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); | ||
172 | m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); | ||
173 | } | ||
174 | |||
175 | #endregion | ||
176 | |||
177 | #region Private Methods | ||
178 | |||
179 | private string MakeRefPath(ProjectNode project) | ||
180 | { | ||
181 | string ret = ""; | ||
182 | foreach(ReferencePathNode node in project.ReferencePaths) | ||
183 | { | ||
184 | try | ||
185 | { | ||
186 | string fullPath = Helper.ResolvePath(node.Path); | ||
187 | if(ret.Length < 1) | ||
188 | { | ||
189 | ret = fullPath; | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | ret += ";" + fullPath; | ||
194 | } | ||
195 | } | ||
196 | catch(ArgumentException) | ||
197 | { | ||
198 | m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | return ret; | ||
203 | } | ||
204 | |||
205 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
206 | { | ||
207 | if(!m_Tools.ContainsKey(project.Language)) | ||
208 | { | ||
209 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
210 | } | ||
211 | |||
212 | ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; | ||
213 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
214 | StreamWriter ps = new StreamWriter(projectFile); | ||
215 | |||
216 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
217 | Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); | ||
218 | |||
219 | IEnumerator enumerator; | ||
220 | //ConfigurationNode scripts; | ||
221 | |||
222 | using(ps) | ||
223 | { | ||
224 | ps.WriteLine("<VisualStudioProject>"); | ||
225 | ps.WriteLine(" <{0}", toolInfo.XmlTag); | ||
226 | ps.WriteLine("\t\t\t\tProjectType = \"Local\""); | ||
227 | ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion); | ||
228 | ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion); | ||
229 | ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); | ||
230 | ps.WriteLine("\t\t>"); | ||
231 | |||
232 | ps.WriteLine("\t\t\t\t<Build>"); | ||
233 | ps.WriteLine(" <Settings"); | ||
234 | ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon); | ||
235 | ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\""); | ||
236 | ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName); | ||
237 | ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\""); | ||
238 | ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\""); | ||
239 | ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\""); | ||
240 | ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\""); | ||
241 | ps.WriteLine("\t\t\t\t DelaySign = \"false\""); | ||
242 | |||
243 | if(this.Version == VSVersion.VS70) | ||
244 | { | ||
245 | ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\""); | ||
246 | } | ||
247 | |||
248 | ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString()); | ||
249 | |||
250 | enumerator = project.Configurations.GetEnumerator(); | ||
251 | enumerator.Reset(); | ||
252 | enumerator.MoveNext(); | ||
253 | foreach(ConfigurationNode conf in project.Configurations) | ||
254 | { | ||
255 | if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) | ||
256 | { | ||
257 | ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); | ||
258 | } | ||
259 | else | ||
260 | { | ||
261 | ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]); | ||
262 | } | ||
263 | if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) | ||
264 | { | ||
265 | ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); | ||
266 | } | ||
267 | else | ||
268 | { | ||
269 | ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]); | ||
270 | } | ||
271 | if (conf.Options["RunPostBuildEvent"] == null) | ||
272 | { | ||
273 | ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess"); | ||
274 | } | ||
275 | else | ||
276 | { | ||
277 | ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]); | ||
278 | } | ||
279 | break; | ||
280 | } | ||
281 | |||
282 | ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace); | ||
283 | ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject); | ||
284 | ps.WriteLine("\t\t >"); | ||
285 | |||
286 | foreach(ConfigurationNode conf in project.Configurations) | ||
287 | { | ||
288 | ps.WriteLine("\t\t\t\t <Config"); | ||
289 | ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name); | ||
290 | ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower()); | ||
291 | ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]); | ||
292 | ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower()); | ||
293 | ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\""); | ||
294 | ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]); | ||
295 | ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name | ||
296 | ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower()); | ||
297 | ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]); | ||
298 | ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower()); | ||
299 | |||
300 | if(this.Version == VSVersion.VS71) | ||
301 | { | ||
302 | ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower()); | ||
303 | ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower()); | ||
304 | } | ||
305 | |||
306 | ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower()); | ||
307 | ps.WriteLine(" OutputPath = \"{0}\"", | ||
308 | Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); | ||
309 | ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower()); | ||
310 | ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower()); | ||
311 | ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower()); | ||
312 | ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]); | ||
313 | ps.WriteLine(" />"); | ||
314 | } | ||
315 | |||
316 | ps.WriteLine(" </Settings>"); | ||
317 | |||
318 | ps.WriteLine(" <References>"); | ||
319 | foreach(ReferenceNode refr in project.References) | ||
320 | { | ||
321 | ps.WriteLine(" <Reference"); | ||
322 | ps.WriteLine(" Name = \"{0}\"", refr.Name); | ||
323 | ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name); | ||
324 | |||
325 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
326 | { | ||
327 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
328 | ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper()); | ||
329 | ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper()); | ||
330 | } | ||
331 | else | ||
332 | { | ||
333 | if(refr.Path != null) | ||
334 | { | ||
335 | ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); | ||
336 | } | ||
337 | |||
338 | } | ||
339 | |||
340 | if(refr.LocalCopySpecified) | ||
341 | { | ||
342 | ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy); | ||
343 | } | ||
344 | |||
345 | ps.WriteLine(" />"); | ||
346 | } | ||
347 | ps.WriteLine(" </References>"); | ||
348 | |||
349 | ps.WriteLine(" </Build>"); | ||
350 | ps.WriteLine(" <Files>"); | ||
351 | |||
352 | ps.WriteLine(" <Include>"); | ||
353 | |||
354 | foreach(string file in project.Files) | ||
355 | { | ||
356 | string fileName = file.Replace(".\\", ""); | ||
357 | ps.WriteLine(" <File"); | ||
358 | ps.WriteLine(" RelPath = \"{0}\"", fileName); | ||
359 | ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file)); | ||
360 | ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file)); | ||
361 | ps.WriteLine(" />"); | ||
362 | |||
363 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
364 | { | ||
365 | ps.WriteLine(" <File"); | ||
366 | ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx"); | ||
367 | int slash = fileName.LastIndexOf('\\'); | ||
368 | if (slash == -1) | ||
369 | { | ||
370 | ps.WriteLine(" DependentUpon = \"{0}\"", fileName); | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1)); | ||
375 | } | ||
376 | ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource"); | ||
377 | ps.WriteLine(" />"); | ||
378 | |||
379 | } | ||
380 | } | ||
381 | ps.WriteLine(" </Include>"); | ||
382 | |||
383 | ps.WriteLine(" </Files>"); | ||
384 | ps.WriteLine(" </{0}>", toolInfo.XmlTag); | ||
385 | ps.WriteLine("</VisualStudioProject>"); | ||
386 | } | ||
387 | |||
388 | ps = new StreamWriter(projectFile + ".user"); | ||
389 | using(ps) | ||
390 | { | ||
391 | ps.WriteLine("<VisualStudioProject>"); | ||
392 | ps.WriteLine(" <{0}>", toolInfo.XmlTag); | ||
393 | ps.WriteLine(" <Build>"); | ||
394 | |||
395 | ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); | ||
396 | foreach(ConfigurationNode conf in project.Configurations) | ||
397 | { | ||
398 | ps.WriteLine(" <Config"); | ||
399 | ps.WriteLine(" Name = \"{0}\"", conf.Name); | ||
400 | ps.WriteLine(" />"); | ||
401 | } | ||
402 | ps.WriteLine(" </Settings>"); | ||
403 | |||
404 | ps.WriteLine(" </Build>"); | ||
405 | ps.WriteLine(" </{0}>", toolInfo.XmlTag); | ||
406 | ps.WriteLine("</VisualStudioProject>"); | ||
407 | } | ||
408 | |||
409 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
410 | } | ||
411 | |||
412 | /// <summary> | ||
413 | /// Gets the XML doc file. | ||
414 | /// </summary> | ||
415 | /// <param name="project">The project.</param> | ||
416 | /// <param name="conf">The conf.</param> | ||
417 | /// <returns></returns> | ||
418 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) | ||
419 | { | ||
420 | if( conf == null ) | ||
421 | { | ||
422 | throw new ArgumentNullException("conf"); | ||
423 | } | ||
424 | if( project == null ) | ||
425 | { | ||
426 | throw new ArgumentNullException("project"); | ||
427 | } | ||
428 | // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false | ||
429 | // { | ||
430 | // return string.Empty; | ||
431 | // } | ||
432 | |||
433 | //default to "AssemblyName.xml" | ||
434 | //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; | ||
435 | //return (string)conf.Options["XmlDocFile", defaultValue]; | ||
436 | |||
437 | //default to no XmlDocFile file | ||
438 | return (string)conf.Options["XmlDocFile", ""]; | ||
439 | } | ||
440 | |||
441 | private void WriteSolution(SolutionNode solution) | ||
442 | { | ||
443 | m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName); | ||
444 | |||
445 | foreach(ProjectNode project in solution.Projects) | ||
446 | { | ||
447 | if(m_Kernel.AllowProject(project.FilterGroups)) | ||
448 | { | ||
449 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | ||
450 | WriteProject(solution, project); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | m_Kernel.Log.Write(""); | ||
455 | string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
456 | StreamWriter ss = new StreamWriter(solutionFile); | ||
457 | |||
458 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
459 | Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); | ||
460 | |||
461 | using(ss) | ||
462 | { | ||
463 | ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); | ||
464 | foreach(ProjectNode project in solution.Projects) | ||
465 | { | ||
466 | if(!m_Tools.ContainsKey(project.Language)) | ||
467 | { | ||
468 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
469 | } | ||
470 | |||
471 | ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; | ||
472 | |||
473 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
474 | ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", | ||
475 | toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, | ||
476 | toolInfo.FileExtension), project.Guid.ToString().ToUpper()); | ||
477 | |||
478 | ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); | ||
479 | ss.WriteLine("\tEndProjectSection"); | ||
480 | |||
481 | ss.WriteLine("EndProject"); | ||
482 | } | ||
483 | |||
484 | ss.WriteLine("Global"); | ||
485 | |||
486 | ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); | ||
487 | foreach(ConfigurationNode conf in solution.Configurations) | ||
488 | { | ||
489 | ss.WriteLine("\t\t{0} = {0}", conf.Name); | ||
490 | } | ||
491 | ss.WriteLine("\tEndGlobalSection"); | ||
492 | |||
493 | ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); | ||
494 | foreach(ProjectNode project in solution.Projects) | ||
495 | { | ||
496 | for(int i = 0; i < project.References.Count; i++) | ||
497 | { | ||
498 | ReferenceNode refr = (ReferenceNode)project.References[i]; | ||
499 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
500 | { | ||
501 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
502 | ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", | ||
503 | project.Guid.ToString().ToUpper() | ||
504 | , i, | ||
505 | refProject.Guid.ToString().ToUpper() | ||
506 | ); | ||
507 | } | ||
508 | } | ||
509 | } | ||
510 | ss.WriteLine("\tEndGlobalSection"); | ||
511 | |||
512 | ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); | ||
513 | foreach(ProjectNode project in solution.Projects) | ||
514 | { | ||
515 | foreach(ConfigurationNode conf in solution.Configurations) | ||
516 | { | ||
517 | ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", | ||
518 | project.Guid.ToString().ToUpper(), | ||
519 | conf.Name); | ||
520 | |||
521 | ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", | ||
522 | project.Guid.ToString().ToUpper(), | ||
523 | conf.Name); | ||
524 | } | ||
525 | } | ||
526 | ss.WriteLine("\tEndGlobalSection"); | ||
527 | |||
528 | if(solution.Files != null) | ||
529 | { | ||
530 | ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); | ||
531 | foreach(string file in solution.Files) | ||
532 | { | ||
533 | ss.WriteLine("\t\t{0} = {0}", file); | ||
534 | } | ||
535 | ss.WriteLine("\tEndGlobalSection"); | ||
536 | } | ||
537 | |||
538 | ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); | ||
539 | ss.WriteLine("\tEndGlobalSection"); | ||
540 | ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); | ||
541 | ss.WriteLine("\tEndGlobalSection"); | ||
542 | |||
543 | ss.WriteLine("EndGlobal"); | ||
544 | } | ||
545 | |||
546 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
547 | } | ||
548 | |||
549 | private void CleanProject(ProjectNode project) | ||
550 | { | ||
551 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
552 | |||
553 | ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; | ||
554 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
555 | string userFile = projectFile + ".user"; | ||
556 | |||
557 | Helper.DeleteIfExists(projectFile); | ||
558 | Helper.DeleteIfExists(userFile); | ||
559 | } | ||
560 | |||
561 | private void CleanSolution(SolutionNode solution) | ||
562 | { | ||
563 | m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", this.VersionName, solution.Name); | ||
564 | |||
565 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
566 | string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); | ||
567 | |||
568 | Helper.DeleteIfExists(slnFile); | ||
569 | Helper.DeleteIfExists(suoFile); | ||
570 | |||
571 | foreach(ProjectNode project in solution.Projects) | ||
572 | { | ||
573 | CleanProject(project); | ||
574 | } | ||
575 | |||
576 | m_Kernel.Log.Write(""); | ||
577 | } | ||
578 | |||
579 | #endregion | ||
580 | |||
581 | #region ITarget Members | ||
582 | |||
583 | /// <summary> | ||
584 | /// Writes the specified kern. | ||
585 | /// </summary> | ||
586 | /// <param name="kern">The kern.</param> | ||
587 | public virtual void Write(Kernel kern) | ||
588 | { | ||
589 | if( kern == null ) | ||
590 | { | ||
591 | throw new ArgumentNullException("kern"); | ||
592 | } | ||
593 | m_Kernel = kern; | ||
594 | foreach(SolutionNode sol in m_Kernel.Solutions) | ||
595 | { | ||
596 | WriteSolution(sol); | ||
597 | } | ||
598 | m_Kernel = null; | ||
599 | } | ||
600 | |||
601 | /// <summary> | ||
602 | /// Cleans the specified kern. | ||
603 | /// </summary> | ||
604 | /// <param name="kern">The kern.</param> | ||
605 | public virtual void Clean(Kernel kern) | ||
606 | { | ||
607 | if( kern == null ) | ||
608 | { | ||
609 | throw new ArgumentNullException("kern"); | ||
610 | } | ||
611 | m_Kernel = kern; | ||
612 | foreach(SolutionNode sol in m_Kernel.Solutions) | ||
613 | { | ||
614 | CleanSolution(sol); | ||
615 | } | ||
616 | m_Kernel = null; | ||
617 | } | ||
618 | |||
619 | /// <summary> | ||
620 | /// Gets the name. | ||
621 | /// </summary> | ||
622 | /// <value>The name.</value> | ||
623 | public virtual string Name | ||
624 | { | ||
625 | get | ||
626 | { | ||
627 | return "vs2003"; | ||
628 | } | ||
629 | } | ||
630 | |||
631 | #endregion | ||
632 | } | ||
633 | } | ||