aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets/XcodeTarget.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-09-11 01:13:08 +0100
committerJustin Clark-Casey (justincc)2010-09-11 01:13:08 +0100
commit7e65590a55ba575d0086bdfc25addaf1051d799b (patch)
tree1dc11683170d45d80d7aab6eefdfcc836d3e773b /Prebuild/src/Core/Targets/XcodeTarget.cs
parentMake it clear that the "create region" command will reference ini files in th... (diff)
downloadopensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.zip
opensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.gz
opensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.bz2
opensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.xz
Update Prebuild.exe with Prebuild r323 + an existing OpenSim specific nant hack to correctly clean up chosen OpenSim exes and dlls in bin/ on a "nant clean"
Source code is included for reference. This can go away again once Prebuild is updated with a more general mechanism for cleaning up files. The Prebuild source code here can be built with nant, or regnerated for other tools using the prebuild at {root}/bin/Prebuild.exe
Diffstat (limited to 'Prebuild/src/Core/Targets/XcodeTarget.cs')
-rw-r--r--Prebuild/src/Core/Targets/XcodeTarget.cs594
1 files changed, 594 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Targets/XcodeTarget.cs b/Prebuild/src/Core/Targets/XcodeTarget.cs
new file mode 100644
index 0000000..5393cec
--- /dev/null
+++ b/Prebuild/src/Core/Targets/XcodeTarget.cs
@@ -0,0 +1,594 @@
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
26using System;
27using System.IO;
28using System.Reflection;
29using System.Text.RegularExpressions;
30
31using Prebuild.Core.Attributes;
32using Prebuild.Core.Interfaces;
33using Prebuild.Core.Nodes;
34using Prebuild.Core.Utilities;
35
36namespace Prebuild.Core.Targets
37{
38 /// <summary>
39 ///
40 /// </summary>
41 [Target("xcode")]
42 public class XcodeTarget : ITarget
43 {
44 #region Fields
45
46 private Kernel m_Kernel;
47
48 #endregion
49
50 #region Private Methods
51
52 private static string PrependPath(string path)
53 {
54 string tmpPath = Helper.NormalizePath(path, '/');
55 Regex regex = new Regex(@"(\w):/(\w+)");
56 Match match = regex.Match(tmpPath);
57 //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
58 //{
59 tmpPath = Helper.NormalizePath(tmpPath);
60 //}
61 // else
62 // {
63 // tmpPath = Helper.NormalizePath("./" + tmpPath);
64 // }
65
66 return tmpPath;
67 }
68
69 private static string BuildReference(SolutionNode solution, ReferenceNode refr)
70 {
71 string ret = "";
72 if (solution.ProjectsTable.ContainsKey(refr.Name))
73 {
74 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
75 string fileRef = FindFileReference(refr.Name, project);
76 string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/');
77 ret += finalPath;
78 return ret;
79 }
80 else
81 {
82 ProjectNode project = (ProjectNode)refr.Parent;
83 string fileRef = FindFileReference(refr.Name, project);
84
85 if (refr.Path != null || fileRef != null)
86 {
87 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef;
88 ret += finalPath;
89 return ret;
90 }
91
92 try
93 {
94 //Assembly assem = Assembly.Load(refr.Name);
95 //if (assem != null)
96 //{
97 //ret += (refr.Name + ".dll");
98 //}
99 //else
100 //{
101 ret += (refr.Name + ".dll");
102 //}
103 }
104 catch (System.NullReferenceException e)
105 {
106 e.ToString();
107 ret += refr.Name + ".dll";
108 }
109 }
110 return ret;
111 }
112
113 private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr)
114 {
115 string ret = "";
116 if (solution.ProjectsTable.ContainsKey(refr.Name))
117 {
118 ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
119 string fileRef = FindFileReference(refr.Name, project);
120 string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/');
121 ret += finalPath;
122 return ret;
123 }
124 else
125 {
126 ProjectNode project = (ProjectNode)refr.Parent;
127 string fileRef = FindFileReference(refr.Name, project);
128
129 if (refr.Path != null || fileRef != null)
130 {
131 string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef;
132 ret += finalPath;
133 return ret;
134 }
135
136 try
137 {
138 Assembly assem = Assembly.Load(refr.Name);
139 if (assem != null)
140 {
141 ret += "";
142 }
143 else
144 {
145 ret += "";
146 }
147 }
148 catch (System.NullReferenceException e)
149 {
150 e.ToString();
151 ret += "";
152 }
153 }
154 return ret;
155 }
156
157 private static string FindFileReference(string refName, ProjectNode project)
158 {
159 foreach (ReferencePathNode refPath in project.ReferencePaths)
160 {
161 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
162
163 if (File.Exists(fullPath))
164 {
165 return fullPath;
166 }
167 }
168
169 return null;
170 }
171
172 /// <summary>
173 /// Gets the XML doc file.
174 /// </summary>
175 /// <param name="project">The project.</param>
176 /// <param name="conf">The conf.</param>
177 /// <returns></returns>
178 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
179 {
180 if (conf == null)
181 {
182 throw new ArgumentNullException("conf");
183 }
184 if (project == null)
185 {
186 throw new ArgumentNullException("project");
187 }
188 string docFile = (string)conf.Options["XmlDocFile"];
189 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
190 // {
191 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
192 // }
193 return docFile;
194 }
195
196 private void WriteProject(SolutionNode solution, ProjectNode project)
197 {
198 string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
199 StreamWriter ss = new StreamWriter(projFile);
200
201 m_Kernel.CurrentWorkingDirectory.Push();
202 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
203 bool hasDoc = false;
204
205 using (ss)
206 {
207 ss.WriteLine("<?xml version=\"1.0\" ?>");
208 ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
209 ss.WriteLine(" <target name=\"{0}\">", "build");
210 ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
211 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
212 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">");
213 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
214 foreach (ReferenceNode refr in project.References)
215 {
216 if (refr.LocalCopy)
217 {
218 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/'));
219 }
220 }
221 ss.WriteLine(" </fileset>");
222 ss.WriteLine(" </copy>");
223 ss.Write(" <csc");
224 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
225 ss.Write(" debug=\"{0}\"", "${build.debug}");
226 foreach (ConfigurationNode conf in project.Configurations)
227 {
228 if (conf.Options.KeyFile != "")
229 {
230 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
231 break;
232 }
233 }
234 foreach (ConfigurationNode conf in project.Configurations)
235 {
236 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
237 break;
238 }
239 foreach (ConfigurationNode conf in project.Configurations)
240 {
241 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
242 break;
243 }
244 foreach (ConfigurationNode conf in project.Configurations)
245 {
246 if (GetXmlDocFile(project, conf) != "")
247 {
248 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
249 hasDoc = true;
250 }
251 break;
252 }
253 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
254 if (project.Type == ProjectType.Library)
255 {
256 ss.Write(".dll\"");
257 }
258 else
259 {
260 ss.Write(".exe\"");
261 }
262 if (project.AppIcon != null && project.AppIcon.Length != 0)
263 {
264 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
265 }
266 ss.WriteLine(">");
267 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
268 foreach (string file in project.Files)
269 {
270 switch (project.Files.GetBuildAction(file))
271 {
272 case BuildAction.EmbeddedResource:
273 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
274 break;
275 default:
276 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
277 {
278 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
279 }
280 break;
281 }
282 }
283 //if (project.Files.GetSubType(file).ToString() != "Code")
284 //{
285 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
286
287 ss.WriteLine(" </resources>");
288 ss.WriteLine(" <sources failonempty=\"true\">");
289 foreach (string file in project.Files)
290 {
291 switch (project.Files.GetBuildAction(file))
292 {
293 case BuildAction.Compile:
294 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
295 break;
296 default:
297 break;
298 }
299 }
300 ss.WriteLine(" </sources>");
301 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
302 ss.WriteLine(" <lib>");
303 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
304 ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />");
305 ss.WriteLine(" </lib>");
306 foreach (ReferenceNode refr in project.References)
307 {
308 ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/'));
309 }
310 ss.WriteLine(" </references>");
311
312 ss.WriteLine(" </csc>");
313 ss.WriteLine(" </target>");
314
315 ss.WriteLine(" <target name=\"clean\">");
316 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
317 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
318 ss.WriteLine(" </target>");
319
320 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
321 if (hasDoc)
322 {
323 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
324 ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
325 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
326 ss.WriteLine(" </if>");
327 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
328 ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
329 ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
330 if (project.Type == ProjectType.Library)
331 {
332 ss.WriteLine(".dll\" />");
333 }
334 else
335 {
336 ss.WriteLine(".exe\" />");
337 }
338
339 ss.WriteLine(" </assemblies>");
340 ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
341 ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
342 ss.WriteLine(" </summaries>");
343 ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
344 ss.WriteLine(" <include name=\"${build.dir}\" />");
345 // foreach(ReferenceNode refr in project.References)
346 // {
347 // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
348 // if (path != "")
349 // {
350 // ss.WriteLine(" <include name=\"{0}\" />", path);
351 // }
352 // }
353 ss.WriteLine(" </referencepaths>");
354 ss.WriteLine(" <documenters>");
355 ss.WriteLine(" <documenter name=\"MSDN\">");
356 ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
357 ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
358 ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
359 ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
360 ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
361 ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
362 ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
363 ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
364 ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
365 ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
366 ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
367 ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
368 ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
369 ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
370 ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
371 ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
372 ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
373 ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
374 ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
375 ss.WriteLine(" </documenter>");
376 ss.WriteLine(" </documenters>");
377 ss.WriteLine(" </ndoc>");
378 }
379 ss.WriteLine(" </target>");
380 ss.WriteLine("</project>");
381 }
382 m_Kernel.CurrentWorkingDirectory.Pop();
383 }
384
385 private void WriteCombine(SolutionNode solution)
386 {
387 m_Kernel.Log.Write("Creating Xcode build files");
388 foreach (ProjectNode project in solution.Projects)
389 {
390 if (m_Kernel.AllowProject(project.FilterGroups))
391 {
392 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
393 WriteProject(solution, project);
394 }
395 }
396
397 m_Kernel.Log.Write("");
398 DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"));
399 if (!directoryInfo.Exists)
400 {
401 directoryInfo.Create();
402 }
403 string combFile = Helper.MakeFilePath(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"), "project", "pbxproj");
404 StreamWriter ss = new StreamWriter(combFile);
405
406 m_Kernel.CurrentWorkingDirectory.Push();
407 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
408
409 using (ss)
410 {
411 ss.WriteLine("<?xml version=\"1.0\" ?>");
412 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
413 ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
414 ss.WriteLine();
415
416 //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
417 //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
418 ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
419 ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
420 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
421 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
422
423 foreach (ConfigurationNode conf in solution.Configurations)
424 {
425 // Set the project.config to a non-debug configuration
426 if (conf.Options["DebugInformation"].ToString().ToLower() != "true")
427 {
428 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
429 }
430 ss.WriteLine();
431 ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name);
432 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
433 ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower());
434 ss.WriteLine(" </target>");
435 ss.WriteLine();
436 }
437
438 ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
439 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
440 ss.WriteLine(" </target>");
441 ss.WriteLine();
442
443 ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
444 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
445 ss.WriteLine(" </target>");
446 ss.WriteLine();
447
448 ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
449 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
450 ss.WriteLine(" </target>");
451 ss.WriteLine();
452
453 ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
454 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
455 ss.WriteLine(" </target>");
456 ss.WriteLine();
457
458 ss.WriteLine(" <target name=\"init\" description=\"\">");
459 ss.WriteLine(" <call target=\"${project.config}\" />");
460 ss.WriteLine(" <sysinfo />");
461 ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />");
462 ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />");
463 ss.WriteLine(" </target>");
464 ss.WriteLine();
465
466 ss.WriteLine(" <target name=\"clean\" description=\"\">");
467 ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />");
468 //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />");
469 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
470 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
471 //foreach(ProjectNode project in solution.Projects)
472 //{
473 // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
474 // ss.Write(" <nant buildfile=\"{0}\"",
475 // Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/'));
476 // ss.WriteLine(" target=\"clean\" />");
477 //}
478 ss.WriteLine(" </target>");
479 ss.WriteLine();
480
481 ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">");
482
483 foreach (ProjectNode project in solution.ProjectsTableOrder)
484 {
485 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
486 ss.Write(" <nant buildfile=\"{0}\"",
487 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
488 ss.WriteLine(" target=\"build\" />");
489 }
490 ss.WriteLine(" </target>");
491 ss.WriteLine();
492
493 ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />");
494 ss.WriteLine();
495 ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />");
496 ss.WriteLine();
497 //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />");
498 ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />");
499 ss.WriteLine();
500
501 ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">");
502 ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />");
503 foreach (ProjectNode project in solution.Projects)
504 {
505 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
506 ss.Write(" <nant buildfile=\"{0}\"",
507 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/'));
508 ss.WriteLine(" target=\"doc\" />");
509 }
510 ss.WriteLine(" </target>");
511 ss.WriteLine();
512 ss.WriteLine("</project>");
513 }
514
515 m_Kernel.CurrentWorkingDirectory.Pop();
516 }
517
518 private void CleanProject(ProjectNode project)
519 {
520 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
521 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
522 Helper.DeleteIfExists(projectFile);
523 }
524
525 private void CleanSolution(SolutionNode solution)
526 {
527 m_Kernel.Log.Write("Cleaning Xcode build files for", solution.Name);
528
529 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
530 Helper.DeleteIfExists(slnFile);
531
532 foreach (ProjectNode project in solution.Projects)
533 {
534 CleanProject(project);
535 }
536
537 m_Kernel.Log.Write("");
538 }
539
540 #endregion
541
542 #region ITarget Members
543
544 /// <summary>
545 /// Writes the specified kern.
546 /// </summary>
547 /// <param name="kern">The kern.</param>
548 public void Write(Kernel kern)
549 {
550 if (kern == null)
551 {
552 throw new ArgumentNullException("kern");
553 }
554 m_Kernel = kern;
555 foreach (SolutionNode solution in kern.Solutions)
556 {
557 WriteCombine(solution);
558 }
559 m_Kernel = null;
560 }
561
562 /// <summary>
563 /// Cleans the specified kern.
564 /// </summary>
565 /// <param name="kern">The kern.</param>
566 public virtual void Clean(Kernel kern)
567 {
568 if (kern == null)
569 {
570 throw new ArgumentNullException("kern");
571 }
572 m_Kernel = kern;
573 foreach (SolutionNode sol in kern.Solutions)
574 {
575 CleanSolution(sol);
576 }
577 m_Kernel = null;
578 }
579
580 /// <summary>
581 /// Gets the name.
582 /// </summary>
583 /// <value>The name.</value>
584 public string Name
585 {
586 get
587 {
588 return "xcode";
589 }
590 }
591
592 #endregion
593 }
594}