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