aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets/NAntTarget.cs
diff options
context:
space:
mode:
authorgareth2007-03-22 10:11:15 +0000
committergareth2007-03-22 10:11:15 +0000
commit7daa3955bc3a1918e40962851f9e8d38597a245e (patch)
treebee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /Prebuild/src/Core/Targets/NAntTarget.cs
parentLoad XML for neighbourinfo from grid (diff)
downloadopensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.zip
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2
opensim-SC_OLD-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz
brought zircon branch into trunk
Diffstat (limited to '')
-rw-r--r--Prebuild/src/Core/Targets/NAntTarget.cs621
1 files changed, 621 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs
new file mode 100644
index 0000000..bd366dc
--- /dev/null
+++ b/Prebuild/src/Core/Targets/NAntTarget.cs
@@ -0,0 +1,621 @@
1#region BSD License
2/*
3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN 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
35using System;
36using System.Collections;
37using System.Collections.Specialized;
38using System.IO;
39using System.Reflection;
40using System.Text.RegularExpressions;
41
42using Prebuild.Core.Attributes;
43using Prebuild.Core.Interfaces;
44using Prebuild.Core.Nodes;
45using Prebuild.Core.Utilities;
46
47namespace 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, ReferenceNode refr)
81 {
82 string ret = "";
83 if(solution.ProjectsTable.ContainsKey(refr.Name))
84 {
85 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
86 string fileRef = FindFileReference(refr.Name, project);
87 string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/');
88 ret += finalPath;
89 return ret;
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 fileRef = FindFileReference(refr.Name, project);
131 string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/');
132 ret += finalPath;
133 return ret;
134 }
135 else
136 {
137 ProjectNode project = (ProjectNode)refr.Parent;
138 string fileRef = FindFileReference(refr.Name, project);
139
140 if(refr.Path != null || fileRef != null)
141 {
142 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef;
143 ret += finalPath;
144 return ret;
145 }
146
147 try
148 {
149 Assembly assem = Assembly.Load(refr.Name);
150 if (assem != null)
151 {
152 ret += "";
153 }
154 else
155 {
156 ret += "";
157 }
158 }
159 catch (System.NullReferenceException e)
160 {
161 e.ToString();
162 ret += "";
163 }
164 }
165 return ret;
166 }
167
168 private static string FindFileReference(string refName, ProjectNode project)
169 {
170 foreach(ReferencePathNode refPath in project.ReferencePaths)
171 {
172 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
173
174 if(File.Exists(fullPath))
175 {
176 return fullPath;
177 }
178 }
179
180 return null;
181 }
182
183 /// <summary>
184 /// Gets the XML doc file.
185 /// </summary>
186 /// <param name="project">The project.</param>
187 /// <param name="conf">The conf.</param>
188 /// <returns></returns>
189 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
190 {
191 if( conf == null )
192 {
193 throw new ArgumentNullException("conf");
194 }
195 if( project == null )
196 {
197 throw new ArgumentNullException("project");
198 }
199 string docFile = (string)conf.Options["XmlDocFile"];
200 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
201 // {
202 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
203 // }
204 return docFile;
205 }
206
207 private void WriteProject(SolutionNode solution, ProjectNode project)
208 {
209 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
210 StreamWriter ss = new StreamWriter(projFile);
211
212 m_Kernel.CurrentWorkingDirectory.Push();
213 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
214 bool hasDoc = false;
215
216 using(ss)
217 {
218 ss.WriteLine("<?xml version=\"1.0\" ?>");
219 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
220 ss.WriteLine(" <target name=\"{0}\">", "build");
221 ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
222 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
223 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">");
224 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
225 foreach(ReferenceNode refr in project.References)
226 {
227 if (refr.LocalCopy)
228 {
229 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr))+"\" />", '/'));
230 }
231 }
232 ss.WriteLine(" </fileset>");
233 ss.WriteLine(" </copy>");
234 ss.Write(" <csc");
235 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
236 ss.Write(" debug=\"{0}\"", "${build.debug}");
237 foreach(ConfigurationNode conf in project.Configurations)
238 {
239 if (conf.Options.KeyFile !="")
240 {
241 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
242 break;
243 }
244 }
245 foreach(ConfigurationNode conf in project.Configurations)
246 {
247 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
248 break;
249 }
250 foreach(ConfigurationNode conf in project.Configurations)
251 {
252 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
253 break;
254 }
255 foreach(ConfigurationNode conf in project.Configurations)
256 {
257 if (GetXmlDocFile(project, conf) !="")
258 {
259 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
260 hasDoc = true;
261 }
262 break;
263 }
264 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
265 if (project.Type == ProjectType.Library)
266 {
267 ss.Write(".dll\"");
268 }
269 else
270 {
271 ss.Write(".exe\"");
272 }
273 if(project.AppIcon != null && project.AppIcon.Length != 0)
274 {
275 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon,'/'));
276 }
277 ss.WriteLine(">");
278 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
279 foreach (string file in project.Files)
280 {
281 switch (project.Files.GetBuildAction(file))
282 {
283 case BuildAction.EmbeddedResource:
284 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
285 break;
286 default:
287 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
288 {
289 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
290 }
291 break;
292 }
293 }
294 //if (project.Files.GetSubType(file).ToString() != "Code")
295 //{
296 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
297
298 ss.WriteLine(" </resources>");
299 ss.WriteLine(" <sources failonempty=\"true\">");
300 foreach(string file in project.Files)
301 {
302 switch(project.Files.GetBuildAction(file))
303 {
304 case BuildAction.Compile:
305 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
306 break;
307 default:
308 break;
309 }
310 }
311 ss.WriteLine(" </sources>");
312 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
313 ss.WriteLine(" <lib>");
314 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
315 ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />");
316 ss.WriteLine(" </lib>");
317 foreach(ReferenceNode refr in project.References)
318 {
319 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr))+"\" />", '/'));
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}