diff options
author | BlueWall | 2010-08-31 17:02:36 -0400 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-09-04 02:12:21 +0100 |
commit | 1e44ec84bd90ec9078027d1d9d78e83c7d305f2a (patch) | |
tree | e34db5ced4bc7bf59b98ff9fb72271dda0f25a33 /Prebuild/src/Core/Targets/VS2003Target.cs | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.zip opensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.tar.gz opensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.tar.bz2 opensim-SC-1e44ec84bd90ec9078027d1d9d78e83c7d305f2a.tar.xz |
Build system upgrade:
Upgrading Prebuild.exe to correctly construct build solutions
for crossplatform tools such as xbuild, monodevelop and nant.
NOTE: Module prebuild files will need modification to work,
as the prebuild must correctly define the reference path for
all assemblies shipped in the OpenSimulator ./bin directory.
These include assemblies such as XMLRPC.dll, OpenMetaverse.dll,
Nini.dll, etc. . The entries should follow the form:
<Reference name="Nini" path="../../../bin/"/>
See the distributed prebuild.xml for further examples.
Crossplatform tools: xbuild and monodevelop use the
vs2008 OpenSim.sln and the .csproj files in each namespace.
Changes to the Prebuild.exe are against svn 322 and are included
in a patch attached to the mantis. And the dnpb source are
available@ svn co https://dnpb.svn.sourceforge.net/svnroot/dnpb dnpb
The patches are pending application by the dnpb team. After which,
the un-modified upstream Prebuild.exe will work as expected.
Diffstat (limited to 'Prebuild/src/Core/Targets/VS2003Target.cs')
-rw-r--r-- | Prebuild/src/Core/Targets/VS2003Target.cs | 602 |
1 files changed, 0 insertions, 602 deletions
diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs deleted file mode 100644 index 1bcb7dc..0000000 --- a/Prebuild/src/Core/Targets/VS2003Target.cs +++ /dev/null | |||
@@ -1,602 +0,0 @@ | |||
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 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using Prebuild.Core.Nodes; | ||
34 | using Prebuild.Core.Utilities; | ||
35 | |||
36 | namespace Prebuild.Core.Targets | ||
37 | { | ||
38 | [Target("vs2003")] | ||
39 | public class VS2003Target : ITarget | ||
40 | { | ||
41 | |||
42 | #region Fields | ||
43 | |||
44 | string solutionVersion = "8.00"; | ||
45 | string productVersion = "7.10.3077"; | ||
46 | string schemaVersion = "2.0"; | ||
47 | string versionName = "2003"; | ||
48 | VSVersion version = VSVersion.VS71; | ||
49 | |||
50 | Hashtable m_Tools; | ||
51 | Kernel m_Kernel; | ||
52 | |||
53 | /// <summary> | ||
54 | /// Gets or sets the solution version. | ||
55 | /// </summary> | ||
56 | /// <value>The solution version.</value> | ||
57 | protected string SolutionVersion | ||
58 | { | ||
59 | get | ||
60 | { | ||
61 | return this.solutionVersion; | ||
62 | } | ||
63 | set | ||
64 | { | ||
65 | this.solutionVersion = value; | ||
66 | } | ||
67 | } | ||
68 | /// <summary> | ||
69 | /// Gets or sets the product version. | ||
70 | /// </summary> | ||
71 | /// <value>The product version.</value> | ||
72 | protected string ProductVersion | ||
73 | { | ||
74 | get | ||
75 | { | ||
76 | return this.productVersion; | ||
77 | } | ||
78 | set | ||
79 | { | ||
80 | this.productVersion = value; | ||
81 | } | ||
82 | } | ||
83 | /// <summary> | ||
84 | /// Gets or sets the schema version. | ||
85 | /// </summary> | ||
86 | /// <value>The schema version.</value> | ||
87 | protected string SchemaVersion | ||
88 | { | ||
89 | get | ||
90 | { | ||
91 | return this.schemaVersion; | ||
92 | } | ||
93 | set | ||
94 | { | ||
95 | this.schemaVersion = value; | ||
96 | } | ||
97 | } | ||
98 | /// <summary> | ||
99 | /// Gets or sets the name of the version. | ||
100 | /// </summary> | ||
101 | /// <value>The name of the version.</value> | ||
102 | protected string VersionName | ||
103 | { | ||
104 | get | ||
105 | { | ||
106 | return this.versionName; | ||
107 | } | ||
108 | set | ||
109 | { | ||
110 | this.versionName = value; | ||
111 | } | ||
112 | } | ||
113 | /// <summary> | ||
114 | /// Gets or sets the version. | ||
115 | /// </summary> | ||
116 | /// <value>The version.</value> | ||
117 | protected VSVersion Version | ||
118 | { | ||
119 | get | ||
120 | { | ||
121 | return this.version; | ||
122 | } | ||
123 | set | ||
124 | { | ||
125 | this.version = value; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | #endregion | ||
130 | |||
131 | #region Constructors | ||
132 | |||
133 | /// <summary> | ||
134 | /// Initializes a new instance of the <see cref="VS2003Target"/> class. | ||
135 | /// </summary> | ||
136 | public VS2003Target() | ||
137 | { | ||
138 | m_Tools = new Hashtable(); | ||
139 | |||
140 | m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); | ||
141 | m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); | ||
142 | } | ||
143 | |||
144 | #endregion | ||
145 | |||
146 | #region Private Methods | ||
147 | |||
148 | private string MakeRefPath(ProjectNode project) | ||
149 | { | ||
150 | string ret = ""; | ||
151 | foreach(ReferencePathNode node in project.ReferencePaths) | ||
152 | { | ||
153 | try | ||
154 | { | ||
155 | string fullPath = Helper.ResolvePath(node.Path); | ||
156 | if(ret.Length < 1) | ||
157 | { | ||
158 | ret = fullPath; | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | ret += ";" + fullPath; | ||
163 | } | ||
164 | } | ||
165 | catch(ArgumentException) | ||
166 | { | ||
167 | m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
175 | { | ||
176 | if(!m_Tools.ContainsKey(project.Language)) | ||
177 | { | ||
178 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
179 | } | ||
180 | |||
181 | ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; | ||
182 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
183 | StreamWriter ps = new StreamWriter(projectFile); | ||
184 | |||
185 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
186 | Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); | ||
187 | |||
188 | IEnumerator enumerator; | ||
189 | //ConfigurationNode scripts; | ||
190 | |||
191 | using(ps) | ||
192 | { | ||
193 | ps.WriteLine("<VisualStudioProject>"); | ||
194 | ps.WriteLine(" <{0}", toolInfo.XmlTag); | ||
195 | ps.WriteLine("\t\t\t\tProjectType = \"Local\""); | ||
196 | ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion); | ||
197 | ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion); | ||
198 | ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); | ||
199 | ps.WriteLine("\t\t>"); | ||
200 | |||
201 | ps.WriteLine("\t\t\t\t<Build>"); | ||
202 | ps.WriteLine(" <Settings"); | ||
203 | ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon); | ||
204 | ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\""); | ||
205 | ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName); | ||
206 | ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\""); | ||
207 | ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\""); | ||
208 | ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\""); | ||
209 | ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\""); | ||
210 | ps.WriteLine("\t\t\t\t DelaySign = \"false\""); | ||
211 | |||
212 | if(this.Version == VSVersion.VS70) | ||
213 | { | ||
214 | ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\""); | ||
215 | } | ||
216 | |||
217 | ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString()); | ||
218 | |||
219 | enumerator = project.Configurations.GetEnumerator(); | ||
220 | enumerator.Reset(); | ||
221 | enumerator.MoveNext(); | ||
222 | foreach(ConfigurationNode conf in project.Configurations) | ||
223 | { | ||
224 | if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) | ||
225 | { | ||
226 | ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]); | ||
231 | } | ||
232 | if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) | ||
233 | { | ||
234 | ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]); | ||
239 | } | ||
240 | if (conf.Options["RunPostBuildEvent"] == null) | ||
241 | { | ||
242 | ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess"); | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]); | ||
247 | } | ||
248 | break; | ||
249 | } | ||
250 | |||
251 | ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace); | ||
252 | ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject); | ||
253 | ps.WriteLine("\t\t >"); | ||
254 | |||
255 | foreach(ConfigurationNode conf in project.Configurations) | ||
256 | { | ||
257 | ps.WriteLine("\t\t\t\t <Config"); | ||
258 | ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name); | ||
259 | ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower()); | ||
260 | ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]); | ||
261 | ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower()); | ||
262 | ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\""); | ||
263 | ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]); | ||
264 | ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name | ||
265 | ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower()); | ||
266 | ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]); | ||
267 | ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower()); | ||
268 | |||
269 | if(this.Version == VSVersion.VS71) | ||
270 | { | ||
271 | ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower()); | ||
272 | ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower()); | ||
273 | } | ||
274 | |||
275 | ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower()); | ||
276 | ps.WriteLine(" OutputPath = \"{0}\"", | ||
277 | Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); | ||
278 | ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower()); | ||
279 | ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower()); | ||
280 | ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower()); | ||
281 | ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]); | ||
282 | ps.WriteLine(" />"); | ||
283 | } | ||
284 | |||
285 | ps.WriteLine(" </Settings>"); | ||
286 | |||
287 | ps.WriteLine(" <References>"); | ||
288 | foreach(ReferenceNode refr in project.References) | ||
289 | { | ||
290 | ps.WriteLine(" <Reference"); | ||
291 | ps.WriteLine(" Name = \"{0}\"", refr.Name); | ||
292 | ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name); | ||
293 | |||
294 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
295 | { | ||
296 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
297 | ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper()); | ||
298 | ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper()); | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | if(refr.Path != null) | ||
303 | { | ||
304 | ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); | ||
305 | } | ||
306 | |||
307 | } | ||
308 | |||
309 | if(refr.LocalCopySpecified) | ||
310 | { | ||
311 | ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy); | ||
312 | } | ||
313 | |||
314 | ps.WriteLine(" />"); | ||
315 | } | ||
316 | ps.WriteLine(" </References>"); | ||
317 | |||
318 | ps.WriteLine(" </Build>"); | ||
319 | ps.WriteLine(" <Files>"); | ||
320 | |||
321 | ps.WriteLine(" <Include>"); | ||
322 | |||
323 | foreach(string file in project.Files) | ||
324 | { | ||
325 | string fileName = file.Replace(".\\", ""); | ||
326 | ps.WriteLine(" <File"); | ||
327 | ps.WriteLine(" RelPath = \"{0}\"", fileName); | ||
328 | ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file)); | ||
329 | ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file)); | ||
330 | ps.WriteLine(" />"); | ||
331 | |||
332 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
333 | { | ||
334 | ps.WriteLine(" <File"); | ||
335 | ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx"); | ||
336 | int slash = fileName.LastIndexOf('\\'); | ||
337 | if (slash == -1) | ||
338 | { | ||
339 | ps.WriteLine(" DependentUpon = \"{0}\"", fileName); | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1)); | ||
344 | } | ||
345 | ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource"); | ||
346 | ps.WriteLine(" />"); | ||
347 | |||
348 | } | ||
349 | } | ||
350 | ps.WriteLine(" </Include>"); | ||
351 | |||
352 | ps.WriteLine(" </Files>"); | ||
353 | ps.WriteLine(" </{0}>", toolInfo.XmlTag); | ||
354 | ps.WriteLine("</VisualStudioProject>"); | ||
355 | } | ||
356 | |||
357 | ps = new StreamWriter(projectFile + ".user"); | ||
358 | using(ps) | ||
359 | { | ||
360 | ps.WriteLine("<VisualStudioProject>"); | ||
361 | ps.WriteLine(" <{0}>", toolInfo.XmlTag); | ||
362 | ps.WriteLine(" <Build>"); | ||
363 | |||
364 | ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); | ||
365 | foreach(ConfigurationNode conf in project.Configurations) | ||
366 | { | ||
367 | ps.WriteLine(" <Config"); | ||
368 | ps.WriteLine(" Name = \"{0}\"", conf.Name); | ||
369 | ps.WriteLine(" />"); | ||
370 | } | ||
371 | ps.WriteLine(" </Settings>"); | ||
372 | |||
373 | ps.WriteLine(" </Build>"); | ||
374 | ps.WriteLine(" </{0}>", toolInfo.XmlTag); | ||
375 | ps.WriteLine("</VisualStudioProject>"); | ||
376 | } | ||
377 | |||
378 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
379 | } | ||
380 | |||
381 | /// <summary> | ||
382 | /// Gets the XML doc file. | ||
383 | /// </summary> | ||
384 | /// <param name="project">The project.</param> | ||
385 | /// <param name="conf">The conf.</param> | ||
386 | /// <returns></returns> | ||
387 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) | ||
388 | { | ||
389 | if( conf == null ) | ||
390 | { | ||
391 | throw new ArgumentNullException("conf"); | ||
392 | } | ||
393 | if( project == null ) | ||
394 | { | ||
395 | throw new ArgumentNullException("project"); | ||
396 | } | ||
397 | // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false | ||
398 | // { | ||
399 | // return string.Empty; | ||
400 | // } | ||
401 | |||
402 | //default to "AssemblyName.xml" | ||
403 | //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; | ||
404 | //return (string)conf.Options["XmlDocFile", defaultValue]; | ||
405 | |||
406 | //default to no XmlDocFile file | ||
407 | return (string)conf.Options["XmlDocFile", ""]; | ||
408 | } | ||
409 | |||
410 | private void WriteSolution(SolutionNode solution) | ||
411 | { | ||
412 | m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName); | ||
413 | |||
414 | foreach(ProjectNode project in solution.Projects) | ||
415 | { | ||
416 | if(m_Kernel.AllowProject(project.FilterGroups)) | ||
417 | { | ||
418 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | ||
419 | WriteProject(solution, project); | ||
420 | } | ||
421 | } | ||
422 | |||
423 | m_Kernel.Log.Write(""); | ||
424 | string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
425 | StreamWriter ss = new StreamWriter(solutionFile); | ||
426 | |||
427 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
428 | Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); | ||
429 | |||
430 | using(ss) | ||
431 | { | ||
432 | ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); | ||
433 | foreach(ProjectNode project in solution.Projects) | ||
434 | { | ||
435 | if(!m_Tools.ContainsKey(project.Language)) | ||
436 | { | ||
437 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
438 | } | ||
439 | |||
440 | ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; | ||
441 | |||
442 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
443 | ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", | ||
444 | toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, | ||
445 | toolInfo.FileExtension), project.Guid.ToString().ToUpper()); | ||
446 | |||
447 | ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); | ||
448 | ss.WriteLine("\tEndProjectSection"); | ||
449 | |||
450 | ss.WriteLine("EndProject"); | ||
451 | } | ||
452 | |||
453 | ss.WriteLine("Global"); | ||
454 | |||
455 | ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); | ||
456 | foreach(ConfigurationNode conf in solution.Configurations) | ||
457 | { | ||
458 | ss.WriteLine("\t\t{0} = {0}", conf.Name); | ||
459 | } | ||
460 | ss.WriteLine("\tEndGlobalSection"); | ||
461 | |||
462 | ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); | ||
463 | foreach(ProjectNode project in solution.Projects) | ||
464 | { | ||
465 | for(int i = 0; i < project.References.Count; i++) | ||
466 | { | ||
467 | ReferenceNode refr = (ReferenceNode)project.References[i]; | ||
468 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
469 | { | ||
470 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
471 | ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", | ||
472 | project.Guid.ToString().ToUpper() | ||
473 | , i, | ||
474 | refProject.Guid.ToString().ToUpper() | ||
475 | ); | ||
476 | } | ||
477 | } | ||
478 | } | ||
479 | ss.WriteLine("\tEndGlobalSection"); | ||
480 | |||
481 | ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); | ||
482 | foreach(ProjectNode project in solution.Projects) | ||
483 | { | ||
484 | foreach(ConfigurationNode conf in solution.Configurations) | ||
485 | { | ||
486 | ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", | ||
487 | project.Guid.ToString().ToUpper(), | ||
488 | conf.Name); | ||
489 | |||
490 | ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", | ||
491 | project.Guid.ToString().ToUpper(), | ||
492 | conf.Name); | ||
493 | } | ||
494 | } | ||
495 | ss.WriteLine("\tEndGlobalSection"); | ||
496 | |||
497 | if(solution.Files != null) | ||
498 | { | ||
499 | ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); | ||
500 | foreach(string file in solution.Files) | ||
501 | { | ||
502 | ss.WriteLine("\t\t{0} = {0}", file); | ||
503 | } | ||
504 | ss.WriteLine("\tEndGlobalSection"); | ||
505 | } | ||
506 | |||
507 | ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); | ||
508 | ss.WriteLine("\tEndGlobalSection"); | ||
509 | ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); | ||
510 | ss.WriteLine("\tEndGlobalSection"); | ||
511 | |||
512 | ss.WriteLine("EndGlobal"); | ||
513 | } | ||
514 | |||
515 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
516 | } | ||
517 | |||
518 | private void CleanProject(ProjectNode project) | ||
519 | { | ||
520 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
521 | |||
522 | ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; | ||
523 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
524 | string userFile = projectFile + ".user"; | ||
525 | |||
526 | Helper.DeleteIfExists(projectFile); | ||
527 | Helper.DeleteIfExists(userFile); | ||
528 | } | ||
529 | |||
530 | private void CleanSolution(SolutionNode solution) | ||
531 | { | ||
532 | m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", this.VersionName, solution.Name); | ||
533 | |||
534 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
535 | string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); | ||
536 | |||
537 | Helper.DeleteIfExists(slnFile); | ||
538 | Helper.DeleteIfExists(suoFile); | ||
539 | |||
540 | foreach(ProjectNode project in solution.Projects) | ||
541 | { | ||
542 | CleanProject(project); | ||
543 | } | ||
544 | |||
545 | m_Kernel.Log.Write(""); | ||
546 | } | ||
547 | |||
548 | #endregion | ||
549 | |||
550 | #region ITarget Members | ||
551 | |||
552 | /// <summary> | ||
553 | /// Writes the specified kern. | ||
554 | /// </summary> | ||
555 | /// <param name="kern">The kern.</param> | ||
556 | public virtual void Write(Kernel kern) | ||
557 | { | ||
558 | if( kern == null ) | ||
559 | { | ||
560 | throw new ArgumentNullException("kern"); | ||
561 | } | ||
562 | m_Kernel = kern; | ||
563 | foreach(SolutionNode sol in m_Kernel.Solutions) | ||
564 | { | ||
565 | WriteSolution(sol); | ||
566 | } | ||
567 | m_Kernel = null; | ||
568 | } | ||
569 | |||
570 | /// <summary> | ||
571 | /// Cleans the specified kern. | ||
572 | /// </summary> | ||
573 | /// <param name="kern">The kern.</param> | ||
574 | public virtual void Clean(Kernel kern) | ||
575 | { | ||
576 | if( kern == null ) | ||
577 | { | ||
578 | throw new ArgumentNullException("kern"); | ||
579 | } | ||
580 | m_Kernel = kern; | ||
581 | foreach(SolutionNode sol in m_Kernel.Solutions) | ||
582 | { | ||
583 | CleanSolution(sol); | ||
584 | } | ||
585 | m_Kernel = null; | ||
586 | } | ||
587 | |||
588 | /// <summary> | ||
589 | /// Gets the name. | ||
590 | /// </summary> | ||
591 | /// <value>The name.</value> | ||
592 | public virtual string Name | ||
593 | { | ||
594 | get | ||
595 | { | ||
596 | return "vs2003"; | ||
597 | } | ||
598 | } | ||
599 | |||
600 | #endregion | ||
601 | } | ||
602 | } | ||