aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Targets
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Targets')
-rw-r--r--Prebuild/src/Core/Targets/AutotoolsTarget.cs1782
-rw-r--r--Prebuild/src/Core/Targets/DebugTarget.cs102
-rw-r--r--Prebuild/src/Core/Targets/MakefileTarget.cs471
-rw-r--r--Prebuild/src/Core/Targets/MonoDevelopTarget.cs464
-rw-r--r--Prebuild/src/Core/Targets/NAntTarget.cs738
-rw-r--r--Prebuild/src/Core/Targets/SharpDevelop2Target.cs82
-rw-r--r--Prebuild/src/Core/Targets/SharpDevelopTarget.cs428
-rw-r--r--Prebuild/src/Core/Targets/ToolInfo.cs197
-rw-r--r--Prebuild/src/Core/Targets/VS2002Target.cs87
-rw-r--r--Prebuild/src/Core/Targets/VS2003Target.cs602
-rw-r--r--Prebuild/src/Core/Targets/VS2005Target.cs149
-rw-r--r--Prebuild/src/Core/Targets/VS2008Target.cs132
-rw-r--r--Prebuild/src/Core/Targets/VS2010Target.cs134
-rw-r--r--Prebuild/src/Core/Targets/VSGenericTarget.cs887
-rw-r--r--Prebuild/src/Core/Targets/VSVersion.cs54
-rw-r--r--Prebuild/src/Core/Targets/XcodeTarget.cs596
16 files changed, 0 insertions, 6905 deletions
diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs
deleted file mode 100644
index 5dcbb38..0000000
--- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs
+++ /dev/null
@@ -1,1782 +0,0 @@
1#region BSD License
2/*
3
4Copyright (c) 2004 - 2008
5Matthew Holmes (matthew@wildfiregames.com),
6Dan Moorehead (dan05a@gmail.com),
7Dave Hudson (jendave@yahoo.com),
8C.J. Adams-Collier (cjac@colliertech.org),
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are
12met:
13
14* Redistributions of source code must retain the above copyright
15notice, this list of conditions and the following disclaimer.
16
17* Redistributions in binary form must reproduce the above copyright
18notice, this list of conditions and the following disclaimer in the
19documentation and/or other materials provided with the distribution.
20
21* The name of the author may not be used to endorse or promote
22products derived from this software without specific prior written
23permission.
24
25THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
29INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
34IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE.
36
37*/
38#endregion
39
40#region MIT X11 license
41
42/*
43 Portions of this file authored by Lluis Sanchez Gual
44
45 Copyright (C) 2006 Novell, Inc (http://www.novell.com)
46
47 Permission is hereby granted, free of charge, to any person obtaining
48 a copy of this software and associated documentation files (the
49 "Software"), to deal in the Software without restriction, including
50 without limitation the rights to use, copy, modify, merge, publish,
51 distribute, sublicense, and/or sell copies of the Software, and to
52 permit persons to whom the Software is furnished to do so, subject to
53 the following conditions:
54
55 The above copyright notice and this permission notice shall be
56 included in all copies or substantial portions of the Software.
57
58 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
59 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
60 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
61 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
62 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
63 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
64 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65 */
66
67#endregion
68using System;
69using System.Collections;
70using System.Collections.Generic;
71using System.Collections.Specialized;
72using System.IO;
73using System.Reflection;
74using System.Text;
75using System.Text.RegularExpressions;
76using System.Xml;
77using System.Xml.Xsl;
78using System.Net;
79using System.Diagnostics;
80
81using Prebuild.Core.Attributes;
82using Prebuild.Core.Interfaces;
83using Prebuild.Core.Nodes;
84using Prebuild.Core.Parse;
85using Prebuild.Core.Utilities;
86
87namespace Prebuild.Core.Targets
88{
89 public enum ClrVersion
90 {
91 Default,
92 Net_1_1,
93 Net_2_0
94 }
95
96 public class SystemPackage
97 {
98 string name;
99 string version;
100 string description;
101 string[] assemblies;
102 bool isInternal;
103 ClrVersion targetVersion;
104
105 public void Initialize(string name,
106 string version,
107 string description,
108 string[] assemblies,
109 ClrVersion targetVersion,
110 bool isInternal)
111 {
112 this.isInternal = isInternal;
113 this.name = name;
114 this.version = version;
115 this.assemblies = assemblies;
116 this.description = description;
117 this.targetVersion = targetVersion;
118 }
119
120 public string Name
121 {
122 get { return name; }
123 }
124
125 public string Version
126 {
127 get { return version; }
128 }
129
130 public string Description
131 {
132 get { return description; }
133 }
134
135 public ClrVersion TargetVersion
136 {
137 get { return targetVersion; }
138 }
139
140 // The package is part of the mono SDK
141 public bool IsCorePackage
142 {
143 get { return name == "mono"; }
144 }
145
146 // The package has been registered by an add-in, and is not installed
147 // in the system.
148 public bool IsInternalPackage
149 {
150 get { return isInternal; }
151 }
152
153 public string[] Assemblies
154 {
155 get { return assemblies; }
156 }
157
158 }
159
160
161 /// <summary>
162 ///
163 /// </summary>
164 [Target("autotools")]
165 public class AutotoolsTarget : ITarget
166 {
167 #region Fields
168
169 Kernel m_Kernel;
170 XmlDocument autotoolsDoc;
171 XmlUrlResolver xr;
172 System.Security.Policy.Evidence e;
173 Hashtable assemblyPathToPackage = new Hashtable();
174 Hashtable assemblyFullNameToPath = new Hashtable();
175 Hashtable packagesHash = new Hashtable();
176 readonly List<SystemPackage> packages = new List<SystemPackage>();
177
178 #endregion
179
180 #region Private Methods
181
182 private void mkdirDashP(string dirName)
183 {
184 DirectoryInfo di = new DirectoryInfo(dirName);
185 if (di.Exists)
186 return;
187
188 string parentDirName = System.IO.Path.GetDirectoryName(dirName);
189 DirectoryInfo parentDi = new DirectoryInfo(parentDirName);
190 if (!parentDi.Exists)
191 mkdirDashP(parentDirName);
192
193 di.Create();
194 }
195
196 private void chkMkDir(string dirName)
197 {
198 System.IO.DirectoryInfo di =
199 new System.IO.DirectoryInfo(dirName);
200
201 if (!di.Exists)
202 di.Create();
203 }
204
205 private void transformToFile(string filename, XsltArgumentList argList, string nodeName)
206 {
207 // Create an XslTransform for this file
208 XslTransform templateTransformer =
209 new XslTransform();
210
211 // Load up the template
212 XmlNode templateNode =
213 autotoolsDoc.SelectSingleNode(nodeName + "/*");
214 templateTransformer.Load(templateNode.CreateNavigator(), xr, e);
215
216 // Create a writer for the transformed template
217 XmlTextWriter templateWriter =
218 new XmlTextWriter(filename, null);
219
220 // Perform transformation, writing the file
221 templateTransformer.Transform
222 (m_Kernel.CurrentDoc, argList, templateWriter, xr);
223 }
224
225 string NormalizeAsmName(string name)
226 {
227 int i = name.IndexOf(", PublicKeyToken=null");
228 if (i != -1)
229 return name.Substring(0, i).Trim();
230 else
231 return name;
232 }
233
234 private void AddAssembly(string assemblyfile, SystemPackage package)
235 {
236 if (!File.Exists(assemblyfile))
237 return;
238
239 try
240 {
241 System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile);
242 assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile;
243 assemblyPathToPackage[assemblyfile] = package;
244 }
245 catch
246 {
247 }
248 }
249
250 private List<string> GetAssembliesWithLibInfo(string line, string file)
251 {
252 List<string> references = new List<string>();
253 List<string> libdirs = new List<string>();
254 List<string> retval = new List<string>();
255 foreach (string piece in line.Split(' '))
256 {
257 if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:"))
258 {
259 references.Add(ProcessPiece(piece.Substring(3).Trim(), file));
260 }
261 else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:"))
262 {
263 libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file));
264 }
265 }
266
267 foreach (string refrnc in references)
268 {
269 foreach (string libdir in libdirs)
270 {
271 if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc))
272 {
273 retval.Add(libdir + Path.DirectorySeparatorChar + refrnc);
274 }
275 }
276 }
277
278 return retval;
279 }
280
281 private List<string> GetAssembliesWithoutLibInfo(string line, string file)
282 {
283 List<string> references = new List<string>();
284 foreach (string reference in line.Split(' '))
285 {
286 if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:"))
287 {
288 string final_ref = reference.Substring(3).Trim();
289 references.Add(ProcessPiece(final_ref, file));
290 }
291 }
292 return references;
293 }
294
295 private string ProcessPiece(string piece, string pcfile)
296 {
297 int start = piece.IndexOf("${");
298 if (start == -1)
299 return piece;
300
301 int end = piece.IndexOf("}");
302 if (end == -1)
303 return piece;
304
305 string variable = piece.Substring(start + 2, end - start - 2);
306 string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile));
307 return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile);
308 }
309
310 private string GetVariableFromPkgConfig(string var, string pcfile)
311 {
312 ProcessStartInfo psi = new ProcessStartInfo("pkg-config");
313 psi.RedirectStandardOutput = true;
314 psi.UseShellExecute = false;
315 psi.Arguments = String.Format("--variable={0} {1}", var, pcfile);
316 Process p = new Process();
317 p.StartInfo = psi;
318 p.Start();
319 string ret = p.StandardOutput.ReadToEnd().Trim();
320 p.WaitForExit();
321 if (String.IsNullOrEmpty(ret))
322 return String.Empty;
323 return ret;
324 }
325
326 private void ParsePCFile(string pcfile)
327 {
328 // Don't register the package twice
329 string pname = Path.GetFileNameWithoutExtension(pcfile);
330 if (packagesHash.Contains(pname))
331 return;
332
333 List<string> fullassemblies = null;
334 string version = "";
335 string desc = "";
336
337 SystemPackage package = new SystemPackage();
338
339 using (StreamReader reader = new StreamReader(pcfile))
340 {
341 string line;
342 while ((line = reader.ReadLine()) != null)
343 {
344 string lowerLine = line.ToLower();
345 if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1)
346 {
347 string choppedLine = line.Substring(5).Trim();
348 if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1)
349 {
350 fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile);
351 }
352 else
353 {
354 fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile);
355 }
356 }
357 else if (lowerLine.StartsWith("version:"))
358 {
359 // "version:".Length == 8
360 version = line.Substring(8).Trim();
361 }
362 else if (lowerLine.StartsWith("description:"))
363 {
364 // "description:".Length == 12
365 desc = line.Substring(12).Trim();
366 }
367 }
368 }
369
370 if (fullassemblies == null)
371 return;
372
373 foreach (string assembly in fullassemblies)
374 {
375 AddAssembly(assembly, package);
376 }
377
378 package.Initialize(pname,
379 version,
380 desc,
381 fullassemblies.ToArray(),
382 ClrVersion.Default,
383 false);
384 packages.Add(package);
385 packagesHash[pname] = package;
386 }
387
388 void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver)
389 {
390 SystemPackage package = new SystemPackage();
391 List<string> list = new List<string>();
392
393 string dir = Path.Combine(prefix, version);
394 if (!Directory.Exists(dir))
395 {
396 return;
397 }
398
399 foreach (string assembly in Directory.GetFiles(dir, "*.dll"))
400 {
401 AddAssembly(assembly, package);
402 list.Add(assembly);
403 }
404
405 package.Initialize("mono",
406 version,
407 "The Mono runtime",
408 list.ToArray(),
409 ver,
410 false);
411 packages.Add(package);
412 }
413
414 void RunInitialization()
415 {
416 string versionDir;
417
418 if (Environment.Version.Major == 1)
419 {
420 versionDir = "1.0";
421 }
422 else
423 {
424 versionDir = "2.0";
425 }
426
427 //Pull up assemblies from the installed mono system.
428 string prefix = Path.GetDirectoryName(typeof(int).Assembly.Location);
429
430 if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1)
431 prefix = Path.Combine(prefix, "mono");
432 else
433 prefix = Path.GetDirectoryName(prefix);
434
435 RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1);
436 RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0);
437
438 string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH");
439 string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH");
440
441 if (String.IsNullOrEmpty(libpath))
442 {
443 string path_dirs = Environment.GetEnvironmentVariable("PATH");
444 foreach (string pathdir in path_dirs.Split(Path.PathSeparator))
445 {
446 if (pathdir == null)
447 continue;
448 if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config"))
449 {
450 libpath = Path.Combine(pathdir, "..");
451 libpath = Path.Combine(libpath, "lib");
452 libpath = Path.Combine(libpath, "pkgconfig");
453 break;
454 }
455 }
456 }
457 search_dirs += Path.PathSeparator + libpath;
458 if (!string.IsNullOrEmpty(search_dirs))
459 {
460 List<string> scanDirs = new List<string>();
461 foreach (string potentialDir in search_dirs.Split(Path.PathSeparator))
462 {
463 if (!scanDirs.Contains(potentialDir))
464 scanDirs.Add(potentialDir);
465 }
466 foreach (string pcdir in scanDirs)
467 {
468 if (pcdir == null)
469 continue;
470
471 if (Directory.Exists(pcdir))
472 {
473 foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc"))
474 {
475 ParsePCFile(pcfile);
476 }
477 }
478 }
479 }
480 }
481
482 private void WriteCombine(SolutionNode solution)
483 {
484 #region "Create Solution directory if it doesn't exist"
485 string solutionDir = Path.Combine(solution.FullPath,
486 Path.Combine("autotools",
487 solution.Name));
488 chkMkDir(solutionDir);
489 #endregion
490
491 #region "Write Solution-level files"
492 XsltArgumentList argList = new XsltArgumentList();
493 argList.AddParam("solutionName", "", solution.Name);
494 // $solutionDir is $rootDir/$solutionName/
495 transformToFile(Path.Combine(solutionDir, "configure.ac"),
496 argList, "/Autotools/SolutionConfigureAc");
497 transformToFile(Path.Combine(solutionDir, "Makefile.am"),
498 argList, "/Autotools/SolutionMakefileAm");
499 transformToFile(Path.Combine(solutionDir, "autogen.sh"),
500 argList, "/Autotools/SolutionAutogenSh");
501 #endregion
502
503 foreach (ProjectNode project in solution.ProjectsTableOrder)
504 {
505 m_Kernel.Log.Write(String.Format("Writing project: {0}",
506 project.Name));
507 WriteProject(solution, project);
508 }
509 }
510 private static string PrependPath(string path)
511 {
512 string tmpPath = Helper.NormalizePath(path, '/');
513 Regex regex = new Regex(@"(\w):/(\w+)");
514 Match match = regex.Match(tmpPath);
515 if (match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
516 {
517 tmpPath = Helper.NormalizePath(tmpPath);
518 }
519 else
520 {
521 tmpPath = Helper.NormalizePath("./" + tmpPath);
522 }
523
524 return tmpPath;
525 }
526
527 private static string BuildReference(SolutionNode solution,
528 ReferenceNode refr)
529 {
530 string ret = "";
531 if (solution.ProjectsTable.ContainsKey(refr.Name))
532 {
533 ProjectNode project =
534 (ProjectNode)solution.ProjectsTable[refr.Name];
535 string fileRef = FindFileReference(refr.Name, project);
536 string finalPath =
537 Helper.NormalizePath(Helper.MakeFilePath(project.FullPath +
538 "/$(BUILD_DIR)/$(CONFIG)/",
539 refr.Name, "dll"),
540 '/');
541 ret += finalPath;
542 return ret;
543 }
544 else
545 {
546 ProjectNode project = (ProjectNode)refr.Parent;
547 string fileRef = FindFileReference(refr.Name, project);
548
549 if (refr.Path != null || fileRef != null)
550 {
551 string finalPath = ((refr.Path != null) ?
552 Helper.NormalizePath(refr.Path + "/" +
553 refr.Name + ".dll",
554 '/') :
555 fileRef
556 );
557 ret += Path.Combine(project.Path, finalPath);
558 return ret;
559 }
560
561 try
562 {
563 //Assembly assem = Assembly.Load(refr.Name);
564 //if (assem != null)
565 //{
566 // int index = refr.Name.IndexOf(",");
567 // if ( index > 0)
568 // {
569 // ret += assem.Location;
570 // //Console.WriteLine("Location1: " + assem.Location);
571 // }
572 // else
573 // {
574 // ret += (refr.Name + ".dll");
575 // //Console.WriteLine("Location2: " + assem.Location);
576 // }
577 //}
578 //else
579 //{
580 int index = refr.Name.IndexOf(",");
581 if (index > 0)
582 {
583 ret += refr.Name.Substring(0, index) + ".dll";
584 //Console.WriteLine("Location3: " + assem.Location);
585 }
586 else
587 {
588 ret += (refr.Name + ".dll");
589 //Console.WriteLine("Location4: " + assem.Location);
590 }
591 //}
592 }
593 catch (System.NullReferenceException e)
594 {
595 e.ToString();
596 int index = refr.Name.IndexOf(",");
597 if (index > 0)
598 {
599 ret += refr.Name.Substring(0, index) + ".dll";
600 //Console.WriteLine("Location5: " + assem.Location);
601 }
602 else
603 {
604 ret += (refr.Name + ".dll");
605 //Console.WriteLine("Location6: " + assem.Location);
606 }
607 }
608 }
609 return ret;
610 }
611
612 private static string BuildReferencePath(SolutionNode solution,
613 ReferenceNode refr)
614 {
615 string ret = "";
616 if (solution.ProjectsTable.ContainsKey(refr.Name))
617 {
618 ProjectNode project =
619 (ProjectNode)solution.ProjectsTable[refr.Name];
620 string finalPath =
621 Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath +
622 "/${build.dir}/"),
623 '/');
624 ret += finalPath;
625 return ret;
626 }
627 else
628 {
629 ProjectNode project = (ProjectNode)refr.Parent;
630 string fileRef = FindFileReference(refr.Name, project);
631
632 if (refr.Path != null || fileRef != null)
633 {
634 string finalPath = ((refr.Path != null) ?
635 Helper.NormalizePath(refr.Path, '/') :
636 fileRef
637 );
638 ret += finalPath;
639 return ret;
640 }
641
642 try
643 {
644 Assembly assem = Assembly.Load(refr.Name);
645 if (assem != null)
646 {
647 ret += "";
648 }
649 else
650 {
651 ret += "";
652 }
653 }
654 catch (System.NullReferenceException e)
655 {
656 e.ToString();
657 ret += "";
658 }
659 }
660 return ret;
661 }
662
663 private static string FindFileReference(string refName,
664 ProjectNode project)
665 {
666 foreach (ReferencePathNode refPath in project.ReferencePaths)
667 {
668 string fullPath =
669 Helper.MakeFilePath(refPath.Path, refName, "dll");
670
671 if (File.Exists(fullPath)) {
672 return fullPath;
673 }
674 }
675
676 return null;
677 }
678
679 /// <summary>
680 /// Gets the XML doc file.
681 /// </summary>
682 /// <param name="project">The project.</param>
683 /// <param name="conf">The conf.</param>
684 /// <returns></returns>
685 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
686 {
687 if (conf == null)
688 {
689 throw new ArgumentNullException("conf");
690 }
691 if (project == null)
692 {
693 throw new ArgumentNullException("project");
694 }
695 string docFile = (string)conf.Options["XmlDocFile"];
696 // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
697 // {
698 // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
699 // }
700 return docFile;
701 }
702
703 /// <summary>
704 /// Normalizes the path.
705 /// </summary>
706 /// <param name="path">The path.</param>
707 /// <returns></returns>
708 public static string NormalizePath(string path)
709 {
710 if (path == null)
711 {
712 return "";
713 }
714
715 StringBuilder tmpPath;
716
717 if (Core.Parse.Preprocessor.GetOS() == "Win32")
718 {
719 tmpPath = new StringBuilder(path.Replace('\\', '/'));
720 tmpPath.Replace("/", @"\\");
721 }
722 else
723 {
724 tmpPath = new StringBuilder(path.Replace('\\', '/'));
725 tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar);
726 }
727 return tmpPath.ToString();
728 }
729
730 private void WriteProject(SolutionNode solution, ProjectNode project)
731 {
732 string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name));
733 string projectDir = Path.Combine(solutionDir, project.Name);
734 string projectVersion = project.Version;
735 bool hasAssemblyConfig = false;
736 chkMkDir(projectDir);
737
738 List<string>
739 compiledFiles = new List<string>(),
740 contentFiles = new List<string>(),
741 embeddedFiles = new List<string>(),
742
743 binaryLibs = new List<string>(),
744 pkgLibs = new List<string>(),
745 systemLibs = new List<string>(),
746 runtimeLibs = new List<string>(),
747
748 extraDistFiles = new List<string>(),
749 localCopyTargets = new List<string>();
750
751 // If there exists a .config file for this assembly, copy
752 // it to the project folder
753
754 // TODO: Support copying .config.osx files
755 // TODO: support processing the .config file for native library deps
756 string projectAssemblyName = project.Name;
757 if (project.AssemblyName != null)
758 projectAssemblyName = project.AssemblyName;
759
760 if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config"))
761 {
762 hasAssemblyConfig = true;
763 System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true);
764 extraDistFiles.Add(project.AssemblyName + ".dll.config");
765 }
766
767 foreach (ConfigurationNode conf in project.Configurations)
768 {
769 if (conf.Options.KeyFile != string.Empty)
770 {
771 // Copy snk file into the project's directory
772 // Use the snk from the project directory directly
773 string source = Path.Combine(project.FullPath, conf.Options.KeyFile);
774 string keyFile = conf.Options.KeyFile;
775 Regex re = new Regex(".*/");
776 keyFile = re.Replace(keyFile, "");
777
778 string dest = Path.Combine(projectDir, keyFile);
779 // Tell the user if there's a problem copying the file
780 try
781 {
782 mkdirDashP(System.IO.Path.GetDirectoryName(dest));
783 System.IO.File.Copy(source, dest, true);
784 }
785 catch (System.IO.IOException e)
786 {
787 Console.WriteLine(e.Message);
788 }
789 }
790 }
791
792 // Copy compiled, embedded and content files into the project's directory
793 foreach (string filename in project.Files)
794 {
795 string source = Path.Combine(project.FullPath, filename);
796 string dest = Path.Combine(projectDir, filename);
797
798 if (filename.Contains("AssemblyInfo.cs"))
799 {
800 // If we've got an AssemblyInfo.cs, pull the version number from it
801 string[] sources = { source };
802 string[] args = { "" };
803 Microsoft.CSharp.CSharpCodeProvider cscp =
804 new Microsoft.CSharp.CSharpCodeProvider();
805
806 string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll");
807 System.CodeDom.Compiler.CompilerParameters cparam =
808 new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile);
809
810 System.CodeDom.Compiler.CompilerResults cr =
811 cscp.CompileAssemblyFromFile(cparam, sources);
812
813 foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors)
814 Console.WriteLine("Error! '{0}'", error.ErrorText);
815
816 try {
817 string projectFullName = cr.CompiledAssembly.FullName;
818 Regex verRegex = new Regex("Version=([\\d\\.]+)");
819 Match verMatch = verRegex.Match(projectFullName);
820 if (verMatch.Success)
821 projectVersion = verMatch.Groups[1].Value;
822 }catch{
823 Console.WriteLine("Couldn't compile AssemblyInfo.cs");
824 }
825
826 // Clean up the temp file
827 try
828 {
829 if (File.Exists(tempAssemblyFile))
830 File.Delete(tempAssemblyFile);
831 }
832 catch
833 {
834 Console.WriteLine("Error! '{0}'", e.ToString());
835 }
836
837 }
838
839 // Tell the user if there's a problem copying the file
840 try
841 {
842 mkdirDashP(System.IO.Path.GetDirectoryName(dest));
843 System.IO.File.Copy(source, dest, true);
844 }
845 catch (System.IO.IOException e)
846 {
847 Console.WriteLine(e.Message);
848 }
849
850 switch (project.Files.GetBuildAction(filename))
851 {
852 case BuildAction.Compile:
853 compiledFiles.Add(filename);
854 break;
855 case BuildAction.Content:
856 contentFiles.Add(filename);
857 extraDistFiles.Add(filename);
858 break;
859 case BuildAction.EmbeddedResource:
860 embeddedFiles.Add(filename);
861 break;
862 }
863 }
864
865 // Set up references
866 for (int refNum = 0; refNum < project.References.Count; refNum++)
867 {
868 ReferenceNode refr = (ReferenceNode)project.References[refNum];
869 Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name);
870
871 /* Determine which pkg-config (.pc) file refers to
872 this assembly */
873
874 SystemPackage package = null;
875
876 if (packagesHash.Contains(refr.Name)){
877 package = (SystemPackage)packagesHash[refr.Name];
878
879 }else{
880 string assemblyFullName = string.Empty;
881 if (refAssembly != null)
882 assemblyFullName = refAssembly.FullName;
883
884 string assemblyFileName = string.Empty;
885 if (assemblyFullName != string.Empty &&
886 assemblyFullNameToPath.Contains(assemblyFullName)
887 )
888 assemblyFileName =
889 (string)assemblyFullNameToPath[assemblyFullName];
890
891 if (assemblyFileName != string.Empty &&
892 assemblyPathToPackage.Contains(assemblyFileName)
893 )
894 package = (SystemPackage)assemblyPathToPackage[assemblyFileName];
895
896 }
897
898 /* If we know the .pc file and it is not "mono"
899 (already in the path), add a -pkg: argument */
900
901 if (package != null &&
902 package.Name != "mono" &&
903 !pkgLibs.Contains(package.Name)
904 )
905 pkgLibs.Add(package.Name);
906
907 string fileRef =
908 FindFileReference(refr.Name, (ProjectNode)refr.Parent);
909
910 if (refr.LocalCopy ||
911 solution.ProjectsTable.ContainsKey(refr.Name) ||
912 fileRef != null ||
913 refr.Path != null
914 )
915 {
916
917 /* Attempt to copy the referenced lib to the
918 project's directory */
919
920 string filename = refr.Name + ".dll";
921 string source = filename;
922 if (refr.Path != null)
923 source = Path.Combine(refr.Path, source);
924 source = Path.Combine(project.FullPath, source);
925 string dest = Path.Combine(projectDir, filename);
926
927 /* Since we depend on this binary dll to build, we
928 * will add a compile- time dependency on the
929 * copied dll, and add the dll to the list of
930 * files distributed with this package
931 */
932
933 binaryLibs.Add(refr.Name + ".dll");
934 extraDistFiles.Add(refr.Name + ".dll");
935
936 // TODO: Support copying .config.osx files
937 // TODO: Support for determining native dependencies
938 if (File.Exists(source + ".config"))
939 {
940 System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true);
941 extraDistFiles.Add(refr.Name + ".dll.config");
942 }
943
944 try
945 {
946 System.IO.File.Copy(source, dest, true);
947 }
948 catch (System.IO.IOException)
949 {
950 if (solution.ProjectsTable.ContainsKey(refr.Name)){
951
952 /* If an assembly is referenced, marked for
953 * local copy, in the list of projects for
954 * this solution, but does not exist, put a
955 * target into the Makefile.am to build the
956 * assembly and copy it to this project's
957 * directory
958 */
959
960 ProjectNode sourcePrj =
961 ((ProjectNode)(solution.ProjectsTable[refr.Name]));
962
963 string target =
964 String.Format("{0}:\n" +
965 "\t$(MAKE) -C ../{1}\n" +
966 "\tln ../{2}/$@ $@\n",
967 filename,
968 sourcePrj.Name,
969 sourcePrj.Name );
970
971 localCopyTargets.Add(target);
972 }
973 }
974 }
975 else if( !pkgLibs.Contains(refr.Name) )
976 {
977 // Else, let's assume it's in the GAC or the lib path
978 string assemName = string.Empty;
979 int index = refr.Name.IndexOf(",");
980
981 if (index > 0)
982 assemName = refr.Name.Substring(0, index);
983 else
984 assemName = refr.Name;
985
986 m_Kernel.Log.Write(String.Format(
987 "Warning: Couldn't find an appropriate assembly " +
988 "for reference:\n'{0}'", refr.Name
989 ));
990 systemLibs.Add(assemName);
991 }
992 }
993
994 const string lineSep = " \\\n\t";
995 string compiledFilesString = string.Empty;
996 if (compiledFiles.Count > 0)
997 compiledFilesString =
998 lineSep + string.Join(lineSep, compiledFiles.ToArray());
999
1000 string embeddedFilesString = "";
1001 if (embeddedFiles.Count > 0)
1002 embeddedFilesString =
1003 lineSep + string.Join(lineSep, embeddedFiles.ToArray());
1004
1005 string contentFilesString = "";
1006 if (contentFiles.Count > 0)
1007 contentFilesString =
1008 lineSep + string.Join(lineSep, contentFiles.ToArray());
1009
1010 string extraDistFilesString = "";
1011 if (extraDistFiles.Count > 0)
1012 extraDistFilesString =
1013 lineSep + string.Join(lineSep, extraDistFiles.ToArray());
1014
1015 string pkgLibsString = "";
1016 if (pkgLibs.Count > 0)
1017 pkgLibsString =
1018 lineSep + string.Join(lineSep, pkgLibs.ToArray());
1019
1020 string binaryLibsString = "";
1021 if (binaryLibs.Count > 0)
1022 binaryLibsString =
1023 lineSep + string.Join(lineSep, binaryLibs.ToArray());
1024
1025 string systemLibsString = "";
1026 if (systemLibs.Count > 0)
1027 systemLibsString =
1028 lineSep + string.Join(lineSep, systemLibs.ToArray());
1029
1030 string localCopyTargetsString = "";
1031 if (localCopyTargets.Count > 0)
1032 localCopyTargetsString =
1033 string.Join("\n", localCopyTargets.ToArray());
1034
1035 string monoPath = "";
1036 foreach (string runtimeLib in runtimeLibs)
1037 {
1038 monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`";
1039 }
1040
1041 // Add the project name to the list of transformation
1042 // parameters
1043 XsltArgumentList argList = new XsltArgumentList();
1044 argList.AddParam("projectName", "", project.Name);
1045 argList.AddParam("solutionName", "", solution.Name);
1046 argList.AddParam("assemblyName", "", projectAssemblyName);
1047 argList.AddParam("compiledFiles", "", compiledFilesString);
1048 argList.AddParam("embeddedFiles", "", embeddedFilesString);
1049 argList.AddParam("contentFiles", "", contentFilesString);
1050 argList.AddParam("extraDistFiles", "", extraDistFilesString);
1051 argList.AddParam("pkgLibs", "", pkgLibsString);
1052 argList.AddParam("binaryLibs", "", binaryLibsString);
1053 argList.AddParam("systemLibs", "", systemLibsString);
1054 argList.AddParam("monoPath", "", monoPath);
1055 argList.AddParam("localCopyTargets", "", localCopyTargetsString);
1056 argList.AddParam("projectVersion", "", projectVersion);
1057 argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : "");
1058
1059 // Transform the templates
1060 transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc");
1061 transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm");
1062 transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh");
1063
1064 if (project.Type == Core.Nodes.ProjectType.Library)
1065 transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn");
1066 if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe)
1067 transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn");
1068 }
1069
1070 private void WriteProjectOld(SolutionNode solution, ProjectNode project)
1071 {
1072 string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
1073 StreamWriter ss = new StreamWriter(projFile);
1074 ss.NewLine = "\n";
1075
1076 m_Kernel.CurrentWorkingDirectory.Push();
1077 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
1078
1079 using (ss)
1080 {
1081 ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":");
1082 ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/");
1083 foreach (string file in project.Files)
1084 {
1085 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
1086 {
1087 ss.Write("\tresgen ");
1088 ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/'));
1089 if (project.Files.GetResourceName(file) != "")
1090 {
1091 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/'));
1092 }
1093 else
1094 {
1095 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/'));
1096 }
1097 }
1098 }
1099 ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\");
1100 ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\");
1101 if (project.References.Count > 0)
1102 {
1103 ss.Write("\t\t/reference:");
1104 bool firstref = true;
1105 foreach (ReferenceNode refr in project.References)
1106 {
1107 if (firstref)
1108 {
1109 firstref = false;
1110 }
1111 else
1112 {
1113 ss.Write(",");
1114 }
1115 ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/'));
1116 }
1117 ss.WriteLine(" \\");
1118 }
1119 //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\");
1120
1121 foreach (string file in project.Files)
1122 {
1123 switch (project.Files.GetBuildAction(file))
1124 {
1125 case BuildAction.EmbeddedResource:
1126 ss.Write("\t\t/resource:");
1127 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\");
1128 break;
1129 default:
1130 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
1131 {
1132 ss.Write("\t\t/resource:");
1133 if (project.Files.GetResourceName(file) != "")
1134 {
1135 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\");
1136 }
1137 else
1138 {
1139 ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\");
1140 }
1141 }
1142 break;
1143 }
1144 }
1145
1146 foreach (ConfigurationNode conf in project.Configurations)
1147 {
1148 if (conf.Options.KeyFile != "")
1149 {
1150 ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\");
1151 break;
1152 }
1153 }
1154 foreach (ConfigurationNode conf in project.Configurations)
1155 {
1156 if (conf.Options.AllowUnsafe)
1157 {
1158 ss.WriteLine("\t\t/unsafe \\");
1159 break;
1160 }
1161 }
1162 if (project.AppIcon != "")
1163 {
1164 ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\");
1165 }
1166
1167 foreach (ConfigurationNode conf in project.Configurations)
1168 {
1169 ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\");
1170 break;
1171 }
1172
1173 foreach (ConfigurationNode conf in project.Configurations)
1174 {
1175 if (GetXmlDocFile(project, conf) != "")
1176 {
1177 ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\");
1178 break;
1179 }
1180 }
1181 foreach (string file in project.Files)
1182 {
1183 switch (project.Files.GetBuildAction(file))
1184 {
1185 case BuildAction.Compile:
1186 ss.WriteLine("\t\t\\");
1187 ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file)));
1188 break;
1189 default:
1190 break;
1191 }
1192 }
1193 ss.WriteLine();
1194 ss.WriteLine();
1195
1196 if (project.Type == ProjectType.Library)
1197 {
1198 ss.WriteLine("install-data-local:");
1199 ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\");
1200 ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;");
1201 ss.WriteLine();
1202 ss.WriteLine("uninstall-local:");
1203 ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\");
1204 ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;");
1205 ss.WriteLine();
1206 }
1207 ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml");
1208 ss.WriteLine("EXTRA_DIST = \\");
1209 ss.Write(" $(FILES)");
1210 foreach (ConfigurationNode conf in project.Configurations)
1211 {
1212 if (conf.Options.KeyFile != "")
1213 {
1214 ss.Write(" \\");
1215 ss.WriteLine("\t" + conf.Options.KeyFile);
1216 }
1217 break;
1218 }
1219 }
1220 m_Kernel.CurrentWorkingDirectory.Pop();
1221 }
1222 bool hasLibrary = false;
1223
1224 private void WriteCombineOld(SolutionNode solution)
1225 {
1226
1227 /* TODO: These vars should be pulled from the prebuild.xml file */
1228 string releaseVersion = "2.0.0";
1229 string assemblyVersion = "2.1.0.0";
1230 string description =
1231 "Tao Framework " + solution.Name + " Binding For .NET";
1232
1233 hasLibrary = false;
1234 m_Kernel.Log.Write("Creating Autotools make files");
1235 foreach (ProjectNode project in solution.Projects)
1236 {
1237 if (m_Kernel.AllowProject(project.FilterGroups))
1238 {
1239 m_Kernel.Log.Write("...Creating makefile: {0}", project.Name);
1240 WriteProject(solution, project);
1241 }
1242 }
1243
1244 m_Kernel.Log.Write("");
1245 string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
1246 StreamWriter ss = new StreamWriter(combFile);
1247 ss.NewLine = "\n";
1248
1249 m_Kernel.CurrentWorkingDirectory.Push();
1250 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
1251
1252 using (ss)
1253 {
1254 foreach (ProjectNode project in solution.ProjectsTableOrder)
1255 {
1256 if (project.Type == ProjectType.Library)
1257 {
1258 hasLibrary = true;
1259 break;
1260 }
1261 }
1262
1263 if (hasLibrary)
1264 {
1265 ss.Write("pkgconfig_in_files = ");
1266 foreach (ProjectNode project in solution.ProjectsTableOrder)
1267 {
1268 if (project.Type == ProjectType.Library)
1269 {
1270 string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in");
1271 ss.Write(" " + project.Name + ".pc.in ");
1272 StreamWriter sspc = new StreamWriter(combFilepc);
1273 sspc.NewLine = "\n";
1274 using (sspc)
1275 {
1276 sspc.WriteLine("prefix=@prefix@");
1277 sspc.WriteLine("exec_prefix=${prefix}");
1278 sspc.WriteLine("libdir=${exec_prefix}/lib");
1279 sspc.WriteLine();
1280 sspc.WriteLine("Name: @PACKAGE_NAME@");
1281 sspc.WriteLine("Description: @DESCRIPTION@");
1282 sspc.WriteLine("Version: @ASSEMBLY_VERSION@");
1283 sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll");
1284 }
1285 }
1286 }
1287
1288 ss.WriteLine();
1289 ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig");
1290 ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)");
1291 }
1292 ss.WriteLine();
1293 foreach (ProjectNode project in solution.ProjectsTableOrder)
1294 {
1295 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
1296 ss.WriteLine("-include x {0}",
1297 Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"), '/'));
1298 }
1299 ss.WriteLine();
1300 ss.WriteLine("all: \\");
1301 ss.Write("\t");
1302 foreach (ProjectNode project in solution.ProjectsTableOrder)
1303 {
1304 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
1305 ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " ");
1306
1307 }
1308 ss.WriteLine();
1309 if (hasLibrary)
1310 {
1311 ss.WriteLine("EXTRA_DIST = \\");
1312 ss.WriteLine("\t$(pkgconfig_in_files)");
1313 }
1314 else
1315 {
1316 ss.WriteLine("EXTRA_DIST = ");
1317 }
1318 ss.WriteLine();
1319 ss.WriteLine("DISTCLEANFILES = \\");
1320 ss.WriteLine("\tconfigure \\");
1321 ss.WriteLine("\tMakefile.in \\");
1322 ss.WriteLine("\taclocal.m4");
1323 }
1324 combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
1325 StreamWriter ts = new StreamWriter(combFile);
1326 ts.NewLine = "\n";
1327 using (ts)
1328 {
1329 if (this.hasLibrary)
1330 {
1331 foreach (ProjectNode project in solution.ProjectsTableOrder)
1332 {
1333 if (project.Type == ProjectType.Library)
1334 {
1335 ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)");
1336 break;
1337 }
1338 }
1339 }
1340 else
1341 {
1342 ts.WriteLine("AC_INIT(Makefile.am)");
1343 }
1344 ts.WriteLine("AC_PREREQ(2.53)");
1345 ts.WriteLine("AC_CANONICAL_SYSTEM");
1346
1347 ts.WriteLine("PACKAGE_NAME={0}", solution.Name);
1348 ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion);
1349 ts.WriteLine("DESCRIPTION=\"{0}\"", description);
1350 ts.WriteLine("AC_SUBST(DESCRIPTION)");
1351 ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])");
1352
1353 ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion);
1354 ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)");
1355
1356 ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`");
1357 ts.WriteLine("AC_SUBST(PUBKEY)");
1358
1359 ts.WriteLine();
1360 ts.WriteLine("AM_MAINTAINER_MODE");
1361 ts.WriteLine();
1362 ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])");
1363 ts.WriteLine();
1364 ts.WriteLine("AC_PROG_INSTALL");
1365 ts.WriteLine();
1366 ts.WriteLine("MONO_REQUIRED_VERSION=1.1");
1367 ts.WriteLine();
1368 ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])");
1369 ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then");
1370 ts.WriteLine(" from_cvs=yes");
1371 ts.WriteLine("else");
1372 ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then");
1373 ts.WriteLine(" from_cvs=yes");
1374 ts.WriteLine(" else");
1375 ts.WriteLine(" from_cvs=no");
1376 ts.WriteLine(" fi");
1377 ts.WriteLine("fi");
1378 ts.WriteLine();
1379 ts.WriteLine("AC_MSG_RESULT($from_cvs)");
1380 ts.WriteLine();
1381 ts.WriteLine("AC_PATH_PROG(MONO, mono)");
1382 ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)");
1383 ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)");
1384 ts.WriteLine();
1385 ts.WriteLine("AC_MSG_CHECKING([for mono])");
1386 ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then");
1387 ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])");
1388 ts.WriteLine("dnl else");
1389 ts.WriteLine(" AC_MSG_RESULT([found])");
1390 ts.WriteLine("dnl fi");
1391 ts.WriteLine();
1392 ts.WriteLine("AC_MSG_CHECKING([for gmcs])");
1393 ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then");
1394 ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])");
1395 ts.WriteLine("dnl else");
1396 ts.WriteLine(" AC_MSG_RESULT([found])");
1397 ts.WriteLine("dnl fi");
1398 ts.WriteLine();
1399 //ts.WriteLine("AC_MSG_CHECKING([for gacutil])");
1400 //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then");
1401 //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])");
1402 //ts.WriteLine("else");
1403 //ts.WriteLine(" AC_MSG_RESULT([found])");
1404 //ts.WriteLine("fi");
1405 ts.WriteLine();
1406 ts.WriteLine("AC_SUBST(PATH)");
1407 ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)");
1408 ts.WriteLine();
1409 ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\"");
1410 ts.WriteLine("CSFLAGS=\"\"");
1411 ts.WriteLine("AC_SUBST(CSFLAGS)");
1412 ts.WriteLine();
1413 // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)");
1414 // ts.WriteLine("AC_ARG_ENABLE(sdl,");
1415 // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],");
1416 // ts.WriteLine(" [disable_sdl=$disableval],");
1417 // ts.WriteLine(" [disable_sdl=\"no\"])");
1418 // ts.WriteLine("AC_MSG_RESULT($disable_sdl)");
1419 // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then");
1420 // ts.WriteLine(" AC_DEFINE(FEAT_SDL)");
1421 // ts.WriteLine("fi");
1422 ts.WriteLine();
1423 ts.WriteLine("dnl Find pkg-config");
1424 ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)");
1425 ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then");
1426 ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])");
1427 ts.WriteLine("fi");
1428 ts.WriteLine();
1429 ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)");
1430 ts.WriteLine("BUILD_DIR=\"bin\"");
1431 ts.WriteLine("AC_SUBST(BUILD_DIR)");
1432 ts.WriteLine("CONFIG=\"Release\"");
1433 ts.WriteLine("AC_SUBST(CONFIG)");
1434 ts.WriteLine();
1435 ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then");
1436 ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)");
1437 ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)");
1438 ts.WriteLine(" if test `uname -s` = \"Darwin\"; then");
1439 ts.WriteLine(" LIB_PREFIX=");
1440 ts.WriteLine(" LIB_SUFFIX=.dylib");
1441 ts.WriteLine(" else");
1442 ts.WriteLine(" LIB_PREFIX=.so");
1443 ts.WriteLine(" LIB_SUFFIX=");
1444 ts.WriteLine(" fi");
1445 ts.WriteLine("else");
1446 ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)");
1447 ts.WriteLine(" if test x$CSC = \"xno\"; then");
1448 ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])");
1449 ts.WriteLine(" else");
1450 ts.WriteLine(" RUNTIME=");
1451 ts.WriteLine(" LIB_PREFIX=");
1452 ts.WriteLine(" LIB_SUFFIX=.dylib");
1453 ts.WriteLine(" fi");
1454 ts.WriteLine("fi");
1455 ts.WriteLine();
1456 ts.WriteLine("AC_SUBST(LIB_PREFIX)");
1457 ts.WriteLine("AC_SUBST(LIB_SUFFIX)");
1458 ts.WriteLine();
1459 ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)");
1460 ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)");
1461 ts.WriteLine();
1462 ts.WriteLine("dnl Find monodoc");
1463 ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0");
1464 ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)");
1465 ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)");
1466 ts.WriteLine();
1467 ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then");
1468 ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)");
1469 ts.WriteLine(" if test x$MONODOC = xno; then");
1470 ts.WriteLine(" enable_monodoc=no");
1471 ts.WriteLine(" fi");
1472 ts.WriteLine("else");
1473 ts.WriteLine(" MONODOC=");
1474 ts.WriteLine("fi");
1475 ts.WriteLine();
1476 ts.WriteLine("AC_SUBST(MONODOC)");
1477 ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")");
1478 ts.WriteLine();
1479 ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)");
1480 ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then");
1481 ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])");
1482 ts.WriteLine("fi");
1483 ts.WriteLine();
1484 // foreach(ProjectNode project in solution.ProjectsTableOrder)
1485 // {
1486 // if (project.Type == ProjectType.Library)
1487 // {
1488 // }
1489 // }
1490 ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'");
1491 ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)");
1492 ts.WriteLine();
1493 ts.WriteLine("winbuild=no");
1494 ts.WriteLine("case \"$host\" in");
1495 ts.WriteLine(" *-*-mingw*|*-*-cygwin*)");
1496 ts.WriteLine(" winbuild=yes");
1497 ts.WriteLine(" ;;");
1498 ts.WriteLine("esac");
1499 ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)");
1500 ts.WriteLine();
1501 // ts.WriteLine("dnl Check for SDL");
1502 // ts.WriteLine();
1503 // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])");
1504 // ts.WriteLine("have_sdl=no");
1505 // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then");
1506 // ts.WriteLine(" have_sdl=yes");
1507 // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`");
1508 // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`");
1509 // ts.WriteLine(" #");
1510 // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library");
1511 // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from");
1512 // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a");
1513 // ts.WriteLine(" # version of the library also exists in SDL's library installation");
1514 // ts.WriteLine(" # directory, typically /usr/lib.");
1515 // ts.WriteLine(" #");
1516 // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`");
1517 // ts.WriteLine("fi");
1518 // ts.WriteLine("AC_SUBST([SDL_CFLAGS])");
1519 // ts.WriteLine("AC_SUBST([SDL_LIBS])");
1520 ts.WriteLine();
1521 ts.WriteLine("AC_OUTPUT([");
1522 ts.WriteLine("Makefile");
1523 // TODO: this does not work quite right.
1524 //ts.WriteLine("Properties/AssemblyInfo.cs");
1525 foreach (ProjectNode project in solution.ProjectsTableOrder)
1526 {
1527 if (project.Type == ProjectType.Library)
1528 {
1529 ts.WriteLine(project.Name + ".pc");
1530 }
1531 // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
1532 // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/'));
1533 }
1534 ts.WriteLine("])");
1535 ts.WriteLine();
1536 ts.WriteLine("#po/Makefile.in");
1537 ts.WriteLine();
1538 ts.WriteLine("echo \"---\"");
1539 ts.WriteLine("echo \"Configuration summary\"");
1540 ts.WriteLine("echo \"\"");
1541 ts.WriteLine("echo \" * Installation prefix: $prefix\"");
1542 ts.WriteLine("echo \" * compiler: $CSC\"");
1543 ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\"");
1544 ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\"");
1545 ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\"");
1546 ts.WriteLine("echo \" * Public Key: $PUBKEY\"");
1547 ts.WriteLine("echo \"\"");
1548 ts.WriteLine("echo \"---\"");
1549 ts.WriteLine();
1550 }
1551
1552 ts.NewLine = "\n";
1553 foreach (ProjectNode project in solution.ProjectsTableOrder)
1554 {
1555 if (project.GenerateAssemblyInfoFile)
1556 {
1557 GenerateAssemblyInfoFile(solution, combFile);
1558 }
1559 }
1560 }
1561
1562 private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile)
1563 {
1564 System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties"));
1565 combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in");
1566 StreamWriter ai = new StreamWriter(combFile);
1567
1568 using (ai)
1569 {
1570 ai.WriteLine("#region License");
1571 ai.WriteLine("/*");
1572 ai.WriteLine("MIT License");
1573 ai.WriteLine("Copyright (c)2003-2006 Tao Framework Team");
1574 ai.WriteLine("http://www.taoframework.com");
1575 ai.WriteLine("All rights reserved.");
1576 ai.WriteLine("");
1577 ai.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a copy");
1578 ai.WriteLine("of this software and associated documentation files (the \"Software\"), to deal");
1579 ai.WriteLine("in the Software without restriction, including without limitation the rights");
1580 ai.WriteLine("to use, copy, modify, merge, publish, distribute, sublicense, and/or sell");
1581 ai.WriteLine("copies of the Software, and to permit persons to whom the Software is");
1582 ai.WriteLine("furnished to do so, subject to the following conditions:");
1583 ai.WriteLine("");
1584 ai.WriteLine("The above copyright notice and this permission notice shall be included in all");
1585 ai.WriteLine("copies or substantial portions of the Software.");
1586 ai.WriteLine("");
1587 ai.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR");
1588 ai.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,");
1589 ai.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE");
1590 ai.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER");
1591 ai.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,");
1592 ai.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE");
1593 ai.WriteLine("SOFTWARE.");
1594 ai.WriteLine("*/");
1595 ai.WriteLine("#endregion License");
1596 ai.WriteLine("");
1597 ai.WriteLine("using System;");
1598 ai.WriteLine("using System.Reflection;");
1599 ai.WriteLine("using System.Runtime.InteropServices;");
1600 ai.WriteLine("using System.Security;");
1601 ai.WriteLine("using System.Security.Permissions;");
1602 ai.WriteLine("");
1603 ai.WriteLine("[assembly: AllowPartiallyTrustedCallers]");
1604 ai.WriteLine("[assembly: AssemblyCompany(\"Tao Framework -- http://www.taoframework.com\")]");
1605 ai.WriteLine("[assembly: AssemblyConfiguration(\"Retail\")]");
1606 ai.WriteLine("[assembly: AssemblyCopyright(\"Copyright (c)2003-2006 Tao Framework Team. All rights reserved.\")]");
1607 ai.WriteLine("[assembly: AssemblyCulture(\"\")]");
1608 ai.WriteLine("[assembly: AssemblyDefaultAlias(\"@PACKAGE_NAME@\")]");
1609 ai.WriteLine("[assembly: AssemblyDelaySign(false)]");
1610 ai.WriteLine("[assembly: AssemblyDescription(\"@DESCRIPTION@\")]");
1611 ai.WriteLine("[assembly: AssemblyFileVersion(\"@ASSEMBLY_VERSION@\")]");
1612 ai.WriteLine("[assembly: AssemblyInformationalVersion(\"@ASSEMBLY_VERSION@\")]");
1613 ai.WriteLine("[assembly: AssemblyKeyName(\"\")]");
1614 ai.WriteLine("[assembly: AssemblyProduct(\"@PACKAGE_NAME@.dll\")]");
1615 ai.WriteLine("[assembly: AssemblyTitle(\"@DESCRIPTION@\")]");
1616 ai.WriteLine("[assembly: AssemblyTrademark(\"Tao Framework -- http://www.taoframework.com\")]");
1617 ai.WriteLine("[assembly: AssemblyVersion(\"@ASSEMBLY_VERSION@\")]");
1618 ai.WriteLine("[assembly: CLSCompliant(true)]");
1619 ai.WriteLine("[assembly: ComVisible(false)]");
1620 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.Execution)]");
1621 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.SkipVerification)]");
1622 ai.WriteLine("[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags = SecurityPermissionFlag.UnmanagedCode)]");
1623
1624 }
1625 //return combFile;
1626 }
1627
1628 private void CleanProject(ProjectNode project)
1629 {
1630 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
1631 string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
1632 Helper.DeleteIfExists(projectFile);
1633 }
1634
1635 private void CleanSolution(SolutionNode solution)
1636 {
1637 m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name);
1638
1639 string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
1640 Helper.DeleteIfExists(slnFile);
1641
1642 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in");
1643 Helper.DeleteIfExists(slnFile);
1644
1645 slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
1646 Helper.DeleteIfExists(slnFile);
1647
1648 slnFile = Helper.MakeFilePath(solution.FullPath, "configure");
1649 Helper.DeleteIfExists(slnFile);
1650
1651 slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile");
1652 Helper.DeleteIfExists(slnFile);
1653
1654 foreach (ProjectNode project in solution.Projects)
1655 {
1656 CleanProject(project);
1657 }
1658
1659 m_Kernel.Log.Write("");
1660 }
1661
1662 #endregion
1663
1664 #region ITarget Members
1665
1666 /// <summary>
1667 /// Writes the specified kern.
1668 /// </summary>
1669 /// <param name="kern">The kern.</param>
1670 public void Write(Kernel kern)
1671 {
1672 if (kern == null)
1673 {
1674 throw new ArgumentNullException("kern");
1675 }
1676 m_Kernel = kern;
1677 m_Kernel.Log.Write("Parsing system pkg-config files");
1678 RunInitialization();
1679
1680 string streamName = "autotools.xml";
1681 string fqStreamName = String.Format("Prebuild.data.{0}",
1682 streamName
1683 );
1684
1685 // Retrieve stream for the autotools template XML
1686 Stream autotoolsStream = Assembly.GetExecutingAssembly()
1687 .GetManifestResourceStream(fqStreamName);
1688
1689 if(autotoolsStream == null) {
1690
1691 /*
1692 * try without the default namespace prepended, in
1693 * case prebuild.exe assembly was compiled with
1694 * something other than Visual Studio .NET
1695 */
1696
1697 autotoolsStream = Assembly.GetExecutingAssembly()
1698 .GetManifestResourceStream(streamName);
1699 if(autotoolsStream == null){
1700 string errStr =
1701 String.Format("Could not find embedded resource file:\n" +
1702 "'{0}' or '{1}'",
1703 streamName, fqStreamName
1704 );
1705
1706 m_Kernel.Log.Write(errStr);
1707
1708 throw new System.Reflection.TargetException(errStr);
1709 }
1710 }
1711
1712 // Create an XML URL Resolver with default credentials
1713 xr = new System.Xml.XmlUrlResolver();
1714 xr.Credentials = CredentialCache.DefaultCredentials;
1715
1716 // Create a default evidence - no need to limit access
1717 e = new System.Security.Policy.Evidence();
1718
1719 // Load the autotools XML
1720 autotoolsDoc = new XmlDocument();
1721 autotoolsDoc.Load(autotoolsStream);
1722
1723 /* rootDir is the filesystem location where the Autotools
1724 * build tree will be created - for now we'll make it
1725 * $PWD/autotools
1726 */
1727
1728 string pwd = Directory.GetCurrentDirectory();
1729 //string pwd = System.Environment.GetEnvironmentVariable("PWD");
1730 string rootDir = "";
1731 //if (pwd.Length != 0)
1732 //{
1733 rootDir = Path.Combine(pwd, "autotools");
1734 //}
1735 //else
1736 //{
1737 // pwd = Assembly.GetExecutingAssembly()
1738 //}
1739 chkMkDir(rootDir);
1740
1741 foreach (SolutionNode solution in kern.Solutions)
1742 {
1743 m_Kernel.Log.Write(String.Format("Writing solution: {0}",
1744 solution.Name));
1745 WriteCombine(solution);
1746 }
1747 m_Kernel = null;
1748 }
1749
1750 /// <summary>
1751 /// Cleans the specified kern.
1752 /// </summary>
1753 /// <param name="kern">The kern.</param>
1754 public virtual void Clean(Kernel kern)
1755 {
1756 if (kern == null)
1757 {
1758 throw new ArgumentNullException("kern");
1759 }
1760 m_Kernel = kern;
1761 foreach (SolutionNode sol in kern.Solutions)
1762 {
1763 CleanSolution(sol);
1764 }
1765 m_Kernel = null;
1766 }
1767
1768 /// <summary>
1769 /// Gets the name.
1770 /// </summary>
1771 /// <value>The name.</value>
1772 public string Name
1773 {
1774 get
1775 {
1776 return "autotools";
1777 }
1778 }
1779
1780 #endregion
1781 }
1782}
diff --git a/Prebuild/src/Core/Targets/DebugTarget.cs b/Prebuild/src/Core/Targets/DebugTarget.cs
deleted file mode 100644
index dc4e666..0000000
--- a/Prebuild/src/Core/Targets/DebugTarget.cs
+++ /dev/null
@@ -1,102 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice, this list of conditions
9 and the following disclaimer.
10* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
11 and the following disclaimer in the documentation and/or other materials provided with the
12 distribution.
13* The name of the author may not be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $
31 * $Revision: 164 $
32 */
33#endregion
34
35using System;
36
37using Prebuild.Core.Attributes;
38using Prebuild.Core.Interfaces;
39using Prebuild.Core.Nodes;
40
41#if (DEBUG && _DEBUG_TARGET)
42namespace Prebuild.Core.Targets
43{
44 [Target("debug")]
45 public class DebugTarget : ITarget
46 {
47#region Fields
48
49 private Kernel m_Kernel = null;
50
51#endregion
52
53#region ITarget Members
54
55 public void Write()
56 {
57 foreach(SolutionNode s in m_Kernel.Solutions)
58 {
59 Console.WriteLine("Solution [ {0}, {1} ]", s.Name, s.Path);
60 foreach(string file in s.Files)
61{
62 Console.WriteLine("\tFile [ {0} ]", file);
63}
64
65 foreach(ProjectNode proj in s.Projects)
66 {
67 Console.WriteLine("\tProject [ {0}, {1}. {2} ]", proj.Name, proj.Path, proj.Language);
68 foreach(string file in proj.Files)
69 Console.WriteLine("\t\tFile [ {0} ]", file);
70 }
71 }
72 }
73
74 public void Clean()
75 {
76 Console.WriteLine("Not implemented");
77 }
78
79 public string Name
80 {
81 get
82 {
83 return "debug";
84 }
85 }
86
87 public Kernel Kernel
88 {
89 get
90 {
91 return m_Kernel;
92 }
93 set
94 {
95 m_Kernel = value;
96 }
97 }
98
99#endregion
100 }
101}
102#endif
diff --git a/Prebuild/src/Core/Targets/MakefileTarget.cs b/Prebuild/src/Core/Targets/MakefileTarget.cs
deleted file mode 100644
index 86676d0..0000000
--- a/Prebuild/src/Core/Targets/MakefileTarget.cs
+++ /dev/null
@@ -1,471 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004 Crestez Leonard (cleonard@go.ro)
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.Collections;
28using System.Collections.Specialized;
29using System.IO;
30using System.Text.RegularExpressions;
31
32using Prebuild.Core.Attributes;
33using Prebuild.Core.Interfaces;
34using Prebuild.Core.Nodes;
35using Prebuild.Core.Utilities;
36
37namespace Prebuild.Core.Targets
38{
39 [Target("makefile")]
40 public class MakefileTarget : ITarget
41 {
42 #region Fields
43
44 private Kernel m_Kernel = null;
45
46 #endregion
47
48 #region Private Methods
49
50 // This converts a path relative to the path of a project to
51 // a path relative to the solution path.
52 private string NicePath(ProjectNode proj, string path)
53 {
54 string res;
55 SolutionNode solution = (SolutionNode)proj.Parent;
56 res = Path.Combine(Helper.NormalizePath(proj.FullPath, '/'), Helper.NormalizePath(path, '/'));
57 res = Helper.NormalizePath(res, '/');
58 res = res.Replace("/./", "/");
59 while (res.IndexOf("/../") >= 0)
60 {
61 int a = res.IndexOf("/../");
62 int b = res.LastIndexOf("/", a - 1);
63 res = res.Remove(b, a - b + 3);
64 }
65 res = Helper.MakePathRelativeTo(solution.FullPath, res);
66 if (res.StartsWith("./"))
67 res = res.Substring(2, res.Length - 2);
68 res = Helper.NormalizePath(res, '/');
69 return res;
70 }
71
72 private void WriteProjectFiles(StreamWriter f, SolutionNode solution, ProjectNode project)
73 {
74 // Write list of source code files
75 f.WriteLine("SOURCES_{0} = \\", project.Name);
76 foreach (string file in project.Files)
77 if (project.Files.GetBuildAction(file) == BuildAction.Compile)
78 f.WriteLine("\t{0} \\", NicePath(project, file));
79 f.WriteLine();
80
81 // Write list of resource files
82 f.WriteLine("RESOURCES_{0} = \\", project.Name);
83 foreach (string file in project.Files)
84 if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource)
85 {
86 string path = NicePath(project, file);
87 f.WriteLine("\t-resource:{0},{1} \\", path, Path.GetFileName(path));
88 }
89 f.WriteLine();
90
91 // There's also Content and None in BuildAction.
92 // What am I supposed to do with that?
93 }
94
95 private string FindFileReference(string refName, ProjectNode project)
96 {
97 foreach (ReferencePathNode refPath in project.ReferencePaths)
98 {
99 string fullPath = NicePath(project, Helper.MakeFilePath(refPath.Path, refName, "dll"));
100 if (File.Exists(fullPath))
101 return fullPath;
102 }
103 return null;
104 }
105
106 private void WriteProjectReferences(StreamWriter f, SolutionNode solution, ProjectNode project)
107 {
108 f.WriteLine("REFERENCES_{0} = \\", project.Name);
109 foreach (ReferenceNode refr in project.References)
110 {
111 string path;
112 // Project references change with configurations.
113 if (solution.ProjectsTable.Contains(refr.Name))
114 continue;
115 path = FindFileReference(refr.Name, project);
116 if (path != null)
117 f.WriteLine("\t-r:{0} \\", path);
118 else
119 f.WriteLine("\t-r:{0} \\", refr.Name);
120 }
121 f.WriteLine();
122 }
123
124 private void WriteProjectDependencies(StreamWriter f, SolutionNode solution, ProjectNode project)
125 {
126 f.WriteLine("DEPENDENCIES_{0} = \\", project.Name);
127 f.WriteLine("\t$(SOURCES_{0}) \\", project.Name);
128 foreach (string file in project.Files)
129 if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource)
130 f.WriteLine("\t{0} \\", NicePath(project, file));
131 f.WriteLine();
132 }
133
134 private string ProjectTypeToExtension(ProjectType t)
135 {
136 if (t == ProjectType.Exe || t == ProjectType.WinExe)
137 {
138 return "exe";
139 }
140 else if (t == ProjectType.Library)
141 {
142 return "dll";
143 }
144 else
145 {
146 throw new FatalException("Bad ProjectType: {0}", t);
147 }
148 }
149
150 private string ProjectTypeToTarget(ProjectType t)
151 {
152 if (t == ProjectType.Exe)
153 {
154 return "exe";
155 }
156 else if (t == ProjectType.WinExe)
157 {
158 return "winexe";
159 }
160 else if (t == ProjectType.Library)
161 {
162 return "library";
163 }
164 else
165 {
166 throw new FatalException("Bad ProjectType: {0}", t);
167 }
168 }
169
170 private string ProjectOutput(ProjectNode project, ConfigurationNode config)
171 {
172 string filepath;
173 filepath = Helper.MakeFilePath((string)config.Options["OutputPath"],
174 project.AssemblyName, ProjectTypeToExtension(project.Type));
175 return NicePath(project, filepath);
176 }
177
178 // Returns true if two configs in one project have the same output.
179 private bool ProjectClashes(ProjectNode project)
180 {
181 foreach (ConfigurationNode conf1 in project.Configurations)
182 foreach (ConfigurationNode conf2 in project.Configurations)
183 if (ProjectOutput(project, conf1) == ProjectOutput(project, conf2) && conf1 != conf2)
184 {
185 m_Kernel.Log.Write("Warning: Configurations {0} and {1} for project {2} output the same file",
186 conf1.Name, conf2.Name, project.Name);
187 m_Kernel.Log.Write("Warning: I'm going to use some timestamps(extra empty files).");
188 return true;
189 }
190 return false;
191 }
192
193 private void WriteProject(StreamWriter f, SolutionNode solution, ProjectNode project)
194 {
195 f.WriteLine("# This is for project {0}", project.Name);
196 f.WriteLine();
197
198 WriteProjectFiles(f, solution, project);
199 WriteProjectReferences(f, solution, project);
200 WriteProjectDependencies(f, solution, project);
201
202 bool clash = ProjectClashes(project);
203
204 foreach (ConfigurationNode conf in project.Configurations)
205 {
206 string outpath = ProjectOutput(project, conf);
207 string filesToClean = outpath;
208
209 if (clash)
210 {
211 f.WriteLine("{0}-{1}: .{0}-{1}-timestamp", project.Name, conf.Name);
212 f.WriteLine();
213 f.Write(".{0}-{1}-timestamp: $(DEPENDENCIES_{0})", project.Name, conf.Name);
214 }
215 else
216 {
217 f.WriteLine("{0}-{1}: {2}", project.Name, conf.Name, outpath);
218 f.WriteLine();
219 f.Write("{2}: $(DEPENDENCIES_{0})", project.Name, conf.Name, outpath);
220 }
221 // Dependencies on other projects.
222 foreach (ReferenceNode refr in project.References)
223 if (solution.ProjectsTable.Contains(refr.Name))
224 {
225 ProjectNode refProj = (ProjectNode)solution.ProjectsTable[refr.Name];
226 if (ProjectClashes(refProj))
227 f.Write(" .{0}-{1}-timestamp", refProj.Name, conf.Name);
228 else
229 f.Write(" {0}", ProjectOutput(refProj, conf));
230 }
231 f.WriteLine();
232
233 // make directory for output.
234 if (Path.GetDirectoryName(outpath) != "")
235 {
236 f.WriteLine("\tmkdir -p {0}", Path.GetDirectoryName(outpath));
237 }
238 // mcs command line.
239 f.Write("\tgmcs", project.Name);
240 f.Write(" -warn:{0}", conf.Options["WarningLevel"]);
241 if ((bool)conf.Options["DebugInformation"])
242 f.Write(" -debug");
243 if ((bool)conf.Options["AllowUnsafe"])
244 f.Write(" -unsafe");
245 if ((bool)conf.Options["CheckUnderflowOverflow"])
246 f.Write(" -checked");
247 if (project.StartupObject != "")
248 f.Write(" -main:{0}", project.StartupObject);
249 if ((string)conf.Options["CompilerDefines"] != "")
250 {
251 f.Write(" -define:\"{0}\"", conf.Options["CompilerDefines"]);
252 }
253
254 f.Write(" -target:{0} -out:{1}", ProjectTypeToTarget(project.Type), outpath);
255
256 // Build references to other projects. Now that sux.
257 // We have to reference the other project in the same conf.
258 foreach (ReferenceNode refr in project.References)
259 if (solution.ProjectsTable.Contains(refr.Name))
260 {
261 ProjectNode refProj;
262 refProj = (ProjectNode)solution.ProjectsTable[refr.Name];
263 f.Write(" -r:{0}", ProjectOutput(refProj, conf));
264 }
265
266 f.Write(" $(REFERENCES_{0})", project.Name);
267 f.Write(" $(RESOURCES_{0})", project.Name);
268 f.Write(" $(SOURCES_{0})", project.Name);
269 f.WriteLine();
270
271 // Copy references with localcopy.
272 foreach (ReferenceNode refr in project.References)
273 if (refr.LocalCopy)
274 {
275 string outPath, srcPath, destPath;
276 outPath = Helper.NormalizePath((string)conf.Options["OutputPath"]);
277 if (solution.ProjectsTable.Contains(refr.Name))
278 {
279 ProjectNode refProj;
280 refProj = (ProjectNode)solution.ProjectsTable[refr.Name];
281 srcPath = ProjectOutput(refProj, conf);
282 destPath = Path.Combine(outPath, Path.GetFileName(srcPath));
283 destPath = NicePath(project, destPath);
284 if (srcPath != destPath)
285 {
286 f.WriteLine("\tcp -f {0} {1}", srcPath, destPath);
287 filesToClean += " " + destPath;
288 }
289 continue;
290 }
291 srcPath = FindFileReference(refr.Name, project);
292 if (srcPath != null)
293 {
294 destPath = Path.Combine(outPath, Path.GetFileName(srcPath));
295 destPath = NicePath(project, destPath);
296 f.WriteLine("\tcp -f {0} {1}", srcPath, destPath);
297 filesToClean += " " + destPath;
298 }
299 }
300
301 if (clash)
302 {
303 filesToClean += String.Format(" .{0}-{1}-timestamp", project.Name, conf.Name);
304 f.WriteLine("\ttouch .{0}-{1}-timestamp", project.Name, conf.Name);
305 f.Write("\trm -rf");
306 foreach (ConfigurationNode otherConf in project.Configurations)
307 if (otherConf != conf)
308 f.WriteLine(" .{0}-{1}-timestamp", project.Name, otherConf.Name);
309 f.WriteLine();
310 }
311 f.WriteLine();
312 f.WriteLine("{0}-{1}-clean:", project.Name, conf.Name);
313 f.WriteLine("\trm -rf {0}", filesToClean);
314 f.WriteLine();
315 }
316 }
317
318 private void WriteIntro(StreamWriter f, SolutionNode solution)
319 {
320 f.WriteLine("# Makefile for {0} generated by Prebuild ( http://dnpb.sf.net )", solution.Name);
321 f.WriteLine("# Do not edit.");
322 f.WriteLine("#");
323
324 f.Write("# Configurations:");
325 foreach (ConfigurationNode conf in solution.Configurations)
326 f.Write(" {0}", conf.Name);
327 f.WriteLine();
328
329 f.WriteLine("# Projects:");
330 foreach (ProjectNode proj in solution.Projects)
331 f.WriteLine("#\t{0}", proj.Name);
332
333 f.WriteLine("#");
334 f.WriteLine("# Building:");
335 f.WriteLine("#\t\"make\" to build everything under the default(first) configuration");
336 f.WriteLine("#\t\"make CONF\" to build every project under configuration CONF");
337 f.WriteLine("#\t\"make PROJ\" to build project PROJ under the default(first) configuration");
338 f.WriteLine("#\t\"make PROJ-CONF\" to build project PROJ under configuration CONF");
339 f.WriteLine("#");
340 f.WriteLine("# Cleaning (removing results of build):");
341 f.WriteLine("#\t\"make clean\" to clean everything, that's what you probably want");
342 f.WriteLine("#\t\"make CONF\" to clean everything for a configuration");
343 f.WriteLine("#\t\"make PROJ\" to clean everything for a project");
344 f.WriteLine("#\t\"make PROJ-CONF\" to clea project PROJ under configuration CONF");
345 f.WriteLine();
346 }
347
348 private void WritePhony(StreamWriter f, SolutionNode solution)
349 {
350 string defconf = "";
351 foreach (ConfigurationNode conf in solution.Configurations)
352 {
353 defconf = conf.Name;
354 break;
355 }
356
357 f.Write(".PHONY: all");
358 foreach (ProjectNode proj in solution.Projects)
359 f.Write(" {0} {0}-clean", proj.Name);
360 foreach (ConfigurationNode conf in solution.Configurations)
361 f.Write(" {0} {0}-clean", conf.Name);
362 foreach (ProjectNode proj in solution.Projects)
363 foreach (ConfigurationNode conf in solution.Configurations)
364 f.Write(" {0}-{1} {0}-{1}-clean", proj.Name, conf.Name);
365 f.WriteLine();
366 f.WriteLine();
367
368 f.WriteLine("all: {0}", defconf);
369 f.WriteLine();
370
371 f.Write("clean:");
372 foreach (ConfigurationNode conf in solution.Configurations)
373 f.Write(" {0}-clean", conf.Name);
374 f.WriteLine();
375 f.WriteLine();
376
377 foreach (ConfigurationNode conf in solution.Configurations)
378 {
379 f.Write("{0}: ", conf.Name);
380 foreach (ProjectNode proj in solution.Projects)
381 f.Write(" {0}-{1}", proj.Name, conf.Name);
382 f.WriteLine();
383 f.WriteLine();
384
385 f.Write("{0}-clean: ", conf.Name);
386 foreach (ProjectNode proj in solution.Projects)
387 f.Write(" {0}-{1}-clean", proj.Name, conf.Name);
388 f.WriteLine();
389 f.WriteLine();
390 }
391
392 foreach (ProjectNode proj in solution.Projects)
393 {
394 f.WriteLine("{0}: {0}-{1}", proj.Name, defconf);
395 f.WriteLine();
396
397 f.Write("{0}-clean:", proj.Name);
398 foreach (ConfigurationNode conf in proj.Configurations)
399 f.Write(" {0}-{1}-clean", proj.Name, conf.Name);
400 f.WriteLine();
401 f.WriteLine();
402 }
403 }
404
405 private void WriteSolution(SolutionNode solution)
406 {
407 m_Kernel.Log.Write("Creating makefile for {0}", solution.Name);
408 m_Kernel.CurrentWorkingDirectory.Push();
409
410 string file = "Makefile";// Helper.MakeFilePath(solution.FullPath, solution.Name, "make");
411 StreamWriter f = new StreamWriter(file);
412
413 Helper.SetCurrentDir(Path.GetDirectoryName(file));
414
415 using (f)
416 {
417 WriteIntro(f, solution);
418 WritePhony(f, solution);
419
420 foreach (ProjectNode project in solution.Projects)
421 {
422 m_Kernel.Log.Write("...Creating Project: {0}", project.Name);
423 WriteProject(f, solution, project);
424 }
425 }
426
427 m_Kernel.Log.Write("");
428 m_Kernel.CurrentWorkingDirectory.Pop();
429 }
430
431 private void CleanSolution(SolutionNode solution)
432 {
433 m_Kernel.Log.Write("Cleaning makefile for {0}", solution.Name);
434
435 string file = Helper.MakeFilePath(solution.FullPath, solution.Name, "make");
436 Helper.DeleteIfExists(file);
437
438 m_Kernel.Log.Write("");
439 }
440
441 #endregion
442
443 #region ITarget Members
444
445 public void Write(Kernel kern)
446 {
447 m_Kernel = kern;
448 foreach (SolutionNode solution in kern.Solutions)
449 WriteSolution(solution);
450 m_Kernel = null;
451 }
452
453 public virtual void Clean(Kernel kern)
454 {
455 m_Kernel = kern;
456 foreach (SolutionNode sol in kern.Solutions)
457 CleanSolution(sol);
458 m_Kernel = null;
459 }
460
461 public string Name
462 {
463 get
464 {
465 return "makefile";
466 }
467 }
468
469 #endregion
470 }
471}
diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs
deleted file mode 100644
index c8401fd..0000000
--- a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs
+++ /dev/null
@@ -1,464 +0,0 @@
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.Collections;
28using System.Collections.Specialized;
29using System.IO;
30using System.Reflection;
31using System.Text.RegularExpressions;
32
33using Prebuild.Core.Attributes;
34using Prebuild.Core.Interfaces;
35using Prebuild.Core.Nodes;
36using Prebuild.Core.Utilities;
37
38namespace Prebuild.Core.Targets
39{
40 /// <summary>
41 ///
42 /// </summary>
43 [Target("monodev")]
44 public class MonoDevelopTarget : 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 = "<ProjectReference type=\"";
74 if(solution.ProjectsTable.ContainsKey(refr.Name))
75 {
76 ret += "Project\"";
77 ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />";
78 }
79 else
80 {
81 ProjectNode project = (ProjectNode)refr.Parent;
82 string fileRef = FindFileReference(refr.Name, project);
83
84 if(refr.Path != null || fileRef != null)
85 {
86 ret += "Assembly\" refto=\"";
87
88 string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
89
90 ret += finalPath;
91 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
92 return ret;
93 }
94
95 ret += "Gac\"";
96 ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\"";
97 ret += " refto=\"";
98 try
99 {
100 /*
101 Day changed to 28 Mar 2007
102 ...
103 08:09 < cj> is there anything that replaces Assembly.LoadFromPartialName() ?
104 08:09 < jonp> no
105 08:10 < jonp> in their infinite wisdom [sic], microsoft decided that the
106 ability to load any assembly version by-name was an inherently
107 bad idea
108 08:11 < cj> I'm thinking of a bunch of four-letter words right now...
109 08:11 < cj> security through making it difficult for the developer!!!
110 08:12 < jonp> just use the Obsolete API
111 08:12 < jonp> it should still work
112 08:12 < cj> alrighty.
113 08:12 < jonp> you just get warnings when using it
114 */
115 Assembly assem = Assembly.LoadWithPartialName(refr.Name);
116 ret += assem.FullName;
117 //ret += refr.Name;
118 }
119 catch (System.NullReferenceException e)
120 {
121 e.ToString();
122 ret += refr.Name;
123 }
124 ret += "\" />";
125 }
126
127 return ret;
128 }
129
130 private static string FindFileReference(string refName, ProjectNode project)
131 {
132 foreach(ReferencePathNode refPath in project.ReferencePaths)
133 {
134 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
135
136 if(File.Exists(fullPath))
137 {
138 return fullPath;
139 }
140 }
141
142 return null;
143 }
144
145 /// <summary>
146 /// Gets the XML doc file.
147 /// </summary>
148 /// <param name="project">The project.</param>
149 /// <param name="conf">The conf.</param>
150 /// <returns></returns>
151 public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
152 {
153 if( conf == null )
154 {
155 throw new ArgumentNullException("conf");
156 }
157 if( project == null )
158 {
159 throw new ArgumentNullException("project");
160 }
161 string docFile = (string)conf.Options["XmlDocFile"];
162 if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
163 {
164 return "False";
165 }
166 return "True";
167 }
168
169 private void WriteProject(SolutionNode solution, ProjectNode project)
170 {
171 string csComp = "Mcs";
172 string netRuntime = "Mono";
173 if(project.Runtime == ClrRuntime.Microsoft)
174 {
175 csComp = "Csc";
176 netRuntime = "MsNet";
177 }
178
179 string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
180 StreamWriter ss = new StreamWriter(projFile);
181
182 m_Kernel.CurrentWorkingDirectory.Push();
183 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
184
185 using(ss)
186 {
187 ss.WriteLine(
188 "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">",
189 project.Name,
190 project.RootNamespace
191 );
192
193 int count = 0;
194
195 ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig);
196
197 foreach(ConfigurationNode conf in project.Configurations)
198 {
199 ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name);
200 ss.Write(" <Output");
201 ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString())));
202 ss.Write(" assembly=\"{0}\"", project.AssemblyName);
203 ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
204 //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
205 //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
206 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
207 {
208 ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
209 }
210 else
211 {
212 ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
213 }
214 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
215 {
216 ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
217 }
218 else
219 {
220 ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
221 }
222 ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
223 ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
224 ss.WriteLine(" />");
225
226 ss.Write(" <Build");
227 ss.Write(" debugmode=\"True\"");
228 if (project.Type == ProjectType.WinExe)
229 {
230 ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString());
231 }
232 else
233 {
234 ss.Write(" target=\"{0}\"", project.Type);
235 }
236 ss.WriteLine(" />");
237
238 ss.Write(" <Execution");
239 ss.Write(" runwithwarnings=\"{0}\"", !conf.Options.WarningsAsErrors);
240 ss.Write(" consolepause=\"True\"");
241 ss.Write(" runtime=\"{0}\"", netRuntime);
242 ss.Write(" clr-version=\"Net_2_0\"");
243 ss.WriteLine(" />");
244
245 ss.Write(" <CodeGeneration");
246 ss.Write(" compiler=\"{0}\"", csComp);
247 ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
248 ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
249 ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
250 ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
251 ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
252 ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
253 ss.Write(" mainclass=\"{0}\"", project.StartupObject);
254 ss.Write(" target=\"{0}\"", project.Type);
255 ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
256 ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
257 ss.Write(" win32Icon=\"{0}\"", project.AppIcon);
258 ss.Write(" ctype=\"CSharpCompilerParameters\"");
259 ss.WriteLine(" />");
260 ss.WriteLine(" </Configuration>");
261
262 count++;
263 }
264 ss.WriteLine(" </Configurations>");
265
266 ss.Write(" <DeploymentInformation");
267 ss.Write(" target=\"\"");
268 ss.Write(" script=\"\"");
269 ss.Write(" strategy=\"File\"");
270 ss.WriteLine(">");
271 ss.WriteLine(" <excludeFiles />");
272 ss.WriteLine(" </DeploymentInformation>");
273
274 ss.WriteLine(" <Contents>");
275 foreach(string file in project.Files)
276 {
277 string buildAction = "Compile";
278 switch(project.Files.GetBuildAction(file))
279 {
280 case BuildAction.None:
281 buildAction = "Nothing";
282 break;
283
284 case BuildAction.Content:
285 buildAction = "Exclude";
286 break;
287
288 case BuildAction.EmbeddedResource:
289 buildAction = "EmbedAsResource";
290 break;
291
292 default:
293 buildAction = "Compile";
294 break;
295 }
296
297 // Sort of a hack, we try and resolve the path and make it relative, if we can.
298 string filePath = PrependPath(file);
299 ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction);
300 }
301 ss.WriteLine(" </Contents>");
302
303 ss.WriteLine(" <References>");
304 foreach(ReferenceNode refr in project.References)
305 {
306 ss.WriteLine(" {0}", BuildReference(solution, refr));
307 }
308 ss.WriteLine(" </References>");
309
310
311 ss.WriteLine("</Project>");
312 }
313
314 m_Kernel.CurrentWorkingDirectory.Pop();
315 }
316
317 private void WriteCombine(SolutionNode solution)
318 {
319 m_Kernel.Log.Write("Creating MonoDevelop combine and project files");
320 foreach(ProjectNode project in solution.Projects)
321 {
322 if(m_Kernel.AllowProject(project.FilterGroups))
323 {
324 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
325 WriteProject(solution, project);
326 }
327 }
328
329 m_Kernel.Log.Write("");
330 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds");
331 StreamWriter ss = new StreamWriter(combFile);
332
333 m_Kernel.CurrentWorkingDirectory.Push();
334 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
335
336 int count = 0;
337
338 using(ss)
339 {
340 ss.WriteLine("<Combine name=\"{0}\" fileversion=\"2.0\" description=\"\">", solution.Name);
341
342 count = 0;
343 foreach(ConfigurationNode conf in solution.Configurations)
344 {
345 if(count == 0)
346 {
347 ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name);
348 }
349
350 ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"CombineConfiguration\">", conf.Name);
351 foreach(ProjectNode project in solution.Projects)
352 {
353 ss.WriteLine(" <Entry configuration=\"{1}\" build=\"True\" name=\"{0}\" />", project.Name, conf.Name);
354 }
355 ss.WriteLine(" </Configuration>");
356
357 count++;
358 }
359 ss.WriteLine(" </Configurations>");
360
361 count = 0;
362
363 foreach(ProjectNode project in solution.Projects)
364 {
365 if(count == 0)
366 ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name);
367
368 ss.WriteLine(" <Execute type=\"None\" entry=\"{0}\" />", project.Name);
369 count++;
370 }
371 ss.WriteLine(" </StartMode>");
372
373 ss.WriteLine(" <Entries>");
374 foreach(ProjectNode project in solution.Projects)
375 {
376 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
377 ss.WriteLine(" <Entry filename=\"{0}\" />",
378 Helper.MakeFilePath(path, project.Name, "mdp"));
379 }
380 ss.WriteLine(" </Entries>");
381
382 ss.WriteLine("</Combine>");
383 }
384
385 m_Kernel.CurrentWorkingDirectory.Pop();
386 }
387
388 private void CleanProject(ProjectNode project)
389 {
390 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
391 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
392 Helper.DeleteIfExists(projectFile);
393 }
394
395 private void CleanSolution(SolutionNode solution)
396 {
397 m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name);
398
399 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds");
400 Helper.DeleteIfExists(slnFile);
401
402 foreach(ProjectNode project in solution.Projects)
403 {
404 CleanProject(project);
405 }
406
407 m_Kernel.Log.Write("");
408 }
409
410 #endregion
411
412 #region ITarget Members
413
414 /// <summary>
415 /// Writes the specified kern.
416 /// </summary>
417 /// <param name="kern">The kern.</param>
418 public void Write(Kernel kern)
419 {
420 if( kern == null )
421 {
422 throw new ArgumentNullException("kern");
423 }
424 m_Kernel = kern;
425 foreach(SolutionNode solution in kern.Solutions)
426 {
427 WriteCombine(solution);
428 }
429 m_Kernel = null;
430 }
431
432 /// <summary>
433 /// Cleans the specified kern.
434 /// </summary>
435 /// <param name="kern">The kern.</param>
436 public virtual void Clean(Kernel kern)
437 {
438 if( kern == null )
439 {
440 throw new ArgumentNullException("kern");
441 }
442 m_Kernel = kern;
443 foreach(SolutionNode sol in kern.Solutions)
444 {
445 CleanSolution(sol);
446 }
447 m_Kernel = null;
448 }
449
450 /// <summary>
451 /// Gets the name.
452 /// </summary>
453 /// <value>The name.</value>
454 public string Name
455 {
456 get
457 {
458 return "sharpdev";
459 }
460 }
461
462 #endregion
463 }
464}
diff --git a/Prebuild/src/Core/Targets/NAntTarget.cs b/Prebuild/src/Core/Targets/NAntTarget.cs
deleted file mode 100644
index 9a6ee17..0000000
--- a/Prebuild/src/Core/Targets/NAntTarget.cs
+++ /dev/null
@@ -1,738 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004 - 2008
4Matthew Holmes (matthew@wildfiregames.com),
5Dan Moorehead (dan05a@gmail.com),
6C.J. Adams-Collier (cjac@colliertech.org),
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are
10met:
11
12* Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14
15* Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in the
17 documentation and/or other materials provided with the distribution.
18
19* The name of the author may not be used to endorse or promote
20 products derived from this software without specific prior written
21 permission.
22
23THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33POSSIBILITY OF SUCH DAMAGE.
34*/
35
36#endregion
37
38using System;
39using System.Collections;
40using System.Collections.Specialized;
41using System.IO;
42using System.Reflection;
43using System.Text.RegularExpressions;
44
45using Prebuild.Core.Attributes;
46using Prebuild.Core.Interfaces;
47using Prebuild.Core.Nodes;
48using Prebuild.Core.Utilities;
49
50namespace Prebuild.Core.Targets
51{
52 /// <summary>
53 ///
54 /// </summary>
55 [Target("nant")]
56 public class NAntTarget : ITarget
57 {
58 #region Fields
59
60 private Kernel m_Kernel;
61
62 #endregion
63
64 #region Private Methods
65
66 private static string PrependPath(string path)
67 {
68 string tmpPath = Helper.NormalizePath(path, '/');
69 Regex regex = new Regex(@"(\w):/(\w+)");
70 Match match = regex.Match(tmpPath);
71 //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/')
72 //{
73 tmpPath = Helper.NormalizePath(tmpPath);
74 //}
75 // else
76 // {
77 // tmpPath = Helper.NormalizePath("./" + tmpPath);
78 // }
79
80 return tmpPath;
81 }
82
83 private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr)
84 {
85
86 if (!String.IsNullOrEmpty(refr.Path))
87 {
88 return refr.Path;
89 }
90
91 if (solution.ProjectsTable.ContainsKey(refr.Name))
92 {
93 ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name];
94 string finalPath =
95 Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/');
96 return finalPath;
97 }
98
99 ProjectNode project = (ProjectNode) refr.Parent;
100
101 // Do we have an explicit file reference?
102 string fileRef = FindFileReference(refr.Name, project);
103 if (fileRef != null)
104 {
105 return fileRef;
106 }
107
108 // Is there an explicit path in the project ref?
109 if (refr.Path != null)
110 {
111 return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/');
112 }
113
114 // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway
115 return refr.Name + ".dll";
116 }
117
118 public static string GetRefFileName(string refName)
119 {
120 if (ExtensionSpecified(refName))
121 {
122 return refName;
123 }
124 else
125 {
126 return refName + ".dll";
127 }
128 }
129
130 private static bool ExtensionSpecified(string refName)
131 {
132 return refName.EndsWith(".dll") || refName.EndsWith(".exe");
133 }
134
135 private static string GetProjectExtension(ProjectNode project)
136 {
137 string extension = ".dll";
138 if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe)
139 {
140 extension = ".exe";
141 }
142 return extension;
143 }
144
145 private static string FindFileReference(string refName, ProjectNode project)
146 {
147 foreach (ReferencePathNode refPath in project.ReferencePaths)
148 {
149 string fullPath = Helper.MakeFilePath(refPath.Path, refName);
150
151 if (File.Exists(fullPath))
152 {
153 return fullPath;
154 }
155
156 fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
157
158 if (File.Exists(fullPath))
159 {
160 return fullPath;
161 }
162
163 fullPath = Helper.MakeFilePath(refPath.Path, refName, "exe");
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 + GetProjectExtension(project), "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}\" flatten=\"true\">");
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, project, refr)) + "\" />", '/'));
221 }
222 }
223
224 ss.WriteLine(" </fileset>");
225 ss.WriteLine(" </copy>");
226 if (project.ConfigFile != null && project.ConfigFile.Length!=0)
227 {
228 ss.Write(" <copy file=\"" + project.ConfigFile + "\" tofile=\"${project::get-base-directory()}/${build.dir}/${project::get-name()}");
229
230 if (project.Type == ProjectType.Library)
231 {
232 ss.Write(".dll.config\"");
233 }
234 else
235 {
236 ss.Write(".exe.config\"");
237 }
238 ss.WriteLine(" />");
239 }
240
241 // Add the content files to just be copied
242 ss.WriteLine(" {0}", "<copy todir=\"${project::get-base-directory()}/${build.dir}\">");
243 ss.WriteLine(" {0}", "<fileset basedir=\".\">");
244
245 foreach (string file in project.Files)
246 {
247 // Ignore if we aren't content
248 if (project.Files.GetBuildAction(file) != BuildAction.Content)
249 continue;
250
251 // Create a include tag
252 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
253 }
254
255 ss.WriteLine(" {0}", "</fileset>");
256 ss.WriteLine(" {0}", "</copy>");
257
258 ss.Write(" <csc");
259 ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
260 ss.Write(" debug=\"{0}\"", "${build.debug}");
261 foreach (ConfigurationNode conf in project.Configurations)
262 {
263 if (conf.Options.KeyFile != "")
264 {
265 ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
266 break;
267 }
268 }
269 foreach (ConfigurationNode conf in project.Configurations)
270 {
271 ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
272 break;
273 }
274 foreach (ConfigurationNode conf in project.Configurations)
275 {
276 ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors);
277 break;
278 }
279 foreach (ConfigurationNode conf in project.Configurations)
280 {
281 ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
282 break;
283 }
284 foreach (ConfigurationNode conf in project.Configurations)
285 {
286 ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
287 break;
288 }
289
290 ss.Write(" main=\"{0}\"", project.StartupObject);
291
292 foreach (ConfigurationNode conf in project.Configurations)
293 {
294 if (GetXmlDocFile(project, conf) != "")
295 {
296 ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
297 hasDoc = true;
298 }
299 break;
300 }
301 ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
302 if (project.Type == ProjectType.Library)
303 {
304 ss.Write(".dll\"");
305 }
306 else
307 {
308 ss.Write(".exe\"");
309 }
310 if (project.AppIcon != null && project.AppIcon.Length != 0)
311 {
312 ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
313 }
314 ss.WriteLine(">");
315 ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
316 foreach (string file in project.Files)
317 {
318 switch (project.Files.GetBuildAction(file))
319 {
320 case BuildAction.EmbeddedResource:
321 ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
322 break;
323 default:
324 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
325 {
326 ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
327 }
328 break;
329 }
330 }
331 //if (project.Files.GetSubType(file).ToString() != "Code")
332 //{
333 // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
334
335 ss.WriteLine(" </resources>");
336 ss.WriteLine(" <sources failonempty=\"true\">");
337 foreach (string file in project.Files)
338 {
339 switch (project.Files.GetBuildAction(file))
340 {
341 case BuildAction.Compile:
342 ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
343 break;
344 default:
345 break;
346 }
347 }
348 ss.WriteLine(" </sources>");
349 ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">");
350 ss.WriteLine(" <lib>");
351 ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />");
352 foreach(ReferencePathNode refPath in project.ReferencePaths)
353 {
354 ss.WriteLine(" <include name=\"${project::get-base-directory()}/" + refPath.Path.TrimEnd('/', '\\') + "\" />");
355 }
356 ss.WriteLine(" </lib>");
357 foreach (ReferenceNode refr in project.References)
358 {
359 string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/');
360 ss.WriteLine(" <include name=\"" + path + "\" />");
361 }
362 ss.WriteLine(" </references>");
363
364 ss.WriteLine(" </csc>");
365
366 foreach (ConfigurationNode conf in project.Configurations)
367 {
368 if (!String.IsNullOrEmpty(conf.Options.OutputPath))
369 {
370 string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/');
371
372 ss.WriteLine(" <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" + targetDir + "\" />");
373
374 ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>");
375
376 ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">");
377 ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >");
378 ss.WriteLine(" <include name=\"*.dll\"/>");
379 ss.WriteLine(" <include name=\"*.exe\"/>");
380 ss.WriteLine(" <include name=\"*.mdb\" if='${build.debug}'/>");
381 ss.WriteLine(" <include name=\"*.pdb\" if='${build.debug}'/>");
382 ss.WriteLine(" </fileset>");
383 ss.WriteLine(" </copy>");
384 break;
385 }
386 }
387
388 ss.WriteLine(" </target>");
389
390 ss.WriteLine(" <target name=\"clean\">");
391 ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
392 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
393 ss.WriteLine(" </target>");
394
395 ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">");
396 if (hasDoc)
397 {
398 ss.WriteLine(" <property name=\"doc.target\" value=\"\" />");
399 ss.WriteLine(" <if test=\"${platform::is-unix()}\">");
400 ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />");
401 ss.WriteLine(" </if>");
402 ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">");
403 ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">");
404 ss.Write(" <include name=\"${build.dir}/${project::get-name()}");
405 if (project.Type == ProjectType.Library)
406 {
407 ss.WriteLine(".dll\" />");
408 }
409 else
410 {
411 ss.WriteLine(".exe\" />");
412 }
413
414 ss.WriteLine(" </assemblies>");
415 ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">");
416 ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
417 ss.WriteLine(" </summaries>");
418 ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">");
419 ss.WriteLine(" <include name=\"${build.dir}\" />");
420 // foreach(ReferenceNode refr in project.References)
421 // {
422 // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
423 // if (path != "")
424 // {
425 // ss.WriteLine(" <include name=\"{0}\" />", path);
426 // }
427 // }
428 ss.WriteLine(" </referencepaths>");
429 ss.WriteLine(" <documenters>");
430 ss.WriteLine(" <documenter name=\"MSDN\">");
431 ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
432 ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />");
433 ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
434 ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />");
435 ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
436 ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />");
437 ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />");
438 ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />");
439 ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />");
440 ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
441 ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
442 ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
443 ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
444 ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
445 ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />");
446 ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />");
447 ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />");
448 ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
449 ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
450 ss.WriteLine(" </documenter>");
451 ss.WriteLine(" </documenters>");
452 ss.WriteLine(" </ndoc>");
453 }
454 ss.WriteLine(" </target>");
455 ss.WriteLine("</project>");
456 }
457 m_Kernel.CurrentWorkingDirectory.Pop();
458 }
459
460 private void WriteCombine(SolutionNode solution)
461 {
462 m_Kernel.Log.Write("Creating NAnt build files");
463 foreach (ProjectNode project in solution.Projects)
464 {
465 if (m_Kernel.AllowProject(project.FilterGroups))
466 {
467 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
468 WriteProject(solution, project);
469 }
470 }
471
472 m_Kernel.Log.Write("");
473 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
474 StreamWriter ss = new StreamWriter(combFile);
475
476 m_Kernel.CurrentWorkingDirectory.Push();
477 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
478
479 using (ss)
480 {
481 ss.WriteLine("<?xml version=\"1.0\" ?>");
482 ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
483 ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
484 ss.WriteLine();
485
486 //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
487 //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
488 ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
489 ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
490 ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
491 ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
492
493 // actually use active config out of prebuild.xml
494 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig);
495
496 foreach (ConfigurationNode conf in solution.Configurations)
497 {
498 ss.WriteLine();
499 ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name);
500 ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
501 ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower());
502 ss.WriteLine(" </target>");
503 ss.WriteLine();
504 }
505
506 ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
507 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
508 ss.WriteLine(" </target>");
509 ss.WriteLine();
510
511 ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
512 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
513 ss.WriteLine(" </target>");
514 ss.WriteLine();
515
516 ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">");
517 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />");
518 ss.WriteLine(" </target>");
519 ss.WriteLine();
520
521 ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
522 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
523 ss.WriteLine(" </target>");
524 ss.WriteLine();
525
526 ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
527 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
528 ss.WriteLine(" </target>");
529 ss.WriteLine();
530
531 ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">");
532 ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />");
533 ss.WriteLine(" </target>");
534 ss.WriteLine();
535
536 ss.WriteLine(" <target name=\"init\" description=\"\">");
537 ss.WriteLine(" <call target=\"${project.config}\" />");
538 ss.WriteLine(" <property name=\"sys.os.platform\"");
539 ss.WriteLine(" value=\"${platform::get-name()}\"");
540 ss.WriteLine(" />");
541 ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />");
542 ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />");
543 ss.WriteLine(" </target>");
544 ss.WriteLine();
545
546
547 // sdague - ok, this is an ugly hack, but what it lets
548 // us do is native include of files into the nant
549 // created files from all .nant/*include files. This
550 // lets us keep using prebuild, but allows for
551 // extended nant targets to do build and the like.
552
553 try
554 {
555 Regex re = new Regex(".include$");
556 DirectoryInfo nantdir = new DirectoryInfo(".nant");
557 foreach (FileSystemInfo item in nantdir.GetFileSystemInfos())
558 {
559 if (item is DirectoryInfo) { }
560 else if (item is FileInfo)
561 {
562 if (re.Match(((FileInfo)item).FullName) !=
563 System.Text.RegularExpressions.Match.Empty)
564 {
565 Console.WriteLine("Including file: " + ((FileInfo)item).FullName);
566
567 using (FileStream fs = new FileStream(((FileInfo)item).FullName,
568 FileMode.Open,
569 FileAccess.Read,
570 FileShare.None))
571 {
572 using (StreamReader sr = new StreamReader(fs))
573 {
574 ss.WriteLine("<!-- included from {0} -->", ((FileInfo)item).FullName);
575 while (sr.Peek() != -1)
576 {
577 ss.WriteLine(sr.ReadLine());
578 }
579 ss.WriteLine();
580 }
581 }
582 }
583 }
584 }
585 }
586 catch { }
587 // ss.WriteLine(" <include buildfile=\".nant/local.include\" />");
588 // ss.WriteLine(" <target name=\"zip\" description=\"\">");
589 // ss.WriteLine(" <zip zipfile=\"{0}-{1}.zip\">", solution.Name, solution.Version);
590 // ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">");
591
592 // ss.WriteLine(" <include name=\"${project::get-base-directory()}/**/*.cs\" />");
593 // // ss.WriteLine(" <include name=\"${project.main.dir}/**/*\" />");
594 // ss.WriteLine(" </fileset>");
595 // ss.WriteLine(" </zip>");
596 // ss.WriteLine(" <echo message=\"Building zip target\" />");
597 // ss.WriteLine(" </target>");
598 ss.WriteLine();
599
600
601 ss.WriteLine(" <target name=\"clean\" description=\"\">");
602 ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />");
603 //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />");
604 ss.WriteLine(" <delete failonerror=\"false\">");
605 ss.WriteLine(" <fileset basedir=\"${bin.dir}\">");
606 ss.WriteLine(" <include name=\"OpenSim*.dll\"/>");
607 ss.WriteLine(" <include name=\"OpenSim*.exe\"/>");
608 ss.WriteLine(" <include name=\"ScriptEngines/*\"/>");
609 ss.WriteLine(" <include name=\"Physics/*\"/>");
610 ss.WriteLine(" <exclude name=\"OpenSim.32BitLaunch.exe\"/>");
611 ss.WriteLine(" <exclude name=\"ScriptEngines/Default.lsl\"/>");
612 ss.WriteLine(" </fileset>");
613 ss.WriteLine(" </delete>");
614 ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
615 foreach (ProjectNode project in solution.Projects)
616 {
617 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
618 ss.Write(" <nant buildfile=\"{0}\"",
619 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
620 ss.WriteLine(" target=\"clean\" />");
621 }
622 ss.WriteLine(" </target>");
623 ss.WriteLine();
624
625 ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">");
626
627 foreach (ProjectNode project in solution.ProjectsTableOrder)
628 {
629 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
630 ss.Write(" <nant buildfile=\"{0}\"",
631 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
632 ss.WriteLine(" target=\"build\" />");
633 }
634 ss.WriteLine(" </target>");
635 ss.WriteLine();
636
637 ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />");
638 ss.WriteLine();
639 ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />");
640 ss.WriteLine();
641 //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />");
642 ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />");
643 ss.WriteLine();
644
645 ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">");
646 ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />");
647 foreach (ProjectNode project in solution.Projects)
648 {
649 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
650 ss.Write(" <nant buildfile=\"{0}\"",
651 Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + GetProjectExtension(project), "build"), '/'));
652 ss.WriteLine(" target=\"doc\" />");
653 }
654 ss.WriteLine(" </target>");
655 ss.WriteLine();
656 ss.WriteLine("</project>");
657 }
658
659 m_Kernel.CurrentWorkingDirectory.Pop();
660 }
661
662 private void CleanProject(ProjectNode project)
663 {
664 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
665 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
666 Helper.DeleteIfExists(projectFile);
667 }
668
669 private void CleanSolution(SolutionNode solution)
670 {
671 m_Kernel.Log.Write("Cleaning NAnt build files for", solution.Name);
672
673 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
674 Helper.DeleteIfExists(slnFile);
675
676 foreach (ProjectNode project in solution.Projects)
677 {
678 CleanProject(project);
679 }
680
681 m_Kernel.Log.Write("");
682 }
683
684 #endregion
685
686 #region ITarget Members
687
688 /// <summary>
689 /// Writes the specified kern.
690 /// </summary>
691 /// <param name="kern">The kern.</param>
692 public void Write(Kernel kern)
693 {
694 if (kern == null)
695 {
696 throw new ArgumentNullException("kern");
697 }
698 m_Kernel = kern;
699 foreach (SolutionNode solution in kern.Solutions)
700 {
701 WriteCombine(solution);
702 }
703 m_Kernel = null;
704 }
705
706 /// <summary>
707 /// Cleans the specified kern.
708 /// </summary>
709 /// <param name="kern">The kern.</param>
710 public virtual void Clean(Kernel kern)
711 {
712 if (kern == null)
713 {
714 throw new ArgumentNullException("kern");
715 }
716 m_Kernel = kern;
717 foreach (SolutionNode sol in kern.Solutions)
718 {
719 CleanSolution(sol);
720 }
721 m_Kernel = null;
722 }
723
724 /// <summary>
725 /// Gets the name.
726 /// </summary>
727 /// <value>The name.</value>
728 public string Name
729 {
730 get
731 {
732 return "nant";
733 }
734 }
735
736 #endregion
737 }
738}
diff --git a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs b/Prebuild/src/Core/Targets/SharpDevelop2Target.cs
deleted file mode 100644
index 66dd1bc..0000000
--- a/Prebuild/src/Core/Targets/SharpDevelop2Target.cs
+++ /dev/null
@@ -1,82 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 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;
27
28using Prebuild.Core.Attributes;
29
30namespace Prebuild.Core.Targets
31{
32 /// <summary>
33 ///
34 /// </summary>
35 [Target("sharpdev2")]
36 public class SharpDevelop2Target : VS2005Target
37 {
38 #region Properties
39 public override string VersionName
40 {
41 get
42 {
43 return "SharpDevelop2";
44 }
45 }
46 #endregion
47
48 #region Public Methods
49
50 /// <summary>
51 /// Writes the specified kern.
52 /// </summary>
53 /// <param name="kern">The kern.</param>
54 public override void Write(Kernel kern)
55 {
56 base.Write(kern);
57 }
58
59 /// <summary>
60 /// Cleans the specified kern.
61 /// </summary>
62 /// <param name="kern">The kern.</param>
63 public override void Clean(Kernel kern)
64 {
65 base.Clean(kern);
66 }
67
68 /// <summary>
69 /// Gets the name.
70 /// </summary>
71 /// <value>The name.</value>
72 public override string Name
73 {
74 get
75 {
76 return "sharpdev2";
77 }
78 }
79
80 #endregion
81 }
82}
diff --git a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs b/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
deleted file mode 100644
index cf7ce02..0000000
--- a/Prebuild/src/Core/Targets/SharpDevelopTarget.cs
+++ /dev/null
@@ -1,428 +0,0 @@
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.Collections;
28using System.Collections.Specialized;
29using System.IO;
30using System.Text.RegularExpressions;
31using System.Reflection;
32
33using Prebuild.Core.Attributes;
34using Prebuild.Core.Interfaces;
35using Prebuild.Core.Nodes;
36using Prebuild.Core.Utilities;
37
38namespace Prebuild.Core.Targets
39{
40 /// <summary>
41 ///
42 /// </summary>
43 [Target("sharpdev")]
44 public class SharpDevelopTarget : 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 = "<Reference type=\"";
74 if(solution.ProjectsTable.ContainsKey(refr.Name))
75 {
76 ret += "Project\" refto=\"" + refr.Name;
77 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
78 }
79 else
80 {
81 ProjectNode project = (ProjectNode)refr.Parent;
82 string fileRef = FindFileReference(refr.Name, project);
83
84 if(refr.Path != null || fileRef != null)
85 {
86 ret += "Assembly\" refto=\"";
87
88 string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
89
90 ret += finalPath;
91 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
92 return ret;
93 }
94
95 ret += "Gac\" refto=\"";
96 try
97 {
98 //Assembly assem = Assembly.Load(refr.Name);
99 ret += refr.Name;// assem.FullName;
100 }
101 catch (System.NullReferenceException e)
102 {
103 e.ToString();
104 ret += refr.Name;
105 }
106 ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
107 }
108
109 return ret;
110 }
111
112 private static string FindFileReference(string refName, ProjectNode project)
113 {
114 foreach(ReferencePathNode refPath in project.ReferencePaths)
115 {
116 string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");
117
118 if(File.Exists(fullPath))
119 {
120 return fullPath;
121 }
122 }
123
124 return null;
125 }
126
127 /// <summary>
128 /// Gets the XML doc file.
129 /// </summary>
130 /// <param name="project">The project.</param>
131 /// <param name="conf">The conf.</param>
132 /// <returns></returns>
133 public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
134 {
135 if( conf == null )
136 {
137 throw new ArgumentNullException("conf");
138 }
139 if( project == null )
140 {
141 throw new ArgumentNullException("project");
142 }
143 string docFile = (string)conf.Options["XmlDocFile"];
144 if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
145 {
146 return "False";
147 }
148 return "True";
149 }
150
151 private void WriteProject(SolutionNode solution, ProjectNode project)
152 {
153 string csComp = "Csc";
154 string netRuntime = "MsNet";
155 if(project.Runtime == ClrRuntime.Mono)
156 {
157 csComp = "Mcs";
158 netRuntime = "Mono";
159 }
160
161 string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
162 StreamWriter ss = new StreamWriter(projFile);
163
164 m_Kernel.CurrentWorkingDirectory.Push();
165 Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
166
167 using(ss)
168 {
169 ss.WriteLine(
170 "<Project name=\"{0}\" standardNamespace=\"{1}\" description=\"\" newfilesearch=\"None\" enableviewstate=\"True\" version=\"1.1\" projecttype=\"C#\">",
171 project.Name,
172 project.RootNamespace
173 );
174
175 ss.WriteLine(" <Contents>");
176 foreach(string file in project.Files)
177 {
178 string buildAction = "Compile";
179 switch(project.Files.GetBuildAction(file))
180 {
181 case BuildAction.None:
182 buildAction = "Nothing";
183 break;
184
185 case BuildAction.Content:
186 buildAction = "Exclude";
187 break;
188
189 case BuildAction.EmbeddedResource:
190 buildAction = "EmbedAsResource";
191 break;
192
193 default:
194 buildAction = "Compile";
195 break;
196 }
197
198 // Sort of a hack, we try and resolve the path and make it relative, if we can.
199 string filePath = PrependPath(file);
200 ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction);
201 }
202 ss.WriteLine(" </Contents>");
203
204 ss.WriteLine(" <References>");
205 foreach(ReferenceNode refr in project.References)
206 {
207 ss.WriteLine(" {0}", BuildReference(solution, refr));
208 }
209 ss.WriteLine(" </References>");
210
211 ss.Write(" <DeploymentInformation");
212 ss.Write(" target=\"\"");
213 ss.Write(" script=\"\"");
214 ss.Write(" strategy=\"File\"");
215 ss.WriteLine(" />");
216
217 int count = 0;
218
219 ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig);
220
221 foreach(ConfigurationNode conf in project.Configurations)
222 {
223 ss.Write(" <Configuration");
224 ss.Write(" runwithwarnings=\"True\"");
225 ss.Write(" name=\"{0}\"", conf.Name);
226 ss.WriteLine(">");
227 ss.Write(" <CodeGeneration");
228 ss.Write(" runtime=\"{0}\"", netRuntime);
229 ss.Write(" compiler=\"{0}\"", csComp);
230 ss.Write(" compilerversion=\"\"");
231 ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
232 ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
233 ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
234 ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
235 ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
236 ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
237 ss.Write(" mainclass=\"{0}\"", project.StartupObject);
238 ss.Write(" target=\"{0}\"", project.Type);
239 ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
240 ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
241 ss.Write(" win32Icon=\"{0}\"", Helper.NormalizePath(".\\" + project.AppIcon));
242 ss.Write(" noconfig=\"{0}\"", "False");
243 ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
244 ss.WriteLine(" />");
245
246 ss.Write(" <Execution");
247 ss.Write(" commandlineparameters=\"\"");
248 ss.Write(" consolepause=\"True\"");
249 ss.WriteLine(" />");
250
251 ss.Write(" <Output");
252 ss.Write(" directory=\".\\{0}\"", Helper.NormalizePath(conf.Options["OutputPath"].ToString()));
253 ss.Write(" assembly=\"{0}\"", project.AssemblyName);
254 ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
255 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
256 {
257 ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
258 }
259 else
260 {
261 ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
262 }
263 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
264 {
265 ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
266 }
267 else
268 {
269 ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
270 }
271 ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
272 ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
273 ss.WriteLine(" />");
274 ss.WriteLine(" </Configuration>");
275
276 count++;
277 }
278 ss.WriteLine(" </Configurations>");
279 ss.WriteLine("</Project>");
280 }
281
282 m_Kernel.CurrentWorkingDirectory.Pop();
283 }
284
285 private void WriteCombine(SolutionNode solution)
286 {
287 m_Kernel.Log.Write("Creating SharpDevelop combine and project files");
288 foreach(ProjectNode project in solution.Projects)
289 {
290 if(m_Kernel.AllowProject(project.FilterGroups))
291 {
292 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
293 WriteProject(solution, project);
294 }
295 }
296
297 m_Kernel.Log.Write("");
298 string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
299 StreamWriter ss = new StreamWriter(combFile);
300
301 m_Kernel.CurrentWorkingDirectory.Push();
302 Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
303
304 using(ss)
305 {
306 ss.WriteLine("<Combine fileversion=\"1.0\" name=\"{0}\" description=\"\">", solution.Name);
307
308 int count = 0;
309 foreach(ProjectNode project in solution.Projects)
310 {
311 if(count == 0)
312 ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name);
313
314 ss.WriteLine(" <Execute entry=\"{0}\" type=\"None\" />", project.Name);
315 count++;
316 }
317 ss.WriteLine(" </StartMode>");
318
319 ss.WriteLine(" <Entries>");
320 foreach(ProjectNode project in solution.Projects)
321 {
322 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
323 ss.WriteLine(" <Entry filename=\"{0}\" />",
324 Helper.MakeFilePath(path, project.Name, "prjx"));
325 }
326 ss.WriteLine(" </Entries>");
327
328 count = 0;
329 foreach(ConfigurationNode conf in solution.Configurations)
330 {
331 if(count == 0)
332 {
333 ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name);
334 }
335
336 ss.WriteLine(" <Configuration name=\"{0}\">", conf.Name);
337 foreach(ProjectNode project in solution.Projects)
338 {
339 ss.WriteLine(" <Entry name=\"{0}\" configurationname=\"{1}\" build=\"True\" />", project.Name, conf.Name);
340 }
341 ss.WriteLine(" </Configuration>");
342
343 count++;
344 }
345 ss.WriteLine(" </Configurations>");
346 ss.WriteLine("</Combine>");
347 }
348
349 m_Kernel.CurrentWorkingDirectory.Pop();
350 }
351
352 private void CleanProject(ProjectNode project)
353 {
354 m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
355 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "prjx");
356 Helper.DeleteIfExists(projectFile);
357 }
358
359 private void CleanSolution(SolutionNode solution)
360 {
361 m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name);
362
363 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
364 Helper.DeleteIfExists(slnFile);
365
366 foreach(ProjectNode project in solution.Projects)
367 {
368 CleanProject(project);
369 }
370
371 m_Kernel.Log.Write("");
372 }
373
374 #endregion
375
376 #region ITarget Members
377
378 /// <summary>
379 /// Writes the specified kern.
380 /// </summary>
381 /// <param name="kern">The kern.</param>
382 public void Write(Kernel kern)
383 {
384 if( kern == null )
385 {
386 throw new ArgumentNullException("kern");
387 }
388 m_Kernel = kern;
389 foreach(SolutionNode solution in kern.Solutions)
390 {
391 WriteCombine(solution);
392 }
393 m_Kernel = null;
394 }
395
396 /// <summary>
397 /// Cleans the specified kern.
398 /// </summary>
399 /// <param name="kern">The kern.</param>
400 public virtual void Clean(Kernel kern)
401 {
402 if( kern == null )
403 {
404 throw new ArgumentNullException("kern");
405 }
406 m_Kernel = kern;
407 foreach(SolutionNode sol in kern.Solutions)
408 {
409 CleanSolution(sol);
410 }
411 m_Kernel = null;
412 }
413
414 /// <summary>
415 /// Gets the name.
416 /// </summary>
417 /// <value>The name.</value>
418 public string Name
419 {
420 get
421 {
422 return "sharpdev";
423 }
424 }
425
426 #endregion
427 }
428}
diff --git a/Prebuild/src/Core/Targets/ToolInfo.cs b/Prebuild/src/Core/Targets/ToolInfo.cs
deleted file mode 100644
index 935c674..0000000
--- a/Prebuild/src/Core/Targets/ToolInfo.cs
+++ /dev/null
@@ -1,197 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Prebuild.Core.Targets
6{
7 /// <summary>
8 ///
9 /// </summary>
10 public struct ToolInfo
11 {
12 string name;
13 string guid;
14 string fileExtension;
15 string xmlTag;
16 string importProject;
17
18 /// <summary>
19 /// Gets or sets the name.
20 /// </summary>
21 /// <value>The name.</value>
22 public string Name
23 {
24 get
25 {
26 return name;
27 }
28 set
29 {
30 name = value;
31 }
32 }
33
34 /// <summary>
35 /// Gets or sets the GUID.
36 /// </summary>
37 /// <value>The GUID.</value>
38 public string Guid
39 {
40 get
41 {
42 return guid;
43 }
44 set
45 {
46 guid = value;
47 }
48 }
49
50 /// <summary>
51 /// Gets or sets the file extension.
52 /// </summary>
53 /// <value>The file extension.</value>
54 public string FileExtension
55 {
56 get
57 {
58 return fileExtension;
59 }
60 set
61 {
62 fileExtension = value;
63 }
64 }
65 public string LanguageExtension
66 {
67 get
68 {
69 switch (this.Name)
70 {
71 case "C#":
72 return ".cs";
73 case "VisualBasic":
74 return ".vb";
75 case "Boo":
76 return ".boo";
77 default:
78 return ".cs";
79 }
80 }
81 }
82 /// <summary>
83 /// Gets or sets the XML tag.
84 /// </summary>
85 /// <value>The XML tag.</value>
86 public string XmlTag
87 {
88 get
89 {
90 return xmlTag;
91 }
92 set
93 {
94 xmlTag = value;
95 }
96 }
97
98 /// <summary>
99 /// Gets or sets the import project property.
100 /// </summary>
101 /// <value>The ImportProject tag.</value>
102 public string ImportProject
103 {
104 get
105 {
106 return importProject;
107 }
108 set
109 {
110 importProject = value;
111 }
112 }
113
114 /// <summary>
115 /// Initializes a new instance of the <see cref="ToolInfo"/> class.
116 /// </summary>
117 /// <param name="name">The name.</param>
118 /// <param name="guid">The GUID.</param>
119 /// <param name="fileExtension">The file extension.</param>
120 /// <param name="xml">The XML.</param>
121 /// <param name="importProject">The import project.</param>
122 public ToolInfo(string name, string guid, string fileExtension, string xml, string importProject)
123 {
124 this.name = name;
125 this.guid = guid;
126 this.fileExtension = fileExtension;
127 this.xmlTag = xml;
128 this.importProject = importProject;
129 }
130
131 /// <summary>
132 /// Initializes a new instance of the <see cref="ToolInfo"/> class.
133 /// </summary>
134 /// <param name="name">The name.</param>
135 /// <param name="guid">The GUID.</param>
136 /// <param name="fileExtension">The file extension.</param>
137 /// <param name="xml">The XML.</param>
138 public ToolInfo(string name, string guid, string fileExtension, string xml)
139 {
140 this.name = name;
141 this.guid = guid;
142 this.fileExtension = fileExtension;
143 this.xmlTag = xml;
144 this.importProject = "$(MSBuildBinPath)\\Microsoft." + xml + ".Targets";
145 }
146
147 /// <summary>
148 /// Equals operator
149 /// </summary>
150 /// <param name="obj">ToolInfo to compare</param>
151 /// <returns>true if toolInfos are equal</returns>
152 public override bool Equals(object obj)
153 {
154 if (obj == null)
155 {
156 throw new ArgumentNullException("obj");
157 }
158 if (obj.GetType() != typeof(ToolInfo))
159 return false;
160
161 ToolInfo c = (ToolInfo)obj;
162 return ((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject));
163 }
164
165 /// <summary>
166 /// Equals operator
167 /// </summary>
168 /// <param name="c1">ToolInfo to compare</param>
169 /// <param name="c2">ToolInfo to compare</param>
170 /// <returns>True if toolInfos are equal</returns>
171 public static bool operator ==(ToolInfo c1, ToolInfo c2)
172 {
173 return ((c1.name == c2.name) && (c1.guid == c2.guid) && (c1.fileExtension == c2.fileExtension) && (c1.importProject == c2.importProject) && (c1.xmlTag == c2.xmlTag));
174 }
175
176 /// <summary>
177 /// Not equals operator
178 /// </summary>
179 /// <param name="c1">ToolInfo to compare</param>
180 /// <param name="c2">ToolInfo to compare</param>
181 /// <returns>True if toolInfos are not equal</returns>
182 public static bool operator !=(ToolInfo c1, ToolInfo c2)
183 {
184 return !(c1 == c2);
185 }
186
187 /// <summary>
188 /// Hash Code
189 /// </summary>
190 /// <returns>Hash code</returns>
191 public override int GetHashCode()
192 {
193 return name.GetHashCode() ^ guid.GetHashCode() ^ this.fileExtension.GetHashCode() ^ this.importProject.GetHashCode() ^ this.xmlTag.GetHashCode();
194
195 }
196 }
197}
diff --git a/Prebuild/src/Core/Targets/VS2002Target.cs b/Prebuild/src/Core/Targets/VS2002Target.cs
deleted file mode 100644
index 2292624..0000000
--- a/Prebuild/src/Core/Targets/VS2002Target.cs
+++ /dev/null
@@ -1,87 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 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;
27
28using Prebuild.Core.Attributes;
29
30namespace Prebuild.Core.Targets
31{
32 /// <summary>
33 ///
34 /// </summary>
35 [Target("vs2002")]
36 public class VS2002Target : VS2003Target
37 {
38 #region Private Methods
39
40 private void SetVS2002()
41 {
42 this.SolutionVersion = "7.00";
43 this.ProductVersion = "7.0.9254";
44 this.SchemaVersion = "1.0";
45 this.VersionName = "2002";
46 this.Version = VSVersion.VS70;
47 }
48
49 #endregion
50
51 #region Public Methods
52
53 /// <summary>
54 /// Writes the specified kern.
55 /// </summary>
56 /// <param name="kern">The kern.</param>
57 public override void Write(Kernel kern)
58 {
59 SetVS2002();
60 base.Write(kern);
61 }
62
63 /// <summary>
64 /// Cleans the specified kern.
65 /// </summary>
66 /// <param name="kern">The kern.</param>
67 public override void Clean(Kernel kern)
68 {
69 SetVS2002();
70 base.Clean(kern);
71 }
72
73 /// <summary>
74 /// Gets the name.
75 /// </summary>
76 /// <value>The name.</value>
77 public override string Name
78 {
79 get
80 {
81 return "vs2002";
82 }
83 }
84
85 #endregion
86 }
87}
diff --git a/Prebuild/src/Core/Targets/VS2003Target.cs b/Prebuild/src/Core/Targets/VS2003Target.cs
deleted file mode 100644
index 1bcb7dc..0000000
--- a/Prebuild/src/Core/Targets/VS2003Target.cs
+++ /dev/null
@@ -1,602 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 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.Collections;
28using System.Collections.Specialized;
29using System.IO;
30
31using Prebuild.Core.Attributes;
32using Prebuild.Core.Interfaces;
33using Prebuild.Core.Nodes;
34using Prebuild.Core.Utilities;
35
36namespace Prebuild.Core.Targets
37{
38 [Target("vs2003")]
39 public class VS2003Target : ITarget
40 {
41
42 #region Fields
43
44 string solutionVersion = "8.00";
45 string productVersion = "7.10.3077";
46 string schemaVersion = "2.0";
47 string versionName = "2003";
48 VSVersion version = VSVersion.VS71;
49
50 Hashtable m_Tools;
51 Kernel m_Kernel;
52
53 /// <summary>
54 /// Gets or sets the solution version.
55 /// </summary>
56 /// <value>The solution version.</value>
57 protected string SolutionVersion
58 {
59 get
60 {
61 return this.solutionVersion;
62 }
63 set
64 {
65 this.solutionVersion = value;
66 }
67 }
68 /// <summary>
69 /// Gets or sets the product version.
70 /// </summary>
71 /// <value>The product version.</value>
72 protected string ProductVersion
73 {
74 get
75 {
76 return this.productVersion;
77 }
78 set
79 {
80 this.productVersion = value;
81 }
82 }
83 /// <summary>
84 /// Gets or sets the schema version.
85 /// </summary>
86 /// <value>The schema version.</value>
87 protected string SchemaVersion
88 {
89 get
90 {
91 return this.schemaVersion;
92 }
93 set
94 {
95 this.schemaVersion = value;
96 }
97 }
98 /// <summary>
99 /// Gets or sets the name of the version.
100 /// </summary>
101 /// <value>The name of the version.</value>
102 protected string VersionName
103 {
104 get
105 {
106 return this.versionName;
107 }
108 set
109 {
110 this.versionName = value;
111 }
112 }
113 /// <summary>
114 /// Gets or sets the version.
115 /// </summary>
116 /// <value>The version.</value>
117 protected VSVersion Version
118 {
119 get
120 {
121 return this.version;
122 }
123 set
124 {
125 this.version = value;
126 }
127 }
128
129 #endregion
130
131 #region Constructors
132
133 /// <summary>
134 /// Initializes a new instance of the <see cref="VS2003Target"/> class.
135 /// </summary>
136 public VS2003Target()
137 {
138 m_Tools = new Hashtable();
139
140 m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP");
141 m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic");
142 }
143
144 #endregion
145
146 #region Private Methods
147
148 private string MakeRefPath(ProjectNode project)
149 {
150 string ret = "";
151 foreach(ReferencePathNode node in project.ReferencePaths)
152 {
153 try
154 {
155 string fullPath = Helper.ResolvePath(node.Path);
156 if(ret.Length < 1)
157 {
158 ret = fullPath;
159 }
160 else
161 {
162 ret += ";" + fullPath;
163 }
164 }
165 catch(ArgumentException)
166 {
167 m_Kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
168 }
169 }
170
171 return ret;
172 }
173
174 private void WriteProject(SolutionNode solution, ProjectNode project)
175 {
176 if(!m_Tools.ContainsKey(project.Language))
177 {
178 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
179 }
180
181 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
182 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
183 StreamWriter ps = new StreamWriter(projectFile);
184
185 m_Kernel.CurrentWorkingDirectory.Push();
186 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
187
188 IEnumerator enumerator;
189 //ConfigurationNode scripts;
190
191 using(ps)
192 {
193 ps.WriteLine("<VisualStudioProject>");
194 ps.WriteLine(" <{0}", toolInfo.XmlTag);
195 ps.WriteLine("\t\t\t\tProjectType = \"Local\"");
196 ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion);
197 ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion);
198 ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper());
199 ps.WriteLine("\t\t>");
200
201 ps.WriteLine("\t\t\t\t<Build>");
202 ps.WriteLine(" <Settings");
203 ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"",project.AppIcon);
204 ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\"");
205 ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName);
206 ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\"");
207 ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\"");
208 ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\"");
209 ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\"");
210 ps.WriteLine("\t\t\t\t DelaySign = \"false\"");
211
212 if(this.Version == VSVersion.VS70)
213 {
214 ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\"");
215 }
216
217 ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString());
218
219 enumerator = project.Configurations.GetEnumerator();
220 enumerator.Reset();
221 enumerator.MoveNext();
222 foreach(ConfigurationNode conf in project.Configurations)
223 {
224 if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
225 {
226 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
227 }
228 else
229 {
230 ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]);
231 }
232 if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
233 {
234 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
235 }
236 else
237 {
238 ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]);
239 }
240 if (conf.Options["RunPostBuildEvent"] == null)
241 {
242 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess");
243 }
244 else
245 {
246 ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]);
247 }
248 break;
249 }
250
251 ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace);
252 ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject);
253 ps.WriteLine("\t\t >");
254
255 foreach(ConfigurationNode conf in project.Configurations)
256 {
257 ps.WriteLine("\t\t\t\t <Config");
258 ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name);
259 ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower());
260 ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]);
261 ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower());
262 ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\"");
263 ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]);
264 ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf));//default to the assembly name
265 ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower());
266 ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]);
267 ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower());
268
269 if(this.Version == VSVersion.VS71)
270 {
271 ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower());
272 ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower());
273 }
274
275 ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower());
276 ps.WriteLine(" OutputPath = \"{0}\"",
277 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
278 ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower());
279 ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower());
280 ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower());
281 ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]);
282 ps.WriteLine(" />");
283 }
284
285 ps.WriteLine(" </Settings>");
286
287 ps.WriteLine(" <References>");
288 foreach(ReferenceNode refr in project.References)
289 {
290 ps.WriteLine(" <Reference");
291 ps.WriteLine(" Name = \"{0}\"", refr.Name);
292 ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name);
293
294 if(solution.ProjectsTable.ContainsKey(refr.Name))
295 {
296 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
297 ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper());
298 ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper());
299 }
300 else
301 {
302 if(refr.Path != null)
303 {
304 ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll"));
305 }
306
307 }
308
309 if(refr.LocalCopySpecified)
310 {
311 ps.WriteLine(" Private = \"{0}\"",refr.LocalCopy);
312 }
313
314 ps.WriteLine(" />");
315 }
316 ps.WriteLine(" </References>");
317
318 ps.WriteLine(" </Build>");
319 ps.WriteLine(" <Files>");
320
321 ps.WriteLine(" <Include>");
322
323 foreach(string file in project.Files)
324 {
325 string fileName = file.Replace(".\\", "");
326 ps.WriteLine(" <File");
327 ps.WriteLine(" RelPath = \"{0}\"", fileName);
328 ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file));
329 ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file));
330 ps.WriteLine(" />");
331
332 if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
333 {
334 ps.WriteLine(" <File");
335 ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx");
336 int slash = fileName.LastIndexOf('\\');
337 if (slash == -1)
338 {
339 ps.WriteLine(" DependentUpon = \"{0}\"", fileName);
340 }
341 else
342 {
343 ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1));
344 }
345 ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource");
346 ps.WriteLine(" />");
347
348 }
349 }
350 ps.WriteLine(" </Include>");
351
352 ps.WriteLine(" </Files>");
353 ps.WriteLine(" </{0}>", toolInfo.XmlTag);
354 ps.WriteLine("</VisualStudioProject>");
355 }
356
357 ps = new StreamWriter(projectFile + ".user");
358 using(ps)
359 {
360 ps.WriteLine("<VisualStudioProject>");
361 ps.WriteLine(" <{0}>", toolInfo.XmlTag);
362 ps.WriteLine(" <Build>");
363
364 ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
365 foreach(ConfigurationNode conf in project.Configurations)
366 {
367 ps.WriteLine(" <Config");
368 ps.WriteLine(" Name = \"{0}\"", conf.Name);
369 ps.WriteLine(" />");
370 }
371 ps.WriteLine(" </Settings>");
372
373 ps.WriteLine(" </Build>");
374 ps.WriteLine(" </{0}>", toolInfo.XmlTag);
375 ps.WriteLine("</VisualStudioProject>");
376 }
377
378 m_Kernel.CurrentWorkingDirectory.Pop();
379 }
380
381 /// <summary>
382 /// Gets the XML doc file.
383 /// </summary>
384 /// <param name="project">The project.</param>
385 /// <param name="conf">The conf.</param>
386 /// <returns></returns>
387 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
388 {
389 if( conf == null )
390 {
391 throw new ArgumentNullException("conf");
392 }
393 if( project == null )
394 {
395 throw new ArgumentNullException("project");
396 }
397 // if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false
398 // {
399 // return string.Empty;
400 // }
401
402 //default to "AssemblyName.xml"
403 //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
404 //return (string)conf.Options["XmlDocFile", defaultValue];
405
406 //default to no XmlDocFile file
407 return (string)conf.Options["XmlDocFile", ""];
408 }
409
410 private void WriteSolution(SolutionNode solution)
411 {
412 m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName);
413
414 foreach(ProjectNode project in solution.Projects)
415 {
416 if(m_Kernel.AllowProject(project.FilterGroups))
417 {
418 m_Kernel.Log.Write("...Creating project: {0}", project.Name);
419 WriteProject(solution, project);
420 }
421 }
422
423 m_Kernel.Log.Write("");
424 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
425 StreamWriter ss = new StreamWriter(solutionFile);
426
427 m_Kernel.CurrentWorkingDirectory.Push();
428 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
429
430 using(ss)
431 {
432 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion);
433 foreach(ProjectNode project in solution.Projects)
434 {
435 if(!m_Tools.ContainsKey(project.Language))
436 {
437 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
438 }
439
440 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
441
442 string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
443 ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"",
444 toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name,
445 toolInfo.FileExtension), project.Guid.ToString().ToUpper());
446
447 ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject");
448 ss.WriteLine("\tEndProjectSection");
449
450 ss.WriteLine("EndProject");
451 }
452
453 ss.WriteLine("Global");
454
455 ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution");
456 foreach(ConfigurationNode conf in solution.Configurations)
457 {
458 ss.WriteLine("\t\t{0} = {0}", conf.Name);
459 }
460 ss.WriteLine("\tEndGlobalSection");
461
462 ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution");
463 foreach(ProjectNode project in solution.Projects)
464 {
465 for(int i = 0; i < project.References.Count; i++)
466 {
467 ReferenceNode refr = (ReferenceNode)project.References[i];
468 if(solution.ProjectsTable.ContainsKey(refr.Name))
469 {
470 ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
471 ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})",
472 project.Guid.ToString().ToUpper()
473 , i,
474 refProject.Guid.ToString().ToUpper()
475 );
476 }
477 }
478 }
479 ss.WriteLine("\tEndGlobalSection");
480
481 ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution");
482 foreach(ProjectNode project in solution.Projects)
483 {
484 foreach(ConfigurationNode conf in solution.Configurations)
485 {
486 ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET",
487 project.Guid.ToString().ToUpper(),
488 conf.Name);
489
490 ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET",
491 project.Guid.ToString().ToUpper(),
492 conf.Name);
493 }
494 }
495 ss.WriteLine("\tEndGlobalSection");
496
497 if(solution.Files != null)
498 {
499 ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution");
500 foreach(string file in solution.Files)
501 {
502 ss.WriteLine("\t\t{0} = {0}", file);
503 }
504 ss.WriteLine("\tEndGlobalSection");
505 }
506
507 ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution");
508 ss.WriteLine("\tEndGlobalSection");
509 ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution");
510 ss.WriteLine("\tEndGlobalSection");
511
512 ss.WriteLine("EndGlobal");
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
522 ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language];
523 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
524 string userFile = projectFile + ".user";
525
526 Helper.DeleteIfExists(projectFile);
527 Helper.DeleteIfExists(userFile);
528 }
529
530 private void CleanSolution(SolutionNode solution)
531 {
532 m_Kernel.Log.Write("Cleaning Visual Studio {0} solution and project files", this.VersionName, solution.Name);
533
534 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
535 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
536
537 Helper.DeleteIfExists(slnFile);
538 Helper.DeleteIfExists(suoFile);
539
540 foreach(ProjectNode project in solution.Projects)
541 {
542 CleanProject(project);
543 }
544
545 m_Kernel.Log.Write("");
546 }
547
548 #endregion
549
550 #region ITarget Members
551
552 /// <summary>
553 /// Writes the specified kern.
554 /// </summary>
555 /// <param name="kern">The kern.</param>
556 public virtual void Write(Kernel kern)
557 {
558 if( kern == null )
559 {
560 throw new ArgumentNullException("kern");
561 }
562 m_Kernel = kern;
563 foreach(SolutionNode sol in m_Kernel.Solutions)
564 {
565 WriteSolution(sol);
566 }
567 m_Kernel = null;
568 }
569
570 /// <summary>
571 /// Cleans the specified kern.
572 /// </summary>
573 /// <param name="kern">The kern.</param>
574 public virtual void Clean(Kernel kern)
575 {
576 if( kern == null )
577 {
578 throw new ArgumentNullException("kern");
579 }
580 m_Kernel = kern;
581 foreach(SolutionNode sol in m_Kernel.Solutions)
582 {
583 CleanSolution(sol);
584 }
585 m_Kernel = null;
586 }
587
588 /// <summary>
589 /// Gets the name.
590 /// </summary>
591 /// <value>The name.</value>
592 public virtual string Name
593 {
594 get
595 {
596 return "vs2003";
597 }
598 }
599
600 #endregion
601 }
602}
diff --git a/Prebuild/src/Core/Targets/VS2005Target.cs b/Prebuild/src/Core/Targets/VS2005Target.cs
deleted file mode 100644
index 63461c9..0000000
--- a/Prebuild/src/Core/Targets/VS2005Target.cs
+++ /dev/null
@@ -1,149 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.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.Collections;
28using System.Collections.Specialized;
29using System.IO;
30using System.Text;
31
32using Prebuild.Core.Attributes;
33using Prebuild.Core.Interfaces;
34using Prebuild.Core.Nodes;
35using Prebuild.Core.Utilities;
36
37namespace Prebuild.Core.Targets
38{
39 /// <summary>
40 ///
41 /// </summary>
42 [Target("vs2005")]
43 public class VS2005Target : VSGenericTarget
44 {
45 #region Inner Classes
46
47 #endregion
48
49 #region Fields
50
51 string solutionVersion = "9.00";
52 string productVersion = "8.0.50727";
53 string schemaVersion = "2.0";
54 string versionName = "Visual C# 2005";
55 string name = "vs2005";
56
57 VSVersion version = VSVersion.VS80;
58
59 public override string SolutionTag
60 {
61 get { return "# Visual Studio 2005"; }
62 }
63
64 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
65 {
66 return string.Empty;
67 }
68 /// <summary>
69 /// Gets or sets the solution version.
70 /// </summary>
71 /// <value>The solution version.</value>
72 public override string SolutionVersion
73 {
74 get
75 {
76 return solutionVersion;
77 }
78 }
79 /// <summary>
80 /// Gets or sets the product version.
81 /// </summary>
82 /// <value>The product version.</value>
83 public override string ProductVersion
84 {
85 get
86 {
87 return productVersion;
88 }
89 }
90 /// <summary>
91 /// Gets or sets the schema version.
92 /// </summary>
93 /// <value>The schema version.</value>
94 public override string SchemaVersion
95 {
96 get
97 {
98 return schemaVersion;
99 }
100 }
101 /// <summary>
102 /// Gets or sets the name of the version.
103 /// </summary>
104 /// <value>The name of the version.</value>
105 public override string VersionName
106 {
107 get
108 {
109 return versionName;
110 }
111 }
112 /// <summary>
113 /// Gets or sets the version.
114 /// </summary>
115 /// <value>The version.</value>
116 public override VSVersion Version
117 {
118 get
119 {
120 return version;
121 }
122 }
123 /// <summary>
124 /// Gets the name.
125 /// </summary>
126 /// <value>The name.</value>
127 public override string Name
128 {
129 get
130 {
131 return name;
132 }
133 }
134
135 #endregion
136
137 #region Constructors
138
139 /// <summary>
140 /// Initializes a new instance of the <see cref="VS2005Target"/> class.
141 /// </summary>
142 public VS2005Target()
143 : base()
144 {
145 }
146
147 #endregion
148 }
149}
diff --git a/Prebuild/src/Core/Targets/VS2008Target.cs b/Prebuild/src/Core/Targets/VS2008Target.cs
deleted file mode 100644
index e685962..0000000
--- a/Prebuild/src/Core/Targets/VS2008Target.cs
+++ /dev/null
@@ -1,132 +0,0 @@
1using System;
2using System.Collections;
3using System.Collections.Specialized;
4using System.IO;
5using System.Text;
6
7using Prebuild.Core.Attributes;
8using Prebuild.Core.Interfaces;
9using Prebuild.Core.Nodes;
10using Prebuild.Core.Utilities;
11using System.CodeDom.Compiler;
12
13namespace Prebuild.Core.Targets
14{
15
16 /// <summary>
17 ///
18 /// </summary>
19 [Target("vs2008")]
20 public class VS2008Target : VSGenericTarget
21 {
22 #region Fields
23 string solutionVersion = "10.00";
24 string productVersion = "9.0.21022";
25 string schemaVersion = "2.0";
26 string versionName = "Visual Studio 2008";
27 string name = "vs2008";
28 VSVersion version = VSVersion.VS90;
29
30 Hashtable tools;
31 Kernel kernel;
32
33 /// <summary>
34 /// Gets or sets the solution version.
35 /// </summary>
36 /// <value>The solution version.</value>
37 public override string SolutionVersion
38 {
39 get
40 {
41 return solutionVersion;
42 }
43 }
44 /// <summary>
45 /// Gets or sets the product version.
46 /// </summary>
47 /// <value>The product version.</value>
48 public override string ProductVersion
49 {
50 get
51 {
52 return productVersion;
53 }
54 }
55 /// <summary>
56 /// Gets or sets the schema version.
57 /// </summary>
58 /// <value>The schema version.</value>
59 public override string SchemaVersion
60 {
61 get
62 {
63 return schemaVersion;
64 }
65 }
66 /// <summary>
67 /// Gets or sets the name of the version.
68 /// </summary>
69 /// <value>The name of the version.</value>
70 public override string VersionName
71 {
72 get
73 {
74 return versionName;
75 }
76 }
77 /// <summary>
78 /// Gets or sets the version.
79 /// </summary>
80 /// <value>The version.</value>
81 public override VSVersion Version
82 {
83 get
84 {
85 return version;
86 }
87 }
88 /// <summary>
89 /// Gets the name.
90 /// </summary>
91 /// <value>The name.</value>
92 public override string Name
93 {
94 get
95 {
96 return name;
97 }
98 }
99
100 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
101 {
102 switch (frameworkVersion)
103 {
104 case FrameworkVersion.v3_5:
105 return "ToolsVersion=\"3.5\"";
106 case FrameworkVersion.v3_0:
107 return "ToolsVersion=\"3.0\"";
108 default:
109 return "ToolsVersion=\"2.0\"";
110 }
111 }
112
113 public override string SolutionTag
114 {
115 get { return "# Visual Studio 2008"; }
116 }
117
118 #endregion
119
120 #region Constructors
121
122 /// <summary>
123 /// Initializes a new instance of the <see cref="VS2008Target"/> class.
124 /// </summary>
125 public VS2008Target()
126 : base()
127 {
128 }
129
130 #endregion
131 }
132}
diff --git a/Prebuild/src/Core/Targets/VS2010Target.cs b/Prebuild/src/Core/Targets/VS2010Target.cs
deleted file mode 100644
index 8772d18..0000000
--- a/Prebuild/src/Core/Targets/VS2010Target.cs
+++ /dev/null
@@ -1,134 +0,0 @@
1using System;
2using System.Collections;
3using System.Collections.Specialized;
4using System.IO;
5using System.Text;
6
7using Prebuild.Core.Attributes;
8using Prebuild.Core.Interfaces;
9using Prebuild.Core.Nodes;
10using Prebuild.Core.Utilities;
11using System.CodeDom.Compiler;
12
13namespace Prebuild.Core.Targets
14{
15
16 /// <summary>
17 ///
18 /// </summary>
19 [Target("vs2010")]
20 public class VS2010Target : VSGenericTarget
21 {
22 #region Fields
23 string solutionVersion = "11.00";
24 string productVersion = "9.0.21022";
25 string schemaVersion = "2.0";
26 string versionName = "Visual Studio 2010";
27 string name = "vs2008";
28 VSVersion version = VSVersion.VS10;
29
30 Hashtable tools;
31 Kernel kernel;
32
33 /// <summary>
34 /// Gets or sets the solution version.
35 /// </summary>
36 /// <value>The solution version.</value>
37 public override string SolutionVersion
38 {
39 get
40 {
41 return solutionVersion;
42 }
43 }
44 /// <summary>
45 /// Gets or sets the product version.
46 /// </summary>
47 /// <value>The product version.</value>
48 public override string ProductVersion
49 {
50 get
51 {
52 return productVersion;
53 }
54 }
55 /// <summary>
56 /// Gets or sets the schema version.
57 /// </summary>
58 /// <value>The schema version.</value>
59 public override string SchemaVersion
60 {
61 get
62 {
63 return schemaVersion;
64 }
65 }
66 /// <summary>
67 /// Gets or sets the name of the version.
68 /// </summary>
69 /// <value>The name of the version.</value>
70 public override string VersionName
71 {
72 get
73 {
74 return versionName;
75 }
76 }
77 /// <summary>
78 /// Gets or sets the version.
79 /// </summary>
80 /// <value>The version.</value>
81 public override VSVersion Version
82 {
83 get
84 {
85 return version;
86 }
87 }
88 /// <summary>
89 /// Gets the name.
90 /// </summary>
91 /// <value>The name.</value>
92 public override string Name
93 {
94 get
95 {
96 return name;
97 }
98 }
99
100 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
101 {
102 switch (frameworkVersion)
103 {
104 case FrameworkVersion.v4_0:
105 return "ToolsVersion=\"4.0\"";
106 case FrameworkVersion.v3_5:
107 return "ToolsVersion=\"3.5\"";
108 case FrameworkVersion.v3_0:
109 return "ToolsVersion=\"3.0\"";
110 default:
111 return "ToolsVersion=\"2.0\"";
112 }
113 }
114
115 public override string SolutionTag
116 {
117 get { return "# Visual Studio 2010"; }
118 }
119
120 #endregion
121
122 #region Constructors
123
124 /// <summary>
125 /// Initializes a new instance of the <see cref="VS2010Target"/> class.
126 /// </summary>
127 public VS2010Target()
128 : base()
129 {
130 }
131
132 #endregion
133 }
134}
diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs
deleted file mode 100644
index fdcc2b9..0000000
--- a/Prebuild/src/Core/Targets/VSGenericTarget.cs
+++ /dev/null
@@ -1,887 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@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.Collections;
28using System.Collections.Generic;
29using System.Collections.Specialized;
30using System.IO;
31using System.Text;
32
33using Prebuild.Core.Attributes;
34using Prebuild.Core.Interfaces;
35using Prebuild.Core.Nodes;
36using Prebuild.Core.Utilities;
37using System.CodeDom.Compiler;
38
39namespace Prebuild.Core.Targets
40{
41
42 /// <summary>
43 ///
44 /// </summary>
45 public abstract class VSGenericTarget : ITarget
46 {
47 #region Fields
48
49 readonly Hashtable tools = new Hashtable();
50 Kernel kernel;
51 #endregion
52
53 #region Properties
54 /// <summary>
55 /// Gets or sets the solution version.
56 /// </summary>
57 /// <value>The solution version.</value>
58 public abstract string SolutionVersion { get; }
59 /// <summary>
60 /// Gets or sets the product version.
61 /// </summary>
62 /// <value>The product version.</value>
63 public abstract string ProductVersion { get; }
64 /// <summary>
65 /// Gets or sets the schema version.
66 /// </summary>
67 /// <value>The schema version.</value>
68 public abstract string SchemaVersion { get; }
69 /// <summary>
70 /// Gets or sets the name of the version.
71 /// </summary>
72 /// <value>The name of the version.</value>
73 public abstract string VersionName { get; }
74 /// <summary>
75 /// Gets or sets the version.
76 /// </summary>
77 /// <value>The version.</value>
78 public abstract VSVersion Version { get; }
79 /// <summary>
80 /// Gets the name.
81 /// </summary>
82 /// <value>The name.</value>
83 public abstract string Name { get; }
84
85 protected abstract string GetToolsVersionXml(FrameworkVersion version);
86 public abstract string SolutionTag { get; }
87
88 #endregion
89
90 #region Constructors
91
92 /// <summary>
93 /// Initializes a new instance of the <see cref="VSGenericTarget"/> class.
94 /// </summary>
95 protected VSGenericTarget()
96 {
97 this.tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets");
98 this.tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN");
99 this.tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets");
100 this.tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets");
101 this.tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null);
102 }
103
104 #endregion
105
106 #region Private Methods
107
108 private string MakeRefPath(ProjectNode project)
109 {
110 string ret = "";
111 foreach (ReferencePathNode node in project.ReferencePaths)
112 {
113 try
114 {
115 string fullPath = Helper.ResolvePath(node.Path);
116 if (ret.Length < 1)
117 {
118 ret = fullPath;
119 }
120 else
121 {
122 ret += ";" + fullPath;
123 }
124 }
125 catch (ArgumentException)
126 {
127 this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
128 }
129 }
130
131 return ret;
132 }
133
134 private static ProjectNode FindProjectInSolution(string name, SolutionNode solution)
135 {
136 SolutionNode node = solution;
137
138 while (node.Parent is SolutionNode)
139 node = node.Parent as SolutionNode;
140
141 return FindProjectInSolutionRecursively(name, node);
142 }
143
144 private static ProjectNode FindProjectInSolutionRecursively(string name, SolutionNode solution)
145 {
146 if (solution.ProjectsTable.ContainsKey(name))
147 return (ProjectNode)solution.ProjectsTable[name];
148
149 foreach (SolutionNode child in solution.Solutions)
150 {
151 ProjectNode node = FindProjectInSolutionRecursively(name, child);
152 if (node != null)
153 return node;
154 }
155
156 return null;
157 }
158
159 private void WriteProject(SolutionNode solution, ProjectNode project)
160 {
161 if (!tools.ContainsKey(project.Language))
162 {
163 throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
164 }
165
166 ToolInfo toolInfo = (ToolInfo)tools[project.Language];
167 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
168 StreamWriter ps = new StreamWriter(projectFile);
169
170 kernel.CurrentWorkingDirectory.Push();
171 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
172
173 #region Project File
174 using (ps)
175 {
176 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" ToolsVersion=\"{0}\">", this.Version == VSVersion.VS10 ? "4.0" : "3.5");
177 ps.WriteLine(" <PropertyGroup>");
178 ps.WriteLine(" <ProjectType>Local</ProjectType>");
179 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion);
180 ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion);
181 ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper());
182
183 // Visual Studio has a hard coded guid for the project type
184 if (project.Type == ProjectType.Web)
185 ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>");
186 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>");
187 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>");
188 ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon);
189 ps.WriteLine(" <AssemblyKeyContainerName>");
190 ps.WriteLine(" </AssemblyKeyContainerName>");
191 ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName);
192 foreach (ConfigurationNode conf in project.Configurations)
193 {
194 if (conf.Options.KeyFile != "")
195 {
196 ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile);
197 ps.WriteLine(" <SignAssembly>true</SignAssembly>");
198 break;
199 }
200 }
201 ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>");
202 ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>");
203 ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>");
204 ps.WriteLine(" <DelaySign>false</DelaySign>");
205 ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", "."));
206
207 ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString());
208 ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder);
209 ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace);
210 ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject);
211 if (string.IsNullOrEmpty(project.DebugStartParameters))
212 {
213 ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters);
214 }
215 ps.WriteLine(" <FileUpgradeFlags>");
216 ps.WriteLine(" </FileUpgradeFlags>");
217
218 ps.WriteLine(" </PropertyGroup>");
219
220 foreach (ConfigurationNode conf in project.Configurations)
221 {
222 ps.Write(" <PropertyGroup ");
223 ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name);
224 ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]);
225 ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]);
226 ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]);
227 ps.WriteLine(" <ConfigurationOverrideFile>");
228 ps.WriteLine(" </ConfigurationOverrideFile>");
229 ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]);
230 ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString()));
231 ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]);
232 ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]);
233 ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]);
234 if (project.Type != ProjectType.Web)
235 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
236 Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString())));
237 else
238 ps.WriteLine(" <OutputPath>{0}</OutputPath>",
239 Helper.EndPath(Helper.NormalizePath("bin\\")));
240
241 ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]);
242 ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]);
243 ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]);
244 ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]);
245 ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]);
246 ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]);
247 ps.WriteLine(" </PropertyGroup>");
248 }
249
250 //ps.WriteLine(" </Settings>");
251
252 List<ProjectNode> projectReferences = new List<ProjectNode>();
253 List<ReferenceNode> otherReferences = new List<ReferenceNode>();
254
255 foreach (ReferenceNode refr in project.References)
256 {
257 ProjectNode projectNode = FindProjectInSolution(refr.Name, solution);
258
259 if (projectNode == null)
260 otherReferences.Add(refr);
261 else
262 projectReferences.Add(projectNode);
263 }
264 // Assembly References
265 ps.WriteLine(" <ItemGroup>");
266
267 foreach (ReferenceNode refr in otherReferences)
268 {
269 ps.Write(" <Reference");
270 ps.Write(" Include=\"");
271 ps.Write(refr.Name);
272 ps.WriteLine("\" >");
273 ps.Write(" <Name>");
274 ps.Write(refr.Name);
275 ps.WriteLine("</Name>");
276 // TODO: Allow reference to *.exe files
277 ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy);
278 ps.WriteLine(" </Reference>");
279 }
280 ps.WriteLine(" </ItemGroup>");
281
282 //Project References
283 ps.WriteLine(" <ItemGroup>");
284 foreach (ProjectNode projectReference in projectReferences)
285 {
286 ToolInfo tool = (ToolInfo)tools[projectReference.Language];
287 if (tools == null)
288 throw new UnknownLanguageException();
289
290 string path =
291 Helper.MakePathRelativeTo(project.FullPath,
292 Helper.MakeFilePath(projectReference.FullPath, projectReference.Name, tool.FileExtension));
293 ps.WriteLine(" <ProjectReference Include=\"{0}\">", path);
294
295 // TODO: Allow reference to visual basic projects
296 ps.WriteLine(" <Name>{0}</Name>", projectReference.Name);
297 ps.WriteLine(" <Project>{0}</Project>", projectReference.Guid.ToString("B").ToUpper());
298 ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper());
299
300 ps.WriteLine(" <Private>False</Private>" );
301
302 ps.WriteLine(" </ProjectReference>");
303 }
304 ps.WriteLine(" </ItemGroup>");
305
306 // ps.WriteLine(" </Build>");
307 ps.WriteLine(" <ItemGroup>");
308
309 // ps.WriteLine(" <Include>");
310 List<string> list = new List<string>();
311
312 foreach (string path in project.Files)
313 {
314 string lower = path.ToLower();
315 if (lower.EndsWith(".resx"))
316 {
317 string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension);
318 if (!list.Contains(codebehind))
319 list.Add(codebehind);
320 }
321 }
322
323 foreach (string file in project.Files)
324 {
325 // if (file == "Properties\\Bind.Designer.cs")
326 // {
327 // Console.WriteLine("Wait a minute!");
328 // Console.WriteLine(project.Files.GetSubType(file).ToString());
329 // }
330
331 SubType subType = project.Files.GetSubType(file);
332
333 if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer
334 && subType != SubType.CodeBehind)
335 {
336 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");
337 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file));
338 ps.WriteLine(" <SubType>Designer</SubType>");
339 ps.WriteLine(" </EmbeddedResource>");
340 //
341 }
342
343 if (subType == SubType.Designer)
344 {
345 ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file);
346 ps.WriteLine(" <SubType>" + subType + "</SubType>");
347 ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>");
348
349 string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs";
350 string dependent_name = file.Substring(0, file.LastIndexOf('.')) + ".cs";
351
352 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", autogen_name);
353
354 // Check for a parent .cs file with the same name as this designer file
355 if (File.Exists(dependent_name))
356 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
357
358 ps.WriteLine(" </EmbeddedResource>");
359 if (File.Exists(autogen_name))
360 {
361 ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name);
362 ps.WriteLine(" <AutoGen>True</AutoGen>");
363 ps.WriteLine(" <DesignTime>True</DesignTime>");
364
365 // If a parent .cs file exists, link this autogen file to it. Otherwise link
366 // to the designer file
367 if (File.Exists(dependent_name))
368 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name));
369 else
370 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file));
371
372 ps.WriteLine(" </Compile>");
373 }
374 list.Add(autogen_name);
375 }
376 if (subType == SubType.Settings)
377 {
378 ps.Write(" <{0} ", project.Files.GetBuildAction(file));
379 ps.WriteLine("Include=\"{0}\">", file);
380 string fileName = Path.GetFileName(file);
381 if (project.Files.GetBuildAction(file) == BuildAction.None)
382 {
383 ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>");
384 ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs");
385 }
386 else
387 {
388 ps.WriteLine(" <SubType>Code</SubType>");
389 ps.WriteLine(" <AutoGen>True</AutoGen>");
390 ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>");
391 string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.'));
392 string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.'));
393 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings"));
394 }
395 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file));
396 }
397 else if (subType != SubType.Designer)
398 {
399 string path = Helper.NormalizePath(file);
400 string path_lower = path.ToLower();
401
402 if (!list.Contains(file))
403 {
404 ps.Write(" <{0} ", project.Files.GetBuildAction(path));
405
406 int startPos = 0;
407 if (project.Files.GetPreservePath(file))
408 {
409 while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1)
410 startPos++;
411
412 }
413 else
414 {
415 startPos = file.LastIndexOf(Path.GetFileName(path));
416 }
417
418 ps.WriteLine("Include=\"{0}\">", path);
419
420 int last_period_index = file.LastIndexOf('.');
421 string short_file_name = file.Substring(0, last_period_index);
422 string extension = Path.GetExtension(path);
423 string designer_format = string.Format(".designer{0}", extension);
424
425 if (path_lower.EndsWith(designer_format))
426 {
427 int designer_index = path_lower.IndexOf(designer_format);
428 string file_name = path.Substring(0, designer_index);
429
430 if (File.Exists(file_name))
431 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name));
432 else if (File.Exists(file_name + ".resx"))
433 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx"));
434 }
435 else if (subType == SubType.CodeBehind)
436 {
437 ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name));
438 }
439 if (project.Files.GetIsLink(file))
440 {
441 string alias = project.Files.GetLinkPath(file);
442 alias += file.Substring(startPos);
443 alias = Helper.NormalizePath(alias);
444 ps.WriteLine(" <Link>{0}</Link>", alias);
445 }
446 else if (project.Files.GetBuildAction(file) != BuildAction.None)
447 {
448 if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource)
449 {
450 ps.WriteLine(" <SubType>{0}</SubType>", subType);
451 }
452 }
453
454 if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never)
455 {
456 ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file));
457 }
458
459 ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file));
460 }
461 }
462 }
463
464 ps.WriteLine(" </ItemGroup>");
465 ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />");
466 ps.WriteLine(" <PropertyGroup>");
467 ps.WriteLine(" <PreBuildEvent>");
468 ps.WriteLine(" </PreBuildEvent>");
469 ps.WriteLine(" <PostBuildEvent>");
470 ps.WriteLine(" </PostBuildEvent>");
471 ps.WriteLine(" </PropertyGroup>");
472 ps.WriteLine("</Project>");
473 }
474 #endregion
475
476 #region User File
477
478 ps = new StreamWriter(projectFile + ".user");
479 using (ps)
480 {
481 ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
482 //ps.WriteLine( "<VisualStudioProject>" );
483 //ps.WriteLine(" <{0}>", toolInfo.XMLTag);
484 //ps.WriteLine(" <Build>");
485 ps.WriteLine(" <PropertyGroup>");
486 //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project));
487 ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>");
488 ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>");
489 ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project));
490 ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion);
491 ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>");
492 ps.WriteLine(" <ProjectTrust>0</ProjectTrust>");
493 ps.WriteLine(" </PropertyGroup>");
494 foreach (ConfigurationNode conf in project.Configurations)
495 {
496 ps.Write(" <PropertyGroup");
497 ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name);
498 ps.WriteLine(" />");
499 }
500 ps.WriteLine("</Project>");
501 }
502 #endregion
503
504 kernel.CurrentWorkingDirectory.Pop();
505 }
506
507 private void WriteSolution(SolutionNode solution, bool writeSolutionToDisk)
508 {
509 kernel.Log.Write("Creating {0} solution and project files", this.VersionName);
510
511 foreach (SolutionNode child in solution.Solutions)
512 {
513 kernel.Log.Write("...Creating folder: {0}", child.Name);
514 WriteSolution(child, false);
515 }
516
517 foreach (ProjectNode project in solution.Projects)
518 {
519 kernel.Log.Write("...Creating project: {0}", project.Name);
520 WriteProject(solution, project);
521 }
522
523 foreach (DatabaseProjectNode project in solution.DatabaseProjects)
524 {
525 kernel.Log.Write("...Creating database project: {0}", project.Name);
526 WriteDatabaseProject(solution, project);
527 }
528
529 if (writeSolutionToDisk) // only write main solution
530 {
531 kernel.Log.Write("");
532 string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
533
534 using (StreamWriter ss = new StreamWriter(solutionFile))
535 {
536 kernel.CurrentWorkingDirectory.Push();
537 Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
538
539 ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion);
540 ss.WriteLine(SolutionTag);
541
542 WriteProjectDeclarations(ss, solution, solution);
543
544 ss.WriteLine("Global");
545
546 ss.WriteLine("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution");
547 foreach (ConfigurationNode conf in solution.Configurations)
548 {
549 ss.WriteLine("\t\t{0}|Any CPU = {0}|Any CPU", conf.Name);
550 }
551 ss.WriteLine("\tEndGlobalSection");
552
553 ss.WriteLine("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution");
554 WriteConfigurationLines(solution.Configurations, solution, ss);
555 ss.WriteLine("\tEndGlobalSection");
556
557 if (solution.Solutions.Count > 0)
558 {
559 ss.WriteLine("\tGlobalSection(NestedProjects) = preSolution");
560 foreach (SolutionNode embeddedSolution in solution.Solutions)
561 {
562 WriteNestedProjectMap(ss, embeddedSolution);
563 }
564 ss.WriteLine("\tEndGlobalSection");
565 }
566
567 ss.WriteLine("EndGlobal");
568 }
569
570 kernel.CurrentWorkingDirectory.Pop();
571 }
572 }
573
574 private void WriteProjectDeclarations(StreamWriter writer, SolutionNode actualSolution, SolutionNode embeddedSolution)
575 {
576 foreach (SolutionNode childSolution in embeddedSolution.Solutions)
577 {
578 WriteEmbeddedSolution(writer, childSolution);
579 WriteProjectDeclarations(writer, actualSolution, childSolution);
580 }
581
582 foreach (ProjectNode project in embeddedSolution.Projects)
583 {
584 WriteProject(actualSolution, writer, project);
585 }
586
587 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
588 {
589 WriteProject(actualSolution, writer, dbProject);
590 }
591
592 if (actualSolution.Guid == embeddedSolution.Guid)
593 {
594 WriteSolutionFiles(actualSolution, writer);
595 }
596 }
597
598 private static void WriteNestedProjectMap(StreamWriter writer, SolutionNode embeddedSolution)
599 {
600 foreach (ProjectNode project in embeddedSolution.Projects)
601 {
602 WriteNestedProject(writer, embeddedSolution, project.Guid);
603 }
604
605 foreach (DatabaseProjectNode dbProject in embeddedSolution.DatabaseProjects)
606 {
607 WriteNestedProject(writer, embeddedSolution, dbProject.Guid);
608 }
609
610 foreach (SolutionNode child in embeddedSolution.Solutions)
611 {
612 WriteNestedProject(writer, embeddedSolution, child.Guid);
613 WriteNestedProjectMap(writer, child);
614 }
615 }
616
617 private static void WriteNestedProject(StreamWriter writer, SolutionNode solution, Guid projectGuid)
618 {
619 WriteNestedFolder(writer, solution.Guid, projectGuid);
620 }
621
622 private static void WriteNestedFolder(StreamWriter writer, Guid parentGuid, Guid childGuid)
623 {
624 writer.WriteLine("\t\t{0} = {1}",
625 childGuid.ToString("B").ToUpper(),
626 parentGuid.ToString("B").ToUpper());
627 }
628
629 private static void WriteConfigurationLines(ICollection configurations, SolutionNode solution, StreamWriter ss)
630 {
631 foreach (ProjectNode project in solution.Projects)
632 {
633 foreach (ConfigurationNode conf in configurations)
634 {
635 ss.WriteLine("\t\t{0}.{1}|Any CPU.ActiveCfg = {1}|Any CPU",
636 project.Guid.ToString("B").ToUpper(),
637 conf.Name);
638
639 ss.WriteLine("\t\t{0}.{1}|Any CPU.Build.0 = {1}|Any CPU",
640 project.Guid.ToString("B").ToUpper(),
641 conf.Name);
642 }
643 }
644
645 foreach (SolutionNode child in solution.Solutions)
646 {
647 WriteConfigurationLines(configurations, child, ss);
648 }
649 }
650
651 private void WriteSolutionFiles(SolutionNode solution, StreamWriter ss)
652 {
653 if (solution.Files != null && solution.Files.Count > 0)
654 {
655 WriteProject(ss, "Folder", solution.Guid, "Solution Files", "Solution Files", solution.Files);
656 }
657 }
658
659 private void WriteEmbeddedSolution(StreamWriter writer, SolutionNode embeddedSolution)
660 {
661 WriteProject(writer, "Folder", embeddedSolution.Guid, embeddedSolution.Name, embeddedSolution.Name, embeddedSolution.Files);
662 }
663
664 private void WriteProject(SolutionNode solution, StreamWriter ss, ProjectNode project)
665 {
666 WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath);
667 }
668
669 private void WriteProject(SolutionNode solution, StreamWriter ss, DatabaseProjectNode dbProject)
670 {
671 if (solution.Files != null && solution.Files.Count > 0)
672 WriteProject(ss, solution, "Database", dbProject.Guid, dbProject.Name, dbProject.FullPath);
673 }
674
675 private static bool ExtensionSpecified(string refName)
676 {
677 return refName.EndsWith(".dll") || refName.EndsWith(".exe");
678 }
679
680 private static string GetProjectExtension(ProjectNode project)
681 {
682 string extension = ".dll";
683 if (project.Type == ProjectType.Exe)
684 {
685 extension = ".exe";
686 }
687 return extension;
688 }
689
690 const string ProjectDeclarationBeginFormat = "Project(\"{0}\") = \"{1}\", \"{2}\", \"{3}\"";
691 const string ProjectDeclarationEndFormat = "EndProject";
692
693 private void WriteProject(StreamWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath)
694 {
695 if (!tools.ContainsKey(language))
696 throw new UnknownLanguageException("Unknown .NET language: " + language);
697
698 ToolInfo toolInfo = (ToolInfo)tools[language];
699
700 string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath);
701
702 path = Helper.MakeFilePath(path, name, toolInfo.FileExtension);
703
704 WriteProject(ss, language, guid, name, path);
705 }
706
707 private void WriteProject(StreamWriter writer, string language, Guid projectGuid, string name, string location)
708 {
709 WriteProject(writer, language, projectGuid, name, location, null);
710 }
711
712 private void WriteProject(StreamWriter writer, string language, Guid projectGuid, string name, string location, FilesNode files)
713 {
714 if (!tools.ContainsKey(language))
715 throw new UnknownLanguageException("Unknown .NET language: " + language);
716
717 ToolInfo toolInfo = (ToolInfo)tools[language];
718
719 writer.WriteLine(ProjectDeclarationBeginFormat,
720 toolInfo.Guid,
721 name,
722 location,
723 projectGuid.ToString("B").ToUpper());
724
725 if (files != null)
726 {
727 writer.WriteLine("\tProjectSection(SolutionItems) = preProject");
728
729 foreach (string file in files)
730 writer.WriteLine("\t\t{0} = {0}", file);
731
732 writer.WriteLine("\tEndProjectSection");
733 }
734
735 writer.WriteLine(ProjectDeclarationEndFormat);
736 }
737
738 private void WriteDatabaseProject(SolutionNode solution, DatabaseProjectNode project)
739 {
740 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "dbp");
741 IndentedTextWriter ps = new IndentedTextWriter(new StreamWriter(projectFile), " ");
742
743 kernel.CurrentWorkingDirectory.Push();
744
745 Helper.SetCurrentDir(Path.GetDirectoryName(projectFile));
746
747 using (ps)
748 {
749 ps.WriteLine("# Microsoft Developer Studio Project File - Database Project");
750 ps.WriteLine("Begin DataProject = \"{0}\"", project.Name);
751 ps.Indent++;
752 ps.WriteLine("MSDTVersion = \"80\"");
753 // TODO: Use the project.Files property
754 if (ContainsSqlFiles(Path.GetDirectoryName(projectFile)))
755 WriteDatabaseFoldersAndFiles(ps, Path.GetDirectoryName(projectFile));
756
757 ps.WriteLine("Begin DBRefFolder = \"Database References\"");
758 ps.Indent++;
759 foreach (DatabaseReferenceNode reference in project.References)
760 {
761 ps.WriteLine("Begin DBRefNode = \"{0}\"", reference.Name);
762 ps.Indent++;
763 ps.WriteLine("ConnectStr = \"{0}\"", reference.ConnectionString);
764 ps.WriteLine("Provider = \"{0}\"", reference.ProviderId.ToString("B").ToUpper());
765 //ps.WriteLine("Colorizer = 5");
766 ps.Indent--;
767 ps.WriteLine("End");
768 }
769 ps.Indent--;
770 ps.WriteLine("End");
771 ps.Indent--;
772 ps.WriteLine("End");
773
774 ps.Flush();
775 }
776
777 kernel.CurrentWorkingDirectory.Pop();
778 }
779
780 private bool ContainsSqlFiles(string folder)
781 {
782 foreach (string file in Directory.GetFiles(folder, "*.sql"))
783 {
784 return true; // if the folder contains 1 .sql file, that's good enough
785 }
786
787 foreach (string child in Directory.GetDirectories(folder))
788 {
789 if (ContainsSqlFiles(child))
790 return true; // if 1 child folder contains a .sql file, still good enough
791 }
792
793 return false;
794 }
795
796 private void WriteDatabaseFoldersAndFiles(IndentedTextWriter writer, string folder)
797 {
798 foreach (string child in Directory.GetDirectories(folder))
799 {
800 if (ContainsSqlFiles(child))
801 {
802 writer.WriteLine("Begin Folder = \"{0}\"", Path.GetFileName(child));
803 writer.Indent++;
804 WriteDatabaseFoldersAndFiles(writer, child);
805 writer.Indent--;
806 writer.WriteLine("End");
807 }
808 }
809 foreach (string file in Directory.GetFiles(folder, "*.sql"))
810 {
811 writer.WriteLine("Script = \"{0}\"", Path.GetFileName(file));
812 }
813 }
814
815 private void CleanProject(ProjectNode project)
816 {
817 kernel.Log.Write("...Cleaning project: {0}", project.Name);
818
819 ToolInfo toolInfo = (ToolInfo)tools[project.Language];
820 string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension);
821 string userFile = projectFile + ".user";
822
823 Helper.DeleteIfExists(projectFile);
824 Helper.DeleteIfExists(userFile);
825 }
826
827 private void CleanSolution(SolutionNode solution)
828 {
829 kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name);
830
831 string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
832 string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
833
834 Helper.DeleteIfExists(slnFile);
835 Helper.DeleteIfExists(suoFile);
836
837 foreach (ProjectNode project in solution.Projects)
838 {
839 CleanProject(project);
840 }
841
842 kernel.Log.Write("");
843 }
844
845 #endregion
846
847 #region ITarget Members
848
849 /// <summary>
850 /// Writes the specified kern.
851 /// </summary>
852 /// <param name="kern">The kern.</param>
853 public virtual void Write(Kernel kern)
854 {
855 if (kern == null)
856 {
857 throw new ArgumentNullException("kern");
858 }
859 kernel = kern;
860 foreach (SolutionNode sol in kernel.Solutions)
861 {
862 WriteSolution(sol, true);
863 }
864 kernel = null;
865 }
866
867 /// <summary>
868 /// Cleans the specified kern.
869 /// </summary>
870 /// <param name="kern">The kern.</param>
871 public virtual void Clean(Kernel kern)
872 {
873 if (kern == null)
874 {
875 throw new ArgumentNullException("kern");
876 }
877 kernel = kern;
878 foreach (SolutionNode sol in kernel.Solutions)
879 {
880 CleanSolution(sol);
881 }
882 kernel = null;
883 }
884
885 #endregion
886 }
887}
diff --git a/Prebuild/src/Core/Targets/VSVersion.cs b/Prebuild/src/Core/Targets/VSVersion.cs
deleted file mode 100644
index 59549b0..0000000
--- a/Prebuild/src/Core/Targets/VSVersion.cs
+++ /dev/null
@@ -1,54 +0,0 @@
1#region BSD License
2/*
3Copyright (c) 2008-2009 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com), John Anderson (sontek@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
26namespace Prebuild.Core.Targets
27{
28 /// <summary>
29 ///
30 /// </summary>
31 public enum VSVersion
32 {
33 /// <summary>
34 /// Visual Studio 2002
35 /// </summary>
36 VS70,
37 /// <summary>
38 /// Visual Studio 2003
39 /// </summary>
40 VS71,
41 /// <summary>
42 /// Visual Studio 2005
43 /// </summary>
44 VS80,
45 /// <summary>
46 /// Visual Studio 2008
47 /// </summary>
48 VS90,
49 /// <summary>
50 /// Visual Studio 2010
51 /// </summary>
52 VS10
53 }
54}
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/*
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.Collections;
28using System.Collections.Specialized;
29using System.IO;
30using System.Reflection;
31using System.Text.RegularExpressions;
32
33using Prebuild.Core.Attributes;
34using Prebuild.Core.Interfaces;
35using Prebuild.Core.Nodes;
36using Prebuild.Core.Utilities;
37
38namespace 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}