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 | |
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')
-rw-r--r-- | Prebuild/src/Core/Targets/AutotoolsTarget.cs | 926 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/DebugTarget.cs | 102 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/MonoDevelopTarget.cs | 458 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/NAntTarget.cs | 621 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/SharpDevelop2Target.cs | 90 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/SharpDevelopTarget.cs | 437 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2002Target.cs | 96 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2003Target.cs | 633 | ||||
-rw-r--r-- | Prebuild/src/Core/Targets/VS2005Target.cs | 883 |
9 files changed, 4246 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs new file mode 100644 index 0000000..2b4a678 --- /dev/null +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs | |||
@@ -0,0 +1,926 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | |||
4 | Copyright (c) 2004 - 2006 | ||
5 | Matthew Holmes (matthew@wildfiregames.com), | ||
6 | Dan Moorehead (dan05a@gmail.com), | ||
7 | Dave Hudson (jendave@yahoo.com), | ||
8 | C.J. Adams-Collier (cjcollier@colliertech.org), | ||
9 | |||
10 | Redistribution and use in source and binary forms, with or without | ||
11 | modification, are permitted provided that the following conditions are | ||
12 | met: | ||
13 | |||
14 | * Redistributions of source code must retain the above copyright | ||
15 | notice, this list of conditions and the following disclaimer. | ||
16 | |||
17 | * Redistributions in binary form must reproduce the above copyright | ||
18 | notice, this list of conditions and the following disclaimer in the | ||
19 | documentation and/or other materials provided with the distribution. | ||
20 | |||
21 | * The name of the author may not be used to endorse or promote | ||
22 | products derived from this software without specific prior written | ||
23 | permission. | ||
24 | |||
25 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
26 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
28 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
29 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
32 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
33 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
34 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
35 | POSSIBILITY OF SUCH DAMAGE. | ||
36 | |||
37 | */ | ||
38 | #endregion | ||
39 | |||
40 | #region CVS Information | ||
41 | /* | ||
42 | * $Source$ | ||
43 | * $Author: jendave $ | ||
44 | * $Date: 2006-07-28 22:43:24 -0700 (Fri, 28 Jul 2006) $ | ||
45 | * $Revision: 136 $ | ||
46 | */ | ||
47 | #endregion | ||
48 | |||
49 | using System; | ||
50 | using System.Collections; | ||
51 | using System.Collections.Specialized; | ||
52 | using System.IO; | ||
53 | using System.Reflection; | ||
54 | using System.Text; | ||
55 | using System.Text.RegularExpressions; | ||
56 | |||
57 | using Prebuild.Core.Attributes; | ||
58 | using Prebuild.Core.Interfaces; | ||
59 | using Prebuild.Core.Nodes; | ||
60 | using Prebuild.Core.Parse; | ||
61 | using Prebuild.Core.Utilities; | ||
62 | |||
63 | namespace Prebuild.Core.Targets | ||
64 | { | ||
65 | /// <summary> | ||
66 | /// | ||
67 | /// </summary> | ||
68 | [Target("autotools")] | ||
69 | public class AutotoolsTarget : ITarget | ||
70 | { | ||
71 | #region Fields | ||
72 | |||
73 | private Kernel m_Kernel; | ||
74 | |||
75 | #endregion | ||
76 | |||
77 | #region Private Methods | ||
78 | |||
79 | private static string PrependPath(string path) | ||
80 | { | ||
81 | string tmpPath = Helper.NormalizePath(path, '/'); | ||
82 | Regex regex = new Regex(@"(\w):/(\w+)"); | ||
83 | Match match = regex.Match(tmpPath); | ||
84 | if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | ||
85 | { | ||
86 | tmpPath = Helper.NormalizePath(tmpPath); | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | tmpPath = Helper.NormalizePath("./" + tmpPath); | ||
91 | } | ||
92 | |||
93 | return tmpPath; | ||
94 | } | ||
95 | |||
96 | private static string BuildReference(SolutionNode solution, ReferenceNode refr) | ||
97 | { | ||
98 | string ret = ""; | ||
99 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
100 | { | ||
101 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
102 | string fileRef = FindFileReference(refr.Name, project); | ||
103 | string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/$(BUILD_DIR)/$(CONFIG)/", refr.Name, "dll"), '/'); | ||
104 | ret += finalPath; | ||
105 | return ret; | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | ProjectNode project = (ProjectNode)refr.Parent; | ||
110 | string fileRef = FindFileReference(refr.Name, project); | ||
111 | |||
112 | if(refr.Path != null || fileRef != null) | ||
113 | { | ||
114 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; | ||
115 | ret += Path.Combine(project.Path, finalPath); | ||
116 | return ret; | ||
117 | } | ||
118 | |||
119 | try | ||
120 | { | ||
121 | //Assembly assem = Assembly.Load(refr.Name); | ||
122 | //if (assem != null) | ||
123 | //{ | ||
124 | // int index = refr.Name.IndexOf(","); | ||
125 | // if ( index > 0) | ||
126 | // { | ||
127 | // ret += assem.Location; | ||
128 | // //Console.WriteLine("Location1: " + assem.Location); | ||
129 | // } | ||
130 | // else | ||
131 | // { | ||
132 | // ret += (refr.Name + ".dll"); | ||
133 | // //Console.WriteLine("Location2: " + assem.Location); | ||
134 | // } | ||
135 | //} | ||
136 | //else | ||
137 | //{ | ||
138 | int index = refr.Name.IndexOf(","); | ||
139 | if ( index > 0) | ||
140 | { | ||
141 | ret += refr.Name.Substring(0, index) + ".dll"; | ||
142 | //Console.WriteLine("Location3: " + assem.Location); | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | ret += (refr.Name + ".dll"); | ||
147 | //Console.WriteLine("Location4: " + assem.Location); | ||
148 | } | ||
149 | //} | ||
150 | } | ||
151 | catch (System.NullReferenceException e) | ||
152 | { | ||
153 | e.ToString(); | ||
154 | int index = refr.Name.IndexOf(","); | ||
155 | if ( index > 0) | ||
156 | { | ||
157 | ret += refr.Name.Substring(0, index) + ".dll"; | ||
158 | //Console.WriteLine("Location5: " + assem.Location); | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | ret += (refr.Name + ".dll"); | ||
163 | //Console.WriteLine("Location6: " + assem.Location); | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | return ret; | ||
168 | } | ||
169 | |||
170 | private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) | ||
171 | { | ||
172 | string ret = ""; | ||
173 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
174 | { | ||
175 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
176 | string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); | ||
177 | ret += finalPath; | ||
178 | return ret; | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | ProjectNode project = (ProjectNode)refr.Parent; | ||
183 | string fileRef = FindFileReference(refr.Name, project); | ||
184 | |||
185 | |||
186 | if(refr.Path != null || fileRef != null) | ||
187 | { | ||
188 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; | ||
189 | ret += finalPath; | ||
190 | return ret; | ||
191 | } | ||
192 | |||
193 | try | ||
194 | { | ||
195 | Assembly assem = Assembly.Load(refr.Name); | ||
196 | if (assem != null) | ||
197 | { | ||
198 | ret += ""; | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | ret += ""; | ||
203 | } | ||
204 | } | ||
205 | catch (System.NullReferenceException e) | ||
206 | { | ||
207 | e.ToString(); | ||
208 | ret += ""; | ||
209 | } | ||
210 | } | ||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | private static string FindFileReference(string refName, ProjectNode project) | ||
215 | { | ||
216 | foreach(ReferencePathNode refPath in project.ReferencePaths) | ||
217 | { | ||
218 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | ||
219 | |||
220 | if(File.Exists(fullPath)) | ||
221 | { | ||
222 | return fullPath; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | return null; | ||
227 | } | ||
228 | |||
229 | /// <summary> | ||
230 | /// Gets the XML doc file. | ||
231 | /// </summary> | ||
232 | /// <param name="project">The project.</param> | ||
233 | /// <param name="conf">The conf.</param> | ||
234 | /// <returns></returns> | ||
235 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) | ||
236 | { | ||
237 | if( conf == null ) | ||
238 | { | ||
239 | throw new ArgumentNullException("conf"); | ||
240 | } | ||
241 | if( project == null ) | ||
242 | { | ||
243 | throw new ArgumentNullException("project"); | ||
244 | } | ||
245 | string docFile = (string)conf.Options["XmlDocFile"]; | ||
246 | // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | ||
247 | // { | ||
248 | // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; | ||
249 | // } | ||
250 | return docFile; | ||
251 | } | ||
252 | |||
253 | /// <summary> | ||
254 | /// Normalizes the path. | ||
255 | /// </summary> | ||
256 | /// <param name="path">The path.</param> | ||
257 | /// <returns></returns> | ||
258 | public static string NormalizePath(string path) | ||
259 | { | ||
260 | if(path == null) | ||
261 | { | ||
262 | return ""; | ||
263 | } | ||
264 | |||
265 | StringBuilder tmpPath; | ||
266 | |||
267 | if (Core.Parse.Preprocessor.GetOS() == "Win32") | ||
268 | { | ||
269 | tmpPath = new StringBuilder(path.Replace('\\', '/')); | ||
270 | tmpPath.Replace("/", @"\\"); | ||
271 | } | ||
272 | else | ||
273 | { | ||
274 | tmpPath = new StringBuilder(path.Replace('\\', '/')); | ||
275 | tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); | ||
276 | } | ||
277 | return tmpPath.ToString(); | ||
278 | } | ||
279 | |||
280 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
281 | { | ||
282 | string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); | ||
283 | StreamWriter ss = new StreamWriter(projFile); | ||
284 | ss.NewLine = "\n"; | ||
285 | |||
286 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
287 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | ||
288 | |||
289 | using(ss) | ||
290 | { | ||
291 | ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":"); | ||
292 | ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/"); | ||
293 | foreach(string file in project.Files) | ||
294 | { | ||
295 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
296 | { | ||
297 | ss.Write("\tresgen "); | ||
298 | ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/')); | ||
299 | if (project.Files.GetResourceName(file) != "") | ||
300 | { | ||
301 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/')); | ||
302 | } | ||
303 | else | ||
304 | { | ||
305 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/')); | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\"); | ||
310 | ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\"); | ||
311 | if (project.References.Count > 0) | ||
312 | { | ||
313 | ss.Write("\t\t/reference:"); | ||
314 | bool firstref = true; | ||
315 | foreach(ReferenceNode refr in project.References) | ||
316 | { | ||
317 | if (firstref) | ||
318 | { | ||
319 | firstref = false; | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | ss.Write(","); | ||
324 | } | ||
325 | ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/')); | ||
326 | } | ||
327 | ss.WriteLine(" \\"); | ||
328 | } | ||
329 | //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\"); | ||
330 | |||
331 | foreach(string file in project.Files) | ||
332 | { | ||
333 | switch(project.Files.GetBuildAction(file)) | ||
334 | { | ||
335 | case BuildAction.EmbeddedResource: | ||
336 | ss.Write("\t\t/resource:"); | ||
337 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\"); | ||
338 | break; | ||
339 | default: | ||
340 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
341 | { | ||
342 | ss.Write("\t\t/resource:"); | ||
343 | if (project.Files.GetResourceName(file) != "") | ||
344 | { | ||
345 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\"); | ||
346 | } | ||
347 | else | ||
348 | { | ||
349 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\"); | ||
350 | } | ||
351 | } | ||
352 | break; | ||
353 | } | ||
354 | } | ||
355 | |||
356 | foreach(ConfigurationNode conf in project.Configurations) | ||
357 | { | ||
358 | if (conf.Options.KeyFile !="") | ||
359 | { | ||
360 | ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\"); | ||
361 | break; | ||
362 | } | ||
363 | } | ||
364 | foreach(ConfigurationNode conf in project.Configurations) | ||
365 | { | ||
366 | if (conf.Options.AllowUnsafe) | ||
367 | { | ||
368 | ss.WriteLine("\t\t/unsafe \\"); | ||
369 | break; | ||
370 | } | ||
371 | } | ||
372 | if (project.AppIcon != "") | ||
373 | { | ||
374 | ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\"); | ||
375 | } | ||
376 | |||
377 | foreach(ConfigurationNode conf in project.Configurations) | ||
378 | { | ||
379 | ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\"); | ||
380 | break; | ||
381 | } | ||
382 | |||
383 | foreach(ConfigurationNode conf in project.Configurations) | ||
384 | { | ||
385 | if (GetXmlDocFile(project, conf) !="") | ||
386 | { | ||
387 | ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\"); | ||
388 | break; | ||
389 | } | ||
390 | } | ||
391 | foreach(string file in project.Files) | ||
392 | { | ||
393 | switch(project.Files.GetBuildAction(file)) | ||
394 | { | ||
395 | case BuildAction.Compile: | ||
396 | ss.WriteLine("\t\t\\"); | ||
397 | ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file))); | ||
398 | break; | ||
399 | default: | ||
400 | break; | ||
401 | } | ||
402 | } | ||
403 | ss.WriteLine(); | ||
404 | ss.WriteLine(); | ||
405 | |||
406 | if (project.Type == ProjectType.Library) | ||
407 | { | ||
408 | ss.WriteLine("install-data-local:"); | ||
409 | ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\"); | ||
410 | ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;"); | ||
411 | ss.WriteLine(); | ||
412 | ss.WriteLine("uninstall-local:"); | ||
413 | ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\"); | ||
414 | ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;"); | ||
415 | ss.WriteLine(); | ||
416 | } | ||
417 | ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml"); | ||
418 | ss.WriteLine("EXTRA_DIST = \\"); | ||
419 | ss.Write(" $(FILES)"); | ||
420 | foreach(ConfigurationNode conf in project.Configurations) | ||
421 | { | ||
422 | if (conf.Options.KeyFile != "") | ||
423 | { | ||
424 | ss.Write(" \\"); | ||
425 | ss.WriteLine("\t" + conf.Options.KeyFile); | ||
426 | } | ||
427 | break; | ||
428 | } | ||
429 | } | ||
430 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
431 | } | ||
432 | bool hasLibrary = false; | ||
433 | |||
434 | private void WriteCombine(SolutionNode solution) | ||
435 | { | ||
436 | |||
437 | /* TODO: These vars should be pulled from the prebuild.xml file */ | ||
438 | string releaseVersion = "2.0.0"; | ||
439 | string assemblyVersion = "2.1.0.0"; | ||
440 | string description = | ||
441 | "Tao Framework " + solution.Name + " Binding For .NET"; | ||
442 | |||
443 | hasLibrary = false; | ||
444 | m_Kernel.Log.Write("Creating Autotools make files"); | ||
445 | foreach(ProjectNode project in solution.Projects) | ||
446 | { | ||
447 | if(m_Kernel.AllowProject(project.FilterGroups)) | ||
448 | { | ||
449 | m_Kernel.Log.Write("...Creating makefile: {0}", project.Name); | ||
450 | WriteProject(solution, project); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | m_Kernel.Log.Write(""); | ||
455 | string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); | ||
456 | StreamWriter ss = new StreamWriter(combFile); | ||
457 | ss.NewLine = "\n"; | ||
458 | |||
459 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
460 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | ||
461 | |||
462 | using(ss) | ||
463 | { | ||
464 | foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
465 | { | ||
466 | if (project.Type == ProjectType.Library) | ||
467 | { | ||
468 | hasLibrary = true; | ||
469 | break; | ||
470 | } | ||
471 | } | ||
472 | |||
473 | if (hasLibrary) | ||
474 | { | ||
475 | ss.Write("pkgconfig_in_files = "); | ||
476 | foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
477 | { | ||
478 | if (project.Type == ProjectType.Library) | ||
479 | { | ||
480 | string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in"); | ||
481 | ss.Write(" " + project.Name + ".pc.in "); | ||
482 | StreamWriter sspc = new StreamWriter(combFilepc); | ||
483 | sspc.NewLine = "\n"; | ||
484 | using(sspc) | ||
485 | { | ||
486 | sspc.WriteLine("prefix=@prefix@"); | ||
487 | sspc.WriteLine("exec_prefix=${prefix}"); | ||
488 | sspc.WriteLine("libdir=${exec_prefix}/lib"); | ||
489 | sspc.WriteLine(); | ||
490 | sspc.WriteLine("Name: @PACKAGE_NAME@"); | ||
491 | sspc.WriteLine("Description: @DESCRIPTION@"); | ||
492 | sspc.WriteLine("Version: @ASSEMBLY_VERSION@"); | ||
493 | sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll"); | ||
494 | } | ||
495 | } | ||
496 | } | ||
497 | |||
498 | ss.WriteLine(); | ||
499 | ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig"); | ||
500 | ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)"); | ||
501 | } | ||
502 | ss.WriteLine(); | ||
503 | foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
504 | { | ||
505 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
506 | ss.WriteLine("-include x {0}", | ||
507 | Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"),'/')); | ||
508 | } | ||
509 | ss.WriteLine(); | ||
510 | ss.WriteLine("all: \\"); | ||
511 | ss.Write("\t"); | ||
512 | foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
513 | { | ||
514 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
515 | ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " "); | ||
516 | |||
517 | } | ||
518 | ss.WriteLine(); | ||
519 | if (hasLibrary) | ||
520 | { | ||
521 | ss.WriteLine("EXTRA_DIST = \\"); | ||
522 | ss.WriteLine("\t$(pkgconfig_in_files)"); | ||
523 | } | ||
524 | else | ||
525 | { | ||
526 | ss.WriteLine("EXTRA_DIST = "); | ||
527 | } | ||
528 | ss.WriteLine(); | ||
529 | ss.WriteLine("DISTCLEANFILES = \\"); | ||
530 | ss.WriteLine("\tconfigure \\"); | ||
531 | ss.WriteLine("\tMakefile.in \\"); | ||
532 | ss.WriteLine("\taclocal.m4"); | ||
533 | } | ||
534 | combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); | ||
535 | StreamWriter ts = new StreamWriter(combFile); | ||
536 | ts.NewLine = "\n"; | ||
537 | using(ts) | ||
538 | { | ||
539 | if (this.hasLibrary) | ||
540 | { | ||
541 | foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
542 | { | ||
543 | if (project.Type == ProjectType.Library) | ||
544 | { | ||
545 | ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)"); | ||
546 | break; | ||
547 | } | ||
548 | } | ||
549 | } | ||
550 | else | ||
551 | { | ||
552 | ts.WriteLine("AC_INIT(Makefile.am)"); | ||
553 | } | ||
554 | ts.WriteLine("AC_PREREQ(2.53)"); | ||
555 | ts.WriteLine("AC_CANONICAL_SYSTEM"); | ||
556 | |||
557 | ts.WriteLine("PACKAGE_NAME={0}", solution.Name); | ||
558 | ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion); | ||
559 | ts.WriteLine("DESCRIPTION=\"{0}\"", description); | ||
560 | ts.WriteLine("AC_SUBST(DESCRIPTION)"); | ||
561 | ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])"); | ||
562 | |||
563 | ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion); | ||
564 | ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)"); | ||
565 | |||
566 | ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`"); | ||
567 | ts.WriteLine("AC_SUBST(PUBKEY)"); | ||
568 | |||
569 | ts.WriteLine(); | ||
570 | ts.WriteLine("AM_MAINTAINER_MODE"); | ||
571 | ts.WriteLine(); | ||
572 | ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])"); | ||
573 | ts.WriteLine(); | ||
574 | ts.WriteLine("AC_PROG_INSTALL"); | ||
575 | ts.WriteLine(); | ||
576 | ts.WriteLine("MONO_REQUIRED_VERSION=1.1"); | ||
577 | ts.WriteLine(); | ||
578 | ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])"); | ||
579 | ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then"); | ||
580 | ts.WriteLine(" from_cvs=yes"); | ||
581 | ts.WriteLine("else"); | ||
582 | ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then"); | ||
583 | ts.WriteLine(" from_cvs=yes"); | ||
584 | ts.WriteLine(" else"); | ||
585 | ts.WriteLine(" from_cvs=no"); | ||
586 | ts.WriteLine(" fi"); | ||
587 | ts.WriteLine("fi"); | ||
588 | ts.WriteLine(); | ||
589 | ts.WriteLine("AC_MSG_RESULT($from_cvs)"); | ||
590 | ts.WriteLine(); | ||
591 | ts.WriteLine("AC_PATH_PROG(MONO, mono)"); | ||
592 | ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)"); | ||
593 | ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)"); | ||
594 | ts.WriteLine(); | ||
595 | ts.WriteLine("AC_MSG_CHECKING([for mono])"); | ||
596 | ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then"); | ||
597 | ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])"); | ||
598 | ts.WriteLine("dnl else"); | ||
599 | ts.WriteLine(" AC_MSG_RESULT([found])"); | ||
600 | ts.WriteLine("dnl fi"); | ||
601 | ts.WriteLine(); | ||
602 | ts.WriteLine("AC_MSG_CHECKING([for gmcs])"); | ||
603 | ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then"); | ||
604 | ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])"); | ||
605 | ts.WriteLine("dnl else"); | ||
606 | ts.WriteLine(" AC_MSG_RESULT([found])"); | ||
607 | ts.WriteLine("dnl fi"); | ||
608 | ts.WriteLine(); | ||
609 | //ts.WriteLine("AC_MSG_CHECKING([for gacutil])"); | ||
610 | //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then"); | ||
611 | //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])"); | ||
612 | //ts.WriteLine("else"); | ||
613 | //ts.WriteLine(" AC_MSG_RESULT([found])"); | ||
614 | //ts.WriteLine("fi"); | ||
615 | ts.WriteLine(); | ||
616 | ts.WriteLine("AC_SUBST(PATH)"); | ||
617 | ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)"); | ||
618 | ts.WriteLine(); | ||
619 | ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\""); | ||
620 | ts.WriteLine("CSFLAGS=\"\""); | ||
621 | ts.WriteLine("AC_SUBST(CSFLAGS)"); | ||
622 | ts.WriteLine(); | ||
623 | // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)"); | ||
624 | // ts.WriteLine("AC_ARG_ENABLE(sdl,"); | ||
625 | // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],"); | ||
626 | // ts.WriteLine(" [disable_sdl=$disableval],"); | ||
627 | // ts.WriteLine(" [disable_sdl=\"no\"])"); | ||
628 | // ts.WriteLine("AC_MSG_RESULT($disable_sdl)"); | ||
629 | // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then"); | ||
630 | // ts.WriteLine(" AC_DEFINE(FEAT_SDL)"); | ||
631 | // ts.WriteLine("fi"); | ||
632 | ts.WriteLine(); | ||
633 | ts.WriteLine("dnl Find pkg-config"); | ||
634 | ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)"); | ||
635 | ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then"); | ||
636 | ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])"); | ||
637 | ts.WriteLine("fi"); | ||
638 | ts.WriteLine(); | ||
639 | ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)"); | ||
640 | ts.WriteLine("BUILD_DIR=\"bin\""); | ||
641 | ts.WriteLine("AC_SUBST(BUILD_DIR)"); | ||
642 | ts.WriteLine("CONFIG=\"Release\""); | ||
643 | ts.WriteLine("AC_SUBST(CONFIG)"); | ||
644 | ts.WriteLine(); | ||
645 | ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then"); | ||
646 | ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)"); | ||
647 | ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)"); | ||
648 | ts.WriteLine(" if test `uname -s` = \"Darwin\"; then"); | ||
649 | ts.WriteLine(" LIB_PREFIX="); | ||
650 | ts.WriteLine(" LIB_SUFFIX=.dylib"); | ||
651 | ts.WriteLine(" else"); | ||
652 | ts.WriteLine(" LIB_PREFIX=.so"); | ||
653 | ts.WriteLine(" LIB_SUFFIX="); | ||
654 | ts.WriteLine(" fi"); | ||
655 | ts.WriteLine("else"); | ||
656 | ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)"); | ||
657 | ts.WriteLine(" if test x$CSC = \"xno\"; then"); | ||
658 | ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])"); | ||
659 | ts.WriteLine(" else"); | ||
660 | ts.WriteLine(" RUNTIME="); | ||
661 | ts.WriteLine(" LIB_PREFIX="); | ||
662 | ts.WriteLine(" LIB_SUFFIX=.dylib"); | ||
663 | ts.WriteLine(" fi"); | ||
664 | ts.WriteLine("fi"); | ||
665 | ts.WriteLine(); | ||
666 | ts.WriteLine("AC_SUBST(LIB_PREFIX)"); | ||
667 | ts.WriteLine("AC_SUBST(LIB_SUFFIX)"); | ||
668 | ts.WriteLine(); | ||
669 | ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)"); | ||
670 | ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)"); | ||
671 | ts.WriteLine(); | ||
672 | ts.WriteLine("dnl Find monodoc"); | ||
673 | ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0"); | ||
674 | ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)"); | ||
675 | ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)"); | ||
676 | ts.WriteLine(); | ||
677 | ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then"); | ||
678 | ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)"); | ||
679 | ts.WriteLine(" if test x$MONODOC = xno; then"); | ||
680 | ts.WriteLine(" enable_monodoc=no"); | ||
681 | ts.WriteLine(" fi"); | ||
682 | ts.WriteLine("else"); | ||
683 | ts.WriteLine(" MONODOC="); | ||
684 | ts.WriteLine("fi"); | ||
685 | ts.WriteLine(); | ||
686 | ts.WriteLine("AC_SUBST(MONODOC)"); | ||
687 | ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")"); | ||
688 | ts.WriteLine(); | ||
689 | ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)"); | ||
690 | ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then"); | ||
691 | ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])"); | ||
692 | ts.WriteLine("fi"); | ||
693 | ts.WriteLine(); | ||
694 | // foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
695 | // { | ||
696 | // if (project.Type == ProjectType.Library) | ||
697 | // { | ||
698 | // } | ||
699 | // } | ||
700 | ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'"); | ||
701 | ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)"); | ||
702 | ts.WriteLine(); | ||
703 | ts.WriteLine("winbuild=no"); | ||
704 | ts.WriteLine("case \"$host\" in"); | ||
705 | ts.WriteLine(" *-*-mingw*|*-*-cygwin*)"); | ||
706 | ts.WriteLine(" winbuild=yes"); | ||
707 | ts.WriteLine(" ;;"); | ||
708 | ts.WriteLine("esac"); | ||
709 | ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)"); | ||
710 | ts.WriteLine(); | ||
711 | // ts.WriteLine("dnl Check for SDL"); | ||
712 | // ts.WriteLine(); | ||
713 | // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])"); | ||
714 | // ts.WriteLine("have_sdl=no"); | ||
715 | // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then"); | ||
716 | // ts.WriteLine(" have_sdl=yes"); | ||
717 | // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`"); | ||
718 | // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`"); | ||
719 | // ts.WriteLine(" #"); | ||
720 | // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library"); | ||
721 | // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from"); | ||
722 | // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a"); | ||
723 | // ts.WriteLine(" # version of the library also exists in SDL's library installation"); | ||
724 | // ts.WriteLine(" # directory, typically /usr/lib."); | ||
725 | // ts.WriteLine(" #"); | ||
726 | // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`"); | ||
727 | // ts.WriteLine("fi"); | ||
728 | // ts.WriteLine("AC_SUBST([SDL_CFLAGS])"); | ||
729 | // ts.WriteLine("AC_SUBST([SDL_LIBS])"); | ||
730 | ts.WriteLine(); | ||
731 | ts.WriteLine("AC_OUTPUT(["); | ||
732 | ts.WriteLine("Makefile"); | ||
733 | // TODO: this does not work quite right. | ||
734 | //ts.WriteLine("Properties/AssemblyInfo.cs"); | ||
735 | foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
736 | { | ||
737 | if (project.Type == ProjectType.Library) | ||
738 | { | ||
739 | ts.WriteLine(project.Name + ".pc"); | ||
740 | } | ||
741 | // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
742 | // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/')); | ||
743 | } | ||
744 | ts.WriteLine("])"); | ||
745 | ts.WriteLine(); | ||
746 | ts.WriteLine("#po/Makefile.in"); | ||
747 | ts.WriteLine(); | ||
748 | ts.WriteLine("echo \"---\""); | ||
749 | ts.WriteLine("echo \"Configuration summary\""); | ||
750 | ts.WriteLine("echo \"\""); | ||
751 | ts.WriteLine("echo \" * Installation prefix: $prefix\""); | ||
752 | ts.WriteLine("echo \" * compiler: $CSC\""); | ||
753 | ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\""); | ||
754 | ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\""); | ||
755 | ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\""); | ||
756 | ts.WriteLine("echo \" * Public Key: $PUBKEY\""); | ||
757 | ts.WriteLine("echo \"\""); | ||
758 | ts.WriteLine("echo \"---\""); | ||
759 | ts.WriteLine(); | ||
760 | } | ||
761 | |||
762 | ts.NewLine = "\n"; | ||
763 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
764 | { | ||
765 | if (project.GenerateAssemblyInfoFile) | ||
766 | { | ||
767 | GenerateAssemblyInfoFile(solution, combFile); | ||
768 | } | ||
769 | } | ||
770 | } | ||
771 | |||
772 | private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile) | ||
773 | { | ||
774 | System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties")); | ||
775 | combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in"); | ||
776 | StreamWriter ai = new StreamWriter(combFile); | ||
777 | |||
778 | using (ai) | ||
779 | { | ||
780 | ai.WriteLine("#region License"); | ||
781 | ai.WriteLine("/*"); | ||
782 | ai.WriteLine("MIT License"); | ||
783 | ai.WriteLine("Copyright (c)2003-2006 Tao Framework Team"); | ||
784 | ai.WriteLine("http://www.taoframework.com"); | ||
785 | ai.WriteLine("All rights reserved."); | ||
786 | ai.WriteLine(""); | ||
787 | ai.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a copy"); | ||
788 | ai.WriteLine("of this software and associated documentation files (the \"Software\"), to deal"); | ||
789 | ai.WriteLine("in the Software without restriction, including without limitation the rights"); | ||
790 | ai.WriteLine("to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"); | ||
791 | ai.WriteLine("copies of the Software, and to permit persons to whom the Software is"); | ||
792 | ai.WriteLine("furnished to do so, subject to the following conditions:"); | ||
793 | ai.WriteLine(""); | ||
794 | ai.WriteLine("The above copyright notice and this permission notice shall be included in all"); | ||
795 | ai.WriteLine("copies or substantial portions of the Software."); | ||
796 | ai.WriteLine(""); | ||
797 | ai.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); | ||
798 | ai.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); | ||
799 | ai.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); | ||
800 | ai.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); | ||
801 | ai.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); | ||
802 | ai.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); | ||
803 | ai.WriteLine("SOFTWARE."); | ||
804 | ai.WriteLine("*/"); | ||
805 | ai.WriteLine("#endregion License"); | ||
806 | ai.WriteLine(""); | ||
807 | ai.WriteLine("using System;"); | ||
808 | ai.WriteLine("using System.Reflection;"); | ||
809 | ai.WriteLine("using System.Runtime.InteropServices;"); | ||
810 | ai.WriteLine("using System.Security;"); | ||
811 | ai.WriteLine("using System.Security.Permissions;"); | ||
812 | ai.WriteLine(""); | ||
813 | ai.WriteLine("[assembly: AllowPartiallyTrustedCallers]"); | ||
814 | ai.WriteLine("[assembly: AssemblyCompany(\"Tao Framework -- http://www.taoframework.com\")]"); | ||
815 | ai.WriteLine("[assembly: AssemblyConfiguration(\"Retail\")]"); | ||
816 | ai.WriteLine("[assembly: AssemblyCopyright(\"Copyright (c)2003-2006 Tao Framework Team. All rights reserved.\")]"); | ||
817 | ai.WriteLine("[assembly: AssemblyCulture(\"\")]"); | ||
818 | ai.WriteLine("[assembly: AssemblyDefaultAlias(\"@PACKAGE_NAME@\")]"); | ||
819 | ai.WriteLine("[assembly: AssemblyDelaySign(false)]"); | ||
820 | ai.WriteLine("[assembly: AssemblyDescription(\"@DESCRIPTION@\")]"); | ||
821 | ai.WriteLine("[assembly: AssemblyFileVersion(\"@ASSEMBLY_VERSION@\")]"); | ||
822 | ai.WriteLine("[assembly: AssemblyInformationalVersion(\"@ASSEMBLY_VERSION@\")]"); | ||
823 | ai.WriteLine("[assembly: AssemblyKeyName(\"\")]"); | ||
824 | ai.WriteLine("[assembly: AssemblyProduct(\"@PACKAGE_NAME@.dll\")]"); | ||
825 | ai.WriteLine("[assembly: AssemblyTitle(\"@DESCRIPTION@\")]"); | ||
826 | ai.WriteLine("[assembly: AssemblyTrademark(\"Tao Framework -- http://www.taoframework.com\")]"); | ||
827 | ai.WriteLine("[assembly: AssemblyVersion(\"@ASSEMBLY_VERSION@\")]"); | ||
828 | ai.WriteLine("[assembly: CLSCompliant(true)]"); | ||
829 | ai.WriteLine("[assembly: ComVisible(false)]"); | ||
830 | ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]"); | ||
831 | ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.SkipVerification)]"); | ||
832 | ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.UnmanagedCode)]"); | ||
833 | |||
834 | } | ||
835 | //return combFile; | ||
836 | } | ||
837 | |||
838 | private void CleanProject(ProjectNode project) | ||
839 | { | ||
840 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
841 | string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); | ||
842 | Helper.DeleteIfExists(projectFile); | ||
843 | } | ||
844 | |||
845 | private void CleanSolution(SolutionNode solution) | ||
846 | { | ||
847 | m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); | ||
848 | |||
849 | string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); | ||
850 | Helper.DeleteIfExists(slnFile); | ||
851 | |||
852 | slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); | ||
853 | Helper.DeleteIfExists(slnFile); | ||
854 | |||
855 | slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); | ||
856 | Helper.DeleteIfExists(slnFile); | ||
857 | |||
858 | slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); | ||
859 | Helper.DeleteIfExists(slnFile); | ||
860 | |||
861 | slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); | ||
862 | Helper.DeleteIfExists(slnFile); | ||
863 | |||
864 | foreach(ProjectNode project in solution.Projects) | ||
865 | { | ||
866 | CleanProject(project); | ||
867 | } | ||
868 | |||
869 | m_Kernel.Log.Write(""); | ||
870 | } | ||
871 | |||
872 | #endregion | ||
873 | |||
874 | #region ITarget Members | ||
875 | |||
876 | /// <summary> | ||
877 | /// Writes the specified kern. | ||
878 | /// </summary> | ||
879 | /// <param name="kern">The kern.</param> | ||
880 | public void Write(Kernel kern) | ||
881 | { | ||
882 | if( kern == null ) | ||
883 | { | ||
884 | throw new ArgumentNullException("kern"); | ||
885 | } | ||
886 | m_Kernel = kern; | ||
887 | foreach(SolutionNode solution in kern.Solutions) | ||
888 | { | ||
889 | WriteCombine(solution); | ||
890 | } | ||
891 | m_Kernel = null; | ||
892 | } | ||
893 | |||
894 | /// <summary> | ||
895 | /// Cleans the specified kern. | ||
896 | /// </summary> | ||
897 | /// <param name="kern">The kern.</param> | ||
898 | public virtual void Clean(Kernel kern) | ||
899 | { | ||
900 | if( kern == null ) | ||
901 | { | ||
902 | throw new ArgumentNullException("kern"); | ||
903 | } | ||
904 | m_Kernel = kern; | ||
905 | foreach(SolutionNode sol in kern.Solutions) | ||
906 | { | ||
907 | CleanSolution(sol); | ||
908 | } | ||
909 | m_Kernel = null; | ||
910 | } | ||
911 | |||
912 | /// <summary> | ||
913 | /// Gets the name. | ||
914 | /// </summary> | ||
915 | /// <value>The name.</value> | ||
916 | public string Name | ||
917 | { | ||
918 | get | ||
919 | { | ||
920 | return "autotools"; | ||
921 | } | ||
922 | } | ||
923 | |||
924 | #endregion | ||
925 | } | ||
926 | } | ||
diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs new file mode 100644 index 0000000..6baa623 --- /dev/null +++ b/Prebuild/src/Core/Targets/DebugTarget.cs | |||
@@ -0,0 +1,102 @@ | |||
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-20 09:42:51 +0200 (on, 20 sep 2006) $ | ||
31 | * $Revision: 164 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | |||
37 | using Prebuild.Core.Attributes; | ||
38 | using Prebuild.Core.Interfaces; | ||
39 | using Prebuild.Core.Nodes; | ||
40 | |||
41 | #if (DEBUG && _DEBUG_TARGET) | ||
42 | namespace Prebuild.Core.Targets | ||
43 | { | ||
44 | [Target("debug")] | ||
45 | public class DebugTarget : ITarget | ||
46 | { | ||
47 | #region Fields | ||
48 | |||
49 | private Kernel m_Kernel = null; | ||
50 | |||
51 | #endregion | ||
52 | |||
53 | #region ITarget Members | ||
54 | |||
55 | public void Write() | ||
56 | { | ||
57 | foreach(SolutionNode s in m_Kernel.Solutions) | ||
58 | { | ||
59 | Console.WriteLine("Solution [ {0}, {1} ]", s.Name, s.Path); | ||
60 | foreach(string file in s.Files) | ||
61 | { | ||
62 | Console.WriteLine("\tFile [ {0} ]", file); | ||
63 | } | ||
64 | |||
65 | foreach(ProjectNode proj in s.Projects) | ||
66 | { | ||
67 | Console.WriteLine("\tProject [ {0}, {1}. {2} ]", proj.Name, proj.Path, proj.Language); | ||
68 | foreach(string file in proj.Files) | ||
69 | Console.WriteLine("\t\tFile [ {0} ]", file); | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | |||
74 | public void Clean() | ||
75 | { | ||
76 | Console.WriteLine("Not implemented"); | ||
77 | } | ||
78 | |||
79 | public string Name | ||
80 | { | ||
81 | get | ||
82 | { | ||
83 | return "debug"; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | public Kernel Kernel | ||
88 | { | ||
89 | get | ||
90 | { | ||
91 | return m_Kernel; | ||
92 | } | ||
93 | set | ||
94 | { | ||
95 | m_Kernel = value; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | #endregion | ||
100 | } | ||
101 | } | ||
102 | #endif | ||
diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs new file mode 100644 index 0000000..8620e4b --- /dev/null +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs | |||
@@ -0,0 +1,458 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004 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: 2007-02-13 22:07:07 +0100 (ti, 13 feb 2007) $ | ||
31 | * $Revision: 206 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.IO; | ||
39 | using System.Reflection; | ||
40 | using System.Text.RegularExpressions; | ||
41 | |||
42 | using Prebuild.Core.Attributes; | ||
43 | using Prebuild.Core.Interfaces; | ||
44 | using Prebuild.Core.Nodes; | ||
45 | using Prebuild.Core.Utilities; | ||
46 | |||
47 | namespace Prebuild.Core.Targets | ||
48 | { | ||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | [Target("monodev")] | ||
53 | public class MonoDevelopTarget : ITarget | ||
54 | { | ||
55 | #region Fields | ||
56 | |||
57 | private Kernel m_Kernel; | ||
58 | |||
59 | #endregion | ||
60 | |||
61 | #region Private Methods | ||
62 | |||
63 | private static string PrependPath(string path) | ||
64 | { | ||
65 | string tmpPath = Helper.NormalizePath(path, '/'); | ||
66 | Regex regex = new Regex(@"(\w):/(\w+)"); | ||
67 | Match match = regex.Match(tmpPath); | ||
68 | if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | ||
69 | { | ||
70 | tmpPath = Helper.NormalizePath(tmpPath); | ||
71 | } | ||
72 | else | ||
73 | { | ||
74 | tmpPath = Helper.NormalizePath("./" + tmpPath); | ||
75 | } | ||
76 | |||
77 | return tmpPath; | ||
78 | } | ||
79 | |||
80 | private static string BuildReference(SolutionNode solution, ReferenceNode refr) | ||
81 | { | ||
82 | string ret = "<ProjectReference type=\""; | ||
83 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
84 | { | ||
85 | ret += "Project\""; | ||
86 | ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />"; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | ProjectNode project = (ProjectNode)refr.Parent; | ||
91 | string fileRef = FindFileReference(refr.Name, project); | ||
92 | |||
93 | if(refr.Path != null || fileRef != null) | ||
94 | { | ||
95 | ret += "Assembly\" refto=\""; | ||
96 | |||
97 | string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; | ||
98 | |||
99 | ret += finalPath; | ||
100 | ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; | ||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | ret += "Gac\""; | ||
105 | ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; | ||
106 | ret += " refto=\""; | ||
107 | try | ||
108 | { | ||
109 | //Assembly assem = Assembly.Load(refr.Name); | ||
110 | //ret += assem.FullName; | ||
111 | ret += refr.Name; | ||
112 | } | ||
113 | catch (System.NullReferenceException e) | ||
114 | { | ||
115 | e.ToString(); | ||
116 | ret += refr.Name; | ||
117 | } | ||
118 | ret += "\" />"; | ||
119 | } | ||
120 | |||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | private static string FindFileReference(string refName, ProjectNode project) | ||
125 | { | ||
126 | foreach(ReferencePathNode refPath in project.ReferencePaths) | ||
127 | { | ||
128 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | ||
129 | |||
130 | if(File.Exists(fullPath)) | ||
131 | { | ||
132 | return fullPath; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | return null; | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// Gets the XML doc file. | ||
141 | /// </summary> | ||
142 | /// <param name="project">The project.</param> | ||
143 | /// <param name="conf">The conf.</param> | ||
144 | /// <returns></returns> | ||
145 | public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) | ||
146 | { | ||
147 | if( conf == null ) | ||
148 | { | ||
149 | throw new ArgumentNullException("conf"); | ||
150 | } | ||
151 | if( project == null ) | ||
152 | { | ||
153 | throw new ArgumentNullException("project"); | ||
154 | } | ||
155 | string docFile = (string)conf.Options["XmlDocFile"]; | ||
156 | if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | ||
157 | { | ||
158 | return "False"; | ||
159 | } | ||
160 | return "True"; | ||
161 | } | ||
162 | |||
163 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
164 | { | ||
165 | string csComp = "Mcs"; | ||
166 | string netRuntime = "Mono"; | ||
167 | if(project.Runtime == ClrRuntime.Microsoft) | ||
168 | { | ||
169 | csComp = "Csc"; | ||
170 | netRuntime = "MsNet"; | ||
171 | } | ||
172 | |||
173 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); | ||
174 | StreamWriter ss = new StreamWriter(projFile); | ||
175 | |||
176 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
177 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | ||
178 | |||
179 | using(ss) | ||
180 | { | ||
181 | ss.WriteLine( | ||
182 | "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">", | ||
183 | project.Name, | ||
184 | project.RootNamespace | ||
185 | ); | ||
186 | |||
187 | int count = 0; | ||
188 | |||
189 | ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig); | ||
190 | |||
191 | foreach(ConfigurationNode conf in project.Configurations) | ||
192 | { | ||
193 | ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name); | ||
194 | ss.Write(" <Output"); | ||
195 | ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString()))); | ||
196 | ss.Write(" assembly=\"{0}\"", project.AssemblyName); | ||
197 | ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]); | ||
198 | //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); | ||
199 | //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); | ||
200 | if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) | ||
201 | { | ||
202 | ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); | ||
207 | } | ||
208 | if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) | ||
209 | { | ||
210 | ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); | ||
215 | } | ||
216 | ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); | ||
217 | ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); | ||
218 | ss.WriteLine(" />"); | ||
219 | |||
220 | ss.Write(" <Build"); | ||
221 | ss.Write(" debugmode=\"True\""); | ||
222 | if (project.Type == ProjectType.WinExe) | ||
223 | { | ||
224 | ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString()); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | ss.Write(" target=\"{0}\"", project.Type); | ||
229 | } | ||
230 | ss.WriteLine(" />"); | ||
231 | |||
232 | ss.Write(" <Execution"); | ||
233 | ss.Write(" runwithwarnings=\"True\""); | ||
234 | ss.Write(" consolepause=\"True\""); | ||
235 | ss.Write(" runtime=\"{0}\"", netRuntime); | ||
236 | ss.Write(" clr-version=\"Net_2_0\""); | ||
237 | ss.WriteLine(" />"); | ||
238 | |||
239 | ss.Write(" <CodeGeneration"); | ||
240 | ss.Write(" compiler=\"{0}\"", csComp); | ||
241 | ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]); | ||
242 | ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]); | ||
243 | ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]); | ||
244 | ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]); | ||
245 | ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]); | ||
246 | ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]); | ||
247 | ss.Write(" mainclass=\"{0}\"", project.StartupObject); | ||
248 | ss.Write(" target=\"{0}\"", project.Type); | ||
249 | ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]); | ||
250 | ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf)); | ||
251 | ss.Write(" win32Icon=\"{0}\"", project.AppIcon); | ||
252 | ss.Write(" ctype=\"CSharpCompilerParameters\""); | ||
253 | ss.WriteLine(" />"); | ||
254 | ss.WriteLine(" </Configuration>"); | ||
255 | |||
256 | count++; | ||
257 | } | ||
258 | ss.WriteLine(" </Configurations>"); | ||
259 | |||
260 | ss.Write(" <DeploymentInformation"); | ||
261 | ss.Write(" target=\"\""); | ||
262 | ss.Write(" script=\"\""); | ||
263 | ss.Write(" strategy=\"File\""); | ||
264 | ss.WriteLine(">"); | ||
265 | ss.WriteLine(" <excludeFiles />"); | ||
266 | ss.WriteLine(" </DeploymentInformation>"); | ||
267 | |||
268 | ss.WriteLine(" <Contents>"); | ||
269 | foreach(string file in project.Files) | ||
270 | { | ||
271 | string buildAction = "Compile"; | ||
272 | switch(project.Files.GetBuildAction(file)) | ||
273 | { | ||
274 | case BuildAction.None: | ||
275 | buildAction = "Nothing"; | ||
276 | break; | ||
277 | |||
278 | case BuildAction.Content: | ||
279 | buildAction = "Exclude"; | ||
280 | break; | ||
281 | |||
282 | case BuildAction.EmbeddedResource: | ||
283 | buildAction = "EmbedAsResource"; | ||
284 | break; | ||
285 | |||
286 | default: | ||
287 | buildAction = "Compile"; | ||
288 | break; | ||
289 | } | ||
290 | |||
291 | // Sort of a hack, we try and resolve the path and make it relative, if we can. | ||
292 | string filePath = PrependPath(file); | ||
293 | ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction); | ||
294 | } | ||
295 | ss.WriteLine(" </Contents>"); | ||
296 | |||
297 | ss.WriteLine(" <References>"); | ||
298 | foreach(ReferenceNode refr in project.References) | ||
299 | { | ||
300 | ss.WriteLine(" {0}", BuildReference(solution, refr)); | ||
301 | } | ||
302 | ss.WriteLine(" </References>"); | ||
303 | |||
304 | |||
305 | ss.WriteLine("</Project>"); | ||
306 | } | ||
307 | |||
308 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
309 | } | ||
310 | |||
311 | private void WriteCombine(SolutionNode solution) | ||
312 | { | ||
313 | m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); | ||
314 | foreach(ProjectNode project in solution.Projects) | ||
315 | { | ||
316 | if(m_Kernel.AllowProject(project.FilterGroups)) | ||
317 | { | ||
318 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | ||
319 | WriteProject(solution, project); | ||
320 | } | ||
321 | } | ||
322 | |||
323 | m_Kernel.Log.Write(""); | ||
324 | string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); | ||
325 | StreamWriter ss = new StreamWriter(combFile); | ||
326 | |||
327 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
328 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | ||
329 | |||
330 | int count = 0; | ||
331 | |||
332 | using(ss) | ||
333 | { | ||
334 | ss.WriteLine("<Combine name=\"{0}\" fileversion=\"2.0\" description=\"\">", solution.Name); | ||
335 | |||
336 | count = 0; | ||
337 | foreach(ConfigurationNode conf in solution.Configurations) | ||
338 | { | ||
339 | if(count == 0) | ||
340 | { | ||
341 | ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name); | ||
342 | } | ||
343 | |||
344 | ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"CombineConfiguration\">", conf.Name); | ||
345 | foreach(ProjectNode project in solution.Projects) | ||
346 | { | ||
347 | ss.WriteLine(" <Entry configuration=\"{1}\" build=\"True\" name=\"{0}\" />", project.Name, conf.Name); | ||
348 | } | ||
349 | ss.WriteLine(" </Configuration>"); | ||
350 | |||
351 | count++; | ||
352 | } | ||
353 | ss.WriteLine(" </Configurations>"); | ||
354 | |||
355 | count = 0; | ||
356 | |||
357 | foreach(ProjectNode project in solution.Projects) | ||
358 | { | ||
359 | if(count == 0) | ||
360 | ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name); | ||
361 | |||
362 | ss.WriteLine(" <Execute type=\"None\" entry=\"{0}\" />", project.Name); | ||
363 | count++; | ||
364 | } | ||
365 | ss.WriteLine(" </StartMode>"); | ||
366 | |||
367 | ss.WriteLine(" <Entries>"); | ||
368 | foreach(ProjectNode project in solution.Projects) | ||
369 | { | ||
370 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
371 | ss.WriteLine(" <Entry filename=\"{0}\" />", | ||
372 | Helper.MakeFilePath(path, project.Name, "mdp")); | ||
373 | } | ||
374 | ss.WriteLine(" </Entries>"); | ||
375 | |||
376 | ss.WriteLine("</Combine>"); | ||
377 | } | ||
378 | |||
379 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
380 | } | ||
381 | |||
382 | private void CleanProject(ProjectNode project) | ||
383 | { | ||
384 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
385 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); | ||
386 | Helper.DeleteIfExists(projectFile); | ||
387 | } | ||
388 | |||
389 | private void CleanSolution(SolutionNode solution) | ||
390 | { | ||
391 | m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name); | ||
392 | |||
393 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); | ||
394 | Helper.DeleteIfExists(slnFile); | ||
395 | |||
396 | foreach(ProjectNode project in solution.Projects) | ||
397 | { | ||
398 | CleanProject(project); | ||
399 | } | ||
400 | |||
401 | m_Kernel.Log.Write(""); | ||
402 | } | ||
403 | |||
404 | #endregion | ||
405 | |||
406 | #region ITarget Members | ||
407 | |||
408 | /// <summary> | ||
409 | /// Writes the specified kern. | ||
410 | /// </summary> | ||
411 | /// <param name="kern">The kern.</param> | ||
412 | public void Write(Kernel kern) | ||
413 | { | ||
414 | if( kern == null ) | ||
415 | { | ||
416 | throw new ArgumentNullException("kern"); | ||
417 | } | ||
418 | m_Kernel = kern; | ||
419 | foreach(SolutionNode solution in kern.Solutions) | ||
420 | { | ||
421 | WriteCombine(solution); | ||
422 | } | ||
423 | m_Kernel = null; | ||
424 | } | ||
425 | |||
426 | /// <summary> | ||
427 | /// Cleans the specified kern. | ||
428 | /// </summary> | ||
429 | /// <param name="kern">The kern.</param> | ||
430 | public virtual void Clean(Kernel kern) | ||
431 | { | ||
432 | if( kern == null ) | ||
433 | { | ||
434 | throw new ArgumentNullException("kern"); | ||
435 | } | ||
436 | m_Kernel = kern; | ||
437 | foreach(SolutionNode sol in kern.Solutions) | ||
438 | { | ||
439 | CleanSolution(sol); | ||
440 | } | ||
441 | m_Kernel = null; | ||
442 | } | ||
443 | |||
444 | /// <summary> | ||
445 | /// Gets the name. | ||
446 | /// </summary> | ||
447 | /// <value>The name.</value> | ||
448 | public string Name | ||
449 | { | ||
450 | get | ||
451 | { | ||
452 | return "sharpdev"; | ||
453 | } | ||
454 | } | ||
455 | |||
456 | #endregion | ||
457 | } | ||
458 | } | ||
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs new file mode 100644 index 0000000..0f0deb2 --- /dev/null +++ b/Prebuild/src/Core/Targets/NAntTarget.cs | |||
@@ -0,0 +1,621 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004 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: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ | ||
31 | * $Revision: 205 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.IO; | ||
39 | using System.Reflection; | ||
40 | using System.Text.RegularExpressions; | ||
41 | |||
42 | using Prebuild.Core.Attributes; | ||
43 | using Prebuild.Core.Interfaces; | ||
44 | using Prebuild.Core.Nodes; | ||
45 | using Prebuild.Core.Utilities; | ||
46 | |||
47 | namespace Prebuild.Core.Targets | ||
48 | { | ||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | [Target("nant")] | ||
53 | public class NAntTarget : ITarget | ||
54 | { | ||
55 | #region Fields | ||
56 | |||
57 | private Kernel m_Kernel; | ||
58 | |||
59 | #endregion | ||
60 | |||
61 | #region Private Methods | ||
62 | |||
63 | private static string PrependPath(string path) | ||
64 | { | ||
65 | string tmpPath = Helper.NormalizePath(path, '/'); | ||
66 | Regex regex = new Regex(@"(\w):/(\w+)"); | ||
67 | Match match = regex.Match(tmpPath); | ||
68 | //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | ||
69 | //{ | ||
70 | tmpPath = Helper.NormalizePath(tmpPath); | ||
71 | //} | ||
72 | // else | ||
73 | // { | ||
74 | // tmpPath = Helper.NormalizePath("./" + tmpPath); | ||
75 | // } | ||
76 | |||
77 | return tmpPath; | ||
78 | } | ||
79 | |||
80 | private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr) | ||
81 | { | ||
82 | string ret = ""; | ||
83 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
84 | { | ||
85 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
86 | |||
87 | string finalPath = Helper.NormalizePath(((ReferencePathNode)currentProject.ReferencePaths[0]).Path + refr.Name + ".dll", '/'); | ||
88 | |||
89 | return finalPath; | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | ProjectNode project = (ProjectNode)refr.Parent; | ||
94 | string fileRef = FindFileReference(refr.Name, project); | ||
95 | |||
96 | if(refr.Path != null || fileRef != null) | ||
97 | { | ||
98 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; | ||
99 | ret += finalPath; | ||
100 | return ret; | ||
101 | } | ||
102 | |||
103 | try | ||
104 | { | ||
105 | //Assembly assem = Assembly.Load(refr.Name); | ||
106 | //if (assem != null) | ||
107 | //{ | ||
108 | //ret += (refr.Name + ".dll"); | ||
109 | //} | ||
110 | //else | ||
111 | //{ | ||
112 | ret += (refr.Name + ".dll"); | ||
113 | //} | ||
114 | } | ||
115 | catch (System.NullReferenceException e) | ||
116 | { | ||
117 | e.ToString(); | ||
118 | ret += refr.Name + ".dll"; | ||
119 | } | ||
120 | } | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) | ||
125 | { | ||
126 | string ret = ""; | ||
127 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
128 | { | ||
129 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
130 | string finalPath = Helper.NormalizePath(((ReferencePathNode)project.ReferencePaths[0]).Path, '/'); | ||
131 | |||
132 | return finalPath; | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | ProjectNode project = (ProjectNode)refr.Parent; | ||
137 | string fileRef = FindFileReference(refr.Name, project); | ||
138 | |||
139 | if(refr.Path != null || fileRef != null) | ||
140 | { | ||
141 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; | ||
142 | ret += finalPath; | ||
143 | return ret; | ||
144 | } | ||
145 | |||
146 | try | ||
147 | { | ||
148 | Assembly assem = Assembly.Load(refr.Name); | ||
149 | if (assem != null) | ||
150 | { | ||
151 | ret += ""; | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | ret += ""; | ||
156 | } | ||
157 | } | ||
158 | catch (System.NullReferenceException e) | ||
159 | { | ||
160 | e.ToString(); | ||
161 | ret += ""; | ||
162 | } | ||
163 | } | ||
164 | return ret; | ||
165 | } | ||
166 | |||
167 | private static string FindFileReference(string refName, ProjectNode project) | ||
168 | { | ||
169 | foreach(ReferencePathNode refPath in project.ReferencePaths) | ||
170 | { | ||
171 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | ||
172 | |||
173 | if(File.Exists(fullPath)) | ||
174 | { | ||
175 | return fullPath; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | return null; | ||
180 | } | ||
181 | |||
182 | /// <summary> | ||
183 | /// Gets the XML doc file. | ||
184 | /// </summary> | ||
185 | /// <param name="project">The project.</param> | ||
186 | /// <param name="conf">The conf.</param> | ||
187 | /// <returns></returns> | ||
188 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) | ||
189 | { | ||
190 | if( conf == null ) | ||
191 | { | ||
192 | throw new ArgumentNullException("conf"); | ||
193 | } | ||
194 | if( project == null ) | ||
195 | { | ||
196 | throw new ArgumentNullException("project"); | ||
197 | } | ||
198 | string docFile = (string)conf.Options["XmlDocFile"]; | ||
199 | // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | ||
200 | // { | ||
201 | // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; | ||
202 | // } | ||
203 | return docFile; | ||
204 | } | ||
205 | |||
206 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
207 | { | ||
208 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); | ||
209 | StreamWriter ss = new StreamWriter(projFile); | ||
210 | |||
211 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
212 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | ||
213 | bool hasDoc = false; | ||
214 | |||
215 | using(ss) | ||
216 | { | ||
217 | ss.WriteLine("<?xml version=\"1.0\" ?>"); | ||
218 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); | ||
219 | ss.WriteLine(" <target name=\"{0}\">", "build"); | ||
220 | ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); | ||
221 | ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); | ||
222 | ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">"); | ||
223 | ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); | ||
224 | foreach(ReferenceNode refr in project.References) | ||
225 | { | ||
226 | if (refr.LocalCopy) | ||
227 | { | ||
228 | ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr))+"\" />", '/')); | ||
229 | } | ||
230 | } | ||
231 | ss.WriteLine(" </fileset>"); | ||
232 | ss.WriteLine(" </copy>"); | ||
233 | ss.Write(" <csc"); | ||
234 | ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); | ||
235 | ss.Write(" debug=\"{0}\"", "${build.debug}"); | ||
236 | foreach(ConfigurationNode conf in project.Configurations) | ||
237 | { | ||
238 | if (conf.Options.KeyFile !="") | ||
239 | { | ||
240 | ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); | ||
241 | break; | ||
242 | } | ||
243 | } | ||
244 | foreach(ConfigurationNode conf in project.Configurations) | ||
245 | { | ||
246 | ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); | ||
247 | break; | ||
248 | } | ||
249 | foreach(ConfigurationNode conf in project.Configurations) | ||
250 | { | ||
251 | ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); | ||
252 | break; | ||
253 | } | ||
254 | foreach(ConfigurationNode conf in project.Configurations) | ||
255 | { | ||
256 | if (GetXmlDocFile(project, conf) !="") | ||
257 | { | ||
258 | ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); | ||
259 | hasDoc = true; | ||
260 | } | ||
261 | break; | ||
262 | } | ||
263 | ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); | ||
264 | if (project.Type == ProjectType.Library) | ||
265 | { | ||
266 | ss.Write(".dll\""); | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | ss.Write(".exe\""); | ||
271 | } | ||
272 | if(project.AppIcon != null && project.AppIcon.Length != 0) | ||
273 | { | ||
274 | ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon,'/')); | ||
275 | } | ||
276 | ss.WriteLine(">"); | ||
277 | ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); | ||
278 | foreach (string file in project.Files) | ||
279 | { | ||
280 | switch (project.Files.GetBuildAction(file)) | ||
281 | { | ||
282 | case BuildAction.EmbeddedResource: | ||
283 | ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
284 | break; | ||
285 | default: | ||
286 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
287 | { | ||
288 | ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
289 | } | ||
290 | break; | ||
291 | } | ||
292 | } | ||
293 | //if (project.Files.GetSubType(file).ToString() != "Code") | ||
294 | //{ | ||
295 | // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
296 | |||
297 | ss.WriteLine(" </resources>"); | ||
298 | ss.WriteLine(" <sources failonempty=\"true\">"); | ||
299 | foreach(string file in project.Files) | ||
300 | { | ||
301 | switch(project.Files.GetBuildAction(file)) | ||
302 | { | ||
303 | case BuildAction.Compile: | ||
304 | ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
305 | break; | ||
306 | default: | ||
307 | break; | ||
308 | } | ||
309 | } | ||
310 | ss.WriteLine(" </sources>"); | ||
311 | ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); | ||
312 | ss.WriteLine(" <lib>"); | ||
313 | ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); | ||
314 | ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />"); | ||
315 | ss.WriteLine(" </lib>"); | ||
316 | foreach(ReferenceNode refr in project.References) | ||
317 | { | ||
318 | string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/'); | ||
319 | ss.WriteLine(" <include name=\""+ path + "\" />" ); | ||
320 | } | ||
321 | ss.WriteLine(" </references>"); | ||
322 | |||
323 | ss.WriteLine(" </csc>"); | ||
324 | |||
325 | foreach (ConfigurationNode conf in project.Configurations) | ||
326 | { | ||
327 | if (!String.IsNullOrEmpty(conf.Options.OutputPath)) | ||
328 | { | ||
329 | string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/'); | ||
330 | |||
331 | ss.WriteLine(" <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" + targetDir + "\" />"); | ||
332 | |||
333 | ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>"); | ||
334 | |||
335 | ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">"); | ||
336 | ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >"); | ||
337 | ss.WriteLine(" <include name=\"*.dll\"/>"); | ||
338 | ss.WriteLine(" <include name=\"*.exe\"/>"); | ||
339 | ss.WriteLine(" </fileset>"); | ||
340 | ss.WriteLine(" </copy>"); | ||
341 | break; | ||
342 | } | ||
343 | } | ||
344 | |||
345 | ss.WriteLine(" </target>"); | ||
346 | |||
347 | ss.WriteLine(" <target name=\"clean\">"); | ||
348 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); | ||
349 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); | ||
350 | ss.WriteLine(" </target>"); | ||
351 | |||
352 | ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); | ||
353 | if (hasDoc) | ||
354 | { | ||
355 | ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); | ||
356 | ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); | ||
357 | ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); | ||
358 | ss.WriteLine(" </if>"); | ||
359 | ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); | ||
360 | ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); | ||
361 | ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); | ||
362 | if (project.Type == ProjectType.Library) | ||
363 | { | ||
364 | ss.WriteLine(".dll\" />"); | ||
365 | } | ||
366 | else | ||
367 | { | ||
368 | ss.WriteLine(".exe\" />"); | ||
369 | } | ||
370 | |||
371 | ss.WriteLine(" </assemblies>"); | ||
372 | ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); | ||
373 | ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); | ||
374 | ss.WriteLine(" </summaries>"); | ||
375 | ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); | ||
376 | ss.WriteLine(" <include name=\"${build.dir}\" />"); | ||
377 | // foreach(ReferenceNode refr in project.References) | ||
378 | // { | ||
379 | // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); | ||
380 | // if (path != "") | ||
381 | // { | ||
382 | // ss.WriteLine(" <include name=\"{0}\" />", path); | ||
383 | // } | ||
384 | // } | ||
385 | ss.WriteLine(" </referencepaths>"); | ||
386 | ss.WriteLine(" <documenters>"); | ||
387 | ss.WriteLine(" <documenter name=\"MSDN\">"); | ||
388 | ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); | ||
389 | ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); | ||
390 | ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); | ||
391 | ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); | ||
392 | ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); | ||
393 | ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); | ||
394 | ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); | ||
395 | ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); | ||
396 | ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); | ||
397 | ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); | ||
398 | ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); | ||
399 | ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); | ||
400 | ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); | ||
401 | ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); | ||
402 | ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); | ||
403 | ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); | ||
404 | ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); | ||
405 | ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); | ||
406 | ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); | ||
407 | ss.WriteLine(" </documenter>"); | ||
408 | ss.WriteLine(" </documenters>"); | ||
409 | ss.WriteLine(" </ndoc>"); | ||
410 | } | ||
411 | ss.WriteLine(" </target>"); | ||
412 | ss.WriteLine("</project>"); | ||
413 | } | ||
414 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
415 | } | ||
416 | |||
417 | private void WriteCombine(SolutionNode solution) | ||
418 | { | ||
419 | m_Kernel.Log.Write("Creating NAnt build files"); | ||
420 | foreach(ProjectNode project in solution.Projects) | ||
421 | { | ||
422 | if(m_Kernel.AllowProject(project.FilterGroups)) | ||
423 | { | ||
424 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | ||
425 | WriteProject(solution, project); | ||
426 | } | ||
427 | } | ||
428 | |||
429 | m_Kernel.Log.Write(""); | ||
430 | string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); | ||
431 | StreamWriter ss = new StreamWriter(combFile); | ||
432 | |||
433 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
434 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | ||
435 | |||
436 | using(ss) | ||
437 | { | ||
438 | ss.WriteLine("<?xml version=\"1.0\" ?>"); | ||
439 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); | ||
440 | ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); | ||
441 | ss.WriteLine(); | ||
442 | |||
443 | //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); | ||
444 | //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); | ||
445 | ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); | ||
446 | ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); | ||
447 | ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); | ||
448 | ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); | ||
449 | |||
450 | foreach(ConfigurationNode conf in solution.Configurations) | ||
451 | { | ||
452 | // Set the project.config to a non-debug configuration | ||
453 | if( conf.Options["DebugInformation"].ToString().ToLower() != "true" ) | ||
454 | { | ||
455 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); | ||
456 | } | ||
457 | ss.WriteLine(); | ||
458 | ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name); | ||
459 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); | ||
460 | ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); | ||
461 | ss.WriteLine(" </target>"); | ||
462 | ss.WriteLine(); | ||
463 | } | ||
464 | |||
465 | ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); | ||
466 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); | ||
467 | ss.WriteLine(" </target>"); | ||
468 | ss.WriteLine(); | ||
469 | |||
470 | ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); | ||
471 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); | ||
472 | ss.WriteLine(" </target>"); | ||
473 | ss.WriteLine(); | ||
474 | |||
475 | ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">"); | ||
476 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />"); | ||
477 | ss.WriteLine(" </target>"); | ||
478 | ss.WriteLine(); | ||
479 | |||
480 | ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); | ||
481 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); | ||
482 | ss.WriteLine(" </target>"); | ||
483 | ss.WriteLine(); | ||
484 | |||
485 | ss.WriteLine(" <target name=\"init\" description=\"\">"); | ||
486 | ss.WriteLine(" <call target=\"${project.config}\" />"); | ||
487 | ss.WriteLine(" <sysinfo />"); | ||
488 | ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />"); | ||
489 | ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />"); | ||
490 | ss.WriteLine(" </target>"); | ||
491 | ss.WriteLine(); | ||
492 | |||
493 | ss.WriteLine(" <target name=\"clean\" description=\"\">"); | ||
494 | ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />"); | ||
495 | //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />"); | ||
496 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); | ||
497 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); | ||
498 | foreach(ProjectNode project in solution.Projects) | ||
499 | { | ||
500 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
501 | ss.Write(" <nant buildfile=\"{0}\"", | ||
502 | Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/')); | ||
503 | ss.WriteLine(" target=\"clean\" />"); | ||
504 | } | ||
505 | ss.WriteLine(" </target>"); | ||
506 | ss.WriteLine(); | ||
507 | |||
508 | ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">"); | ||
509 | |||
510 | foreach(ProjectNode project in solution.ProjectsTableOrder) | ||
511 | { | ||
512 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
513 | ss.Write(" <nant buildfile=\"{0}\"", | ||
514 | Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/')); | ||
515 | ss.WriteLine(" target=\"build\" />"); | ||
516 | } | ||
517 | ss.WriteLine(" </target>"); | ||
518 | ss.WriteLine(); | ||
519 | |||
520 | ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />"); | ||
521 | ss.WriteLine(); | ||
522 | ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />"); | ||
523 | ss.WriteLine(); | ||
524 | //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />"); | ||
525 | ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />"); | ||
526 | ss.WriteLine(); | ||
527 | |||
528 | ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">"); | ||
529 | ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />"); | ||
530 | foreach (ProjectNode project in solution.Projects) | ||
531 | { | ||
532 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
533 | ss.Write(" <nant buildfile=\"{0}\"", | ||
534 | Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); | ||
535 | ss.WriteLine(" target=\"doc\" />"); | ||
536 | } | ||
537 | ss.WriteLine(" </target>"); | ||
538 | ss.WriteLine(); | ||
539 | ss.WriteLine("</project>"); | ||
540 | } | ||
541 | |||
542 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
543 | } | ||
544 | |||
545 | private void CleanProject(ProjectNode project) | ||
546 | { | ||
547 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
548 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); | ||
549 | Helper.DeleteIfExists(projectFile); | ||
550 | } | ||
551 | |||
552 | private void CleanSolution(SolutionNode solution) | ||
553 | { | ||
554 | m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name); | ||
555 | |||
556 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); | ||
557 | Helper.DeleteIfExists(slnFile); | ||
558 | |||
559 | foreach(ProjectNode project in solution.Projects) | ||
560 | { | ||
561 | CleanProject(project); | ||
562 | } | ||
563 | |||
564 | m_Kernel.Log.Write(""); | ||
565 | } | ||
566 | |||
567 | #endregion | ||
568 | |||
569 | #region ITarget Members | ||
570 | |||
571 | /// <summary> | ||
572 | /// Writes the specified kern. | ||
573 | /// </summary> | ||
574 | /// <param name="kern">The kern.</param> | ||
575 | public void Write(Kernel kern) | ||
576 | { | ||
577 | if( kern == null ) | ||
578 | { | ||
579 | throw new ArgumentNullException("kern"); | ||
580 | } | ||
581 | m_Kernel = kern; | ||
582 | foreach(SolutionNode solution in kern.Solutions) | ||
583 | { | ||
584 | WriteCombine(solution); | ||
585 | } | ||
586 | m_Kernel = null; | ||
587 | } | ||
588 | |||
589 | /// <summary> | ||
590 | /// Cleans the specified kern. | ||
591 | /// </summary> | ||
592 | /// <param name="kern">The kern.</param> | ||
593 | public virtual void Clean(Kernel kern) | ||
594 | { | ||
595 | if( kern == null ) | ||
596 | { | ||
597 | throw new ArgumentNullException("kern"); | ||
598 | } | ||
599 | m_Kernel = kern; | ||
600 | foreach(SolutionNode sol in kern.Solutions) | ||
601 | { | ||
602 | CleanSolution(sol); | ||
603 | } | ||
604 | m_Kernel = null; | ||
605 | } | ||
606 | |||
607 | /// <summary> | ||
608 | /// Gets the name. | ||
609 | /// </summary> | ||
610 | /// <value>The name.</value> | ||
611 | public string Name | ||
612 | { | ||
613 | get | ||
614 | { | ||
615 | return "nant"; | ||
616 | } | ||
617 | } | ||
618 | |||
619 | #endregion | ||
620 | } | ||
621 | } | ||
diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs new file mode 100644 index 0000000..bc84b96 --- /dev/null +++ b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs | |||
@@ -0,0 +1,90 @@ | |||
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-01-27 16:49:58 -0800 (Fri, 27 Jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | |||
37 | using Prebuild.Core.Attributes; | ||
38 | |||
39 | namespace Prebuild.Core.Targets | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// | ||
43 | /// </summary> | ||
44 | [Target("sharpdev2")] | ||
45 | public class SharpDevelop2Target : VS2005Target | ||
46 | { | ||
47 | #region Private Methods | ||
48 | private void SetSharpDevelop2() | ||
49 | { | ||
50 | this.VersionName = "SharpDevelop2"; | ||
51 | } | ||
52 | #endregion | ||
53 | |||
54 | #region Public Methods | ||
55 | |||
56 | /// <summary> | ||
57 | /// Writes the specified kern. | ||
58 | /// </summary> | ||
59 | /// <param name="kern">The kern.</param> | ||
60 | public override void Write(Kernel kern) | ||
61 | { | ||
62 | SetSharpDevelop2(); | ||
63 | base.Write(kern); | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// Cleans the specified kern. | ||
68 | /// </summary> | ||
69 | /// <param name="kern">The kern.</param> | ||
70 | public override void Clean(Kernel kern) | ||
71 | { | ||
72 | SetSharpDevelop2(); | ||
73 | base.Clean(kern); | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Gets the name. | ||
78 | /// </summary> | ||
79 | /// <value>The name.</value> | ||
80 | public override string Name | ||
81 | { | ||
82 | get | ||
83 | { | ||
84 | return "sharpdev2"; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | #endregion | ||
89 | } | ||
90 | } | ||
diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs new file mode 100644 index 0000000..c725730 --- /dev/null +++ b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs | |||
@@ -0,0 +1,437 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004 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: 2007-02-13 21:58:03 +0100 (ti, 13 feb 2007) $ | ||
31 | * $Revision: 205 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.IO; | ||
39 | using System.Text.RegularExpressions; | ||
40 | using System.Reflection; | ||
41 | |||
42 | using Prebuild.Core.Attributes; | ||
43 | using Prebuild.Core.Interfaces; | ||
44 | using Prebuild.Core.Nodes; | ||
45 | using Prebuild.Core.Utilities; | ||
46 | |||
47 | namespace Prebuild.Core.Targets | ||
48 | { | ||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | [Target("sharpdev")] | ||
53 | public class SharpDevelopTarget : ITarget | ||
54 | { | ||
55 | #region Fields | ||
56 | |||
57 | private Kernel m_Kernel; | ||
58 | |||
59 | #endregion | ||
60 | |||
61 | #region Private Methods | ||
62 | |||
63 | private static string PrependPath(string path) | ||
64 | { | ||
65 | string tmpPath = Helper.NormalizePath(path, '/'); | ||
66 | Regex regex = new Regex(@"(\w):/(\w+)"); | ||
67 | Match match = regex.Match(tmpPath); | ||
68 | if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | ||
69 | { | ||
70 | tmpPath = Helper.NormalizePath(tmpPath); | ||
71 | } | ||
72 | else | ||
73 | { | ||
74 | tmpPath = Helper.NormalizePath("./" + tmpPath); | ||
75 | } | ||
76 | |||
77 | return tmpPath; | ||
78 | } | ||
79 | |||
80 | private static string BuildReference(SolutionNode solution, ReferenceNode refr) | ||
81 | { | ||
82 | string ret = "<Reference type=\""; | ||
83 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | ||
84 | { | ||
85 | ret += "Project\" refto=\"" + refr.Name; | ||
86 | ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | ProjectNode project = (ProjectNode)refr.Parent; | ||
91 | string fileRef = FindFileReference(refr.Name, project); | ||
92 | |||
93 | if(refr.Path != null || fileRef != null) | ||
94 | { | ||
95 | ret += "Assembly\" refto=\""; | ||
96 | |||
97 | string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; | ||
98 | |||
99 | ret += finalPath; | ||
100 | ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; | ||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | ret += "Gac\" refto=\""; | ||
105 | try | ||
106 | { | ||
107 | //Assembly assem = Assembly.Load(refr.Name); | ||
108 | ret += refr.Name;// assem.FullName; | ||
109 | } | ||
110 | catch (System.NullReferenceException e) | ||
111 | { | ||
112 | e.ToString(); | ||
113 | ret += refr.Name; | ||
114 | } | ||
115 | ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; | ||
116 | } | ||
117 | |||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | private static string FindFileReference(string refName, ProjectNode project) | ||
122 | { | ||
123 | foreach(ReferencePathNode refPath in project.ReferencePaths) | ||
124 | { | ||
125 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | ||
126 | |||
127 | if(File.Exists(fullPath)) | ||
128 | { | ||
129 | return fullPath; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | return null; | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Gets the XML doc file. | ||
138 | /// </summary> | ||
139 | /// <param name="project">The project.</param> | ||
140 | /// <param name="conf">The conf.</param> | ||
141 | /// <returns></returns> | ||
142 | public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) | ||
143 | { | ||
144 | if( conf == null ) | ||
145 | { | ||
146 | throw new ArgumentNullException("conf"); | ||
147 | } | ||
148 | if( project == null ) | ||
149 | { | ||
150 | throw new ArgumentNullException("project"); | ||
151 | } | ||
152 | string docFile = (string)conf.Options["XmlDocFile"]; | ||
153 | if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | ||
154 | { | ||
155 | return "False"; | ||
156 | } | ||
157 | return "True"; | ||
158 | } | ||
159 | |||
160 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
161 | { | ||
162 | string csComp = "Csc"; | ||
163 | string netRuntime = "MsNet"; | ||
164 | if(project.Runtime == ClrRuntime.Mono) | ||
165 | { | ||
166 | csComp = "Mcs"; | ||
167 | netRuntime = "Mono"; | ||
168 | } | ||
169 | |||
170 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); | ||
171 | StreamWriter ss = new StreamWriter(projFile); | ||
172 | |||
173 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
174 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | ||
175 | |||
176 | using(ss) | ||
177 | { | ||
178 | ss.WriteLine( | ||
179 | "<Project name=\"{0}\" standardNamespace=\"{1}\" description=\"\" newfilesearch=\"None\" enableviewstate=\"True\" version=\"1.1\" projecttype=\"C#\">", | ||
180 | project.Name, | ||
181 | project.RootNamespace | ||
182 | ); | ||
183 | |||
184 | ss.WriteLine(" <Contents>"); | ||
185 | foreach(string file in project.Files) | ||
186 | { | ||
187 | string buildAction = "Compile"; | ||
188 | switch(project.Files.GetBuildAction(file)) | ||
189 | { | ||
190 | case BuildAction.None: | ||
191 | buildAction = "Nothing"; | ||
192 | break; | ||
193 | |||
194 | case BuildAction.Content: | ||
195 | buildAction = "Exclude"; | ||
196 | break; | ||
197 | |||
198 | case BuildAction.EmbeddedResource: | ||
199 | buildAction = "EmbedAsResource"; | ||
200 | break; | ||
201 | |||
202 | default: | ||
203 | buildAction = "Compile"; | ||
204 | break; | ||
205 | } | ||
206 | |||
207 | // Sort of a hack, we try and resolve the path and make it relative, if we can. | ||
208 | string filePath = PrependPath(file); | ||
209 | ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction); | ||
210 | } | ||
211 | ss.WriteLine(" </Contents>"); | ||
212 | |||
213 | ss.WriteLine(" <References>"); | ||
214 | foreach(ReferenceNode refr in project.References) | ||
215 | { | ||
216 | ss.WriteLine(" {0}", BuildReference(solution, refr)); | ||
217 | } | ||
218 | ss.WriteLine(" </References>"); | ||
219 | |||
220 | ss.Write(" <DeploymentInformation"); | ||
221 | ss.Write(" target=\"\""); | ||
222 | ss.Write(" script=\"\""); | ||
223 | ss.Write(" strategy=\"File\""); | ||
224 | ss.WriteLine(" />"); | ||
225 | |||
226 | int count = 0; | ||
227 | |||
228 | ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig); | ||
229 | |||
230 | foreach(ConfigurationNode conf in project.Configurations) | ||
231 | { | ||
232 | ss.Write(" <Configuration"); | ||
233 | ss.Write(" runwithwarnings=\"True\""); | ||
234 | ss.Write(" name=\"{0}\"", conf.Name); | ||
235 | ss.WriteLine(">"); | ||
236 | ss.Write(" <CodeGeneration"); | ||
237 | ss.Write(" runtime=\"{0}\"", netRuntime); | ||
238 | ss.Write(" compiler=\"{0}\"", csComp); | ||
239 | ss.Write(" compilerversion=\"\""); | ||
240 | ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]); | ||
241 | ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]); | ||
242 | ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]); | ||
243 | ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]); | ||
244 | ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]); | ||
245 | ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]); | ||
246 | ss.Write(" mainclass=\"{0}\"", project.StartupObject); | ||
247 | ss.Write(" target=\"{0}\"", project.Type); | ||
248 | ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]); | ||
249 | ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf)); | ||
250 | ss.Write(" win32Icon=\"{0}\"", Helper.NormalizePath(".\\" + project.AppIcon)); | ||
251 | ss.Write(" noconfig=\"{0}\"", "False"); | ||
252 | ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]); | ||
253 | ss.WriteLine(" />"); | ||
254 | |||
255 | ss.Write(" <Execution"); | ||
256 | ss.Write(" commandlineparameters=\"\""); | ||
257 | ss.Write(" consolepause=\"True\""); | ||
258 | ss.WriteLine(" />"); | ||
259 | |||
260 | ss.Write(" <Output"); | ||
261 | ss.Write(" directory=\".\\{0}\"", Helper.NormalizePath(conf.Options["OutputPath"].ToString())); | ||
262 | ss.Write(" assembly=\"{0}\"", project.AssemblyName); | ||
263 | ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]); | ||
264 | if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) | ||
265 | { | ||
266 | ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); | ||
271 | } | ||
272 | if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) | ||
273 | { | ||
274 | ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); | ||
275 | } | ||
276 | else | ||
277 | { | ||
278 | ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); | ||
279 | } | ||
280 | ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); | ||
281 | ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); | ||
282 | ss.WriteLine(" />"); | ||
283 | ss.WriteLine(" </Configuration>"); | ||
284 | |||
285 | count++; | ||
286 | } | ||
287 | ss.WriteLine(" </Configurations>"); | ||
288 | ss.WriteLine("</Project>"); | ||
289 | } | ||
290 | |||
291 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
292 | } | ||
293 | |||
294 | private void WriteCombine(SolutionNode solution) | ||
295 | { | ||
296 | m_Kernel.Log.Write("Creating SharpDevelop combine and project files"); | ||
297 | foreach(ProjectNode project in solution.Projects) | ||
298 | { | ||
299 | if(m_Kernel.AllowProject(project.FilterGroups)) | ||
300 | { | ||
301 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | ||
302 | WriteProject(solution, project); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | m_Kernel.Log.Write(""); | ||
307 | string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); | ||
308 | StreamWriter ss = new StreamWriter(combFile); | ||
309 | |||
310 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
311 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | ||
312 | |||
313 | using(ss) | ||
314 | { | ||
315 | ss.WriteLine("<Combine fileversion=\"1.0\" name=\"{0}\" description=\"\">", solution.Name); | ||
316 | |||
317 | int count = 0; | ||
318 | foreach(ProjectNode project in solution.Projects) | ||
319 | { | ||
320 | if(count == 0) | ||
321 | ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name); | ||
322 | |||
323 | ss.WriteLine(" <Execute entry=\"{0}\" type=\"None\" />", project.Name); | ||
324 | count++; | ||
325 | } | ||
326 | ss.WriteLine(" </StartMode>"); | ||
327 | |||
328 | ss.WriteLine(" <Entries>"); | ||
329 | foreach(ProjectNode project in solution.Projects) | ||
330 | { | ||
331 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
332 | ss.WriteLine(" <Entry filename=\"{0}\" />", | ||
333 | Helper.MakeFilePath(path, project.Name, "prjx")); | ||
334 | } | ||
335 | ss.WriteLine(" </Entries>"); | ||
336 | |||
337 | count = 0; | ||
338 | foreach(ConfigurationNode conf in solution.Configurations) | ||
339 | { | ||
340 | if(count == 0) | ||
341 | { | ||
342 | ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name); | ||
343 | } | ||
344 | |||
345 | ss.WriteLine(" <Configuration name=\"{0}\">", conf.Name); | ||
346 | foreach(ProjectNode project in solution.Projects) | ||
347 | { | ||
348 | ss.WriteLine(" <Entry name=\"{0}\" configurationname=\"{1}\" build=\"True\" />", project.Name, conf.Name); | ||
349 | } | ||
350 | ss.WriteLine(" </Configuration>"); | ||
351 | |||
352 | count++; | ||
353 | } | ||
354 | ss.WriteLine(" </Configurations>"); | ||
355 | ss.WriteLine("</Combine>"); | ||
356 | } | ||
357 | |||
358 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
359 | } | ||
360 | |||
361 | private void CleanProject(ProjectNode project) | ||
362 | { | ||
363 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
364 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx"); | ||
365 | Helper.DeleteIfExists(projectFile); | ||
366 | } | ||
367 | |||
368 | private void CleanSolution(SolutionNode solution) | ||
369 | { | ||
370 | m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name); | ||
371 | |||
372 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx"); | ||
373 | Helper.DeleteIfExists(slnFile); | ||
374 | |||
375 | foreach(ProjectNode project in solution.Projects) | ||
376 | { | ||
377 | CleanProject(project); | ||
378 | } | ||
379 | |||
380 | m_Kernel.Log.Write(""); | ||
381 | } | ||
382 | |||
383 | #endregion | ||
384 | |||
385 | #region ITarget Members | ||
386 | |||
387 | /// <summary> | ||
388 | /// Writes the specified kern. | ||
389 | /// </summary> | ||
390 | /// <param name="kern">The kern.</param> | ||
391 | public void Write(Kernel kern) | ||
392 | { | ||
393 | if( kern == null ) | ||
394 | { | ||
395 | throw new ArgumentNullException("kern"); | ||
396 | } | ||
397 | m_Kernel = kern; | ||
398 | foreach(SolutionNode solution in kern.Solutions) | ||
399 | { | ||
400 | WriteCombine(solution); | ||
401 | } | ||
402 | m_Kernel = null; | ||
403 | } | ||
404 | |||
405 | /// <summary> | ||
406 | /// Cleans the specified kern. | ||
407 | /// </summary> | ||
408 | /// <param name="kern">The kern.</param> | ||
409 | public virtual void Clean(Kernel kern) | ||
410 | { | ||
411 | if( kern == null ) | ||
412 | { | ||
413 | throw new ArgumentNullException("kern"); | ||
414 | } | ||
415 | m_Kernel = kern; | ||
416 | foreach(SolutionNode sol in kern.Solutions) | ||
417 | { | ||
418 | CleanSolution(sol); | ||
419 | } | ||
420 | m_Kernel = null; | ||
421 | } | ||
422 | |||
423 | /// <summary> | ||
424 | /// Gets the name. | ||
425 | /// </summary> | ||
426 | /// <value>The name.</value> | ||
427 | public string Name | ||
428 | { | ||
429 | get | ||
430 | { | ||
431 | return "sharpdev"; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | #endregion | ||
436 | } | ||
437 | } | ||
diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs new file mode 100644 index 0000000..66216dc --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2002Target.cs | |||
@@ -0,0 +1,96 @@ | |||
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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $ | ||
31 | * $Revision: 71 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | |||
37 | using Prebuild.Core.Attributes; | ||
38 | |||
39 | namespace Prebuild.Core.Targets | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// | ||
43 | /// </summary> | ||
44 | [Target("vs2002")] | ||
45 | public class VS2002Target : VS2003Target | ||
46 | { | ||
47 | #region Private Methods | ||
48 | |||
49 | private void SetVS2002() | ||
50 | { | ||
51 | this.SolutionVersion = "7.00"; | ||
52 | this.ProductVersion = "7.0.9254"; | ||
53 | this.SchemaVersion = "1.0"; | ||
54 | this.VersionName = "2002"; | ||
55 | this.Version = VSVersion.VS70; | ||
56 | } | ||
57 | |||
58 | #endregion | ||
59 | |||
60 | #region Public Methods | ||
61 | |||
62 | /// <summary> | ||
63 | /// Writes the specified kern. | ||
64 | /// </summary> | ||
65 | /// <param name="kern">The kern.</param> | ||
66 | public override void Write(Kernel kern) | ||
67 | { | ||
68 | SetVS2002(); | ||
69 | base.Write(kern); | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Cleans the specified kern. | ||
74 | /// </summary> | ||
75 | /// <param name="kern">The kern.</param> | ||
76 | public override void Clean(Kernel kern) | ||
77 | { | ||
78 | SetVS2002(); | ||
79 | base.Clean(kern); | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// Gets the name. | ||
84 | /// </summary> | ||
85 | /// <value>The name.</value> | ||
86 | public override string Name | ||
87 | { | ||
88 | get | ||
89 | { | ||
90 | return "vs2002"; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | #endregion | ||
95 | } | ||
96 | } | ||
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 | } | ||
diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs new file mode 100644 index 0000000..23b6116 --- /dev/null +++ b/Prebuild/src/Core/Targets/VS2005Target.cs | |||
@@ -0,0 +1,883 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.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: robloach $ | ||
30 | * $Date: 2007-02-27 19:52:34 +0100 (ti, 27 feb 2007) $ | ||
31 | * $Revision: 207 $ | ||
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 struct ToolInfo | ||
51 | { | ||
52 | string name; | ||
53 | string guid; | ||
54 | string fileExtension; | ||
55 | string xmlTag; | ||
56 | string importProject; | ||
57 | |||
58 | /// <summary> | ||
59 | /// Gets or sets the name. | ||
60 | /// </summary> | ||
61 | /// <value>The name.</value> | ||
62 | public string Name | ||
63 | { | ||
64 | get | ||
65 | { | ||
66 | return name; | ||
67 | } | ||
68 | set | ||
69 | { | ||
70 | name = value; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Gets or sets the GUID. | ||
76 | /// </summary> | ||
77 | /// <value>The GUID.</value> | ||
78 | public string Guid | ||
79 | { | ||
80 | get | ||
81 | { | ||
82 | return guid; | ||
83 | } | ||
84 | set | ||
85 | { | ||
86 | guid = value; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | /// <summary> | ||
91 | /// Gets or sets the file extension. | ||
92 | /// </summary> | ||
93 | /// <value>The file extension.</value> | ||
94 | public string FileExtension | ||
95 | { | ||
96 | get | ||
97 | { | ||
98 | return fileExtension; | ||
99 | } | ||
100 | set | ||
101 | { | ||
102 | fileExtension = value; | ||
103 | } | ||
104 | } | ||
105 | /// <summary> | ||
106 | /// Gets or sets the XML tag. | ||
107 | /// </summary> | ||
108 | /// <value>The XML tag.</value> | ||
109 | public string XmlTag | ||
110 | { | ||
111 | get | ||
112 | { | ||
113 | return xmlTag; | ||
114 | } | ||
115 | set | ||
116 | { | ||
117 | xmlTag = value; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Gets or sets the import project property. | ||
123 | /// </summary> | ||
124 | /// <value>The ImportProject tag.</value> | ||
125 | public string ImportProject | ||
126 | { | ||
127 | get | ||
128 | { | ||
129 | return importProject; | ||
130 | } | ||
131 | set | ||
132 | { | ||
133 | importProject = value; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Initializes a new instance of the <see cref="ToolInfo"/> class. | ||
139 | /// </summary> | ||
140 | /// <param name="name">The name.</param> | ||
141 | /// <param name="guid">The GUID.</param> | ||
142 | /// <param name="fileExtension">The file extension.</param> | ||
143 | /// <param name="xml">The XML.</param> | ||
144 | /// <param name="importProject">The import project.</param> | ||
145 | public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject) | ||
146 | { | ||
147 | this.name = name; | ||
148 | this.guid = guid; | ||
149 | this.fileExtension = fileExtension; | ||
150 | this.xmlTag = xml; | ||
151 | this.importProject = importProject; | ||
152 | } | ||
153 | |||
154 | /// <summary> | ||
155 | /// Initializes a new instance of the <see cref="ToolInfo"/> class. | ||
156 | /// </summary> | ||
157 | /// <param name="name">The name.</param> | ||
158 | /// <param name="guid">The GUID.</param> | ||
159 | /// <param name="fileExtension">The file extension.</param> | ||
160 | /// <param name="xml">The XML.</param> | ||
161 | public ToolInfo(string name, string guid, string fileExtension, string xml) | ||
162 | { | ||
163 | this.name = name; | ||
164 | this.guid = guid; | ||
165 | this.fileExtension = fileExtension; | ||
166 | this.xmlTag = xml; | ||
167 | this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets"; | ||
168 | } | ||
169 | |||
170 | /// <summary> | ||
171 | /// Equals operator | ||
172 | /// </summary> | ||
173 | /// <param name="obj">ToolInfo to compare</param> | ||
174 | /// <returns>true if toolInfos are equal</returns> | ||
175 | public override bool Equals(object obj) | ||
176 | { | ||
177 | if (obj == null) | ||
178 | { | ||
179 | throw new ArgumentNullException("obj"); | ||
180 | } | ||
181 | if (obj.GetType() != typeof(ToolInfo)) | ||
182 | return false; | ||
183 | |||
184 | ToolInfo c = (ToolInfo)obj; | ||
185 | return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); | ||
186 | } | ||
187 | |||
188 | /// <summary> | ||
189 | /// Equals operator | ||
190 | /// </summary> | ||
191 | /// <param name="c1">ToolInfo to compare</param> | ||
192 | /// <param name="c2">ToolInfo to compare</param> | ||
193 | /// <returns>True if toolInfos are equal</returns> | ||
194 | public static bool operator ==(ToolInfo c1, ToolInfo c2) | ||
195 | { | ||
196 | return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag)); | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// Not equals operator | ||
201 | /// </summary> | ||
202 | /// <param name="c1">ToolInfo to compare</param> | ||
203 | /// <param name="c2">ToolInfo to compare</param> | ||
204 | /// <returns>True if toolInfos are not equal</returns> | ||
205 | public static bool operator !=(ToolInfo c1, ToolInfo c2) | ||
206 | { | ||
207 | return !(c1 == c2); | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Hash Code | ||
212 | /// </summary> | ||
213 | /// <returns>Hash code</returns> | ||
214 | public override int GetHashCode() | ||
215 | { | ||
216 | return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode(); | ||
217 | |||
218 | } | ||
219 | } | ||
220 | |||
221 | /// <summary> | ||
222 | /// | ||
223 | /// </summary> | ||
224 | [Target("vs2005")] | ||
225 | public class VS2005Target : ITarget | ||
226 | { | ||
227 | #region Inner Classes | ||
228 | |||
229 | #endregion | ||
230 | |||
231 | #region Fields | ||
232 | |||
233 | string solutionVersion = "9.00"; | ||
234 | string productVersion = "8.0.50727"; | ||
235 | string schemaVersion = "2.0"; | ||
236 | string versionName = "Visual C# 2005"; | ||
237 | VSVersion version = VSVersion.VS80; | ||
238 | |||
239 | Hashtable tools; | ||
240 | Kernel kernel; | ||
241 | |||
242 | /// <summary> | ||
243 | /// Gets or sets the solution version. | ||
244 | /// </summary> | ||
245 | /// <value>The solution version.</value> | ||
246 | protected string SolutionVersion | ||
247 | { | ||
248 | get | ||
249 | { | ||
250 | return this.solutionVersion; | ||
251 | } | ||
252 | set | ||
253 | { | ||
254 | this.solutionVersion = value; | ||
255 | } | ||
256 | } | ||
257 | /// <summary> | ||
258 | /// Gets or sets the product version. | ||
259 | /// </summary> | ||
260 | /// <value>The product version.</value> | ||
261 | protected string ProductVersion | ||
262 | { | ||
263 | get | ||
264 | { | ||
265 | return this.productVersion; | ||
266 | } | ||
267 | set | ||
268 | { | ||
269 | this.productVersion = value; | ||
270 | } | ||
271 | } | ||
272 | /// <summary> | ||
273 | /// Gets or sets the schema version. | ||
274 | /// </summary> | ||
275 | /// <value>The schema version.</value> | ||
276 | protected string SchemaVersion | ||
277 | { | ||
278 | get | ||
279 | { | ||
280 | return this.schemaVersion; | ||
281 | } | ||
282 | set | ||
283 | { | ||
284 | this.schemaVersion = value; | ||
285 | } | ||
286 | } | ||
287 | /// <summary> | ||
288 | /// Gets or sets the name of the version. | ||
289 | /// </summary> | ||
290 | /// <value>The name of the version.</value> | ||
291 | protected string VersionName | ||
292 | { | ||
293 | get | ||
294 | { | ||
295 | return this.versionName; | ||
296 | } | ||
297 | set | ||
298 | { | ||
299 | this.versionName = value; | ||
300 | } | ||
301 | } | ||
302 | /// <summary> | ||
303 | /// Gets or sets the version. | ||
304 | /// </summary> | ||
305 | /// <value>The version.</value> | ||
306 | protected VSVersion Version | ||
307 | { | ||
308 | get | ||
309 | { | ||
310 | return this.version; | ||
311 | } | ||
312 | set | ||
313 | { | ||
314 | this.version = value; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | #endregion | ||
319 | |||
320 | #region Constructors | ||
321 | |||
322 | /// <summary> | ||
323 | /// Initializes a new instance of the <see cref="VS2005Target"/> class. | ||
324 | /// </summary> | ||
325 | public VS2005Target() | ||
326 | { | ||
327 | this.tools = new Hashtable(); | ||
328 | |||
329 | this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); | ||
330 | this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); | ||
331 | this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); | ||
332 | } | ||
333 | |||
334 | #endregion | ||
335 | |||
336 | #region Private Methods | ||
337 | |||
338 | private string MakeRefPath(ProjectNode project) | ||
339 | { | ||
340 | string ret = ""; | ||
341 | foreach (ReferencePathNode node in project.ReferencePaths) | ||
342 | { | ||
343 | try | ||
344 | { | ||
345 | string fullPath = Helper.ResolvePath(node.Path); | ||
346 | if (ret.Length < 1) | ||
347 | { | ||
348 | ret = fullPath; | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | ret += ";" + fullPath; | ||
353 | } | ||
354 | } | ||
355 | catch (ArgumentException) | ||
356 | { | ||
357 | this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path); | ||
358 | } | ||
359 | } | ||
360 | |||
361 | return ret; | ||
362 | } | ||
363 | |||
364 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
365 | { | ||
366 | if (!tools.ContainsKey(project.Language)) | ||
367 | { | ||
368 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
369 | } | ||
370 | |||
371 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
372 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
373 | StreamWriter ps = new StreamWriter(projectFile); | ||
374 | |||
375 | kernel.CurrentWorkingDirectory.Push(); | ||
376 | Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); | ||
377 | |||
378 | #region Project File | ||
379 | using (ps) | ||
380 | { | ||
381 | ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); | ||
382 | //ps.WriteLine(" <{0}", toolInfo.XMLTag); | ||
383 | ps.WriteLine(" <PropertyGroup>"); | ||
384 | ps.WriteLine(" <ProjectType>Local</ProjectType>"); | ||
385 | ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion); | ||
386 | ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion); | ||
387 | ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); | ||
388 | |||
389 | ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); | ||
390 | ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); | ||
391 | //ps.WriteLine(" <Build>"); | ||
392 | |||
393 | //ps.WriteLine(" <Settings"); | ||
394 | ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); | ||
395 | ps.WriteLine(" <AssemblyKeyContainerName>"); | ||
396 | ps.WriteLine(" </AssemblyKeyContainerName>"); | ||
397 | ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); | ||
398 | foreach (ConfigurationNode conf in project.Configurations) | ||
399 | { | ||
400 | if (conf.Options.KeyFile != "") | ||
401 | { | ||
402 | ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); | ||
403 | ps.WriteLine(" <SignAssembly>true</SignAssembly>"); | ||
404 | break; | ||
405 | } | ||
406 | } | ||
407 | ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); | ||
408 | ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); | ||
409 | ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); | ||
410 | ps.WriteLine(" <DelaySign>false</DelaySign>"); | ||
411 | |||
412 | //if(m_Version == VSVersion.VS70) | ||
413 | // ps.WriteLine(" NoStandardLibraries = \"false\""); | ||
414 | |||
415 | ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type.ToString()); | ||
416 | ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); | ||
417 | ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); | ||
418 | ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); | ||
419 | //ps.WriteLine(" >"); | ||
420 | ps.WriteLine(" <FileUpgradeFlags>"); | ||
421 | ps.WriteLine(" </FileUpgradeFlags>"); | ||
422 | |||
423 | ps.WriteLine(" </PropertyGroup>"); | ||
424 | |||
425 | foreach (ConfigurationNode conf in project.Configurations) | ||
426 | { | ||
427 | ps.Write(" <PropertyGroup "); | ||
428 | ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name); | ||
429 | ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); | ||
430 | ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); | ||
431 | ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); | ||
432 | ps.WriteLine(" <ConfigurationOverrideFile>"); | ||
433 | ps.WriteLine(" </ConfigurationOverrideFile>"); | ||
434 | ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); | ||
435 | ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", conf.Options["XmlDocFile"]); | ||
436 | ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); | ||
437 | ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); | ||
438 | // ps.WriteLine(" <IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"]); | ||
439 | |||
440 | // if(m_Version == VSVersion.VS71) | ||
441 | // { | ||
442 | // ps.WriteLine(" NoStdLib = \"{0}\"", conf.Options["NoStdLib"]); | ||
443 | // ps.WriteLine(" NoWarn = \"{0}\"", conf.Options["SuppressWarnings"]); | ||
444 | // } | ||
445 | |||
446 | ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); | ||
447 | ps.WriteLine(" <OutputPath>{0}</OutputPath>", | ||
448 | Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); | ||
449 | ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); | ||
450 | ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); | ||
451 | ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); | ||
452 | ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); | ||
453 | ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); | ||
454 | ps.WriteLine(" </PropertyGroup>"); | ||
455 | } | ||
456 | |||
457 | //ps.WriteLine(" </Settings>"); | ||
458 | |||
459 | // Assembly References | ||
460 | ps.WriteLine(" <ItemGroup>"); | ||
461 | string refPath = ((ReferencePathNode) project.ReferencePaths[0]).Path; | ||
462 | |||
463 | foreach (ReferenceNode refr in project.References) | ||
464 | { | ||
465 | if (!solution.ProjectsTable.ContainsKey(refr.Name)) | ||
466 | { | ||
467 | ps.Write(" <Reference"); | ||
468 | ps.Write(" Include=\""); | ||
469 | ps.Write(refr.Name); | ||
470 | |||
471 | ps.WriteLine("\" >"); | ||
472 | |||
473 | string path; | ||
474 | |||
475 | if( refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase )) | ||
476 | { | ||
477 | path = Helper.NormalizePath(Path.Combine( refPath, refr.Name), '\\'); | ||
478 | } | ||
479 | else | ||
480 | { | ||
481 | path = refr.Name + ".dll"; | ||
482 | } | ||
483 | |||
484 | // TODO: Allow reference to *.exe files | ||
485 | ps.WriteLine(" <HintPath>{0}</HintPath>", path ); | ||
486 | ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); | ||
487 | ps.WriteLine(" </Reference>"); | ||
488 | } | ||
489 | } | ||
490 | ps.WriteLine(" </ItemGroup>"); | ||
491 | |||
492 | //Project References | ||
493 | ps.WriteLine(" <ItemGroup>"); | ||
494 | foreach (ReferenceNode refr in project.References) | ||
495 | { | ||
496 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | ||
497 | { | ||
498 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
499 | // TODO: Allow reference to visual basic projects | ||
500 | string path = | ||
501 | Helper.MakePathRelativeTo(project.FullPath, | ||
502 | Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj")); | ||
503 | ps.WriteLine(" <ProjectReference Include=\"{0}\">", path ); | ||
504 | //<ProjectReference Include="..\..\RealmForge\Utility\RealmForge.Utility.csproj"> | ||
505 | ps.WriteLine(" <Name>{0}</Name>", refProject.Name); | ||
506 | // <Name>RealmForge.Utility</Name> | ||
507 | ps.WriteLine(" <Project>{{{0}}}</Project>", refProject.Guid.ToString().ToUpper()); | ||
508 | // <Project>{6880D1D3-69EE-461B-B841-5319845B20D3}</Project> | ||
509 | ps.WriteLine(" <Package>{0}</Package>", toolInfo.Guid.ToString().ToUpper()); | ||
510 | // <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
511 | ps.WriteLine("\t\t\t<Private>{0}</Private>", refr.LocalCopy); | ||
512 | ps.WriteLine(" </ProjectReference>"); | ||
513 | //</ProjectReference> | ||
514 | } | ||
515 | else | ||
516 | { | ||
517 | } | ||
518 | } | ||
519 | ps.WriteLine(" </ItemGroup>"); | ||
520 | |||
521 | // ps.WriteLine(" </Build>"); | ||
522 | ps.WriteLine(" <ItemGroup>"); | ||
523 | |||
524 | // ps.WriteLine(" <Include>"); | ||
525 | ArrayList list = new ArrayList(); | ||
526 | foreach (string file in project.Files) | ||
527 | { | ||
528 | // if (file == "Properties\\Bind.Designer.cs") | ||
529 | // { | ||
530 | // Console.WriteLine("Wait a minute!"); | ||
531 | // Console.WriteLine(project.Files.GetSubType(file).ToString()); | ||
532 | // } | ||
533 | |||
534 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings && project.Files.GetSubType(file) != SubType.Designer) | ||
535 | { | ||
536 | ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
537 | |||
538 | int slash = file.LastIndexOf('\\'); | ||
539 | if (slash == -1) | ||
540 | { | ||
541 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file); | ||
542 | } | ||
543 | else | ||
544 | { | ||
545 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(slash + 1, file.Length - slash - 1)); | ||
546 | } | ||
547 | ps.WriteLine(" <SubType>Designer</SubType>"); | ||
548 | ps.WriteLine(" </EmbeddedResource>"); | ||
549 | // | ||
550 | } | ||
551 | |||
552 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) == SubType.Designer) | ||
553 | { | ||
554 | ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
555 | ps.WriteLine(" <SubType>" + project.Files.GetSubType(file) + "</SubType>"); | ||
556 | ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); | ||
557 | ps.WriteLine(" <LastGenOutput>Resources.Designer.cs</LastGenOutput>"); | ||
558 | ps.WriteLine(" </EmbeddedResource>"); | ||
559 | ps.WriteLine(" <Compile Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); | ||
560 | ps.WriteLine(" <AutoGen>True</AutoGen>"); | ||
561 | ps.WriteLine(" <DesignTime>True</DesignTime>"); | ||
562 | ps.WriteLine(" <DependentUpon>Resources.resx</DependentUpon>"); | ||
563 | ps.WriteLine(" </Compile>"); | ||
564 | list.Add(file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); | ||
565 | } | ||
566 | if (project.Files.GetSubType(file).ToString() == "Settings") | ||
567 | { | ||
568 | //Console.WriteLine("File: " + file); | ||
569 | //Console.WriteLine("Last index: " + file.LastIndexOf('.')); | ||
570 | //Console.WriteLine("Length: " + file.Length); | ||
571 | ps.Write(" <{0} ", project.Files.GetBuildAction(file)); | ||
572 | ps.WriteLine("Include=\"{0}\">", file); | ||
573 | int slash = file.LastIndexOf('\\'); | ||
574 | string fileName = file.Substring(slash + 1, file.Length - slash - 1); | ||
575 | if (project.Files.GetBuildAction(file) == BuildAction.None) | ||
576 | { | ||
577 | ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); | ||
578 | |||
579 | //Console.WriteLine("FileName: " + fileName); | ||
580 | //Console.WriteLine("FileNameMain: " + fileName.Substring(0, fileName.LastIndexOf('.'))); | ||
581 | //Console.WriteLine("FileNameExt: " + fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'))); | ||
582 | if (slash == -1) | ||
583 | { | ||
584 | ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); | ||
589 | } | ||
590 | } | ||
591 | else | ||
592 | { | ||
593 | ps.WriteLine(" <SubType>Code</SubType>"); | ||
594 | ps.WriteLine(" <AutoGen>True</AutoGen>"); | ||
595 | ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); | ||
596 | string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); | ||
597 | string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); | ||
598 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", fileNameShorter + ".settings"); | ||
599 | } | ||
600 | ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); | ||
601 | } | ||
602 | else if (project.Files.GetSubType(file) != SubType.Designer) | ||
603 | { | ||
604 | if (!list.Contains(file)) | ||
605 | { | ||
606 | ps.Write(" <{0} ", project.Files.GetBuildAction(file)); | ||
607 | ps.WriteLine("Include=\"{0}\">", file); | ||
608 | |||
609 | |||
610 | if (file.Contains("Designer.cs")) | ||
611 | { | ||
612 | ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(0, file.IndexOf(".Designer.cs")) + ".cs"); | ||
613 | } | ||
614 | |||
615 | if (project.Files.GetIsLink(file)) | ||
616 | { | ||
617 | ps.WriteLine(" <Link>{0}</Link>", Path.GetFileName(file)); | ||
618 | } | ||
619 | else if (project.Files.GetBuildAction(file) != BuildAction.None) | ||
620 | { | ||
621 | if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) | ||
622 | { | ||
623 | ps.WriteLine(" <SubType>{0}</SubType>", project.Files.GetSubType(file)); | ||
624 | } | ||
625 | } | ||
626 | if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) | ||
627 | { | ||
628 | ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file)); | ||
629 | } | ||
630 | |||
631 | ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); | ||
632 | } | ||
633 | } | ||
634 | } | ||
635 | // ps.WriteLine(" </Include>"); | ||
636 | |||
637 | ps.WriteLine(" </ItemGroup>"); | ||
638 | ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); | ||
639 | ps.WriteLine(" <PropertyGroup>"); | ||
640 | ps.WriteLine(" <PreBuildEvent>"); | ||
641 | ps.WriteLine(" </PreBuildEvent>"); | ||
642 | ps.WriteLine(" <PostBuildEvent>"); | ||
643 | ps.WriteLine(" </PostBuildEvent>"); | ||
644 | ps.WriteLine(" </PropertyGroup>"); | ||
645 | // ps.WriteLine(" </{0}>", toolInfo.XMLTag); | ||
646 | ps.WriteLine("</Project>"); | ||
647 | } | ||
648 | #endregion | ||
649 | |||
650 | #region User File | ||
651 | |||
652 | ps = new StreamWriter(projectFile + ".user"); | ||
653 | using (ps) | ||
654 | { | ||
655 | ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); | ||
656 | //ps.WriteLine( "<VisualStudioProject>" ); | ||
657 | //ps.WriteLine(" <{0}>", toolInfo.XMLTag); | ||
658 | //ps.WriteLine(" <Build>"); | ||
659 | ps.WriteLine(" <PropertyGroup>"); | ||
660 | //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); | ||
661 | |||
662 | |||
663 | ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); | ||
664 | ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); | ||
665 | |||
666 | if (projectFile.Contains( "OpenSim.csproj" )) | ||
667 | { | ||
668 | ps.WriteLine(" <StartArguments>-loginserver -sandbox -accounts</StartArguments>"); | ||
669 | } | ||
670 | |||
671 | ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); | ||
672 | ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion); | ||
673 | ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); | ||
674 | ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); | ||
675 | ps.WriteLine(" </PropertyGroup>"); | ||
676 | foreach (ConfigurationNode conf in project.Configurations) | ||
677 | { | ||
678 | ps.Write(" <PropertyGroup"); | ||
679 | ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); | ||
680 | ps.WriteLine(" />"); | ||
681 | } | ||
682 | |||
683 | ps.WriteLine("</Project>"); | ||
684 | } | ||
685 | #endregion | ||
686 | |||
687 | kernel.CurrentWorkingDirectory.Pop(); | ||
688 | } | ||
689 | |||
690 | private void WriteSolution(SolutionNode solution) | ||
691 | { | ||
692 | kernel.Log.Write("Creating {0} solution and project files", this.VersionName); | ||
693 | |||
694 | foreach (ProjectNode project in solution.Projects) | ||
695 | { | ||
696 | kernel.Log.Write("...Creating project: {0}", project.Name); | ||
697 | WriteProject(solution, project); | ||
698 | } | ||
699 | |||
700 | kernel.Log.Write(""); | ||
701 | string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
702 | StreamWriter ss = new StreamWriter(solutionFile); | ||
703 | |||
704 | kernel.CurrentWorkingDirectory.Push(); | ||
705 | Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); | ||
706 | |||
707 | using (ss) | ||
708 | { | ||
709 | ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); | ||
710 | ss.WriteLine("# Visual Studio 2005"); | ||
711 | foreach (ProjectNode project in solution.Projects) | ||
712 | { | ||
713 | if (!tools.ContainsKey(project.Language)) | ||
714 | { | ||
715 | throw new UnknownLanguageException("Unknown .NET language: " + project.Language); | ||
716 | } | ||
717 | |||
718 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
719 | |||
720 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
721 | ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", | ||
722 | toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, | ||
723 | toolInfo.FileExtension), project.Guid.ToString().ToUpper()); | ||
724 | |||
725 | //ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject"); | ||
726 | //ss.WriteLine(" EndProjectSection"); | ||
727 | |||
728 | ss.WriteLine("EndProject"); | ||
729 | } | ||
730 | |||
731 | if (solution.Files != null) | ||
732 | { | ||
733 | ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}"); | ||
734 | ss.WriteLine("\tProjectSection(SolutionItems) = preProject"); | ||
735 | foreach (string file in solution.Files) | ||
736 | ss.WriteLine("\t\t{0} = {0}", file); | ||
737 | ss.WriteLine("\tEndProjectSection"); | ||
738 | ss.WriteLine("EndProject"); | ||
739 | } | ||
740 | |||
741 | ss.WriteLine("Global"); | ||
742 | |||
743 | ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution"); | ||
744 | foreach (ConfigurationNode conf in solution.Configurations) | ||
745 | { | ||
746 | ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name); | ||
747 | } | ||
748 | ss.WriteLine(" EndGlobalSection"); | ||
749 | |||
750 | if (solution.Projects.Count > 1) | ||
751 | { | ||
752 | ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution"); | ||
753 | } | ||
754 | foreach (ProjectNode project in solution.Projects) | ||
755 | { | ||
756 | for (int i = 0; i < project.References.Count; i++) | ||
757 | { | ||
758 | ReferenceNode refr = (ReferenceNode)project.References[i]; | ||
759 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | ||
760 | { | ||
761 | ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
762 | ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})", | ||
763 | project.Guid.ToString().ToUpper() | ||
764 | , i, | ||
765 | refProject.Guid.ToString().ToUpper() | ||
766 | ); | ||
767 | } | ||
768 | } | ||
769 | } | ||
770 | if (solution.Projects.Count > 1) | ||
771 | { | ||
772 | ss.WriteLine(" EndGlobalSection"); | ||
773 | } | ||
774 | ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution"); | ||
775 | foreach (ProjectNode project in solution.Projects) | ||
776 | { | ||
777 | foreach (ConfigurationNode conf in solution.Configurations) | ||
778 | { | ||
779 | ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", | ||
780 | project.Guid.ToString().ToUpper(), | ||
781 | conf.Name); | ||
782 | |||
783 | ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU", | ||
784 | project.Guid.ToString().ToUpper(), | ||
785 | conf.Name); | ||
786 | } | ||
787 | } | ||
788 | ss.WriteLine(" EndGlobalSection"); | ||
789 | ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution"); | ||
790 | ss.WriteLine(" HideSolutionNode = FALSE"); | ||
791 | ss.WriteLine(" EndGlobalSection"); | ||
792 | |||
793 | ss.WriteLine("EndGlobal"); | ||
794 | } | ||
795 | |||
796 | kernel.CurrentWorkingDirectory.Pop(); | ||
797 | } | ||
798 | |||
799 | private void CleanProject(ProjectNode project) | ||
800 | { | ||
801 | kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
802 | |||
803 | ToolInfo toolInfo = (ToolInfo)tools[project.Language]; | ||
804 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); | ||
805 | string userFile = projectFile + ".user"; | ||
806 | |||
807 | Helper.DeleteIfExists(projectFile); | ||
808 | Helper.DeleteIfExists(userFile); | ||
809 | } | ||
810 | |||
811 | private void CleanSolution(SolutionNode solution) | ||
812 | { | ||
813 | kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name); | ||
814 | |||
815 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); | ||
816 | string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo"); | ||
817 | |||
818 | Helper.DeleteIfExists(slnFile); | ||
819 | Helper.DeleteIfExists(suoFile); | ||
820 | |||
821 | foreach (ProjectNode project in solution.Projects) | ||
822 | { | ||
823 | CleanProject(project); | ||
824 | } | ||
825 | |||
826 | kernel.Log.Write(""); | ||
827 | } | ||
828 | |||
829 | #endregion | ||
830 | |||
831 | #region ITarget Members | ||
832 | |||
833 | /// <summary> | ||
834 | /// Writes the specified kern. | ||
835 | /// </summary> | ||
836 | /// <param name="kern">The kern.</param> | ||
837 | public virtual void Write(Kernel kern) | ||
838 | { | ||
839 | if (kern == null) | ||
840 | { | ||
841 | throw new ArgumentNullException("kern"); | ||
842 | } | ||
843 | kernel = kern; | ||
844 | foreach (SolutionNode sol in kernel.Solutions) | ||
845 | { | ||
846 | WriteSolution(sol); | ||
847 | } | ||
848 | kernel = null; | ||
849 | } | ||
850 | |||
851 | /// <summary> | ||
852 | /// Cleans the specified kern. | ||
853 | /// </summary> | ||
854 | /// <param name="kern">The kern.</param> | ||
855 | public virtual void Clean(Kernel kern) | ||
856 | { | ||
857 | if (kern == null) | ||
858 | { | ||
859 | throw new ArgumentNullException("kern"); | ||
860 | } | ||
861 | kernel = kern; | ||
862 | foreach (SolutionNode sol in kernel.Solutions) | ||
863 | { | ||
864 | CleanSolution(sol); | ||
865 | } | ||
866 | kernel = null; | ||
867 | } | ||
868 | |||
869 | /// <summary> | ||
870 | /// Gets the name. | ||
871 | /// </summary> | ||
872 | /// <value>The name.</value> | ||
873 | public virtual string Name | ||
874 | { | ||
875 | get | ||
876 | { | ||
877 | return "vs2005"; | ||
878 | } | ||
879 | } | ||
880 | |||
881 | #endregion | ||
882 | } | ||
883 | } | ||