diff options
Diffstat (limited to 'Prebuild/src/Core/Targets/XcodeTarget.cs')
-rw-r--r-- | Prebuild/src/Core/Targets/XcodeTarget.cs | 605 |
1 files changed, 605 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..ee3b241 --- /dev/null +++ b/Prebuild/src/Core/Targets/XcodeTarget.cs | |||
@@ -0,0 +1,605 @@ | |||
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 12:58:03 -0800 (Tue, 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("xcode")] | ||
53 | public class XcodeTarget : 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 | ss.WriteLine(" </target>"); | ||
325 | |||
326 | ss.WriteLine(" <target name=\"clean\">"); | ||
327 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); | ||
328 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); | ||
329 | ss.WriteLine(" </target>"); | ||
330 | |||
331 | ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); | ||
332 | if (hasDoc) | ||
333 | { | ||
334 | ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); | ||
335 | ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); | ||
336 | ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); | ||
337 | ss.WriteLine(" </if>"); | ||
338 | ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); | ||
339 | ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); | ||
340 | ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); | ||
341 | if (project.Type == ProjectType.Library) | ||
342 | { | ||
343 | ss.WriteLine(".dll\" />"); | ||
344 | } | ||
345 | else | ||
346 | { | ||
347 | ss.WriteLine(".exe\" />"); | ||
348 | } | ||
349 | |||
350 | ss.WriteLine(" </assemblies>"); | ||
351 | ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); | ||
352 | ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); | ||
353 | ss.WriteLine(" </summaries>"); | ||
354 | ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); | ||
355 | ss.WriteLine(" <include name=\"${build.dir}\" />"); | ||
356 | // foreach(ReferenceNode refr in project.References) | ||
357 | // { | ||
358 | // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); | ||
359 | // if (path != "") | ||
360 | // { | ||
361 | // ss.WriteLine(" <include name=\"{0}\" />", path); | ||
362 | // } | ||
363 | // } | ||
364 | ss.WriteLine(" </referencepaths>"); | ||
365 | ss.WriteLine(" <documenters>"); | ||
366 | ss.WriteLine(" <documenter name=\"MSDN\">"); | ||
367 | ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); | ||
368 | ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); | ||
369 | ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); | ||
370 | ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); | ||
371 | ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); | ||
372 | ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); | ||
373 | ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); | ||
374 | ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); | ||
375 | ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); | ||
376 | ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); | ||
377 | ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); | ||
378 | ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); | ||
379 | ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); | ||
380 | ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); | ||
381 | ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); | ||
382 | ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); | ||
383 | ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); | ||
384 | ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); | ||
385 | ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); | ||
386 | ss.WriteLine(" </documenter>"); | ||
387 | ss.WriteLine(" </documenters>"); | ||
388 | ss.WriteLine(" </ndoc>"); | ||
389 | } | ||
390 | ss.WriteLine(" </target>"); | ||
391 | ss.WriteLine("</project>"); | ||
392 | } | ||
393 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
394 | } | ||
395 | |||
396 | private void WriteCombine(SolutionNode solution) | ||
397 | { | ||
398 | m_Kernel.Log.Write("Creating Xcode build files"); | ||
399 | foreach (ProjectNode project in solution.Projects) | ||
400 | { | ||
401 | if (m_Kernel.AllowProject(project.FilterGroups)) | ||
402 | { | ||
403 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | ||
404 | WriteProject(solution, project); | ||
405 | } | ||
406 | } | ||
407 | |||
408 | m_Kernel.Log.Write(""); | ||
409 | DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj")); | ||
410 | if (!directoryInfo.Exists) | ||
411 | { | ||
412 | directoryInfo.Create(); | ||
413 | } | ||
414 | string combFile = Helper.MakeFilePath(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"), "project", "pbxproj"); | ||
415 | StreamWriter ss = new StreamWriter(combFile); | ||
416 | |||
417 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
418 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | ||
419 | |||
420 | using (ss) | ||
421 | { | ||
422 | ss.WriteLine("<?xml version=\"1.0\" ?>"); | ||
423 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); | ||
424 | ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); | ||
425 | ss.WriteLine(); | ||
426 | |||
427 | //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); | ||
428 | //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); | ||
429 | ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); | ||
430 | ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); | ||
431 | ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); | ||
432 | ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); | ||
433 | |||
434 | foreach (ConfigurationNode conf in solution.Configurations) | ||
435 | { | ||
436 | // Set the project.config to a non-debug configuration | ||
437 | if (conf.Options["DebugInformation"].ToString().ToLower() != "true") | ||
438 | { | ||
439 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); | ||
440 | } | ||
441 | ss.WriteLine(); | ||
442 | ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name); | ||
443 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); | ||
444 | ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); | ||
445 | ss.WriteLine(" </target>"); | ||
446 | ss.WriteLine(); | ||
447 | } | ||
448 | |||
449 | ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); | ||
450 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); | ||
451 | ss.WriteLine(" </target>"); | ||
452 | ss.WriteLine(); | ||
453 | |||
454 | ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); | ||
455 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); | ||
456 | ss.WriteLine(" </target>"); | ||
457 | ss.WriteLine(); | ||
458 | |||
459 | ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">"); | ||
460 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />"); | ||
461 | ss.WriteLine(" </target>"); | ||
462 | ss.WriteLine(); | ||
463 | |||
464 | ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); | ||
465 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); | ||
466 | ss.WriteLine(" </target>"); | ||
467 | ss.WriteLine(); | ||
468 | |||
469 | ss.WriteLine(" <target name=\"init\" description=\"\">"); | ||
470 | ss.WriteLine(" <call target=\"${project.config}\" />"); | ||
471 | ss.WriteLine(" <sysinfo />"); | ||
472 | ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />"); | ||
473 | ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />"); | ||
474 | ss.WriteLine(" </target>"); | ||
475 | ss.WriteLine(); | ||
476 | |||
477 | ss.WriteLine(" <target name=\"clean\" description=\"\">"); | ||
478 | ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />"); | ||
479 | //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />"); | ||
480 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); | ||
481 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); | ||
482 | //foreach(ProjectNode project in solution.Projects) | ||
483 | //{ | ||
484 | // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
485 | // ss.Write(" <nant buildfile=\"{0}\"", | ||
486 | // Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/')); | ||
487 | // ss.WriteLine(" target=\"clean\" />"); | ||
488 | //} | ||
489 | ss.WriteLine(" </target>"); | ||
490 | ss.WriteLine(); | ||
491 | |||
492 | ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">"); | ||
493 | |||
494 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
495 | { | ||
496 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
497 | ss.Write(" <nant buildfile=\"{0}\"", | ||
498 | Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); | ||
499 | ss.WriteLine(" target=\"build\" />"); | ||
500 | } | ||
501 | ss.WriteLine(" </target>"); | ||
502 | ss.WriteLine(); | ||
503 | |||
504 | ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />"); | ||
505 | ss.WriteLine(); | ||
506 | ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />"); | ||
507 | ss.WriteLine(); | ||
508 | //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />"); | ||
509 | ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />"); | ||
510 | ss.WriteLine(); | ||
511 | |||
512 | ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">"); | ||
513 | ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />"); | ||
514 | foreach (ProjectNode project in solution.Projects) | ||
515 | { | ||
516 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
517 | ss.Write(" <nant buildfile=\"{0}\"", | ||
518 | Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); | ||
519 | ss.WriteLine(" target=\"doc\" />"); | ||
520 | } | ||
521 | ss.WriteLine(" </target>"); | ||
522 | ss.WriteLine(); | ||
523 | ss.WriteLine("</project>"); | ||
524 | } | ||
525 | |||
526 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
527 | } | ||
528 | |||
529 | private void CleanProject(ProjectNode project) | ||
530 | { | ||
531 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
532 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); | ||
533 | Helper.DeleteIfExists(projectFile); | ||
534 | } | ||
535 | |||
536 | private void CleanSolution(SolutionNode solution) | ||
537 | { | ||
538 | m_Kernel.Log.Write("Cleaning Xcode build files for", solution.Name); | ||
539 | |||
540 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); | ||
541 | Helper.DeleteIfExists(slnFile); | ||
542 | |||
543 | foreach (ProjectNode project in solution.Projects) | ||
544 | { | ||
545 | CleanProject(project); | ||
546 | } | ||
547 | |||
548 | m_Kernel.Log.Write(""); | ||
549 | } | ||
550 | |||
551 | #endregion | ||
552 | |||
553 | #region ITarget Members | ||
554 | |||
555 | /// <summary> | ||
556 | /// Writes the specified kern. | ||
557 | /// </summary> | ||
558 | /// <param name="kern">The kern.</param> | ||
559 | public void Write(Kernel kern) | ||
560 | { | ||
561 | if (kern == null) | ||
562 | { | ||
563 | throw new ArgumentNullException("kern"); | ||
564 | } | ||
565 | m_Kernel = kern; | ||
566 | foreach (SolutionNode solution in kern.Solutions) | ||
567 | { | ||
568 | WriteCombine(solution); | ||
569 | } | ||
570 | m_Kernel = null; | ||
571 | } | ||
572 | |||
573 | /// <summary> | ||
574 | /// Cleans the specified kern. | ||
575 | /// </summary> | ||
576 | /// <param name="kern">The kern.</param> | ||
577 | public virtual void Clean(Kernel kern) | ||
578 | { | ||
579 | if (kern == null) | ||
580 | { | ||
581 | throw new ArgumentNullException("kern"); | ||
582 | } | ||
583 | m_Kernel = kern; | ||
584 | foreach (SolutionNode sol in kern.Solutions) | ||
585 | { | ||
586 | CleanSolution(sol); | ||
587 | } | ||
588 | m_Kernel = null; | ||
589 | } | ||
590 | |||
591 | /// <summary> | ||
592 | /// Gets the name. | ||
593 | /// </summary> | ||
594 | /// <value>The name.</value> | ||
595 | public string Name | ||
596 | { | ||
597 | get | ||
598 | { | ||
599 | return "xcode"; | ||
600 | } | ||
601 | } | ||
602 | |||
603 | #endregion | ||
604 | } | ||
605 | } | ||