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