diff options
author | Justin Clark-Casey (justincc) | 2010-09-10 22:38:56 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-09-10 22:38:56 +0100 |
commit | 29708e47a56e6935f8965ef43556570bb82b64a9 (patch) | |
tree | 8ba76776609118904f8fd8350cd2f2712eda132c /Prebuild/src/Core | |
parent | Remove parenthesis around the release flavour to get the version string back ... (diff) | |
parent | Build system upgrade: (diff) | |
download | opensim-SC_OLD-29708e47a56e6935f8965ef43556570bb82b64a9.zip opensim-SC_OLD-29708e47a56e6935f8965ef43556570bb82b64a9.tar.gz opensim-SC_OLD-29708e47a56e6935f8965ef43556570bb82b64a9.tar.bz2 opensim-SC_OLD-29708e47a56e6935f8965ef43556570bb82b64a9.tar.xz |
Merge branch 'prebuild-update'
Diffstat (limited to 'Prebuild/src/Core')
47 files changed, 0 insertions, 13756 deletions
diff --git a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs b/Prebuild/src/Core/Attributes/DataNodeAttribute.cs deleted file mode 100644 index f1938a2..0000000 --- a/Prebuild/src/Core/Attributes/DataNodeAttribute.cs +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections.Specialized; | ||
28 | |||
29 | namespace Prebuild.Core.Attributes | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// | ||
33 | /// </summary> | ||
34 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple=true)] | ||
35 | public sealed class DataNodeAttribute : Attribute | ||
36 | { | ||
37 | #region Fields | ||
38 | |||
39 | private string m_Name = "unknown"; | ||
40 | |||
41 | #endregion | ||
42 | |||
43 | #region Constructors | ||
44 | |||
45 | /// <summary> | ||
46 | /// Initializes a new instance of the <see cref="DataNodeAttribute"/> class. | ||
47 | /// </summary> | ||
48 | /// <param name="name">The name.</param> | ||
49 | public DataNodeAttribute(string name) | ||
50 | { | ||
51 | m_Name = name; | ||
52 | } | ||
53 | |||
54 | #endregion | ||
55 | |||
56 | #region Properties | ||
57 | |||
58 | /// <summary> | ||
59 | /// Gets the name. | ||
60 | /// </summary> | ||
61 | /// <value>The name.</value> | ||
62 | public string Name | ||
63 | { | ||
64 | get | ||
65 | { | ||
66 | return m_Name; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | #endregion | ||
71 | } | ||
72 | } | ||
diff --git a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs b/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs deleted file mode 100644 index 2d6a6a7..0000000 --- a/Prebuild/src/Core/Attributes/OptionNodeAttribute.cs +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | |||
28 | namespace Prebuild.Core.Attributes | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// | ||
32 | /// </summary> | ||
33 | [AttributeUsage(AttributeTargets.Field)] | ||
34 | public sealed class OptionNodeAttribute : Attribute | ||
35 | { | ||
36 | #region Fields | ||
37 | |||
38 | private string m_NodeName; | ||
39 | |||
40 | #endregion | ||
41 | |||
42 | #region Constructors | ||
43 | |||
44 | /// <summary> | ||
45 | /// Initializes a new instance of the <see cref="OptionNodeAttribute"/> class. | ||
46 | /// </summary> | ||
47 | /// <param name="nodeName">Name of the node.</param> | ||
48 | public OptionNodeAttribute(string nodeName) | ||
49 | { | ||
50 | m_NodeName = nodeName; | ||
51 | } | ||
52 | |||
53 | #endregion | ||
54 | |||
55 | #region Properties | ||
56 | |||
57 | /// <summary> | ||
58 | /// Gets the name of the node. | ||
59 | /// </summary> | ||
60 | /// <value>The name of the node.</value> | ||
61 | public string NodeName | ||
62 | { | ||
63 | get | ||
64 | { | ||
65 | return m_NodeName; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | #endregion | ||
70 | } | ||
71 | } | ||
diff --git a/Prebuild/src/Core/Attributes/TargetAttribute.cs b/Prebuild/src/Core/Attributes/TargetAttribute.cs deleted file mode 100644 index 5ad62ee..0000000 --- a/Prebuild/src/Core/Attributes/TargetAttribute.cs +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | |||
28 | namespace Prebuild.Core.Attributes | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// | ||
32 | /// </summary> | ||
33 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] | ||
34 | public sealed class TargetAttribute : Attribute | ||
35 | { | ||
36 | #region Fields | ||
37 | |||
38 | private string m_Name; | ||
39 | |||
40 | #endregion | ||
41 | |||
42 | #region Constructors | ||
43 | |||
44 | /// <summary> | ||
45 | /// Initializes a new instance of the <see cref="TargetAttribute"/> class. | ||
46 | /// </summary> | ||
47 | /// <param name="name">The name.</param> | ||
48 | public TargetAttribute(string name) | ||
49 | { | ||
50 | m_Name = name; | ||
51 | } | ||
52 | |||
53 | #endregion | ||
54 | |||
55 | #region Properties | ||
56 | |||
57 | /// <summary> | ||
58 | /// Gets the name. | ||
59 | /// </summary> | ||
60 | /// <value>The name.</value> | ||
61 | public string Name | ||
62 | { | ||
63 | get | ||
64 | { | ||
65 | return m_Name; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | #endregion | ||
70 | } | ||
71 | } | ||
diff --git a/Prebuild/src/Core/FatalException.cs b/Prebuild/src/Core/FatalException.cs deleted file mode 100644 index 3487905..0000000 --- a/Prebuild/src/Core/FatalException.cs +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Runtime.Serialization; | ||
28 | |||
29 | namespace Prebuild.Core | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// | ||
33 | /// </summary> | ||
34 | [Serializable()] | ||
35 | public class FatalException : Exception | ||
36 | { | ||
37 | #region Constructors | ||
38 | |||
39 | |||
40 | /// <summary> | ||
41 | /// Initializes a new instance of the <see cref="FatalException"/> class. | ||
42 | /// </summary> | ||
43 | public FatalException() | ||
44 | { | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// Initializes a new instance of the <see cref="FatalException"/> class. | ||
49 | /// </summary> | ||
50 | /// <param name="format">The format.</param> | ||
51 | /// <param name="args">The args.</param> | ||
52 | public FatalException(string format, params object[] args) | ||
53 | : base(String.Format(format, args)) | ||
54 | { | ||
55 | } | ||
56 | |||
57 | /// <summary> | ||
58 | /// Exception with specified string | ||
59 | /// </summary> | ||
60 | /// <param name="message">Exception message</param> | ||
61 | public FatalException(string message): base(message) | ||
62 | { | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// | ||
67 | /// </summary> | ||
68 | /// <param name="message"></param> | ||
69 | /// <param name="exception"></param> | ||
70 | public FatalException(string message, Exception exception) : base(message, exception) | ||
71 | { | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// | ||
76 | /// </summary> | ||
77 | /// <param name="info"></param> | ||
78 | /// <param name="context"></param> | ||
79 | protected FatalException(SerializationInfo info, StreamingContext context) : base( info, context ) | ||
80 | { | ||
81 | } | ||
82 | |||
83 | #endregion | ||
84 | } | ||
85 | } | ||
diff --git a/Prebuild/src/Core/Interfaces/IDataNode.cs b/Prebuild/src/Core/Interfaces/IDataNode.cs deleted file mode 100644 index 986dd2d..0000000 --- a/Prebuild/src/Core/Interfaces/IDataNode.cs +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Xml; | ||
28 | |||
29 | namespace Prebuild.Core.Interfaces | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// | ||
33 | /// </summary> | ||
34 | public interface IDataNode | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Gets or sets the parent. | ||
38 | /// </summary> | ||
39 | /// <value>The parent.</value> | ||
40 | IDataNode Parent { get; set; } | ||
41 | /// <summary> | ||
42 | /// Parses the specified node. | ||
43 | /// </summary> | ||
44 | /// <param name="node">The node.</param> | ||
45 | void Parse(XmlNode node); | ||
46 | } | ||
47 | } | ||
diff --git a/Prebuild/src/Core/Interfaces/ITarget.cs b/Prebuild/src/Core/Interfaces/ITarget.cs deleted file mode 100644 index 47115c6..0000000 --- a/Prebuild/src/Core/Interfaces/ITarget.cs +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | |||
28 | namespace Prebuild.Core.Interfaces | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// | ||
32 | /// </summary> | ||
33 | public interface ITarget | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Writes the specified kern. | ||
37 | /// </summary> | ||
38 | /// <param name="kern">The kern.</param> | ||
39 | void Write(Kernel kern); | ||
40 | /// <summary> | ||
41 | /// Cleans the specified kern. | ||
42 | /// </summary> | ||
43 | /// <param name="kern">The kern.</param> | ||
44 | void Clean(Kernel kern); | ||
45 | /// <summary> | ||
46 | /// Gets the name. | ||
47 | /// </summary> | ||
48 | /// <value>The name.</value> | ||
49 | string Name { get; } | ||
50 | } | ||
51 | } \ No newline at end of file | ||
diff --git a/Prebuild/src/Core/Kernel.cs b/Prebuild/src/Core/Kernel.cs deleted file mode 100644 index 95ef04e..0000000 --- a/Prebuild/src/Core/Kernel.cs +++ /dev/null | |||
@@ -1,831 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2008 | ||
4 | Matthew Holmes (matthew@wildfiregames.com), | ||
5 | Dan Moorehead (dan05a@gmail.com), | ||
6 | Rob Loach (http://www.robloach.net), | ||
7 | C.J. Adams-Collier (cjac@colliertech.org) | ||
8 | |||
9 | Redistribution and use in source and binary forms, with or without | ||
10 | modification, are permitted provided that the following conditions are | ||
11 | met: | ||
12 | |||
13 | * Redistributions of source code must retain the above copyright | ||
14 | notice, this list of conditions and the following disclaimer. | ||
15 | |||
16 | * Redistributions in binary form must reproduce the above copyright | ||
17 | notice, this list of conditions and the following disclaimer in the | ||
18 | documentation and/or other materials provided with the distribution. | ||
19 | |||
20 | * The name of the author may not be used to endorse or promote | ||
21 | products derived from this software without specific prior written | ||
22 | permission. | ||
23 | |||
24 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
25 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
27 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
28 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
31 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
32 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
33 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | POSSIBILITY OF SUCH DAMAGE. | ||
35 | |||
36 | */ | ||
37 | #endregion | ||
38 | |||
39 | using System; | ||
40 | using System.Collections.Generic; | ||
41 | using System.Diagnostics; | ||
42 | using System.Collections; | ||
43 | using System.Collections.Specialized; | ||
44 | using System.IO; | ||
45 | using System.Reflection; | ||
46 | using System.Xml; | ||
47 | using System.Xml.Schema; | ||
48 | using System.Text; | ||
49 | |||
50 | using Prebuild.Core.Attributes; | ||
51 | using Prebuild.Core.Interfaces; | ||
52 | using Prebuild.Core.Nodes; | ||
53 | using Prebuild.Core.Parse; | ||
54 | using Prebuild.Core.Utilities; | ||
55 | |||
56 | namespace Prebuild.Core | ||
57 | { | ||
58 | /// <summary> | ||
59 | /// | ||
60 | /// </summary> | ||
61 | public class Kernel : IDisposable | ||
62 | { | ||
63 | #region Inner Classes | ||
64 | |||
65 | private struct NodeEntry | ||
66 | { | ||
67 | public Type Type; | ||
68 | public DataNodeAttribute Attribute; | ||
69 | } | ||
70 | |||
71 | #endregion | ||
72 | |||
73 | #region Fields | ||
74 | |||
75 | private static readonly Kernel m_Instance = new Kernel(); | ||
76 | |||
77 | /// <summary> | ||
78 | /// This must match the version of the schema that is embeeded | ||
79 | /// </summary> | ||
80 | private const string m_SchemaVersion = "1.7"; | ||
81 | private const string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; | ||
82 | private const string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; | ||
83 | bool disposed; | ||
84 | private Version m_Version; | ||
85 | private const string m_Revision = ""; | ||
86 | private CommandLineCollection m_CommandLine; | ||
87 | private Log m_Log; | ||
88 | private CurrentDirectory m_CurrentWorkingDirectory; | ||
89 | private XmlSchemaCollection m_Schemas; | ||
90 | |||
91 | private Hashtable m_Targets; | ||
92 | private Hashtable m_Nodes; | ||
93 | |||
94 | readonly List<SolutionNode> m_Solutions = new List<SolutionNode>(); | ||
95 | string m_Target; | ||
96 | string m_Clean; | ||
97 | string[] m_RemoveDirectories; | ||
98 | XmlDocument m_CurrentDoc; | ||
99 | bool m_PauseAfterFinish; | ||
100 | string[] m_ProjectGroups; | ||
101 | |||
102 | #endregion | ||
103 | |||
104 | #region Constructors | ||
105 | |||
106 | private Kernel() | ||
107 | { | ||
108 | } | ||
109 | |||
110 | #endregion | ||
111 | |||
112 | #region Properties | ||
113 | |||
114 | /// <summary> | ||
115 | /// Gets a value indicating whether [pause after finish]. | ||
116 | /// </summary> | ||
117 | /// <value><c>true</c> if [pause after finish]; otherwise, <c>false</c>.</value> | ||
118 | public bool PauseAfterFinish | ||
119 | { | ||
120 | get | ||
121 | { | ||
122 | return m_PauseAfterFinish; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | /// <summary> | ||
127 | /// Gets the instance. | ||
128 | /// </summary> | ||
129 | /// <value>The instance.</value> | ||
130 | public static Kernel Instance | ||
131 | { | ||
132 | get | ||
133 | { | ||
134 | return m_Instance; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | /// <summary> | ||
139 | /// Gets the version. | ||
140 | /// </summary> | ||
141 | /// <value>The version.</value> | ||
142 | public string Version | ||
143 | { | ||
144 | get | ||
145 | { | ||
146 | return String.Format("{0}.{1}.{2}{3}", m_Version.Major, m_Version.Minor, m_Version.Build, m_Revision); | ||
147 | } | ||
148 | } | ||
149 | |||
150 | /// <summary> | ||
151 | /// Gets the command line. | ||
152 | /// </summary> | ||
153 | /// <value>The command line.</value> | ||
154 | public CommandLineCollection CommandLine | ||
155 | { | ||
156 | get | ||
157 | { | ||
158 | return m_CommandLine; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | /// <summary> | ||
163 | /// Gets the targets. | ||
164 | /// </summary> | ||
165 | /// <value>The targets.</value> | ||
166 | public Hashtable Targets | ||
167 | { | ||
168 | get | ||
169 | { | ||
170 | return m_Targets; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | /// <summary> | ||
175 | /// Gets the log. | ||
176 | /// </summary> | ||
177 | /// <value>The log.</value> | ||
178 | public Log Log | ||
179 | { | ||
180 | get | ||
181 | { | ||
182 | return m_Log; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | /// <summary> | ||
187 | /// Gets the current working directory. | ||
188 | /// </summary> | ||
189 | /// <value>The current working directory.</value> | ||
190 | public CurrentDirectory CurrentWorkingDirectory | ||
191 | { | ||
192 | get | ||
193 | { | ||
194 | return m_CurrentWorkingDirectory; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | /// <summary> | ||
199 | /// Gets the solutions. | ||
200 | /// </summary> | ||
201 | /// <value>The solutions.</value> | ||
202 | public List<SolutionNode> Solutions | ||
203 | { | ||
204 | get | ||
205 | { | ||
206 | return m_Solutions; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Gets the XmlDocument object representing the prebuild.xml | ||
212 | /// being processed | ||
213 | /// </summary> | ||
214 | /// <value>The XmlDocument object</value> | ||
215 | public XmlDocument CurrentDoc | ||
216 | { | ||
217 | get | ||
218 | { | ||
219 | return m_CurrentDoc; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | #endregion | ||
224 | |||
225 | #region Private Methods | ||
226 | |||
227 | private static void RemoveDirectories(string rootDir, string[] dirNames) | ||
228 | { | ||
229 | foreach(string dir in Directory.GetDirectories(rootDir)) | ||
230 | { | ||
231 | string simpleName = Path.GetFileName(dir); | ||
232 | |||
233 | if(Array.IndexOf(dirNames, simpleName) != -1) | ||
234 | { | ||
235 | //delete if the name matches one of the directory names to delete | ||
236 | string fullDirPath = Path.GetFullPath(dir); | ||
237 | Directory.Delete(fullDirPath,true); | ||
238 | } | ||
239 | else//not a match, so check children | ||
240 | { | ||
241 | RemoveDirectories(dir,dirNames); | ||
242 | //recurse, checking children for them | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | |||
247 | // private void RemoveDirectoryMatches(string rootDir, string dirPattern) | ||
248 | // { | ||
249 | // foreach(string dir in Directory.GetDirectories(rootDir)) | ||
250 | // { | ||
251 | // foreach(string match in Directory.GetDirectories(dir)) | ||
252 | // {//delete all child directories that match | ||
253 | // Directory.Delete(Path.GetFullPath(match),true); | ||
254 | // } | ||
255 | // //recure through the rest checking for nested matches to delete | ||
256 | // RemoveDirectoryMatches(dir,dirPattern); | ||
257 | // } | ||
258 | // } | ||
259 | |||
260 | private void LoadSchema() | ||
261 | { | ||
262 | Assembly assembly = this.GetType().Assembly; | ||
263 | Stream stream = assembly.GetManifestResourceStream("Prebuild.data." + m_Schema); | ||
264 | if(stream == null) | ||
265 | { | ||
266 | //try without the default namespace prepending to it in case was compiled with SharpDevelop or MonoDevelop instead of Visual Studio .NET | ||
267 | stream = assembly.GetManifestResourceStream(m_Schema); | ||
268 | if(stream == null) | ||
269 | { | ||
270 | throw new System.Reflection.TargetException(string.Format("Could not find the scheme embedded resource file '{0}'.", m_Schema)); | ||
271 | } | ||
272 | } | ||
273 | XmlReader schema = new XmlTextReader(stream); | ||
274 | |||
275 | m_Schemas = new XmlSchemaCollection(); | ||
276 | m_Schemas.Add(m_SchemaURI, schema); | ||
277 | } | ||
278 | |||
279 | private void CacheVersion() | ||
280 | { | ||
281 | m_Version = Assembly.GetEntryAssembly().GetName().Version; | ||
282 | } | ||
283 | |||
284 | private void CacheTargets(Assembly assm) | ||
285 | { | ||
286 | foreach(Type t in assm.GetTypes()) | ||
287 | { | ||
288 | TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget)); | ||
289 | |||
290 | if(ta == null) | ||
291 | continue; | ||
292 | |||
293 | if (t.IsAbstract) | ||
294 | continue; | ||
295 | |||
296 | ITarget target = (ITarget)assm.CreateInstance(t.FullName); | ||
297 | if (target == null) | ||
298 | { | ||
299 | throw new MissingMethodException("Could not create ITarget instance"); | ||
300 | } | ||
301 | |||
302 | m_Targets[ta.Name] = target; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | private void CacheNodeTypes(Assembly assm) | ||
307 | { | ||
308 | foreach(Type t in assm.GetTypes()) | ||
309 | { | ||
310 | foreach (DataNodeAttribute dna in t.GetCustomAttributes(typeof(DataNodeAttribute), true)) | ||
311 | { | ||
312 | NodeEntry ne = new NodeEntry(); | ||
313 | ne.Type = t; | ||
314 | ne.Attribute = dna; | ||
315 | m_Nodes[dna.Name] = ne; | ||
316 | } | ||
317 | } | ||
318 | } | ||
319 | |||
320 | private void LogBanner() | ||
321 | { | ||
322 | m_Log.Write("Prebuild v" + this.Version); | ||
323 | m_Log.Write("Copyright (c) 2004-2008"); | ||
324 | m_Log.Write("Matthew Holmes (matthew@wildfiregames.com),"); | ||
325 | m_Log.Write("Dan Moorehead (dan05a@gmail.com),"); | ||
326 | m_Log.Write("David Hudson (jendave@yahoo.com),"); | ||
327 | m_Log.Write("Rob Loach (http://www.robloach.net),"); | ||
328 | m_Log.Write("C.J. Adams-Collier (cjac@colliertech.org),"); | ||
329 | |||
330 | m_Log.Write("See 'prebuild /usage' for help"); | ||
331 | m_Log.Write(); | ||
332 | } | ||
333 | |||
334 | |||
335 | |||
336 | private void ProcessFile(string file) | ||
337 | { | ||
338 | ProcessFile(file, this.m_Solutions); | ||
339 | } | ||
340 | |||
341 | public void ProcessFile(ProcessNode node, SolutionNode parent) | ||
342 | { | ||
343 | if (node.IsValid) | ||
344 | { | ||
345 | List<SolutionNode> list = new List<SolutionNode>(); | ||
346 | ProcessFile(node.Path, list); | ||
347 | |||
348 | foreach (SolutionNode solution in list) | ||
349 | parent.SolutionsTable[solution.Name] = solution; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | /// <summary> | ||
354 | /// | ||
355 | /// </summary> | ||
356 | /// <param name="file"></param> | ||
357 | /// <param name="solutions"></param> | ||
358 | /// <returns></returns> | ||
359 | public void ProcessFile(string file, IList<SolutionNode> solutions) | ||
360 | { | ||
361 | m_CurrentWorkingDirectory.Push(); | ||
362 | |||
363 | string path = file; | ||
364 | try | ||
365 | { | ||
366 | try | ||
367 | { | ||
368 | path = Helper.ResolvePath(path); | ||
369 | } | ||
370 | catch(ArgumentException) | ||
371 | { | ||
372 | m_Log.Write("Could not open Prebuild file: " + path); | ||
373 | m_CurrentWorkingDirectory.Pop(); | ||
374 | return; | ||
375 | } | ||
376 | |||
377 | Helper.SetCurrentDir(Path.GetDirectoryName(path)); | ||
378 | |||
379 | XmlTextReader reader = new XmlTextReader(path); | ||
380 | |||
381 | Core.Parse.Preprocessor pre = new Core.Parse.Preprocessor(); | ||
382 | |||
383 | //register command line arguments as XML variables | ||
384 | IDictionaryEnumerator dict = m_CommandLine.GetEnumerator(); | ||
385 | while (dict.MoveNext()) | ||
386 | { | ||
387 | string name = dict.Key.ToString().Trim(); | ||
388 | if (name.Length > 0) | ||
389 | pre.RegisterVariable(name, dict.Value.ToString()); | ||
390 | } | ||
391 | |||
392 | string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML | ||
393 | |||
394 | // See if the user put into a pseudo target of "prebuild:preprocessed-input" to indicate they want to see the | ||
395 | // output before the system processes it. | ||
396 | if (m_CommandLine.WasPassed("ppi")) | ||
397 | { | ||
398 | // Get the filename if there is one, otherwise use a default. | ||
399 | string ppiFile = m_CommandLine["ppi"]; | ||
400 | if (ppiFile == null || ppiFile.Trim().Length == 0) | ||
401 | { | ||
402 | ppiFile = "preprocessed-input.xml"; | ||
403 | } | ||
404 | |||
405 | // Write out the string to the given stream. | ||
406 | try | ||
407 | { | ||
408 | using (StreamWriter ppiWriter = new StreamWriter(ppiFile)) | ||
409 | { | ||
410 | ppiWriter.WriteLine(xml); | ||
411 | } | ||
412 | } | ||
413 | catch(IOException ex) | ||
414 | { | ||
415 | Console.WriteLine("Could not write PPI file '{0}': {1}", ppiFile, ex.Message); | ||
416 | } | ||
417 | |||
418 | // Finish processing this special tag. | ||
419 | return; | ||
420 | } | ||
421 | |||
422 | m_CurrentDoc = new XmlDocument(); | ||
423 | try | ||
424 | { | ||
425 | XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); | ||
426 | |||
427 | //validate while reading from string into XmlDocument DOM structure in memory | ||
428 | foreach(XmlSchema schema in m_Schemas) | ||
429 | { | ||
430 | validator.Schemas.Add(schema); | ||
431 | } | ||
432 | m_CurrentDoc.Load(validator); | ||
433 | } | ||
434 | catch(XmlException e) | ||
435 | { | ||
436 | throw new XmlException(e.ToString()); | ||
437 | } | ||
438 | |||
439 | //is there a purpose to writing it? An syntax/schema problem would have been found during pre.Process() and reported with details | ||
440 | if(m_CommandLine.WasPassed("ppo")) | ||
441 | { | ||
442 | string ppoFile = m_CommandLine["ppo"]; | ||
443 | if(ppoFile == null || ppoFile.Trim().Length < 1) | ||
444 | { | ||
445 | ppoFile = "preprocessed.xml"; | ||
446 | } | ||
447 | |||
448 | StreamWriter writer = null; | ||
449 | try | ||
450 | { | ||
451 | writer = new StreamWriter(ppoFile); | ||
452 | writer.Write(xml); | ||
453 | } | ||
454 | catch(IOException ex) | ||
455 | { | ||
456 | Console.WriteLine("Could not write PPO file '{0}': {1}", ppoFile, ex.Message); | ||
457 | } | ||
458 | finally | ||
459 | { | ||
460 | if(writer != null) | ||
461 | { | ||
462 | writer.Close(); | ||
463 | } | ||
464 | } | ||
465 | return; | ||
466 | } | ||
467 | //start reading the xml config file | ||
468 | XmlElement rootNode = m_CurrentDoc.DocumentElement; | ||
469 | //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); | ||
470 | Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); | ||
471 | |||
472 | foreach(XmlNode node in rootNode.ChildNodes)//solutions or if pre-proc instructions | ||
473 | { | ||
474 | IDataNode dataNode = ParseNode(node, null); | ||
475 | if(dataNode is ProcessNode) | ||
476 | { | ||
477 | ProcessNode proc = (ProcessNode)dataNode; | ||
478 | if(proc.IsValid) | ||
479 | { | ||
480 | ProcessFile(proc.Path); | ||
481 | } | ||
482 | } | ||
483 | else if(dataNode is SolutionNode) | ||
484 | { | ||
485 | solutions.Add((SolutionNode)dataNode); | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | catch(XmlSchemaException xse) | ||
490 | { | ||
491 | m_Log.Write("XML validation error at line {0} in {1}:\n\n{2}", | ||
492 | xse.LineNumber, path, xse.Message); | ||
493 | } | ||
494 | finally | ||
495 | { | ||
496 | m_CurrentWorkingDirectory.Pop(); | ||
497 | } | ||
498 | } | ||
499 | |||
500 | #endregion | ||
501 | |||
502 | #region Public Methods | ||
503 | |||
504 | /// <summary> | ||
505 | /// Allows the project. | ||
506 | /// </summary> | ||
507 | /// <param name="projectGroupsFlags">The project groups flags.</param> | ||
508 | /// <returns></returns> | ||
509 | public bool AllowProject(string projectGroupsFlags) | ||
510 | { | ||
511 | if(m_ProjectGroups != null && m_ProjectGroups.Length > 0) | ||
512 | { | ||
513 | if(projectGroupsFlags != null && projectGroupsFlags.Length == 0) | ||
514 | { | ||
515 | foreach(string group in projectGroupsFlags.Split('|')) | ||
516 | { | ||
517 | if(Array.IndexOf(m_ProjectGroups, group) != -1) //if included in the filter list | ||
518 | { | ||
519 | return true; | ||
520 | } | ||
521 | } | ||
522 | } | ||
523 | return false;//not included in the list or no groups specified for the project | ||
524 | } | ||
525 | return true;//no filter specified in the command line args | ||
526 | } | ||
527 | |||
528 | /// <summary> | ||
529 | /// Gets the type of the node. | ||
530 | /// </summary> | ||
531 | /// <param name="node">The node.</param> | ||
532 | /// <returns></returns> | ||
533 | public Type GetNodeType(XmlNode node) | ||
534 | { | ||
535 | if( node == null ) | ||
536 | { | ||
537 | throw new ArgumentNullException("node"); | ||
538 | } | ||
539 | if(!m_Nodes.ContainsKey(node.Name)) | ||
540 | { | ||
541 | return null; | ||
542 | } | ||
543 | |||
544 | NodeEntry ne = (NodeEntry)m_Nodes[node.Name]; | ||
545 | return ne.Type; | ||
546 | } | ||
547 | |||
548 | /// <summary> | ||
549 | /// | ||
550 | /// </summary> | ||
551 | /// <param name="node"></param> | ||
552 | /// <param name="parent"></param> | ||
553 | /// <returns></returns> | ||
554 | public IDataNode ParseNode(XmlNode node, IDataNode parent) | ||
555 | { | ||
556 | return ParseNode(node, parent, null); | ||
557 | } | ||
558 | |||
559 | //Create an instance of the data node type that is mapped to the name of the xml DOM node | ||
560 | /// <summary> | ||
561 | /// Parses the node. | ||
562 | /// </summary> | ||
563 | /// <param name="node">The node.</param> | ||
564 | /// <param name="parent">The parent.</param> | ||
565 | /// <param name="preNode">The pre node.</param> | ||
566 | /// <returns></returns> | ||
567 | public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) | ||
568 | { | ||
569 | IDataNode dataNode; | ||
570 | |||
571 | try | ||
572 | { | ||
573 | if( node == null ) | ||
574 | { | ||
575 | throw new ArgumentNullException("node"); | ||
576 | } | ||
577 | if(preNode == null) | ||
578 | { | ||
579 | if(!m_Nodes.ContainsKey(node.Name)) | ||
580 | { | ||
581 | //throw new XmlException("Unknown XML node: " + node.Name); | ||
582 | return null; | ||
583 | } | ||
584 | |||
585 | NodeEntry ne = (NodeEntry)m_Nodes[node.Name]; | ||
586 | Type type = ne.Type; | ||
587 | //DataNodeAttribute dna = ne.Attribute; | ||
588 | |||
589 | dataNode = (IDataNode)type.Assembly.CreateInstance(type.FullName); | ||
590 | if(dataNode == null) | ||
591 | { | ||
592 | throw new System.Reflection.TargetException("Could not create new parser instance: " + type.FullName); | ||
593 | } | ||
594 | } | ||
595 | else | ||
596 | dataNode = preNode; | ||
597 | |||
598 | dataNode.Parent = parent; | ||
599 | dataNode.Parse(node); | ||
600 | } | ||
601 | catch(WarningException wex) | ||
602 | { | ||
603 | m_Log.Write(LogType.Warning, wex.Message); | ||
604 | return null; | ||
605 | } | ||
606 | catch(FatalException fex) | ||
607 | { | ||
608 | m_Log.WriteException(LogType.Error, fex); | ||
609 | throw; | ||
610 | } | ||
611 | catch(Exception ex) | ||
612 | { | ||
613 | m_Log.WriteException(LogType.Error, ex); | ||
614 | throw; | ||
615 | } | ||
616 | |||
617 | return dataNode; | ||
618 | } | ||
619 | |||
620 | /// <summary> | ||
621 | /// Initializes the specified target. | ||
622 | /// </summary> | ||
623 | /// <param name="target">The target.</param> | ||
624 | /// <param name="args">The args.</param> | ||
625 | public void Initialize(LogTargets target, string[] args) | ||
626 | { | ||
627 | m_Targets = new Hashtable(); | ||
628 | CacheTargets(this.GetType().Assembly); | ||
629 | m_Nodes = new Hashtable(); | ||
630 | CacheNodeTypes(this.GetType().Assembly); | ||
631 | CacheVersion(); | ||
632 | |||
633 | m_CommandLine = new CommandLineCollection(args); | ||
634 | |||
635 | string logFile = null; | ||
636 | if(m_CommandLine.WasPassed("log")) | ||
637 | { | ||
638 | logFile = m_CommandLine["log"]; | ||
639 | |||
640 | if(logFile != null && logFile.Length == 0) | ||
641 | { | ||
642 | logFile = "Prebuild.log"; | ||
643 | } | ||
644 | } | ||
645 | else | ||
646 | { | ||
647 | target = target & ~LogTargets.File; //dont output to a file | ||
648 | } | ||
649 | |||
650 | m_Log = new Log(target, logFile); | ||
651 | LogBanner(); | ||
652 | |||
653 | m_CurrentWorkingDirectory = new CurrentDirectory(); | ||
654 | |||
655 | m_Target = m_CommandLine["target"]; | ||
656 | m_Clean = m_CommandLine["clean"]; | ||
657 | string removeDirs = m_CommandLine["removedir"]; | ||
658 | if(removeDirs != null && removeDirs.Length == 0) | ||
659 | { | ||
660 | m_RemoveDirectories = removeDirs.Split('|'); | ||
661 | } | ||
662 | |||
663 | string flags = m_CommandLine["allowedgroups"];//allows filtering by specifying a pipe-delimited list of groups to include | ||
664 | if(flags != null && flags.Length == 0) | ||
665 | { | ||
666 | m_ProjectGroups = flags.Split('|'); | ||
667 | } | ||
668 | m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); | ||
669 | |||
670 | LoadSchema(); | ||
671 | } | ||
672 | |||
673 | /// <summary> | ||
674 | /// Processes this instance. | ||
675 | /// </summary> | ||
676 | public void Process() | ||
677 | { | ||
678 | bool perfomedOtherTask = false; | ||
679 | if(m_RemoveDirectories != null && m_RemoveDirectories.Length > 0) | ||
680 | { | ||
681 | try | ||
682 | { | ||
683 | RemoveDirectories(".",m_RemoveDirectories); | ||
684 | } | ||
685 | catch(IOException e) | ||
686 | { | ||
687 | m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); | ||
688 | m_Log.WriteException(LogType.Error,e); | ||
689 | } | ||
690 | catch(UnauthorizedAccessException e) | ||
691 | { | ||
692 | m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); | ||
693 | m_Log.WriteException(LogType.Error,e); | ||
694 | } | ||
695 | perfomedOtherTask = true; | ||
696 | } | ||
697 | |||
698 | if(m_Target != null && m_Clean != null) | ||
699 | { | ||
700 | m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); | ||
701 | return; | ||
702 | } | ||
703 | |||
704 | if(m_Target == null && m_Clean == null) | ||
705 | { | ||
706 | if(perfomedOtherTask) //finished | ||
707 | { | ||
708 | return; | ||
709 | } | ||
710 | m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); | ||
711 | return; | ||
712 | } | ||
713 | |||
714 | string file = "./prebuild.xml"; | ||
715 | if(m_CommandLine.WasPassed("file")) | ||
716 | { | ||
717 | file = m_CommandLine["file"]; | ||
718 | } | ||
719 | |||
720 | ProcessFile(file); | ||
721 | |||
722 | string target = (m_Target != null ? m_Target.ToLower() : m_Clean.ToLower()); | ||
723 | bool clean = (m_Target == null); | ||
724 | if(clean && target != null && target.Length == 0) | ||
725 | { | ||
726 | target = "all"; | ||
727 | } | ||
728 | if(clean && target == "all")//default to all if no target was specified for clean | ||
729 | { | ||
730 | //check if they passed yes | ||
731 | if (!m_CommandLine.WasPassed("yes")) | ||
732 | { | ||
733 | Console.WriteLine("WARNING: This operation will clean ALL project files for all targets, are you sure? (y/n):"); | ||
734 | string ret = Console.ReadLine(); | ||
735 | if(ret == null) | ||
736 | { | ||
737 | return; | ||
738 | } | ||
739 | ret = ret.Trim().ToLower(); | ||
740 | if((ret.ToLower() != "y" && ret.ToLower() != "yes")) | ||
741 | { | ||
742 | return; | ||
743 | } | ||
744 | } | ||
745 | //clean all targets (just cleaning vs2002 target didn't clean nant) | ||
746 | foreach(ITarget targ in m_Targets.Values) | ||
747 | { | ||
748 | targ.Clean(this); | ||
749 | } | ||
750 | } | ||
751 | else | ||
752 | { | ||
753 | if (!m_Targets.Contains(target)) { | ||
754 | m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target); | ||
755 | return; | ||
756 | } | ||
757 | ITarget targ = (ITarget)m_Targets[target]; | ||
758 | |||
759 | if(clean) | ||
760 | { | ||
761 | targ.Clean(this); | ||
762 | } | ||
763 | else | ||
764 | { | ||
765 | targ.Write(this); | ||
766 | } | ||
767 | } | ||
768 | |||
769 | m_Log.Flush(); | ||
770 | } | ||
771 | |||
772 | #endregion | ||
773 | |||
774 | #region IDisposable Members | ||
775 | |||
776 | /// <summary> | ||
777 | /// | ||
778 | /// </summary> | ||
779 | public void Dispose() | ||
780 | { | ||
781 | Dispose(true); | ||
782 | GC.SuppressFinalize(this); | ||
783 | } | ||
784 | |||
785 | /// <summary> | ||
786 | /// Dispose objects | ||
787 | /// </summary> | ||
788 | /// <param name="disposing"> | ||
789 | /// If true, it will dispose close the handle | ||
790 | /// </param> | ||
791 | /// <remarks> | ||
792 | /// Will dispose managed and unmanaged resources. | ||
793 | /// </remarks> | ||
794 | protected virtual void Dispose(bool disposing) | ||
795 | { | ||
796 | if (!this.disposed) | ||
797 | { | ||
798 | if (disposing) | ||
799 | { | ||
800 | if (this.m_Log != null) | ||
801 | { | ||
802 | this.m_Log.Close(); | ||
803 | this.m_Log = null; | ||
804 | } | ||
805 | } | ||
806 | } | ||
807 | this.disposed = true; | ||
808 | } | ||
809 | |||
810 | /// <summary> | ||
811 | /// | ||
812 | /// </summary> | ||
813 | ~Kernel() | ||
814 | { | ||
815 | this.Dispose(false); | ||
816 | } | ||
817 | |||
818 | /// <summary> | ||
819 | /// Closes and destroys this object | ||
820 | /// </summary> | ||
821 | /// <remarks> | ||
822 | /// Same as Dispose(true) | ||
823 | /// </remarks> | ||
824 | public void Close() | ||
825 | { | ||
826 | Dispose(); | ||
827 | } | ||
828 | |||
829 | #endregion | ||
830 | } | ||
831 | } | ||
diff --git a/Prebuild/src/Core/Nodes/AuthorNode.cs b/Prebuild/src/Core/Nodes/AuthorNode.cs deleted file mode 100644 index 20e72c0..0000000 --- a/Prebuild/src/Core/Nodes/AuthorNode.cs +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Xml; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using Prebuild.Core.Utilities; | ||
34 | |||
35 | namespace Prebuild.Core.Nodes | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// | ||
39 | /// </summary> | ||
40 | [DataNode("Author")] | ||
41 | public class AuthorNode : DataNode | ||
42 | { | ||
43 | #region Fields | ||
44 | |||
45 | private string m_Signature; | ||
46 | |||
47 | #endregion | ||
48 | |||
49 | #region Properties | ||
50 | |||
51 | /// <summary> | ||
52 | /// Gets the signature. | ||
53 | /// </summary> | ||
54 | /// <value>The signature.</value> | ||
55 | public string Signature | ||
56 | { | ||
57 | get | ||
58 | { | ||
59 | return m_Signature; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | #endregion | ||
64 | |||
65 | #region Public Methods | ||
66 | |||
67 | /// <summary> | ||
68 | /// Parses the specified node. | ||
69 | /// </summary> | ||
70 | /// <param name="node">The node.</param> | ||
71 | public override void Parse(XmlNode node) | ||
72 | { | ||
73 | if( node == null ) | ||
74 | { | ||
75 | throw new ArgumentNullException("node"); | ||
76 | } | ||
77 | |||
78 | m_Signature = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
79 | if(m_Signature == null) | ||
80 | { | ||
81 | m_Signature = ""; | ||
82 | } | ||
83 | |||
84 | m_Signature = m_Signature.Trim(); | ||
85 | } | ||
86 | |||
87 | #endregion | ||
88 | } | ||
89 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs deleted file mode 100644 index 67d78d5..0000000 --- a/Prebuild/src/Core/Nodes/ConfigurationNode.cs +++ /dev/null | |||
@@ -1,178 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Xml; | ||
28 | |||
29 | using Prebuild.Core.Attributes; | ||
30 | using Prebuild.Core.Interfaces; | ||
31 | using Prebuild.Core.Utilities; | ||
32 | |||
33 | namespace Prebuild.Core.Nodes | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// | ||
37 | /// </summary> | ||
38 | [DataNode("Configuration")] | ||
39 | public class ConfigurationNode : DataNode, ICloneable, IComparable | ||
40 | { | ||
41 | #region Fields | ||
42 | |||
43 | private string m_Name = "unknown"; | ||
44 | private OptionsNode m_Options; | ||
45 | |||
46 | #endregion | ||
47 | |||
48 | #region Constructors | ||
49 | |||
50 | /// <summary> | ||
51 | /// Initializes a new instance of the <see cref="ConfigurationNode"/> class. | ||
52 | /// </summary> | ||
53 | public ConfigurationNode() | ||
54 | { | ||
55 | m_Options = new OptionsNode(); | ||
56 | } | ||
57 | |||
58 | #endregion | ||
59 | |||
60 | #region Properties | ||
61 | |||
62 | /// <summary> | ||
63 | /// Gets or sets the parent. | ||
64 | /// </summary> | ||
65 | /// <value>The parent.</value> | ||
66 | public override IDataNode Parent | ||
67 | { | ||
68 | get | ||
69 | { | ||
70 | return base.Parent; | ||
71 | } | ||
72 | set | ||
73 | { | ||
74 | base.Parent = value; | ||
75 | if(base.Parent is SolutionNode) | ||
76 | { | ||
77 | SolutionNode node = (SolutionNode)base.Parent; | ||
78 | if(node != null && node.Options != null) | ||
79 | { | ||
80 | node.Options.CopyTo(m_Options); | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | |||
86 | /// <summary> | ||
87 | /// Gets the name. | ||
88 | /// </summary> | ||
89 | /// <value>The name.</value> | ||
90 | public string Name | ||
91 | { | ||
92 | get | ||
93 | { | ||
94 | return m_Name; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | /// <summary> | ||
99 | /// Gets or sets the options. | ||
100 | /// </summary> | ||
101 | /// <value>The options.</value> | ||
102 | public OptionsNode Options | ||
103 | { | ||
104 | get | ||
105 | { | ||
106 | return m_Options; | ||
107 | } | ||
108 | set | ||
109 | { | ||
110 | m_Options = value; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | #endregion | ||
115 | |||
116 | #region Public Methods | ||
117 | |||
118 | /// <summary> | ||
119 | /// Parses the specified node. | ||
120 | /// </summary> | ||
121 | /// <param name="node">The node.</param> | ||
122 | public override void Parse(XmlNode node) | ||
123 | { | ||
124 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
125 | if( node == null ) | ||
126 | { | ||
127 | throw new ArgumentNullException("node"); | ||
128 | } | ||
129 | foreach(XmlNode child in node.ChildNodes) | ||
130 | { | ||
131 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
132 | if(dataNode is OptionsNode) | ||
133 | { | ||
134 | ((OptionsNode)dataNode).CopyTo(m_Options); | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// Copies to. | ||
141 | /// </summary> | ||
142 | /// <param name="conf">The conf.</param> | ||
143 | public void CopyTo(ConfigurationNode conf) | ||
144 | { | ||
145 | m_Options.CopyTo(conf.m_Options); | ||
146 | } | ||
147 | |||
148 | #endregion | ||
149 | |||
150 | #region ICloneable Members | ||
151 | |||
152 | /// <summary> | ||
153 | /// Creates a new object that is a copy of the current instance. | ||
154 | /// </summary> | ||
155 | /// <returns> | ||
156 | /// A new object that is a copy of this instance. | ||
157 | /// </returns> | ||
158 | public object Clone() | ||
159 | { | ||
160 | ConfigurationNode ret = new ConfigurationNode(); | ||
161 | ret.m_Name = m_Name; | ||
162 | m_Options.CopyTo(ret.m_Options); | ||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | #endregion | ||
167 | |||
168 | #region IComparable Members | ||
169 | |||
170 | public int CompareTo(object obj) | ||
171 | { | ||
172 | ConfigurationNode that = (ConfigurationNode) obj; | ||
173 | return this.m_Name.CompareTo(that.m_Name); | ||
174 | } | ||
175 | |||
176 | #endregion | ||
177 | } | ||
178 | } | ||
diff --git a/Prebuild/src/Core/Nodes/DataNode.cs b/Prebuild/src/Core/Nodes/DataNode.cs deleted file mode 100644 index 763e6c3..0000000 --- a/Prebuild/src/Core/Nodes/DataNode.cs +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Xml; | ||
28 | |||
29 | using Prebuild.Core.Attributes; | ||
30 | using Prebuild.Core.Interfaces; | ||
31 | using System.IO; | ||
32 | |||
33 | namespace Prebuild.Core.Nodes | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// | ||
37 | /// </summary> | ||
38 | public abstract class DataNode : IDataNode | ||
39 | { | ||
40 | #region Fields | ||
41 | |||
42 | private IDataNode parent; | ||
43 | string[] m_WebTypes = new string[] { "aspx", "ascx", "master", "ashx", "asmx" }; | ||
44 | |||
45 | #endregion | ||
46 | |||
47 | #region IDataNode Members | ||
48 | |||
49 | /// <summary> | ||
50 | /// Gets or sets the parent. | ||
51 | /// </summary> | ||
52 | /// <value>The parent.</value> | ||
53 | public virtual IDataNode Parent | ||
54 | { | ||
55 | get | ||
56 | { | ||
57 | return parent; | ||
58 | } | ||
59 | set | ||
60 | { | ||
61 | parent = value; | ||
62 | } | ||
63 | } | ||
64 | public string[] WebTypes | ||
65 | { | ||
66 | get { return m_WebTypes; } | ||
67 | } | ||
68 | /// <summary> | ||
69 | /// Parses the specified node. | ||
70 | /// </summary> | ||
71 | /// <param name="node">The node.</param> | ||
72 | public virtual void Parse(XmlNode node) | ||
73 | { | ||
74 | } | ||
75 | public BuildAction GetBuildActionByFileName(string fileName) | ||
76 | { | ||
77 | string extension = Path.GetExtension(fileName).ToLower(); | ||
78 | foreach (string type in WebTypes) | ||
79 | { | ||
80 | if (extension == type) | ||
81 | return BuildAction.Content; | ||
82 | } | ||
83 | return BuildAction.Compile; | ||
84 | } | ||
85 | /// <summary> | ||
86 | /// Parses the file type to figure out what type it is | ||
87 | /// </summary> | ||
88 | /// <returns></returns> | ||
89 | public SubType GetSubTypeByFileName(string fileName) | ||
90 | { | ||
91 | string extension = System.IO.Path.GetExtension(fileName).ToLower(); | ||
92 | string designer = String.Format(".designer{0}", extension); | ||
93 | string path = fileName.ToLower(); | ||
94 | if (extension == ".resx") | ||
95 | { | ||
96 | return SubType.Designer; | ||
97 | } | ||
98 | else if (path.EndsWith(".settings")) | ||
99 | { | ||
100 | return SubType.Settings; | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | |||
105 | foreach (string type in WebTypes) | ||
106 | { | ||
107 | if (path.EndsWith(string.Format("{0}{1}", type, extension))) | ||
108 | { | ||
109 | return SubType.CodeBehind; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | return SubType.Code; | ||
114 | } | ||
115 | #endregion | ||
116 | } | ||
117 | } | ||
diff --git a/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs b/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs deleted file mode 100644 index 27c2051..0000000 --- a/Prebuild/src/Core/Nodes/DatabaseProjectNode.cs +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | using System.Xml; | ||
6 | |||
7 | using Prebuild.Core.Attributes; | ||
8 | using Prebuild.Core.Interfaces; | ||
9 | using Prebuild.Core.Utilities; | ||
10 | |||
11 | namespace Prebuild.Core.Nodes | ||
12 | { | ||
13 | [DataNode("DatabaseProject")] | ||
14 | public class DatabaseProjectNode : DataNode | ||
15 | { | ||
16 | string name; | ||
17 | string path; | ||
18 | string fullpath; | ||
19 | Guid guid = Guid.NewGuid(); | ||
20 | readonly List<AuthorNode> authors = new List<AuthorNode>(); | ||
21 | readonly List<DatabaseReferenceNode> references = new List<DatabaseReferenceNode>(); | ||
22 | |||
23 | public Guid Guid | ||
24 | { | ||
25 | get { return guid; } | ||
26 | } | ||
27 | |||
28 | public string Name | ||
29 | { | ||
30 | get { return name; } | ||
31 | } | ||
32 | |||
33 | public string Path | ||
34 | { | ||
35 | get { return path; } | ||
36 | } | ||
37 | |||
38 | public string FullPath | ||
39 | { | ||
40 | get { return fullpath; } | ||
41 | } | ||
42 | |||
43 | public IEnumerable<DatabaseReferenceNode> References | ||
44 | { | ||
45 | get { return references; } | ||
46 | } | ||
47 | |||
48 | public override void Parse(XmlNode node) | ||
49 | { | ||
50 | name = Helper.AttributeValue(node, "name", name); | ||
51 | path = Helper.AttributeValue(node, "path", name); | ||
52 | |||
53 | try | ||
54 | { | ||
55 | fullpath = Helper.ResolvePath(path); | ||
56 | } | ||
57 | catch | ||
58 | { | ||
59 | throw new WarningException("Could not resolve Solution path: {0}", path); | ||
60 | } | ||
61 | |||
62 | Kernel.Instance.CurrentWorkingDirectory.Push(); | ||
63 | |||
64 | try | ||
65 | { | ||
66 | Helper.SetCurrentDir(fullpath); | ||
67 | |||
68 | if (node == null) | ||
69 | { | ||
70 | throw new ArgumentNullException("node"); | ||
71 | } | ||
72 | |||
73 | foreach (XmlNode child in node.ChildNodes) | ||
74 | { | ||
75 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
76 | |||
77 | if (dataNode == null) | ||
78 | continue; | ||
79 | |||
80 | if (dataNode is AuthorNode) | ||
81 | authors.Add((AuthorNode)dataNode); | ||
82 | else if (dataNode is DatabaseReferenceNode) | ||
83 | references.Add((DatabaseReferenceNode)dataNode); | ||
84 | } | ||
85 | } | ||
86 | finally | ||
87 | { | ||
88 | Kernel.Instance.CurrentWorkingDirectory.Pop(); | ||
89 | } | ||
90 | |||
91 | base.Parse(node); | ||
92 | } | ||
93 | } | ||
94 | } | ||
diff --git a/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs b/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs deleted file mode 100644 index 845db24..0000000 --- a/Prebuild/src/Core/Nodes/DatabaseReferenceNode.cs +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | using System; | ||
2 | using Prebuild.Core.Attributes; | ||
3 | using Prebuild.Core.Utilities; | ||
4 | |||
5 | namespace Prebuild.Core.Nodes | ||
6 | { | ||
7 | [DataNode("DatabaseReference")] | ||
8 | public class DatabaseReferenceNode : DataNode | ||
9 | { | ||
10 | string name; | ||
11 | Guid providerId; | ||
12 | string connectionString; | ||
13 | |||
14 | public string Name | ||
15 | { | ||
16 | get { return name; } | ||
17 | } | ||
18 | |||
19 | public Guid ProviderId | ||
20 | { | ||
21 | get { return providerId; } | ||
22 | } | ||
23 | |||
24 | public string ConnectionString | ||
25 | { | ||
26 | get { return connectionString; } | ||
27 | } | ||
28 | |||
29 | public override void Parse(System.Xml.XmlNode node) | ||
30 | { | ||
31 | name = Helper.AttributeValue(node, "name", name); | ||
32 | |||
33 | string providerName = Helper.AttributeValue(node, "providerName", string.Empty); | ||
34 | if (providerName != null) | ||
35 | { | ||
36 | switch (providerName) | ||
37 | { | ||
38 | // digitaljeebus: pulled from HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\DataProviders\* | ||
39 | // Not sure if these will help other operating systems, or if there's a better way. | ||
40 | case "Microsoft.SqlServerCe.Client.3.5": | ||
41 | providerId = new Guid("7C602B5B-ACCB-4acd-9DC0-CA66388C1533"); break; | ||
42 | case "System.Data.OleDb": | ||
43 | providerId = new Guid("7F041D59-D76A-44ed-9AA2-FBF6B0548B80"); break; | ||
44 | case "System.Data.OracleClient": | ||
45 | providerId = new Guid("8F5C5018-AE09-42cf-B2CC-2CCCC7CFC2BB"); break; | ||
46 | case "System.Data.SqlClient": | ||
47 | providerId = new Guid("91510608-8809-4020-8897-FBA057E22D54"); break; | ||
48 | case "System.Data.Odbc": | ||
49 | providerId = new Guid("C3D4F4CE-2C48-4381-B4D6-34FA50C51C86"); break; | ||
50 | |||
51 | default: | ||
52 | throw new ArgumentOutOfRangeException("providerName", providerName, "Could not provider name to an id."); | ||
53 | } | ||
54 | } | ||
55 | else | ||
56 | providerId = new Guid(Helper.AttributeValue(node, "providerId", Guid.Empty.ToString("B"))); | ||
57 | |||
58 | connectionString = Helper.AttributeValue(node, "connectionString", connectionString); | ||
59 | |||
60 | base.Parse(node); | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/Prebuild/src/Core/Nodes/DescriptionNode.cs b/Prebuild/src/Core/Nodes/DescriptionNode.cs deleted file mode 100644 index 353a5ae..0000000 --- a/Prebuild/src/Core/Nodes/DescriptionNode.cs +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2007 C.J. Adams-Collier (cjac@colliertech.org) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Xml; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using Prebuild.Core.Utilities; | ||
34 | |||
35 | namespace Prebuild.Core.Nodes | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// The object representing the /Prebuild/Solution/Project/Description element | ||
39 | /// </summary> | ||
40 | [DataNode("Description")] | ||
41 | public class DescriptionNode : DataNode | ||
42 | { | ||
43 | #region Fields | ||
44 | |||
45 | private string m_Value; | ||
46 | |||
47 | #endregion | ||
48 | |||
49 | #region Properties | ||
50 | |||
51 | /// <summary> | ||
52 | /// Gets the description Value. | ||
53 | /// </summary> | ||
54 | /// <value>The description Value.</value> | ||
55 | public string Value | ||
56 | { | ||
57 | get | ||
58 | { | ||
59 | return m_Value; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | #endregion | ||
64 | |||
65 | #region Public Methods | ||
66 | |||
67 | /// <summary> | ||
68 | /// Parses the specified node. | ||
69 | /// </summary> | ||
70 | /// <param name="node">The node.</param> | ||
71 | public override void Parse(XmlNode node) | ||
72 | { | ||
73 | if( node == null ) | ||
74 | { | ||
75 | throw new ArgumentNullException("node"); | ||
76 | } | ||
77 | |||
78 | m_Value = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
79 | if(m_Value == null) | ||
80 | { | ||
81 | m_Value = ""; | ||
82 | } | ||
83 | |||
84 | m_Value = m_Value.Trim(); | ||
85 | } | ||
86 | |||
87 | #endregion | ||
88 | } | ||
89 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ExcludeNode.cs b/Prebuild/src/Core/Nodes/ExcludeNode.cs deleted file mode 100644 index 7f04cba..0000000 --- a/Prebuild/src/Core/Nodes/ExcludeNode.cs +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Xml; | ||
28 | |||
29 | using Prebuild.Core.Attributes; | ||
30 | using Prebuild.Core.Interfaces; | ||
31 | using Prebuild.Core.Utilities; | ||
32 | |||
33 | namespace Prebuild.Core.Nodes | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// | ||
37 | /// </summary> | ||
38 | [DataNode("Exclude")] | ||
39 | public class ExcludeNode : DataNode | ||
40 | { | ||
41 | #region Fields | ||
42 | |||
43 | private string m_Pattern = ""; | ||
44 | |||
45 | #endregion | ||
46 | |||
47 | #region Properties | ||
48 | |||
49 | /// <summary> | ||
50 | /// Gets the name. | ||
51 | /// </summary> | ||
52 | /// <value>The name.</value> | ||
53 | public string Name | ||
54 | { | ||
55 | get | ||
56 | { | ||
57 | return m_Pattern; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | /// <summary> | ||
62 | /// Gets the pattern. | ||
63 | /// </summary> | ||
64 | /// <value>The pattern.</value> | ||
65 | public string Pattern | ||
66 | { | ||
67 | get | ||
68 | { | ||
69 | return m_Pattern; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | #endregion | ||
74 | |||
75 | #region Public Methods | ||
76 | |||
77 | /// <summary> | ||
78 | /// Parses the specified node. | ||
79 | /// </summary> | ||
80 | /// <param name="node">The node.</param> | ||
81 | public override void Parse(XmlNode node) | ||
82 | { | ||
83 | m_Pattern = Helper.AttributeValue( node, "name", m_Pattern ); | ||
84 | m_Pattern = Helper.AttributeValue(node, "pattern", m_Pattern ); | ||
85 | } | ||
86 | |||
87 | #endregion | ||
88 | } | ||
89 | } | ||
diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs deleted file mode 100644 index 1520fcb..0000000 --- a/Prebuild/src/Core/Nodes/FileNode.cs +++ /dev/null | |||
@@ -1,271 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.IO; | ||
28 | using System.Xml; | ||
29 | |||
30 | using Prebuild.Core.Attributes; | ||
31 | using Prebuild.Core.Interfaces; | ||
32 | using Prebuild.Core.Utilities; | ||
33 | using Prebuild.Core.Targets; | ||
34 | |||
35 | namespace Prebuild.Core.Nodes | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// | ||
39 | /// </summary> | ||
40 | public enum BuildAction | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// | ||
44 | /// </summary> | ||
45 | None, | ||
46 | /// <summary> | ||
47 | /// | ||
48 | /// </summary> | ||
49 | Compile, | ||
50 | /// <summary> | ||
51 | /// | ||
52 | /// </summary> | ||
53 | Content, | ||
54 | /// <summary> | ||
55 | /// | ||
56 | /// </summary> | ||
57 | EmbeddedResource | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// | ||
62 | /// </summary> | ||
63 | public enum SubType | ||
64 | { | ||
65 | /// <summary> | ||
66 | /// | ||
67 | /// </summary> | ||
68 | Code, | ||
69 | /// <summary> | ||
70 | /// | ||
71 | /// </summary> | ||
72 | Component, | ||
73 | /// <summary> | ||
74 | /// | ||
75 | /// </summary> | ||
76 | Designer, | ||
77 | /// <summary> | ||
78 | /// | ||
79 | /// </summary> | ||
80 | Form, | ||
81 | /// <summary> | ||
82 | /// | ||
83 | /// </summary> | ||
84 | Settings, | ||
85 | /// <summary> | ||
86 | /// | ||
87 | /// </summary> | ||
88 | UserControl, | ||
89 | /// <summary> | ||
90 | /// | ||
91 | /// </summary> | ||
92 | CodeBehind, | ||
93 | } | ||
94 | |||
95 | public enum CopyToOutput | ||
96 | { | ||
97 | Never, | ||
98 | Always, | ||
99 | PreserveNewest | ||
100 | } | ||
101 | |||
102 | /// <summary> | ||
103 | /// | ||
104 | /// </summary> | ||
105 | [DataNode("File")] | ||
106 | public class FileNode : DataNode | ||
107 | { | ||
108 | #region Fields | ||
109 | |||
110 | private string m_Path; | ||
111 | private string m_ResourceName = ""; | ||
112 | private BuildAction? m_BuildAction; | ||
113 | private bool m_Valid; | ||
114 | private SubType? m_SubType; | ||
115 | private CopyToOutput m_CopyToOutput = CopyToOutput.Never; | ||
116 | private bool m_Link = false; | ||
117 | private string m_LinkPath = string.Empty; | ||
118 | private bool m_PreservePath = false; | ||
119 | |||
120 | |||
121 | #endregion | ||
122 | |||
123 | #region Properties | ||
124 | |||
125 | /// <summary> | ||
126 | /// | ||
127 | /// </summary> | ||
128 | public string Path | ||
129 | { | ||
130 | get | ||
131 | { | ||
132 | return m_Path; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// | ||
138 | /// </summary> | ||
139 | public string ResourceName | ||
140 | { | ||
141 | get | ||
142 | { | ||
143 | return m_ResourceName; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// | ||
149 | /// </summary> | ||
150 | public BuildAction BuildAction | ||
151 | { | ||
152 | get | ||
153 | { | ||
154 | if (m_BuildAction != null) | ||
155 | return m_BuildAction.Value; | ||
156 | else | ||
157 | return GetBuildActionByFileName(this.Path); | ||
158 | |||
159 | } | ||
160 | } | ||
161 | |||
162 | public CopyToOutput CopyToOutput | ||
163 | { | ||
164 | get | ||
165 | { | ||
166 | return this.m_CopyToOutput; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | public bool IsLink | ||
171 | { | ||
172 | get | ||
173 | { | ||
174 | return this.m_Link; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | public string LinkPath | ||
179 | { | ||
180 | get | ||
181 | { | ||
182 | return this.m_LinkPath; | ||
183 | } | ||
184 | } | ||
185 | /// <summary> | ||
186 | /// | ||
187 | /// </summary> | ||
188 | public SubType SubType | ||
189 | { | ||
190 | get | ||
191 | { | ||
192 | if (m_SubType != null) | ||
193 | return m_SubType.Value; | ||
194 | else | ||
195 | return GetSubTypeByFileName(this.Path); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// | ||
201 | /// </summary> | ||
202 | public bool IsValid | ||
203 | { | ||
204 | get | ||
205 | { | ||
206 | return m_Valid; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// | ||
212 | /// </summary> | ||
213 | /// <param name="file"></param> | ||
214 | /// <returns></returns> | ||
215 | public bool PreservePath | ||
216 | { | ||
217 | get | ||
218 | { | ||
219 | return m_PreservePath; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | #endregion | ||
224 | |||
225 | #region Public Methods | ||
226 | |||
227 | /// <summary> | ||
228 | /// | ||
229 | /// </summary> | ||
230 | /// <param name="node"></param> | ||
231 | public override void Parse(XmlNode node) | ||
232 | { | ||
233 | string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); | ||
234 | if (buildAction != string.Empty) | ||
235 | m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); | ||
236 | string subType = Helper.AttributeValue(node, "subType", string.Empty); | ||
237 | if (subType != String.Empty) | ||
238 | m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); | ||
239 | |||
240 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); | ||
241 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); | ||
242 | if ( this.m_Link == true ) | ||
243 | { | ||
244 | this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); | ||
245 | } | ||
246 | this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); | ||
247 | this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); | ||
248 | |||
249 | if( node == null ) | ||
250 | { | ||
251 | throw new ArgumentNullException("node"); | ||
252 | } | ||
253 | |||
254 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
255 | if(m_Path == null) | ||
256 | { | ||
257 | m_Path = ""; | ||
258 | } | ||
259 | |||
260 | m_Path = m_Path.Trim(); | ||
261 | m_Valid = true; | ||
262 | if(!File.Exists(m_Path)) | ||
263 | { | ||
264 | m_Valid = false; | ||
265 | Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); | ||
266 | } | ||
267 | } | ||
268 | |||
269 | #endregion | ||
270 | } | ||
271 | } | ||
diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs deleted file mode 100644 index dc306c2..0000000 --- a/Prebuild/src/Core/Nodes/FilesNode.cs +++ /dev/null | |||
@@ -1,247 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Xml; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using System.IO; | ||
34 | |||
35 | namespace Prebuild.Core.Nodes | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// | ||
39 | /// </summary> | ||
40 | [DataNode("Files")] | ||
41 | public class FilesNode : DataNode | ||
42 | { | ||
43 | #region Fields | ||
44 | |||
45 | private StringCollection m_Files; | ||
46 | private Hashtable m_BuildActions; | ||
47 | private Hashtable m_SubTypes; | ||
48 | private Hashtable m_ResourceNames; | ||
49 | private Hashtable m_CopyToOutputs; | ||
50 | private Hashtable m_Links; | ||
51 | private Hashtable m_LinkPaths; | ||
52 | private Hashtable m_PreservePaths; | ||
53 | |||
54 | #endregion | ||
55 | |||
56 | #region Constructors | ||
57 | |||
58 | /// <summary> | ||
59 | /// | ||
60 | /// </summary> | ||
61 | public FilesNode() | ||
62 | { | ||
63 | m_Files = new StringCollection(); | ||
64 | m_BuildActions = new Hashtable(); | ||
65 | m_SubTypes = new Hashtable(); | ||
66 | m_ResourceNames = new Hashtable(); | ||
67 | m_CopyToOutputs = new Hashtable(); | ||
68 | m_Links = new Hashtable(); | ||
69 | m_LinkPaths = new Hashtable(); | ||
70 | m_PreservePaths = new Hashtable(); | ||
71 | } | ||
72 | |||
73 | #endregion | ||
74 | |||
75 | #region Properties | ||
76 | |||
77 | /// <summary> | ||
78 | /// | ||
79 | /// </summary> | ||
80 | public int Count | ||
81 | { | ||
82 | get | ||
83 | { | ||
84 | return m_Files.Count; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | #endregion | ||
89 | |||
90 | #region Public Methods | ||
91 | |||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | /// <param name="file"></param> | ||
96 | /// <returns></returns> | ||
97 | public BuildAction GetBuildAction(string file) | ||
98 | { | ||
99 | if(!m_BuildActions.ContainsKey(file)) | ||
100 | { | ||
101 | return BuildAction.Compile; | ||
102 | } | ||
103 | |||
104 | return (BuildAction)m_BuildActions[file]; | ||
105 | } | ||
106 | |||
107 | public CopyToOutput GetCopyToOutput(string file) | ||
108 | { | ||
109 | if (!this.m_CopyToOutputs.ContainsKey(file)) | ||
110 | { | ||
111 | return CopyToOutput.Never; | ||
112 | } | ||
113 | return (CopyToOutput) this.m_CopyToOutputs[file]; | ||
114 | } | ||
115 | |||
116 | public bool GetIsLink(string file) | ||
117 | { | ||
118 | if (!this.m_Links.ContainsKey(file)) | ||
119 | { | ||
120 | return false; | ||
121 | } | ||
122 | return (bool) this.m_Links[file]; | ||
123 | } | ||
124 | |||
125 | public string GetLinkPath( string file ) | ||
126 | { | ||
127 | if ( !this.m_LinkPaths.ContainsKey( file ) ) | ||
128 | { | ||
129 | return string.Empty; | ||
130 | } | ||
131 | return (string)this.m_LinkPaths[ file ]; | ||
132 | } | ||
133 | |||
134 | /// <summary> | ||
135 | /// | ||
136 | /// </summary> | ||
137 | /// <param name="file"></param> | ||
138 | /// <returns></returns> | ||
139 | public SubType GetSubType(string file) | ||
140 | { | ||
141 | if(!m_SubTypes.ContainsKey(file)) | ||
142 | { | ||
143 | return SubType.Code; | ||
144 | } | ||
145 | |||
146 | return (SubType)m_SubTypes[file]; | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// | ||
151 | /// </summary> | ||
152 | /// <param name="file"></param> | ||
153 | /// <returns></returns> | ||
154 | public string GetResourceName(string file) | ||
155 | { | ||
156 | if(!m_ResourceNames.ContainsKey(file)) | ||
157 | { | ||
158 | return ""; | ||
159 | } | ||
160 | |||
161 | return (string)m_ResourceNames[file]; | ||
162 | } | ||
163 | |||
164 | /// <summary> | ||
165 | /// | ||
166 | /// </summary> | ||
167 | /// <param name="file"></param> | ||
168 | /// <returns></returns> | ||
169 | public bool GetPreservePath( string file ) | ||
170 | { | ||
171 | if ( !m_PreservePaths.ContainsKey( file ) ) | ||
172 | { | ||
173 | return false; | ||
174 | } | ||
175 | |||
176 | return (bool)m_PreservePaths[ file ]; | ||
177 | } | ||
178 | |||
179 | /// <summary> | ||
180 | /// | ||
181 | /// </summary> | ||
182 | /// <param name="node"></param> | ||
183 | public override void Parse(XmlNode node) | ||
184 | { | ||
185 | if( node == null ) | ||
186 | { | ||
187 | throw new ArgumentNullException("node"); | ||
188 | } | ||
189 | foreach(XmlNode child in node.ChildNodes) | ||
190 | { | ||
191 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
192 | if(dataNode is FileNode) | ||
193 | { | ||
194 | FileNode fileNode = (FileNode)dataNode; | ||
195 | if(fileNode.IsValid) | ||
196 | { | ||
197 | if (!m_Files.Contains(fileNode.Path)) | ||
198 | { | ||
199 | m_Files.Add(fileNode.Path); | ||
200 | m_BuildActions[fileNode.Path] = fileNode.BuildAction; | ||
201 | m_SubTypes[fileNode.Path] = fileNode.SubType; | ||
202 | m_ResourceNames[fileNode.Path] = fileNode.ResourceName; | ||
203 | this.m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; | ||
204 | this.m_Links[ fileNode.Path ] = fileNode.IsLink; | ||
205 | this.m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; | ||
206 | this.m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; | ||
207 | |||
208 | } | ||
209 | } | ||
210 | } | ||
211 | else if(dataNode is MatchNode) | ||
212 | { | ||
213 | foreach(string file in ((MatchNode)dataNode).Files) | ||
214 | { | ||
215 | MatchNode matchNode = (MatchNode)dataNode; | ||
216 | if (!m_Files.Contains(file)) | ||
217 | { | ||
218 | m_Files.Add(file); | ||
219 | m_BuildActions[ file ] = matchNode.BuildAction == null ? GetBuildActionByFileName(file) : matchNode.BuildAction; | ||
220 | m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; | ||
221 | m_ResourceNames[ file ] = matchNode.ResourceName; | ||
222 | this.m_PreservePaths[ file ] = matchNode.PreservePath; | ||
223 | this.m_Links[ file ] = matchNode.IsLink; | ||
224 | this.m_LinkPaths[ file ] = matchNode.LinkPath; | ||
225 | this.m_CopyToOutputs[ file ] = matchNode.CopyToOutput; | ||
226 | |||
227 | } | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | |||
233 | // TODO: Check in to why StringCollection's enumerator doesn't implement | ||
234 | // IEnumerator? | ||
235 | /// <summary> | ||
236 | /// | ||
237 | /// </summary> | ||
238 | /// <returns></returns> | ||
239 | public StringEnumerator GetEnumerator() | ||
240 | { | ||
241 | return m_Files.GetEnumerator(); | ||
242 | } | ||
243 | |||
244 | #endregion | ||
245 | |||
246 | } | ||
247 | } | ||
diff --git a/Prebuild/src/Core/Nodes/MatchNode.cs b/Prebuild/src/Core/Nodes/MatchNode.cs deleted file mode 100644 index 656d7d0..0000000 --- a/Prebuild/src/Core/Nodes/MatchNode.cs +++ /dev/null | |||
@@ -1,330 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections.Generic; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | using System.Text.RegularExpressions; | ||
31 | using System.Xml; | ||
32 | |||
33 | using Prebuild.Core.Attributes; | ||
34 | using Prebuild.Core.Interfaces; | ||
35 | using Prebuild.Core.Utilities; | ||
36 | using System.Collections; | ||
37 | |||
38 | namespace Prebuild.Core.Nodes | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// | ||
42 | /// </summary> | ||
43 | [DataNode("Match")] | ||
44 | public class MatchNode : DataNode | ||
45 | { | ||
46 | #region Fields | ||
47 | |||
48 | private readonly StringCollection m_Files = new StringCollection(); | ||
49 | private Regex m_Regex; | ||
50 | private BuildAction? m_BuildAction; | ||
51 | private SubType? m_SubType; | ||
52 | string m_ResourceName = ""; | ||
53 | private CopyToOutput m_CopyToOutput; | ||
54 | private bool m_Link; | ||
55 | private string m_LinkPath; | ||
56 | private bool m_PreservePath; | ||
57 | private readonly List<ExcludeNode> m_Exclusions = new List<ExcludeNode>(); | ||
58 | |||
59 | #endregion | ||
60 | |||
61 | #region Properties | ||
62 | |||
63 | /// <summary> | ||
64 | /// | ||
65 | /// </summary> | ||
66 | public StringCollection Files | ||
67 | { | ||
68 | get | ||
69 | { | ||
70 | return m_Files; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// | ||
76 | /// </summary> | ||
77 | public BuildAction? BuildAction | ||
78 | { | ||
79 | get | ||
80 | { | ||
81 | return m_BuildAction; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// | ||
87 | /// </summary> | ||
88 | public SubType? SubType | ||
89 | { | ||
90 | get | ||
91 | { | ||
92 | return m_SubType; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public CopyToOutput CopyToOutput | ||
97 | { | ||
98 | get | ||
99 | { | ||
100 | return this.m_CopyToOutput; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public bool IsLink | ||
105 | { | ||
106 | get | ||
107 | { | ||
108 | return this.m_Link; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | public string LinkPath | ||
113 | { | ||
114 | get | ||
115 | { | ||
116 | return this.m_LinkPath; | ||
117 | } | ||
118 | } | ||
119 | /// <summary> | ||
120 | /// | ||
121 | /// </summary> | ||
122 | public string ResourceName | ||
123 | { | ||
124 | get | ||
125 | { | ||
126 | return m_ResourceName; | ||
127 | } | ||
128 | } | ||
129 | |||
130 | public bool PreservePath | ||
131 | { | ||
132 | get | ||
133 | { | ||
134 | return m_PreservePath; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | #endregion | ||
139 | |||
140 | #region Private Methods | ||
141 | |||
142 | /// <summary> | ||
143 | /// Recurses the directories. | ||
144 | /// </summary> | ||
145 | /// <param name="path">The path.</param> | ||
146 | /// <param name="pattern">The pattern.</param> | ||
147 | /// <param name="recurse">if set to <c>true</c> [recurse].</param> | ||
148 | /// <param name="useRegex">if set to <c>true</c> [use regex].</param> | ||
149 | private void RecurseDirectories(string path, string pattern, bool recurse, bool useRegex, List<ExcludeNode> exclusions) | ||
150 | { | ||
151 | Match match; | ||
152 | Boolean excludeFile; | ||
153 | try | ||
154 | { | ||
155 | string[] files; | ||
156 | |||
157 | if(!useRegex) | ||
158 | { | ||
159 | files = Directory.GetFiles(path, pattern); | ||
160 | if(files != null) | ||
161 | { | ||
162 | string fileTemp; | ||
163 | foreach (string file in files) | ||
164 | { | ||
165 | excludeFile = false; | ||
166 | if (file.Substring(0,2) == "./" || file.Substring(0,2) == ".\\") | ||
167 | { | ||
168 | fileTemp = file.Substring(2); | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | fileTemp = file; | ||
173 | } | ||
174 | |||
175 | // Check all excludions and set flag if there are any hits. | ||
176 | foreach ( ExcludeNode exclude in exclusions ) | ||
177 | { | ||
178 | Regex exRegEx = new Regex( exclude.Pattern ); | ||
179 | match = exRegEx.Match( file ); | ||
180 | excludeFile |= match.Success; | ||
181 | } | ||
182 | |||
183 | if ( !excludeFile ) | ||
184 | { | ||
185 | m_Files.Add( fileTemp ); | ||
186 | } | ||
187 | |||
188 | } | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | return; | ||
193 | } | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | files = Directory.GetFiles(path); | ||
198 | foreach(string file in files) | ||
199 | { | ||
200 | excludeFile = false; | ||
201 | |||
202 | match = m_Regex.Match(file); | ||
203 | if(match.Success) | ||
204 | { | ||
205 | // Check all excludions and set flag if there are any hits. | ||
206 | foreach ( ExcludeNode exclude in exclusions ) | ||
207 | { | ||
208 | Regex exRegEx = new Regex( exclude.Pattern ); | ||
209 | match = exRegEx.Match( file ); | ||
210 | excludeFile |= !match.Success; | ||
211 | } | ||
212 | |||
213 | if ( !excludeFile ) | ||
214 | { | ||
215 | m_Files.Add( file ); | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | } | ||
220 | |||
221 | if(recurse) | ||
222 | { | ||
223 | string[] dirs = Directory.GetDirectories(path); | ||
224 | if(dirs != null && dirs.Length > 0) | ||
225 | { | ||
226 | foreach(string str in dirs) | ||
227 | { | ||
228 | RecurseDirectories(Helper.NormalizePath(str), pattern, recurse, useRegex, exclusions); | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | } | ||
233 | catch(DirectoryNotFoundException) | ||
234 | { | ||
235 | return; | ||
236 | } | ||
237 | catch(ArgumentException) | ||
238 | { | ||
239 | return; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | #endregion | ||
244 | |||
245 | #region Public Methods | ||
246 | |||
247 | /// <summary> | ||
248 | /// | ||
249 | /// </summary> | ||
250 | /// <param name="node"></param> | ||
251 | public override void Parse(XmlNode node) | ||
252 | { | ||
253 | if( node == null ) | ||
254 | { | ||
255 | throw new ArgumentNullException("node"); | ||
256 | } | ||
257 | string path = Helper.AttributeValue(node, "path", "."); | ||
258 | string pattern = Helper.AttributeValue(node, "pattern", "*"); | ||
259 | bool recurse = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false")); | ||
260 | bool useRegex = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false")); | ||
261 | string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); | ||
262 | if (buildAction != string.Empty) | ||
263 | m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); | ||
264 | |||
265 | //TODO: Figure out where the subtype node is being assigned | ||
266 | //string subType = Helper.AttributeValue(node, "subType", string.Empty); | ||
267 | //if (subType != String.Empty) | ||
268 | // m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); | ||
269 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); | ||
270 | this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); | ||
271 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); | ||
272 | if ( this.m_Link == true ) | ||
273 | { | ||
274 | this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); | ||
275 | } | ||
276 | this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); | ||
277 | |||
278 | |||
279 | if(path != null && path.Length == 0) | ||
280 | { | ||
281 | path = ".";//use current directory | ||
282 | } | ||
283 | //throw new WarningException("Match must have a 'path' attribute"); | ||
284 | |||
285 | if(pattern == null) | ||
286 | { | ||
287 | throw new WarningException("Match must have a 'pattern' attribute"); | ||
288 | } | ||
289 | |||
290 | path = Helper.NormalizePath(path); | ||
291 | if(!Directory.Exists(path)) | ||
292 | { | ||
293 | throw new WarningException("Match path does not exist: {0}", path); | ||
294 | } | ||
295 | |||
296 | try | ||
297 | { | ||
298 | if(useRegex) | ||
299 | { | ||
300 | m_Regex = new Regex(pattern); | ||
301 | } | ||
302 | } | ||
303 | catch(ArgumentException ex) | ||
304 | { | ||
305 | throw new WarningException("Could not compile regex pattern: {0}", ex.Message); | ||
306 | } | ||
307 | |||
308 | |||
309 | foreach(XmlNode child in node.ChildNodes) | ||
310 | { | ||
311 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
312 | if(dataNode is ExcludeNode) | ||
313 | { | ||
314 | ExcludeNode excludeNode = (ExcludeNode)dataNode; | ||
315 | m_Exclusions.Add( excludeNode ); | ||
316 | } | ||
317 | } | ||
318 | |||
319 | RecurseDirectories( path, pattern, recurse, useRegex, m_Exclusions ); | ||
320 | |||
321 | if(m_Files.Count < 1) | ||
322 | { | ||
323 | throw new WarningException("Match returned no files: {0}{1}", Helper.EndPath(path), pattern); | ||
324 | } | ||
325 | m_Regex = null; | ||
326 | } | ||
327 | |||
328 | #endregion | ||
329 | } | ||
330 | } | ||
diff --git a/Prebuild/src/Core/Nodes/OptionsNode.cs b/Prebuild/src/Core/Nodes/OptionsNode.cs deleted file mode 100644 index b63034b..0000000 --- a/Prebuild/src/Core/Nodes/OptionsNode.cs +++ /dev/null | |||
@@ -1,644 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Reflection; | ||
30 | using System.Xml; | ||
31 | |||
32 | using Prebuild.Core.Attributes; | ||
33 | using Prebuild.Core.Interfaces; | ||
34 | using Prebuild.Core.Utilities; | ||
35 | |||
36 | namespace Prebuild.Core.Nodes | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// | ||
40 | /// </summary> | ||
41 | [DataNode("Options")] | ||
42 | public class OptionsNode : DataNode | ||
43 | { | ||
44 | #region Fields | ||
45 | |||
46 | private static Hashtable m_OptionFields; | ||
47 | |||
48 | [OptionNode("CompilerDefines")] | ||
49 | private string m_CompilerDefines = ""; | ||
50 | |||
51 | /// <summary> | ||
52 | /// | ||
53 | /// </summary> | ||
54 | public string CompilerDefines | ||
55 | { | ||
56 | get | ||
57 | { | ||
58 | return m_CompilerDefines; | ||
59 | } | ||
60 | set | ||
61 | { | ||
62 | m_CompilerDefines = value; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | [OptionNode("OptimizeCode")] | ||
67 | private bool m_OptimizeCode; | ||
68 | |||
69 | /// <summary> | ||
70 | /// | ||
71 | /// </summary> | ||
72 | public bool OptimizeCode | ||
73 | { | ||
74 | get | ||
75 | { | ||
76 | return m_OptimizeCode; | ||
77 | } | ||
78 | set | ||
79 | { | ||
80 | m_OptimizeCode = value; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | [OptionNode("CheckUnderflowOverflow")] | ||
85 | private bool m_CheckUnderflowOverflow; | ||
86 | |||
87 | /// <summary> | ||
88 | /// | ||
89 | /// </summary> | ||
90 | public bool CheckUnderflowOverflow | ||
91 | { | ||
92 | get | ||
93 | { | ||
94 | return m_CheckUnderflowOverflow; | ||
95 | } | ||
96 | set | ||
97 | { | ||
98 | m_CheckUnderflowOverflow = value; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | [OptionNode("AllowUnsafe")] | ||
103 | private bool m_AllowUnsafe; | ||
104 | |||
105 | /// <summary> | ||
106 | /// | ||
107 | /// </summary> | ||
108 | public bool AllowUnsafe | ||
109 | { | ||
110 | get | ||
111 | { | ||
112 | return m_AllowUnsafe; | ||
113 | } | ||
114 | set | ||
115 | { | ||
116 | m_AllowUnsafe = value; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | [OptionNode("PreBuildEvent")] | ||
121 | private string m_PreBuildEvent; | ||
122 | |||
123 | /// <summary> | ||
124 | /// | ||
125 | /// </summary> | ||
126 | public string PreBuildEvent | ||
127 | { | ||
128 | get | ||
129 | { | ||
130 | return m_PreBuildEvent; | ||
131 | } | ||
132 | set | ||
133 | { | ||
134 | m_PreBuildEvent = value; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | [OptionNode("PostBuildEvent")] | ||
139 | private string m_PostBuildEvent; | ||
140 | |||
141 | /// <summary> | ||
142 | /// | ||
143 | /// </summary> | ||
144 | public string PostBuildEvent | ||
145 | { | ||
146 | get | ||
147 | { | ||
148 | return m_PostBuildEvent; | ||
149 | } | ||
150 | set | ||
151 | { | ||
152 | m_PostBuildEvent = value; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | [OptionNode("PreBuildEventArgs")] | ||
157 | private string m_PreBuildEventArgs; | ||
158 | |||
159 | /// <summary> | ||
160 | /// | ||
161 | /// </summary> | ||
162 | public string PreBuildEventArgs | ||
163 | { | ||
164 | get | ||
165 | { | ||
166 | return m_PreBuildEventArgs; | ||
167 | } | ||
168 | set | ||
169 | { | ||
170 | m_PreBuildEventArgs = value; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | [OptionNode("PostBuildEventArgs")] | ||
175 | private string m_PostBuildEventArgs; | ||
176 | |||
177 | /// <summary> | ||
178 | /// | ||
179 | /// </summary> | ||
180 | public string PostBuildEventArgs | ||
181 | { | ||
182 | get | ||
183 | { | ||
184 | return m_PostBuildEventArgs; | ||
185 | } | ||
186 | set | ||
187 | { | ||
188 | m_PostBuildEventArgs = value; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | [OptionNode("RunPostBuildEvent")] | ||
193 | private string m_RunPostBuildEvent; | ||
194 | |||
195 | /// <summary> | ||
196 | /// | ||
197 | /// </summary> | ||
198 | public string RunPostBuildEvent | ||
199 | { | ||
200 | get | ||
201 | { | ||
202 | return m_RunPostBuildEvent; | ||
203 | } | ||
204 | set | ||
205 | { | ||
206 | m_RunPostBuildEvent = value; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | [OptionNode("RunScript")] | ||
211 | private string m_RunScript; | ||
212 | |||
213 | /// <summary> | ||
214 | /// | ||
215 | /// </summary> | ||
216 | public string RunScript | ||
217 | { | ||
218 | get | ||
219 | { | ||
220 | return m_RunScript; | ||
221 | } | ||
222 | set | ||
223 | { | ||
224 | m_RunScript = value; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | [OptionNode("WarningLevel")] | ||
229 | private int m_WarningLevel = 4; | ||
230 | |||
231 | /// <summary> | ||
232 | /// | ||
233 | /// </summary> | ||
234 | public int WarningLevel | ||
235 | { | ||
236 | get | ||
237 | { | ||
238 | return m_WarningLevel; | ||
239 | } | ||
240 | set | ||
241 | { | ||
242 | m_WarningLevel = value; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | [OptionNode("WarningsAsErrors")] | ||
247 | private bool m_WarningsAsErrors; | ||
248 | |||
249 | /// <summary> | ||
250 | /// | ||
251 | /// </summary> | ||
252 | public bool WarningsAsErrors | ||
253 | { | ||
254 | get | ||
255 | { | ||
256 | return m_WarningsAsErrors; | ||
257 | } | ||
258 | set | ||
259 | { | ||
260 | m_WarningsAsErrors = value; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | [OptionNode("SuppressWarnings")] | ||
265 | private string m_SuppressWarnings = ""; | ||
266 | |||
267 | /// <summary> | ||
268 | /// | ||
269 | /// </summary> | ||
270 | public string SuppressWarnings | ||
271 | { | ||
272 | get | ||
273 | { | ||
274 | return m_SuppressWarnings; | ||
275 | } | ||
276 | set | ||
277 | { | ||
278 | m_SuppressWarnings = value; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | [OptionNode("OutputPath")] | ||
283 | private string m_OutputPath = "bin/"; | ||
284 | |||
285 | /// <summary> | ||
286 | /// | ||
287 | /// </summary> | ||
288 | public string OutputPath | ||
289 | { | ||
290 | get | ||
291 | { | ||
292 | return m_OutputPath; | ||
293 | } | ||
294 | set | ||
295 | { | ||
296 | m_OutputPath = value; | ||
297 | } | ||
298 | } | ||
299 | |||
300 | [OptionNode("GenerateDocumentation")] | ||
301 | private bool m_GenerateDocumentation; | ||
302 | |||
303 | /// <summary> | ||
304 | /// | ||
305 | /// </summary> | ||
306 | public bool GenerateDocumentation | ||
307 | { | ||
308 | get | ||
309 | { | ||
310 | return m_GenerateDocumentation; | ||
311 | } | ||
312 | set | ||
313 | { | ||
314 | m_GenerateDocumentation = value; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | [OptionNode("GenerateXmlDocFile")] | ||
319 | private bool m_GenerateXmlDocFile; | ||
320 | |||
321 | /// <summary> | ||
322 | /// | ||
323 | /// </summary> | ||
324 | public bool GenerateXmlDocFile | ||
325 | { | ||
326 | get | ||
327 | { | ||
328 | return m_GenerateXmlDocFile; | ||
329 | } | ||
330 | set | ||
331 | { | ||
332 | m_GenerateXmlDocFile = value; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | [OptionNode("XmlDocFile")] | ||
337 | private string m_XmlDocFile = ""; | ||
338 | |||
339 | /// <summary> | ||
340 | /// | ||
341 | /// </summary> | ||
342 | public string XmlDocFile | ||
343 | { | ||
344 | get | ||
345 | { | ||
346 | return m_XmlDocFile; | ||
347 | } | ||
348 | set | ||
349 | { | ||
350 | m_XmlDocFile = value; | ||
351 | } | ||
352 | } | ||
353 | |||
354 | [OptionNode("KeyFile")] | ||
355 | private string m_KeyFile = ""; | ||
356 | |||
357 | /// <summary> | ||
358 | /// | ||
359 | /// </summary> | ||
360 | public string KeyFile | ||
361 | { | ||
362 | get | ||
363 | { | ||
364 | return m_KeyFile; | ||
365 | } | ||
366 | set | ||
367 | { | ||
368 | m_KeyFile = value; | ||
369 | } | ||
370 | } | ||
371 | |||
372 | [OptionNode("DebugInformation")] | ||
373 | private bool m_DebugInformation; | ||
374 | |||
375 | /// <summary> | ||
376 | /// | ||
377 | /// </summary> | ||
378 | public bool DebugInformation | ||
379 | { | ||
380 | get | ||
381 | { | ||
382 | return m_DebugInformation; | ||
383 | } | ||
384 | set | ||
385 | { | ||
386 | m_DebugInformation = value; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | [OptionNode("RegisterComInterop")] | ||
391 | private bool m_RegisterComInterop; | ||
392 | |||
393 | /// <summary> | ||
394 | /// | ||
395 | /// </summary> | ||
396 | public bool RegisterComInterop | ||
397 | { | ||
398 | get | ||
399 | { | ||
400 | return m_RegisterComInterop; | ||
401 | } | ||
402 | set | ||
403 | { | ||
404 | m_RegisterComInterop = value; | ||
405 | } | ||
406 | } | ||
407 | |||
408 | [OptionNode("RemoveIntegerChecks")] | ||
409 | private bool m_RemoveIntegerChecks; | ||
410 | |||
411 | /// <summary> | ||
412 | /// | ||
413 | /// </summary> | ||
414 | public bool RemoveIntegerChecks | ||
415 | { | ||
416 | get | ||
417 | { | ||
418 | return m_RemoveIntegerChecks; | ||
419 | } | ||
420 | set | ||
421 | { | ||
422 | m_RemoveIntegerChecks = value; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | [OptionNode("IncrementalBuild")] | ||
427 | private bool m_IncrementalBuild; | ||
428 | |||
429 | /// <summary> | ||
430 | /// | ||
431 | /// </summary> | ||
432 | public bool IncrementalBuild | ||
433 | { | ||
434 | get | ||
435 | { | ||
436 | return m_IncrementalBuild; | ||
437 | } | ||
438 | set | ||
439 | { | ||
440 | m_IncrementalBuild = value; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | [OptionNode("BaseAddress")] | ||
445 | private string m_BaseAddress = "285212672"; | ||
446 | |||
447 | /// <summary> | ||
448 | /// | ||
449 | /// </summary> | ||
450 | public string BaseAddress | ||
451 | { | ||
452 | get | ||
453 | { | ||
454 | return m_BaseAddress; | ||
455 | } | ||
456 | set | ||
457 | { | ||
458 | m_BaseAddress = value; | ||
459 | } | ||
460 | } | ||
461 | |||
462 | [OptionNode("FileAlignment")] | ||
463 | private int m_FileAlignment = 4096; | ||
464 | |||
465 | /// <summary> | ||
466 | /// | ||
467 | /// </summary> | ||
468 | public int FileAlignment | ||
469 | { | ||
470 | get | ||
471 | { | ||
472 | return m_FileAlignment; | ||
473 | } | ||
474 | set | ||
475 | { | ||
476 | m_FileAlignment = value; | ||
477 | } | ||
478 | } | ||
479 | |||
480 | [OptionNode("NoStdLib")] | ||
481 | private bool m_NoStdLib; | ||
482 | |||
483 | /// <summary> | ||
484 | /// | ||
485 | /// </summary> | ||
486 | public bool NoStdLib | ||
487 | { | ||
488 | get | ||
489 | { | ||
490 | return m_NoStdLib; | ||
491 | } | ||
492 | set | ||
493 | { | ||
494 | m_NoStdLib = value; | ||
495 | } | ||
496 | } | ||
497 | |||
498 | private StringCollection m_FieldsDefined; | ||
499 | |||
500 | #endregion | ||
501 | |||
502 | #region Constructors | ||
503 | |||
504 | /// <summary> | ||
505 | /// Initializes the <see cref="OptionsNode"/> class. | ||
506 | /// </summary> | ||
507 | static OptionsNode() | ||
508 | { | ||
509 | Type t = typeof(OptionsNode); | ||
510 | |||
511 | m_OptionFields = new Hashtable(); | ||
512 | foreach(FieldInfo f in t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)) | ||
513 | { | ||
514 | object[] attrs = f.GetCustomAttributes(typeof(OptionNodeAttribute), false); | ||
515 | if(attrs == null || attrs.Length < 1) | ||
516 | { | ||
517 | continue; | ||
518 | } | ||
519 | |||
520 | OptionNodeAttribute ona = (OptionNodeAttribute)attrs[0]; | ||
521 | m_OptionFields[ona.NodeName] = f; | ||
522 | } | ||
523 | } | ||
524 | |||
525 | /// <summary> | ||
526 | /// Initializes a new instance of the <see cref="OptionsNode"/> class. | ||
527 | /// </summary> | ||
528 | public OptionsNode() | ||
529 | { | ||
530 | m_FieldsDefined = new StringCollection(); | ||
531 | } | ||
532 | |||
533 | #endregion | ||
534 | |||
535 | #region Properties | ||
536 | |||
537 | /// <summary> | ||
538 | /// Gets the <see cref="Object"/> at the specified index. | ||
539 | /// </summary> | ||
540 | /// <value></value> | ||
541 | public object this[string index] | ||
542 | { | ||
543 | get | ||
544 | { | ||
545 | if(!m_OptionFields.ContainsKey(index)) | ||
546 | { | ||
547 | return null; | ||
548 | } | ||
549 | |||
550 | FieldInfo f = (FieldInfo)m_OptionFields[index]; | ||
551 | return f.GetValue(this); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | /// <summary> | ||
556 | /// Gets the <see cref="Object"/> at the specified index. | ||
557 | /// </summary> | ||
558 | /// <value></value> | ||
559 | public object this[string index, object defaultValue] | ||
560 | { | ||
561 | get | ||
562 | { | ||
563 | object valueObject = this[index]; | ||
564 | if(valueObject != null && valueObject is string && ((string)valueObject).Length == 0) | ||
565 | { | ||
566 | return defaultValue; | ||
567 | } | ||
568 | return valueObject; | ||
569 | } | ||
570 | } | ||
571 | |||
572 | |||
573 | #endregion | ||
574 | |||
575 | #region Private Methods | ||
576 | |||
577 | private void FlagDefined(string name) | ||
578 | { | ||
579 | if(!m_FieldsDefined.Contains(name)) | ||
580 | { | ||
581 | m_FieldsDefined.Add(name); | ||
582 | } | ||
583 | } | ||
584 | |||
585 | private void SetOption(string nodeName, string val) | ||
586 | { | ||
587 | lock(m_OptionFields) | ||
588 | { | ||
589 | if(!m_OptionFields.ContainsKey(nodeName)) | ||
590 | { | ||
591 | return; | ||
592 | } | ||
593 | |||
594 | FieldInfo f = (FieldInfo)m_OptionFields[nodeName]; | ||
595 | f.SetValue(this, Helper.TranslateValue(f.FieldType, val)); | ||
596 | FlagDefined(f.Name); | ||
597 | } | ||
598 | } | ||
599 | |||
600 | #endregion | ||
601 | |||
602 | #region Public Methods | ||
603 | |||
604 | /// <summary> | ||
605 | /// Parses the specified node. | ||
606 | /// </summary> | ||
607 | /// <param name="node">The node.</param> | ||
608 | public override void Parse(XmlNode node) | ||
609 | { | ||
610 | if( node == null ) | ||
611 | { | ||
612 | throw new ArgumentNullException("node"); | ||
613 | } | ||
614 | |||
615 | foreach(XmlNode child in node.ChildNodes) | ||
616 | { | ||
617 | SetOption(child.Name, Helper.InterpolateForEnvironmentVariables(child.InnerText)); | ||
618 | } | ||
619 | } | ||
620 | |||
621 | /// <summary> | ||
622 | /// Copies to. | ||
623 | /// </summary> | ||
624 | /// <param name="opt">The opt.</param> | ||
625 | public void CopyTo(OptionsNode opt) | ||
626 | { | ||
627 | if(opt == null) | ||
628 | { | ||
629 | return; | ||
630 | } | ||
631 | |||
632 | foreach(FieldInfo f in m_OptionFields.Values) | ||
633 | { | ||
634 | if(m_FieldsDefined.Contains(f.Name)) | ||
635 | { | ||
636 | f.SetValue(opt, f.GetValue(this)); | ||
637 | opt.m_FieldsDefined.Add(f.Name); | ||
638 | } | ||
639 | } | ||
640 | } | ||
641 | |||
642 | #endregion | ||
643 | } | ||
644 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ProcessNode.cs b/Prebuild/src/Core/Nodes/ProcessNode.cs deleted file mode 100644 index 6bfbe16..0000000 --- a/Prebuild/src/Core/Nodes/ProcessNode.cs +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Xml; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using Prebuild.Core.Utilities; | ||
34 | |||
35 | namespace Prebuild.Core.Nodes | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// | ||
39 | /// </summary> | ||
40 | [DataNode("Process")] | ||
41 | public class ProcessNode : DataNode | ||
42 | { | ||
43 | #region Fields | ||
44 | |||
45 | private string m_Path; | ||
46 | private bool m_IsValid = true; | ||
47 | |||
48 | #endregion | ||
49 | |||
50 | #region Properties | ||
51 | |||
52 | /// <summary> | ||
53 | /// Gets the path. | ||
54 | /// </summary> | ||
55 | /// <value>The path.</value> | ||
56 | public string Path | ||
57 | { | ||
58 | get | ||
59 | { | ||
60 | return m_Path; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Gets a value indicating whether this instance is valid. | ||
66 | /// </summary> | ||
67 | /// <value><c>true</c> if this instance is valid; otherwise, <c>false</c>.</value> | ||
68 | public bool IsValid | ||
69 | { | ||
70 | get | ||
71 | { | ||
72 | return m_IsValid; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | #endregion | ||
77 | |||
78 | #region Public Methods | ||
79 | |||
80 | /// <summary> | ||
81 | /// Parses the specified node. | ||
82 | /// </summary> | ||
83 | /// <param name="node">The node.</param> | ||
84 | public override void Parse(XmlNode node) | ||
85 | { | ||
86 | if( node == null ) | ||
87 | { | ||
88 | throw new ArgumentNullException("node"); | ||
89 | } | ||
90 | |||
91 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
92 | if(m_Path == null) | ||
93 | { | ||
94 | m_Path = ""; | ||
95 | } | ||
96 | |||
97 | try | ||
98 | { | ||
99 | m_Path = Helper.ResolvePath(m_Path); | ||
100 | } | ||
101 | catch(ArgumentException) | ||
102 | { | ||
103 | Kernel.Instance.Log.Write(LogType.Warning, "Could not find prebuild file for processing: {0}", m_Path); | ||
104 | m_IsValid = false; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | #endregion | ||
109 | } | ||
110 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs deleted file mode 100644 index 04af7a3..0000000 --- a/Prebuild/src/Core/Nodes/ProjectNode.cs +++ /dev/null | |||
@@ -1,580 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Xml; | ||
31 | |||
32 | using Prebuild.Core.Attributes; | ||
33 | using Prebuild.Core.Interfaces; | ||
34 | using Prebuild.Core.Utilities; | ||
35 | |||
36 | namespace Prebuild.Core.Nodes | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// A set of values that the Project's type can be | ||
40 | /// </summary> | ||
41 | public enum ProjectType | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// The project is a console executable | ||
45 | /// </summary> | ||
46 | Exe, | ||
47 | /// <summary> | ||
48 | /// The project is a windows executable | ||
49 | /// </summary> | ||
50 | WinExe, | ||
51 | /// <summary> | ||
52 | /// The project is a library | ||
53 | /// </summary> | ||
54 | Library, | ||
55 | /// <summary> | ||
56 | /// The project is a website | ||
57 | /// </summary> | ||
58 | Web, | ||
59 | } | ||
60 | |||
61 | /// <summary> | ||
62 | /// | ||
63 | /// </summary> | ||
64 | public enum ClrRuntime | ||
65 | { | ||
66 | /// <summary> | ||
67 | /// | ||
68 | /// </summary> | ||
69 | Microsoft, | ||
70 | /// <summary> | ||
71 | /// | ||
72 | /// </summary> | ||
73 | Mono | ||
74 | } | ||
75 | /// <summary> | ||
76 | /// The version of the .NET framework to use (Required for VS2008) | ||
77 | /// <remarks>We don't need .NET 1.1 in here, it'll default when using vs2003.</remarks> | ||
78 | /// </summary> | ||
79 | public enum FrameworkVersion | ||
80 | { | ||
81 | /// <summary> | ||
82 | /// .NET 2.0 | ||
83 | /// </summary> | ||
84 | v2_0, | ||
85 | /// <summary> | ||
86 | /// .NET 3.0 | ||
87 | /// </summary> | ||
88 | v3_0, | ||
89 | /// <summary> | ||
90 | /// .NET 3.5 | ||
91 | /// </summary> | ||
92 | v3_5, | ||
93 | /// <summary> | ||
94 | /// .NET 4.0 | ||
95 | /// </summary> | ||
96 | v4_0, | ||
97 | } | ||
98 | /// <summary> | ||
99 | /// The Node object representing /Prebuild/Solution/Project elements | ||
100 | /// </summary> | ||
101 | [DataNode("Project")] | ||
102 | public class ProjectNode : DataNode, IComparable | ||
103 | { | ||
104 | #region Fields | ||
105 | |||
106 | private string m_Name = "unknown"; | ||
107 | private string m_Path = ""; | ||
108 | private string m_FullPath = ""; | ||
109 | private string m_AssemblyName; | ||
110 | private string m_AppIcon = ""; | ||
111 | private string m_ConfigFile = ""; | ||
112 | private string m_DesignerFolder = ""; | ||
113 | private string m_Language = "C#"; | ||
114 | private ProjectType m_Type = ProjectType.Exe; | ||
115 | private ClrRuntime m_Runtime = ClrRuntime.Microsoft; | ||
116 | private FrameworkVersion m_Framework = FrameworkVersion.v2_0; | ||
117 | private string m_StartupObject = ""; | ||
118 | private string m_RootNamespace; | ||
119 | private string m_FilterGroups = ""; | ||
120 | private string m_Version = ""; | ||
121 | private Guid m_Guid; | ||
122 | private string m_DebugStartParameters; | ||
123 | |||
124 | private Hashtable m_Configurations = new Hashtable(); | ||
125 | private readonly List<ReferencePathNode> m_ReferencePaths = new List<ReferencePathNode>(); | ||
126 | private readonly List<ReferenceNode> m_References = new List<ReferenceNode>(); | ||
127 | private readonly List<AuthorNode> m_Authors = new List<AuthorNode>(); | ||
128 | private FilesNode m_Files; | ||
129 | |||
130 | #endregion | ||
131 | |||
132 | #region Properties | ||
133 | |||
134 | /// <summary> | ||
135 | /// Gets the name. | ||
136 | /// </summary> | ||
137 | /// <value>The name.</value> | ||
138 | public string Name | ||
139 | { | ||
140 | get | ||
141 | { | ||
142 | return m_Name; | ||
143 | } | ||
144 | } | ||
145 | /// <summary> | ||
146 | /// The version of the .NET Framework to compile under | ||
147 | /// </summary> | ||
148 | public FrameworkVersion FrameworkVersion | ||
149 | { | ||
150 | get | ||
151 | { | ||
152 | return this.m_Framework; | ||
153 | } | ||
154 | } | ||
155 | /// <summary> | ||
156 | /// Gets the path. | ||
157 | /// </summary> | ||
158 | /// <value>The path.</value> | ||
159 | public string Path | ||
160 | { | ||
161 | get | ||
162 | { | ||
163 | return m_Path; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | /// <summary> | ||
168 | /// Gets the filter groups. | ||
169 | /// </summary> | ||
170 | /// <value>The filter groups.</value> | ||
171 | public string FilterGroups | ||
172 | { | ||
173 | get | ||
174 | { | ||
175 | return m_FilterGroups; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | /// <summary> | ||
180 | /// Gets the project's version | ||
181 | /// </summary> | ||
182 | /// <value>The project's version.</value> | ||
183 | public string Version | ||
184 | { | ||
185 | get | ||
186 | { | ||
187 | return m_Version; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | /// <summary> | ||
192 | /// Gets the full path. | ||
193 | /// </summary> | ||
194 | /// <value>The full path.</value> | ||
195 | public string FullPath | ||
196 | { | ||
197 | get | ||
198 | { | ||
199 | return m_FullPath; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | /// <summary> | ||
204 | /// Gets the name of the assembly. | ||
205 | /// </summary> | ||
206 | /// <value>The name of the assembly.</value> | ||
207 | public string AssemblyName | ||
208 | { | ||
209 | get | ||
210 | { | ||
211 | return m_AssemblyName; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | /// <summary> | ||
216 | /// Gets the app icon. | ||
217 | /// </summary> | ||
218 | /// <value>The app icon.</value> | ||
219 | public string AppIcon | ||
220 | { | ||
221 | get | ||
222 | { | ||
223 | return m_AppIcon; | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /// <summary> | ||
228 | /// Gets the app icon. | ||
229 | /// </summary> | ||
230 | /// <value>The app icon.</value> | ||
231 | public string ConfigFile | ||
232 | { | ||
233 | get | ||
234 | { | ||
235 | return m_ConfigFile; | ||
236 | } | ||
237 | } | ||
238 | |||
239 | /// <summary> | ||
240 | /// | ||
241 | /// </summary> | ||
242 | public string DesignerFolder | ||
243 | { | ||
244 | get | ||
245 | { | ||
246 | return m_DesignerFolder; | ||
247 | } | ||
248 | } | ||
249 | |||
250 | /// <summary> | ||
251 | /// Gets the language. | ||
252 | /// </summary> | ||
253 | /// <value>The language.</value> | ||
254 | public string Language | ||
255 | { | ||
256 | get | ||
257 | { | ||
258 | return m_Language; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | /// <summary> | ||
263 | /// Gets the type. | ||
264 | /// </summary> | ||
265 | /// <value>The type.</value> | ||
266 | public ProjectType Type | ||
267 | { | ||
268 | get | ||
269 | { | ||
270 | return m_Type; | ||
271 | } | ||
272 | } | ||
273 | |||
274 | /// <summary> | ||
275 | /// Gets the runtime. | ||
276 | /// </summary> | ||
277 | /// <value>The runtime.</value> | ||
278 | public ClrRuntime Runtime | ||
279 | { | ||
280 | get | ||
281 | { | ||
282 | return m_Runtime; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | private bool m_GenerateAssemblyInfoFile = false; | ||
287 | |||
288 | /// <summary> | ||
289 | /// | ||
290 | /// </summary> | ||
291 | public bool GenerateAssemblyInfoFile | ||
292 | { | ||
293 | get | ||
294 | { | ||
295 | return m_GenerateAssemblyInfoFile; | ||
296 | } | ||
297 | set | ||
298 | { | ||
299 | m_GenerateAssemblyInfoFile = value; | ||
300 | } | ||
301 | } | ||
302 | |||
303 | /// <summary> | ||
304 | /// Gets the startup object. | ||
305 | /// </summary> | ||
306 | /// <value>The startup object.</value> | ||
307 | public string StartupObject | ||
308 | { | ||
309 | get | ||
310 | { | ||
311 | return m_StartupObject; | ||
312 | } | ||
313 | } | ||
314 | |||
315 | /// <summary> | ||
316 | /// Gets the root namespace. | ||
317 | /// </summary> | ||
318 | /// <value>The root namespace.</value> | ||
319 | public string RootNamespace | ||
320 | { | ||
321 | get | ||
322 | { | ||
323 | return m_RootNamespace; | ||
324 | } | ||
325 | } | ||
326 | |||
327 | /// <summary> | ||
328 | /// Gets the configurations. | ||
329 | /// </summary> | ||
330 | /// <value>The configurations.</value> | ||
331 | public IList Configurations | ||
332 | { | ||
333 | get | ||
334 | { | ||
335 | ArrayList tmp = new ArrayList(ConfigurationsTable.Values); | ||
336 | tmp.Sort(); | ||
337 | return tmp; | ||
338 | } | ||
339 | } | ||
340 | |||
341 | /// <summary> | ||
342 | /// Gets the configurations table. | ||
343 | /// </summary> | ||
344 | /// <value>The configurations table.</value> | ||
345 | public Hashtable ConfigurationsTable | ||
346 | { | ||
347 | get | ||
348 | { | ||
349 | return m_Configurations; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | /// <summary> | ||
354 | /// Gets the reference paths. | ||
355 | /// </summary> | ||
356 | /// <value>The reference paths.</value> | ||
357 | public List<ReferencePathNode> ReferencePaths | ||
358 | { | ||
359 | get | ||
360 | { | ||
361 | List<ReferencePathNode> tmp = new List<ReferencePathNode>(m_ReferencePaths); | ||
362 | tmp.Sort(); | ||
363 | return tmp; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | /// <summary> | ||
368 | /// Gets the references. | ||
369 | /// </summary> | ||
370 | /// <value>The references.</value> | ||
371 | public List<ReferenceNode> References | ||
372 | { | ||
373 | get | ||
374 | { | ||
375 | List<ReferenceNode> tmp = new List<ReferenceNode>(m_References); | ||
376 | tmp.Sort(); | ||
377 | return tmp; | ||
378 | } | ||
379 | } | ||
380 | |||
381 | /// <summary> | ||
382 | /// Gets the Authors list. | ||
383 | /// </summary> | ||
384 | /// <value>The list of the project's authors.</value> | ||
385 | public List<AuthorNode> Authors | ||
386 | { | ||
387 | get | ||
388 | { | ||
389 | return m_Authors; | ||
390 | } | ||
391 | } | ||
392 | |||
393 | /// <summary> | ||
394 | /// Gets the files. | ||
395 | /// </summary> | ||
396 | /// <value>The files.</value> | ||
397 | public FilesNode Files | ||
398 | { | ||
399 | get | ||
400 | { | ||
401 | return m_Files; | ||
402 | } | ||
403 | } | ||
404 | |||
405 | /// <summary> | ||
406 | /// Gets or sets the parent. | ||
407 | /// </summary> | ||
408 | /// <value>The parent.</value> | ||
409 | public override IDataNode Parent | ||
410 | { | ||
411 | get | ||
412 | { | ||
413 | return base.Parent; | ||
414 | } | ||
415 | set | ||
416 | { | ||
417 | base.Parent = value; | ||
418 | if(base.Parent is SolutionNode && m_Configurations.Count < 1) | ||
419 | { | ||
420 | SolutionNode parent = (SolutionNode)base.Parent; | ||
421 | foreach(ConfigurationNode conf in parent.Configurations) | ||
422 | { | ||
423 | m_Configurations[conf.Name] = conf.Clone(); | ||
424 | } | ||
425 | } | ||
426 | } | ||
427 | } | ||
428 | |||
429 | /// <summary> | ||
430 | /// Gets the GUID. | ||
431 | /// </summary> | ||
432 | /// <value>The GUID.</value> | ||
433 | public Guid Guid | ||
434 | { | ||
435 | get | ||
436 | { | ||
437 | return m_Guid; | ||
438 | } | ||
439 | } | ||
440 | |||
441 | public string DebugStartParameters | ||
442 | { | ||
443 | get | ||
444 | { | ||
445 | return m_DebugStartParameters; | ||
446 | } | ||
447 | } | ||
448 | |||
449 | #endregion | ||
450 | |||
451 | #region Private Methods | ||
452 | |||
453 | private void HandleConfiguration(ConfigurationNode conf) | ||
454 | { | ||
455 | if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first, | ||
456 | //so it *may* override changes to the same properties for configurations defines at the project level | ||
457 | { | ||
458 | foreach(ConfigurationNode confNode in this.m_Configurations.Values) | ||
459 | { | ||
460 | conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides | ||
461 | } | ||
462 | } | ||
463 | if(m_Configurations.ContainsKey(conf.Name)) | ||
464 | { | ||
465 | ConfigurationNode parentConf = (ConfigurationNode)m_Configurations[conf.Name]; | ||
466 | conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides | ||
467 | } | ||
468 | else | ||
469 | { | ||
470 | m_Configurations[conf.Name] = conf; | ||
471 | } | ||
472 | } | ||
473 | |||
474 | #endregion | ||
475 | |||
476 | #region Public Methods | ||
477 | |||
478 | /// <summary> | ||
479 | /// Parses the specified node. | ||
480 | /// </summary> | ||
481 | /// <param name="node">The node.</param> | ||
482 | public override void Parse(XmlNode node) | ||
483 | { | ||
484 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
485 | m_Path = Helper.AttributeValue(node, "path", m_Path); | ||
486 | m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups); | ||
487 | m_Version = Helper.AttributeValue(node, "version", m_Version); | ||
488 | m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon); | ||
489 | m_ConfigFile = Helper.AttributeValue(node, "configFile", m_ConfigFile); | ||
490 | m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder); | ||
491 | m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName); | ||
492 | m_Language = Helper.AttributeValue(node, "language", m_Language); | ||
493 | m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type); | ||
494 | m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime); | ||
495 | m_Framework = (FrameworkVersion)Helper.EnumAttributeValue(node, "frameworkVersion", typeof(FrameworkVersion), m_Framework); | ||
496 | m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject); | ||
497 | m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace); | ||
498 | |||
499 | int hash = m_Name.GetHashCode(); | ||
500 | Guid guidByHash = new Guid(hash, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
501 | string guid = Helper.AttributeValue(node, "guid", guidByHash.ToString()); | ||
502 | m_Guid = new Guid(guid); | ||
503 | |||
504 | m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false); | ||
505 | m_DebugStartParameters = Helper.AttributeValue(node, "debugStartParameters", string.Empty); | ||
506 | |||
507 | if(m_AssemblyName == null || m_AssemblyName.Length < 1) | ||
508 | { | ||
509 | m_AssemblyName = m_Name; | ||
510 | } | ||
511 | |||
512 | if(m_RootNamespace == null || m_RootNamespace.Length < 1) | ||
513 | { | ||
514 | m_RootNamespace = m_Name; | ||
515 | } | ||
516 | |||
517 | m_FullPath = m_Path; | ||
518 | try | ||
519 | { | ||
520 | m_FullPath = Helper.ResolvePath(m_FullPath); | ||
521 | } | ||
522 | catch | ||
523 | { | ||
524 | throw new WarningException("Could not resolve Solution path: {0}", m_Path); | ||
525 | } | ||
526 | |||
527 | Kernel.Instance.CurrentWorkingDirectory.Push(); | ||
528 | try | ||
529 | { | ||
530 | Helper.SetCurrentDir(m_FullPath); | ||
531 | |||
532 | if( node == null ) | ||
533 | { | ||
534 | throw new ArgumentNullException("node"); | ||
535 | } | ||
536 | |||
537 | foreach(XmlNode child in node.ChildNodes) | ||
538 | { | ||
539 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
540 | if(dataNode is ConfigurationNode) | ||
541 | { | ||
542 | HandleConfiguration((ConfigurationNode)dataNode); | ||
543 | } | ||
544 | else if(dataNode is ReferencePathNode) | ||
545 | { | ||
546 | m_ReferencePaths.Add((ReferencePathNode)dataNode); | ||
547 | } | ||
548 | else if(dataNode is ReferenceNode) | ||
549 | { | ||
550 | m_References.Add((ReferenceNode)dataNode); | ||
551 | } | ||
552 | else if(dataNode is AuthorNode) | ||
553 | { | ||
554 | m_Authors.Add((AuthorNode)dataNode); | ||
555 | } | ||
556 | else if(dataNode is FilesNode) | ||
557 | { | ||
558 | m_Files = (FilesNode)dataNode; | ||
559 | } | ||
560 | } | ||
561 | } | ||
562 | finally | ||
563 | { | ||
564 | Kernel.Instance.CurrentWorkingDirectory.Pop(); | ||
565 | } | ||
566 | } | ||
567 | |||
568 | #endregion | ||
569 | |||
570 | #region IComparable Members | ||
571 | |||
572 | public int CompareTo(object obj) | ||
573 | { | ||
574 | ProjectNode that = (ProjectNode)obj; | ||
575 | return this.m_Name.CompareTo(that.m_Name); | ||
576 | } | ||
577 | |||
578 | #endregion | ||
579 | } | ||
580 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ReferenceNode.cs b/Prebuild/src/Core/Nodes/ReferenceNode.cs deleted file mode 100644 index 9c5d1a3..0000000 --- a/Prebuild/src/Core/Nodes/ReferenceNode.cs +++ /dev/null | |||
@@ -1,144 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Xml; | ||
28 | |||
29 | using Prebuild.Core.Attributes; | ||
30 | using Prebuild.Core.Interfaces; | ||
31 | using Prebuild.Core.Utilities; | ||
32 | |||
33 | namespace Prebuild.Core.Nodes | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// | ||
37 | /// </summary> | ||
38 | [DataNode("Reference")] | ||
39 | public class ReferenceNode : DataNode, IComparable | ||
40 | { | ||
41 | #region Fields | ||
42 | |||
43 | private string m_Name = "unknown"; | ||
44 | private string m_Path; | ||
45 | private string m_LocalCopy; | ||
46 | private string m_Version; | ||
47 | |||
48 | #endregion | ||
49 | |||
50 | #region Properties | ||
51 | |||
52 | /// <summary> | ||
53 | /// Gets the name. | ||
54 | /// </summary> | ||
55 | /// <value>The name.</value> | ||
56 | public string Name | ||
57 | { | ||
58 | get | ||
59 | { | ||
60 | return m_Name; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Gets the path. | ||
66 | /// </summary> | ||
67 | /// <value>The path.</value> | ||
68 | public string Path | ||
69 | { | ||
70 | get | ||
71 | { | ||
72 | return m_Path; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Gets a value indicating whether [local copy specified]. | ||
78 | /// </summary> | ||
79 | /// <value><c>true</c> if [local copy specified]; otherwise, <c>false</c>.</value> | ||
80 | public bool LocalCopySpecified | ||
81 | { | ||
82 | get | ||
83 | { | ||
84 | return ( m_LocalCopy != null && m_LocalCopy.Length == 0); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | /// <summary> | ||
89 | /// Gets a value indicating whether [local copy]. | ||
90 | /// </summary> | ||
91 | /// <value><c>true</c> if [local copy]; otherwise, <c>false</c>.</value> | ||
92 | public bool LocalCopy | ||
93 | { | ||
94 | get | ||
95 | { | ||
96 | if( m_LocalCopy == null) | ||
97 | { | ||
98 | return false; | ||
99 | } | ||
100 | return bool.Parse(m_LocalCopy); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Gets the version. | ||
106 | /// </summary> | ||
107 | /// <value>The version.</value> | ||
108 | public string Version | ||
109 | { | ||
110 | get | ||
111 | { | ||
112 | return m_Version; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | #endregion | ||
117 | |||
118 | #region Public Methods | ||
119 | |||
120 | /// <summary> | ||
121 | /// Parses the specified node. | ||
122 | /// </summary> | ||
123 | /// <param name="node">The node.</param> | ||
124 | public override void Parse(XmlNode node) | ||
125 | { | ||
126 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
127 | m_Path = Helper.AttributeValue(node, "path", m_Path); | ||
128 | m_LocalCopy = Helper.AttributeValue(node, "localCopy", m_LocalCopy); | ||
129 | m_Version = Helper.AttributeValue(node, "version", m_Version); | ||
130 | } | ||
131 | |||
132 | #endregion | ||
133 | |||
134 | #region IComparable Members | ||
135 | |||
136 | public int CompareTo(object obj) | ||
137 | { | ||
138 | ReferenceNode that = (ReferenceNode)obj; | ||
139 | return this.m_Name.CompareTo(that.m_Name); | ||
140 | } | ||
141 | |||
142 | #endregion | ||
143 | } | ||
144 | } | ||
diff --git a/Prebuild/src/Core/Nodes/ReferencePathNode.cs b/Prebuild/src/Core/Nodes/ReferencePathNode.cs deleted file mode 100644 index f0543c2..0000000 --- a/Prebuild/src/Core/Nodes/ReferencePathNode.cs +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Xml; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using Prebuild.Core.Utilities; | ||
34 | |||
35 | namespace Prebuild.Core.Nodes | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// | ||
39 | /// </summary> | ||
40 | [DataNode("ReferencePath")] | ||
41 | public class ReferencePathNode : DataNode, IComparable | ||
42 | { | ||
43 | #region Fields | ||
44 | |||
45 | private string m_Path; | ||
46 | |||
47 | #endregion | ||
48 | |||
49 | #region Properties | ||
50 | |||
51 | /// <summary> | ||
52 | /// Gets the path. | ||
53 | /// </summary> | ||
54 | /// <value>The path.</value> | ||
55 | public string Path | ||
56 | { | ||
57 | get | ||
58 | { | ||
59 | return m_Path; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | #endregion | ||
64 | |||
65 | #region Public Methods | ||
66 | |||
67 | /// <summary> | ||
68 | /// Parses the specified node. | ||
69 | /// </summary> | ||
70 | /// <param name="node">The node.</param> | ||
71 | public override void Parse(XmlNode node) | ||
72 | { | ||
73 | if( node == null ) | ||
74 | { | ||
75 | throw new ArgumentNullException("node"); | ||
76 | } | ||
77 | |||
78 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
79 | if(m_Path == null) | ||
80 | { | ||
81 | m_Path = ""; | ||
82 | } | ||
83 | |||
84 | m_Path = m_Path.Trim(); | ||
85 | } | ||
86 | |||
87 | #endregion | ||
88 | |||
89 | #region IComparable Members | ||
90 | |||
91 | public int CompareTo(object obj) | ||
92 | { | ||
93 | ReferencePathNode that = (ReferencePathNode)obj; | ||
94 | return this.m_Path.CompareTo(that.m_Path); | ||
95 | } | ||
96 | |||
97 | #endregion | ||
98 | } | ||
99 | } | ||
diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs deleted file mode 100644 index 2a1b8e2..0000000 --- a/Prebuild/src/Core/Nodes/SolutionNode.cs +++ /dev/null | |||
@@ -1,358 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Diagnostics; | ||
30 | using System.IO; | ||
31 | using System.Xml; | ||
32 | |||
33 | using Prebuild.Core.Attributes; | ||
34 | using Prebuild.Core.Interfaces; | ||
35 | using Prebuild.Core.Utilities; | ||
36 | |||
37 | namespace Prebuild.Core.Nodes | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// | ||
41 | /// </summary> | ||
42 | [DataNode("Solution")] | ||
43 | [DataNode("EmbeddedSolution")] | ||
44 | [DebuggerDisplay("{Name}")] | ||
45 | public class SolutionNode : DataNode | ||
46 | { | ||
47 | #region Fields | ||
48 | |||
49 | private Guid m_Guid = Guid.NewGuid(); | ||
50 | private string m_Name = "unknown"; | ||
51 | private string m_Path = ""; | ||
52 | private string m_FullPath = ""; | ||
53 | private string m_ActiveConfig = "Debug"; | ||
54 | private string m_Version = "1.0.0"; | ||
55 | |||
56 | private OptionsNode m_Options; | ||
57 | private FilesNode m_Files; | ||
58 | private readonly Hashtable m_Configurations = new Hashtable(); | ||
59 | private readonly Hashtable m_Projects = new Hashtable(); | ||
60 | private readonly Hashtable m_DatabaseProjects = new Hashtable(); | ||
61 | private readonly List<ProjectNode> m_ProjectsOrder = new List<ProjectNode>(); | ||
62 | private readonly Hashtable m_Solutions = new Hashtable(); | ||
63 | |||
64 | #endregion | ||
65 | |||
66 | #region Properties | ||
67 | public override IDataNode Parent | ||
68 | { | ||
69 | get | ||
70 | { | ||
71 | return base.Parent; | ||
72 | } | ||
73 | set | ||
74 | { | ||
75 | if (value is SolutionNode) | ||
76 | { | ||
77 | SolutionNode solution = (SolutionNode)value; | ||
78 | foreach (ConfigurationNode conf in solution.Configurations) | ||
79 | { | ||
80 | m_Configurations[conf.Name] = conf.Clone(); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | base.Parent = value; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | public Guid Guid | ||
89 | { | ||
90 | get | ||
91 | { | ||
92 | return m_Guid; | ||
93 | } | ||
94 | set | ||
95 | { | ||
96 | m_Guid = value; | ||
97 | } | ||
98 | } | ||
99 | /// <summary> | ||
100 | /// Gets or sets the active config. | ||
101 | /// </summary> | ||
102 | /// <value>The active config.</value> | ||
103 | public string ActiveConfig | ||
104 | { | ||
105 | get | ||
106 | { | ||
107 | return m_ActiveConfig; | ||
108 | } | ||
109 | set | ||
110 | { | ||
111 | m_ActiveConfig = value; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /// <summary> | ||
116 | /// Gets the name. | ||
117 | /// </summary> | ||
118 | /// <value>The name.</value> | ||
119 | public string Name | ||
120 | { | ||
121 | get | ||
122 | { | ||
123 | return m_Name; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// Gets the path. | ||
129 | /// </summary> | ||
130 | /// <value>The path.</value> | ||
131 | public string Path | ||
132 | { | ||
133 | get | ||
134 | { | ||
135 | return m_Path; | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /// <summary> | ||
140 | /// Gets the full path. | ||
141 | /// </summary> | ||
142 | /// <value>The full path.</value> | ||
143 | public string FullPath | ||
144 | { | ||
145 | get | ||
146 | { | ||
147 | return m_FullPath; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | /// <summary> | ||
152 | /// Gets the version. | ||
153 | /// </summary> | ||
154 | /// <value>The version.</value> | ||
155 | public string Version | ||
156 | { | ||
157 | get | ||
158 | { | ||
159 | return m_Version; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | /// <summary> | ||
164 | /// Gets the options. | ||
165 | /// </summary> | ||
166 | /// <value>The options.</value> | ||
167 | public OptionsNode Options | ||
168 | { | ||
169 | get | ||
170 | { | ||
171 | return m_Options; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | /// <summary> | ||
176 | /// Gets the files. | ||
177 | /// </summary> | ||
178 | /// <value>The files.</value> | ||
179 | public FilesNode Files | ||
180 | { | ||
181 | get | ||
182 | { | ||
183 | return m_Files; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | /// <summary> | ||
188 | /// Gets the configurations. | ||
189 | /// </summary> | ||
190 | /// <value>The configurations.</value> | ||
191 | public ICollection Configurations | ||
192 | { | ||
193 | get | ||
194 | { | ||
195 | ArrayList tmp = new ArrayList(ConfigurationsTable.Values); | ||
196 | tmp.Sort(); | ||
197 | return tmp; | ||
198 | } | ||
199 | } | ||
200 | |||
201 | /// <summary> | ||
202 | /// Gets the configurations table. | ||
203 | /// </summary> | ||
204 | /// <value>The configurations table.</value> | ||
205 | public Hashtable ConfigurationsTable | ||
206 | { | ||
207 | get | ||
208 | { | ||
209 | return m_Configurations; | ||
210 | } | ||
211 | } | ||
212 | /// <summary> | ||
213 | /// Gets the database projects. | ||
214 | /// </summary> | ||
215 | public ICollection DatabaseProjects | ||
216 | { | ||
217 | get | ||
218 | { | ||
219 | return m_DatabaseProjects.Values; | ||
220 | } | ||
221 | } | ||
222 | /// <summary> | ||
223 | /// Gets the nested solutions. | ||
224 | /// </summary> | ||
225 | public ICollection Solutions | ||
226 | { | ||
227 | get | ||
228 | { | ||
229 | return m_Solutions.Values; | ||
230 | } | ||
231 | } | ||
232 | /// <summary> | ||
233 | /// Gets the nested solutions hash table. | ||
234 | /// </summary> | ||
235 | public Hashtable SolutionsTable | ||
236 | { | ||
237 | get | ||
238 | { | ||
239 | return this.m_Solutions; | ||
240 | } | ||
241 | } | ||
242 | /// <summary> | ||
243 | /// Gets the projects. | ||
244 | /// </summary> | ||
245 | /// <value>The projects.</value> | ||
246 | public ICollection Projects | ||
247 | { | ||
248 | get | ||
249 | { | ||
250 | ArrayList tmp = new ArrayList(m_Projects.Values); | ||
251 | tmp.Sort(); | ||
252 | return tmp; | ||
253 | } | ||
254 | } | ||
255 | |||
256 | /// <summary> | ||
257 | /// Gets the projects table. | ||
258 | /// </summary> | ||
259 | /// <value>The projects table.</value> | ||
260 | public Hashtable ProjectsTable | ||
261 | { | ||
262 | get | ||
263 | { | ||
264 | return m_Projects; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | /// <summary> | ||
269 | /// Gets the projects table. | ||
270 | /// </summary> | ||
271 | /// <value>The projects table.</value> | ||
272 | public List<ProjectNode> ProjectsTableOrder | ||
273 | { | ||
274 | get | ||
275 | { | ||
276 | return m_ProjectsOrder; | ||
277 | } | ||
278 | } | ||
279 | |||
280 | #endregion | ||
281 | |||
282 | #region Public Methods | ||
283 | |||
284 | /// <summary> | ||
285 | /// Parses the specified node. | ||
286 | /// </summary> | ||
287 | /// <param name="node">The node.</param> | ||
288 | public override void Parse(XmlNode node) | ||
289 | { | ||
290 | m_Name = Helper.AttributeValue(node, "name", m_Name); | ||
291 | m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); | ||
292 | m_Path = Helper.AttributeValue(node, "path", m_Path); | ||
293 | m_Version = Helper.AttributeValue(node, "version", m_Version); | ||
294 | |||
295 | m_FullPath = m_Path; | ||
296 | try | ||
297 | { | ||
298 | m_FullPath = Helper.ResolvePath(m_FullPath); | ||
299 | } | ||
300 | catch | ||
301 | { | ||
302 | throw new WarningException("Could not resolve solution path: {0}", m_Path); | ||
303 | } | ||
304 | |||
305 | Kernel.Instance.CurrentWorkingDirectory.Push(); | ||
306 | try | ||
307 | { | ||
308 | Helper.SetCurrentDir(m_FullPath); | ||
309 | |||
310 | if( node == null ) | ||
311 | { | ||
312 | throw new ArgumentNullException("node"); | ||
313 | } | ||
314 | |||
315 | foreach(XmlNode child in node.ChildNodes) | ||
316 | { | ||
317 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
318 | if(dataNode is OptionsNode) | ||
319 | { | ||
320 | m_Options = (OptionsNode)dataNode; | ||
321 | } | ||
322 | else if(dataNode is FilesNode) | ||
323 | { | ||
324 | m_Files = (FilesNode)dataNode; | ||
325 | } | ||
326 | else if(dataNode is ConfigurationNode) | ||
327 | { | ||
328 | m_Configurations[((ConfigurationNode)dataNode).Name] = dataNode; | ||
329 | } | ||
330 | else if(dataNode is ProjectNode) | ||
331 | { | ||
332 | m_Projects[((ProjectNode)dataNode).Name] = dataNode; | ||
333 | m_ProjectsOrder.Add((ProjectNode)dataNode); | ||
334 | } | ||
335 | else if(dataNode is SolutionNode) | ||
336 | { | ||
337 | m_Solutions[((SolutionNode)dataNode).Name] = dataNode; | ||
338 | } | ||
339 | else if (dataNode is ProcessNode) | ||
340 | { | ||
341 | ProcessNode p = (ProcessNode)dataNode; | ||
342 | Kernel.Instance.ProcessFile(p, this); | ||
343 | } | ||
344 | else if (dataNode is DatabaseProjectNode) | ||
345 | { | ||
346 | m_DatabaseProjects[((DatabaseProjectNode)dataNode).Name] = dataNode; | ||
347 | } | ||
348 | } | ||
349 | } | ||
350 | finally | ||
351 | { | ||
352 | Kernel.Instance.CurrentWorkingDirectory.Pop(); | ||
353 | } | ||
354 | } | ||
355 | |||
356 | #endregion | ||
357 | } | ||
358 | } | ||
diff --git a/Prebuild/src/Core/Parse/IfContext.cs b/Prebuild/src/Core/Parse/IfContext.cs deleted file mode 100644 index 3c79d38..0000000 --- a/Prebuild/src/Core/Parse/IfContext.cs +++ /dev/null | |||
@@ -1,154 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | |||
28 | namespace Prebuild.Core.Parse | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// | ||
32 | /// </summary> | ||
33 | public enum IfState | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// | ||
37 | /// </summary> | ||
38 | None, | ||
39 | /// <summary> | ||
40 | /// | ||
41 | /// </summary> | ||
42 | If, | ||
43 | /// <summary> | ||
44 | /// | ||
45 | /// </summary> | ||
46 | ElseIf, | ||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | Else | ||
51 | } | ||
52 | |||
53 | /// <summary> | ||
54 | /// Summary description for IfContext. | ||
55 | /// </summary> | ||
56 | // Inspired by the equivalent WiX class (see www.sourceforge.net/projects/wix/) | ||
57 | public class IfContext | ||
58 | { | ||
59 | #region Properties | ||
60 | |||
61 | bool m_Active; | ||
62 | bool m_Keep; | ||
63 | bool m_EverKept; | ||
64 | IfState m_State = IfState.None; | ||
65 | |||
66 | #endregion | ||
67 | |||
68 | #region Constructors | ||
69 | |||
70 | /// <summary> | ||
71 | /// Initializes a new instance of the <see cref="IfContext"/> class. | ||
72 | /// </summary> | ||
73 | /// <param name="active">if set to <c>true</c> [active].</param> | ||
74 | /// <param name="keep">if set to <c>true</c> [keep].</param> | ||
75 | /// <param name="state">The state.</param> | ||
76 | public IfContext(bool active, bool keep, IfState state) | ||
77 | { | ||
78 | m_Active = active; | ||
79 | m_Keep = keep; | ||
80 | m_EverKept = keep; | ||
81 | m_State = state; | ||
82 | } | ||
83 | |||
84 | #endregion | ||
85 | |||
86 | #region Properties | ||
87 | |||
88 | /// <summary> | ||
89 | /// Gets or sets a value indicating whether this <see cref="IfContext"/> is active. | ||
90 | /// </summary> | ||
91 | /// <value><c>true</c> if active; otherwise, <c>false</c>.</value> | ||
92 | public bool Active | ||
93 | { | ||
94 | get | ||
95 | { | ||
96 | return m_Active; | ||
97 | } | ||
98 | set | ||
99 | { | ||
100 | m_Active = value; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Gets or sets a value indicating whether this <see cref="IfContext"/> is keep. | ||
106 | /// </summary> | ||
107 | /// <value><c>true</c> if keep; otherwise, <c>false</c>.</value> | ||
108 | public bool Keep | ||
109 | { | ||
110 | get | ||
111 | { | ||
112 | return m_Keep; | ||
113 | } | ||
114 | set | ||
115 | { | ||
116 | m_Keep = value; | ||
117 | if(m_Keep) | ||
118 | { | ||
119 | m_EverKept = true; | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /// <summary> | ||
125 | /// Gets a value indicating whether [ever kept]. | ||
126 | /// </summary> | ||
127 | /// <value><c>true</c> if [ever kept]; otherwise, <c>false</c>.</value> | ||
128 | public bool EverKept | ||
129 | { | ||
130 | get | ||
131 | { | ||
132 | return m_EverKept; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Gets or sets the state. | ||
138 | /// </summary> | ||
139 | /// <value>The state.</value> | ||
140 | public IfState State | ||
141 | { | ||
142 | get | ||
143 | { | ||
144 | return m_State; | ||
145 | } | ||
146 | set | ||
147 | { | ||
148 | m_State = value; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | #endregion | ||
153 | } | ||
154 | } | ||
diff --git a/Prebuild/src/Core/Parse/Preprocessor.cs b/Prebuild/src/Core/Parse/Preprocessor.cs deleted file mode 100644 index b2306e4..0000000 --- a/Prebuild/src/Core/Parse/Preprocessor.cs +++ /dev/null | |||
@@ -1,663 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.IO; | ||
29 | using System.Text.RegularExpressions; | ||
30 | using System.Xml; | ||
31 | |||
32 | namespace Prebuild.Core.Parse | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// | ||
36 | /// </summary> | ||
37 | public enum OperatorSymbol | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// | ||
41 | /// </summary> | ||
42 | None, | ||
43 | /// <summary> | ||
44 | /// | ||
45 | /// </summary> | ||
46 | Equal, | ||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | NotEqual, | ||
51 | /// <summary> | ||
52 | /// | ||
53 | /// </summary> | ||
54 | LessThan, | ||
55 | /// <summary> | ||
56 | /// | ||
57 | /// </summary> | ||
58 | GreaterThan, | ||
59 | /// <summary> | ||
60 | /// | ||
61 | /// </summary> | ||
62 | LessThanEqual, | ||
63 | /// <summary> | ||
64 | /// | ||
65 | /// </summary> | ||
66 | GreaterThanEqual | ||
67 | } | ||
68 | |||
69 | /// <summary> | ||
70 | /// | ||
71 | /// </summary> | ||
72 | public class Preprocessor | ||
73 | { | ||
74 | #region Constants | ||
75 | |||
76 | /// <summary> | ||
77 | /// Includes the regex to look for file tags in the <?include | ||
78 | /// ?> processing instruction. | ||
79 | /// </summary> | ||
80 | private static readonly Regex includeFileRegex = new Regex("file=\"(.+?)\""); | ||
81 | |||
82 | #endregion | ||
83 | |||
84 | #region Fields | ||
85 | |||
86 | XmlDocument m_OutDoc; | ||
87 | Stack m_IfStack; | ||
88 | Hashtable m_Variables; | ||
89 | |||
90 | #endregion | ||
91 | |||
92 | #region Constructors | ||
93 | |||
94 | /// <summary> | ||
95 | /// Initializes a new instance of the <see cref="Preprocessor"/> class. | ||
96 | /// </summary> | ||
97 | public Preprocessor() | ||
98 | { | ||
99 | m_OutDoc = new XmlDocument(); | ||
100 | m_IfStack = new Stack(); | ||
101 | m_Variables = new Hashtable(); | ||
102 | |||
103 | RegisterVariable("OS", GetOS()); | ||
104 | RegisterVariable("RuntimeVersion", Environment.Version.Major); | ||
105 | RegisterVariable("RuntimeMajor", Environment.Version.Major); | ||
106 | RegisterVariable("RuntimeMinor", Environment.Version.Minor); | ||
107 | RegisterVariable("RuntimeRevision", Environment.Version.Revision); | ||
108 | } | ||
109 | |||
110 | #endregion | ||
111 | |||
112 | #region Properties | ||
113 | |||
114 | /// <summary> | ||
115 | /// Gets the processed doc. | ||
116 | /// </summary> | ||
117 | /// <value>The processed doc.</value> | ||
118 | public XmlDocument ProcessedDoc | ||
119 | { | ||
120 | get | ||
121 | { | ||
122 | return m_OutDoc; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | #endregion | ||
127 | |||
128 | #region Private Methods | ||
129 | |||
130 | /// <summary> | ||
131 | /// Parts of this code were taken from NAnt and is subject to the GPL | ||
132 | /// as per NAnt's license. Thanks to the NAnt guys for this little gem. | ||
133 | /// </summary> | ||
134 | /// <returns></returns> | ||
135 | public static string GetOS() | ||
136 | { | ||
137 | PlatformID platId = Environment.OSVersion.Platform; | ||
138 | if(platId == PlatformID.Win32NT || platId == PlatformID.Win32Windows) | ||
139 | { | ||
140 | return "Win32"; | ||
141 | } | ||
142 | |||
143 | if (File.Exists("/System/Library/Frameworks/Cocoa.framework/Cocoa")) | ||
144 | { | ||
145 | return "MACOSX"; | ||
146 | } | ||
147 | |||
148 | /* | ||
149 | * .NET 1.x, under Mono, the UNIX code is 128. Under | ||
150 | * .NET 2.x, Mono or MS, the UNIX code is 4 | ||
151 | */ | ||
152 | if(Environment.Version.Major == 1) | ||
153 | { | ||
154 | if((int)platId == 128) | ||
155 | { | ||
156 | return "UNIX"; | ||
157 | } | ||
158 | } | ||
159 | else if((int)platId == 4) | ||
160 | { | ||
161 | return "UNIX"; | ||
162 | } | ||
163 | |||
164 | return "Unknown"; | ||
165 | } | ||
166 | |||
167 | private static bool CompareNum(OperatorSymbol oper, int val1, int val2) | ||
168 | { | ||
169 | switch(oper) | ||
170 | { | ||
171 | case OperatorSymbol.Equal: | ||
172 | return (val1 == val2); | ||
173 | case OperatorSymbol.NotEqual: | ||
174 | return (val1 != val2); | ||
175 | case OperatorSymbol.LessThan: | ||
176 | return (val1 < val2); | ||
177 | case OperatorSymbol.LessThanEqual: | ||
178 | return (val1 <= val2); | ||
179 | case OperatorSymbol.GreaterThan: | ||
180 | return (val1 > val2); | ||
181 | case OperatorSymbol.GreaterThanEqual: | ||
182 | return (val1 >= val2); | ||
183 | } | ||
184 | |||
185 | throw new WarningException("Unknown operator type"); | ||
186 | } | ||
187 | |||
188 | private static bool CompareStr(OperatorSymbol oper, string val1, string val2) | ||
189 | { | ||
190 | switch(oper) | ||
191 | { | ||
192 | case OperatorSymbol.Equal: | ||
193 | return (val1 == val2); | ||
194 | case OperatorSymbol.NotEqual: | ||
195 | return (val1 != val2); | ||
196 | case OperatorSymbol.LessThan: | ||
197 | return (val1.CompareTo(val2) < 0); | ||
198 | case OperatorSymbol.LessThanEqual: | ||
199 | return (val1.CompareTo(val2) <= 0); | ||
200 | case OperatorSymbol.GreaterThan: | ||
201 | return (val1.CompareTo(val2) > 0); | ||
202 | case OperatorSymbol.GreaterThanEqual: | ||
203 | return (val1.CompareTo(val2) >= 0); | ||
204 | } | ||
205 | |||
206 | throw new WarningException("Unknown operator type"); | ||
207 | } | ||
208 | |||
209 | private static char NextChar(int idx, string str) | ||
210 | { | ||
211 | if((idx + 1) >= str.Length) | ||
212 | { | ||
213 | return Char.MaxValue; | ||
214 | } | ||
215 | |||
216 | return str[idx + 1]; | ||
217 | } | ||
218 | // Very very simple expression parser. Can only match expressions of the form | ||
219 | // <var> <op> <value>: | ||
220 | // OS = Windows | ||
221 | // OS != Linux | ||
222 | // RuntimeMinor > 0 | ||
223 | private bool ParseExpression(string exp) | ||
224 | { | ||
225 | if(exp == null) | ||
226 | { | ||
227 | throw new ArgumentException("Invalid expression, cannot be null"); | ||
228 | } | ||
229 | |||
230 | exp = exp.Trim(); | ||
231 | if(exp.Length < 1) | ||
232 | { | ||
233 | throw new ArgumentException("Invalid expression, cannot be 0 length"); | ||
234 | } | ||
235 | |||
236 | string id = ""; | ||
237 | string str = ""; | ||
238 | OperatorSymbol oper = OperatorSymbol.None; | ||
239 | bool inStr = false; | ||
240 | char c; | ||
241 | |||
242 | for(int i = 0; i < exp.Length; i++) | ||
243 | { | ||
244 | c = exp[i]; | ||
245 | if(Char.IsWhiteSpace(c)) | ||
246 | { | ||
247 | continue; | ||
248 | } | ||
249 | |||
250 | if(Char.IsLetterOrDigit(c) || c == '_') | ||
251 | { | ||
252 | if(inStr) | ||
253 | { | ||
254 | str += c; | ||
255 | } | ||
256 | else | ||
257 | { | ||
258 | id += c; | ||
259 | } | ||
260 | } | ||
261 | else if(c == '\"') | ||
262 | { | ||
263 | inStr = !inStr; | ||
264 | if(inStr) | ||
265 | { | ||
266 | str = ""; | ||
267 | } | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | if(inStr) | ||
272 | { | ||
273 | str += c; | ||
274 | } | ||
275 | else | ||
276 | { | ||
277 | switch(c) | ||
278 | { | ||
279 | case '=': | ||
280 | oper = OperatorSymbol.Equal; | ||
281 | break; | ||
282 | |||
283 | case '!': | ||
284 | if(NextChar(i, exp) == '=') | ||
285 | { | ||
286 | oper = OperatorSymbol.NotEqual; | ||
287 | } | ||
288 | |||
289 | break; | ||
290 | |||
291 | case '<': | ||
292 | if(NextChar(i, exp) == '=') | ||
293 | { | ||
294 | oper = OperatorSymbol.LessThanEqual; | ||
295 | } | ||
296 | else | ||
297 | { | ||
298 | oper = OperatorSymbol.LessThan; | ||
299 | } | ||
300 | |||
301 | break; | ||
302 | |||
303 | case '>': | ||
304 | if(NextChar(i, exp) == '=') | ||
305 | { | ||
306 | oper = OperatorSymbol.GreaterThanEqual; | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | oper = OperatorSymbol.GreaterThan; | ||
311 | } | ||
312 | |||
313 | break; | ||
314 | } | ||
315 | } | ||
316 | } | ||
317 | } | ||
318 | |||
319 | |||
320 | if(inStr) | ||
321 | { | ||
322 | throw new WarningException("Expected end of string in expression"); | ||
323 | } | ||
324 | |||
325 | if(oper == OperatorSymbol.None) | ||
326 | { | ||
327 | throw new WarningException("Expected operator in expression"); | ||
328 | } | ||
329 | else if(id.Length < 1) | ||
330 | { | ||
331 | throw new WarningException("Expected identifier in expression"); | ||
332 | } | ||
333 | else if(str.Length < 1) | ||
334 | { | ||
335 | throw new WarningException("Expected value in expression"); | ||
336 | } | ||
337 | |||
338 | bool ret = false; | ||
339 | try | ||
340 | { | ||
341 | object val = m_Variables[id.ToLower()]; | ||
342 | if(val == null) | ||
343 | { | ||
344 | throw new WarningException("Unknown identifier '{0}'", id); | ||
345 | } | ||
346 | |||
347 | int numVal, numVal2; | ||
348 | string strVal, strVal2; | ||
349 | Type t = val.GetType(); | ||
350 | if(t.IsAssignableFrom(typeof(int))) | ||
351 | { | ||
352 | numVal = (int)val; | ||
353 | numVal2 = Int32.Parse(str); | ||
354 | ret = CompareNum(oper, numVal, numVal2); | ||
355 | } | ||
356 | else | ||
357 | { | ||
358 | strVal = val.ToString(); | ||
359 | strVal2 = str; | ||
360 | ret = CompareStr(oper, strVal, strVal2); | ||
361 | } | ||
362 | } | ||
363 | catch(ArgumentException ex) | ||
364 | { | ||
365 | ex.ToString(); | ||
366 | throw new WarningException("Invalid value type for system variable '{0}', expected int", id); | ||
367 | } | ||
368 | |||
369 | return ret; | ||
370 | } | ||
371 | |||
372 | #endregion | ||
373 | |||
374 | #region Public Methods | ||
375 | |||
376 | /// <summary> | ||
377 | /// | ||
378 | /// </summary> | ||
379 | /// <param name="name"></param> | ||
380 | /// <param name="variableValue"></param> | ||
381 | public void RegisterVariable(string name, object variableValue) | ||
382 | { | ||
383 | if(name == null || variableValue == null) | ||
384 | { | ||
385 | return; | ||
386 | } | ||
387 | |||
388 | m_Variables[name.ToLower()] = variableValue; | ||
389 | } | ||
390 | |||
391 | /// <summary> | ||
392 | /// Performs validation on the xml source as well as evaluates conditional and flow expresions | ||
393 | /// </summary> | ||
394 | /// <exception cref="ArgumentException">For invalid use of conditional expressions or for invalid XML syntax. If a XmlValidatingReader is passed, then will also throw exceptions for non-schema-conforming xml</exception> | ||
395 | /// <param name="reader"></param> | ||
396 | /// <returns>the output xml </returns> | ||
397 | public string Process(XmlReader initialReader) | ||
398 | { | ||
399 | if(initialReader == null) | ||
400 | { | ||
401 | throw new ArgumentException("Invalid XML reader to pre-process"); | ||
402 | } | ||
403 | |||
404 | IfContext context = new IfContext(true, true, IfState.None); | ||
405 | StringWriter xmlText = new StringWriter(); | ||
406 | XmlTextWriter writer = new XmlTextWriter(xmlText); | ||
407 | writer.Formatting = Formatting.Indented; | ||
408 | |||
409 | // Create a queue of XML readers and add the initial | ||
410 | // reader to it. Then we process until we run out of | ||
411 | // readers which lets the <?include?> operation add more | ||
412 | // readers to generate a multi-file parser and not require | ||
413 | // XML fragments that a recursive version would use. | ||
414 | Stack readerStack = new Stack(); | ||
415 | readerStack.Push(initialReader); | ||
416 | |||
417 | while(readerStack.Count > 0) | ||
418 | { | ||
419 | // Pop off the next reader. | ||
420 | XmlReader reader = (XmlReader) readerStack.Pop(); | ||
421 | |||
422 | // Process through this XML reader until it is | ||
423 | // completed (or it is replaced by the include | ||
424 | // operation). | ||
425 | while(reader.Read()) | ||
426 | { | ||
427 | // The prebuild file has a series of processing | ||
428 | // instructions which allow for specific | ||
429 | // inclusions based on operating system or to | ||
430 | // include additional files. | ||
431 | if(reader.NodeType == XmlNodeType.ProcessingInstruction) | ||
432 | { | ||
433 | bool ignore = false; | ||
434 | |||
435 | switch(reader.LocalName) | ||
436 | { | ||
437 | case "include": | ||
438 | // use regular expressions to parse out the attributes. | ||
439 | MatchCollection matches = includeFileRegex.Matches(reader.Value); | ||
440 | |||
441 | // make sure there is only one file attribute. | ||
442 | if(matches.Count > 1) | ||
443 | { | ||
444 | throw new WarningException("An <?include ?> node was found, but it specified more than one file."); | ||
445 | } | ||
446 | |||
447 | if(matches.Count == 0) | ||
448 | { | ||
449 | throw new WarningException("An <?include ?> node was found, but it did not specify the file attribute."); | ||
450 | } | ||
451 | |||
452 | // Push current reader back onto the stack. | ||
453 | readerStack.Push(reader); | ||
454 | |||
455 | // Pull the file out from the regex and make sure it is a valid file before using it. | ||
456 | string filename = matches[0].Groups[1].Value; | ||
457 | |||
458 | filename = String.Join(Path.DirectorySeparatorChar.ToString(), filename.Split(new char[] { '/', '\\' })); | ||
459 | |||
460 | if (!filename.Contains("*")) | ||
461 | { | ||
462 | FileInfo includeFile = new FileInfo(filename); | ||
463 | |||
464 | if (!includeFile.Exists) | ||
465 | { | ||
466 | throw new WarningException("Cannot include file: " + includeFile.FullName); | ||
467 | } | ||
468 | |||
469 | // Create a new reader object for this file, and push it onto the stack | ||
470 | XmlReader newReader = new XmlTextReader(includeFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read)); | ||
471 | readerStack.Push(newReader); | ||
472 | } | ||
473 | else | ||
474 | { | ||
475 | WildCardInclude(readerStack, filename); | ||
476 | } | ||
477 | |||
478 | // continue reading with whatever reader is on the top of the stack | ||
479 | reader = (XmlReader)readerStack.Pop(); | ||
480 | ignore = true; | ||
481 | |||
482 | break; | ||
483 | |||
484 | case "if": | ||
485 | m_IfStack.Push(context); | ||
486 | context = new IfContext(context.Keep & context.Active, ParseExpression(reader.Value), IfState.If); | ||
487 | ignore = true; | ||
488 | break; | ||
489 | |||
490 | case "elseif": | ||
491 | if(m_IfStack.Count == 0) | ||
492 | { | ||
493 | throw new WarningException("Unexpected 'elseif' outside of 'if'"); | ||
494 | } | ||
495 | else if(context.State != IfState.If && context.State != IfState.ElseIf) | ||
496 | { | ||
497 | throw new WarningException("Unexpected 'elseif' outside of 'if'"); | ||
498 | } | ||
499 | |||
500 | context.State = IfState.ElseIf; | ||
501 | if(!context.EverKept) | ||
502 | { | ||
503 | context.Keep = ParseExpression(reader.Value); | ||
504 | } | ||
505 | else | ||
506 | { | ||
507 | context.Keep = false; | ||
508 | } | ||
509 | |||
510 | ignore = true; | ||
511 | break; | ||
512 | |||
513 | case "else": | ||
514 | if(m_IfStack.Count == 0) | ||
515 | { | ||
516 | throw new WarningException("Unexpected 'else' outside of 'if'"); | ||
517 | } | ||
518 | else if(context.State != IfState.If && context.State != IfState.ElseIf) | ||
519 | { | ||
520 | throw new WarningException("Unexpected 'else' outside of 'if'"); | ||
521 | } | ||
522 | |||
523 | context.State = IfState.Else; | ||
524 | context.Keep = !context.EverKept; | ||
525 | ignore = true; | ||
526 | break; | ||
527 | |||
528 | case "endif": | ||
529 | if(m_IfStack.Count == 0) | ||
530 | { | ||
531 | throw new WarningException("Unexpected 'endif' outside of 'if'"); | ||
532 | } | ||
533 | |||
534 | context = (IfContext)m_IfStack.Pop(); | ||
535 | ignore = true; | ||
536 | break; | ||
537 | } | ||
538 | |||
539 | if(ignore) | ||
540 | { | ||
541 | continue; | ||
542 | } | ||
543 | }//end pre-proc instruction | ||
544 | |||
545 | if(!context.Active || !context.Keep) | ||
546 | { | ||
547 | continue; | ||
548 | } | ||
549 | |||
550 | switch(reader.NodeType) | ||
551 | { | ||
552 | case XmlNodeType.Element: | ||
553 | bool empty = reader.IsEmptyElement; | ||
554 | writer.WriteStartElement(reader.Name); | ||
555 | |||
556 | while (reader.MoveToNextAttribute()) | ||
557 | { | ||
558 | writer.WriteAttributeString(reader.Name, reader.Value); | ||
559 | } | ||
560 | |||
561 | if(empty) | ||
562 | { | ||
563 | writer.WriteEndElement(); | ||
564 | } | ||
565 | |||
566 | break; | ||
567 | |||
568 | case XmlNodeType.EndElement: | ||
569 | writer.WriteEndElement(); | ||
570 | break; | ||
571 | |||
572 | case XmlNodeType.Text: | ||
573 | writer.WriteString(reader.Value); | ||
574 | break; | ||
575 | |||
576 | case XmlNodeType.CDATA: | ||
577 | writer.WriteCData(reader.Value); | ||
578 | break; | ||
579 | |||
580 | default: | ||
581 | break; | ||
582 | } | ||
583 | } | ||
584 | |||
585 | if(m_IfStack.Count != 0) | ||
586 | { | ||
587 | throw new WarningException("Mismatched 'if', 'endif' pair"); | ||
588 | } | ||
589 | } | ||
590 | |||
591 | return xmlText.ToString(); | ||
592 | } | ||
593 | |||
594 | private static void WildCardInclude(Stack readerStack, string include) | ||
595 | { | ||
596 | if (!include.Contains("*")) | ||
597 | { | ||
598 | return; | ||
599 | } | ||
600 | |||
601 | // Console.WriteLine("Processing {0}", include); | ||
602 | |||
603 | // Break up the include into pre and post wildcard sections | ||
604 | string preWildcard = include.Substring(0, include.IndexOf("*")); | ||
605 | string postWildcard = include.Substring(include.IndexOf("*") + 2); | ||
606 | |||
607 | // If preWildcard is a directory, recurse | ||
608 | if (Directory.Exists(preWildcard)) | ||
609 | { | ||
610 | string[] directories = Directory.GetDirectories(preWildcard); | ||
611 | Array.Sort(directories); | ||
612 | Array.Reverse(directories); | ||
613 | foreach (string dirPath in directories ) | ||
614 | { | ||
615 | Console.WriteLine("Scanning : {0}", dirPath); | ||
616 | |||
617 | string includeFile = Path.Combine(dirPath, postWildcard); | ||
618 | if (includeFile.Contains("*")) | ||
619 | { | ||
620 | // postWildcard included another wildcard, recurse. | ||
621 | WildCardInclude(readerStack, includeFile); | ||
622 | } | ||
623 | else | ||
624 | { | ||
625 | FileInfo file = new FileInfo(includeFile); | ||
626 | if (file.Exists) | ||
627 | { | ||
628 | Console.WriteLine("Including File: {0}", includeFile); | ||
629 | XmlReader newReader = new XmlTextReader(file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)); | ||
630 | readerStack.Push(newReader); | ||
631 | } | ||
632 | } | ||
633 | } | ||
634 | } | ||
635 | else | ||
636 | { | ||
637 | // preWildcard is not a path to a directory, so the wildcard is in the filename | ||
638 | string searchFilename = Path.GetFileName(preWildcard.Substring(preWildcard.IndexOf("/") + 1) + "*" + postWildcard); | ||
639 | // Console.WriteLine("searchFilename: {0}", searchFilename); | ||
640 | |||
641 | string searchDirectory = Path.GetDirectoryName(preWildcard); | ||
642 | // Console.WriteLine("searchDirectory: {0}", searchDirectory); | ||
643 | |||
644 | string[] files = Directory.GetFiles(searchDirectory, searchFilename); | ||
645 | Array.Sort(files); | ||
646 | Array.Reverse(files); | ||
647 | foreach (string includeFile in files) | ||
648 | { | ||
649 | FileInfo file = new FileInfo(includeFile); | ||
650 | if (file.Exists) | ||
651 | { | ||
652 | Console.WriteLine("Including File: {0}", includeFile); | ||
653 | XmlReader newReader = new XmlTextReader(file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)); | ||
654 | readerStack.Push(newReader); | ||
655 | } | ||
656 | } | ||
657 | } | ||
658 | |||
659 | } | ||
660 | |||
661 | #endregion | ||
662 | } | ||
663 | } | ||
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 | |||
4 | Copyright (c) 2004 - 2008 | ||
5 | Matthew Holmes (matthew@wildfiregames.com), | ||
6 | Dan Moorehead (dan05a@gmail.com), | ||
7 | Dave Hudson (jendave@yahoo.com), | ||
8 | C.J. Adams-Collier (cjac@colliertech.org), | ||
9 | |||
10 | Redistribution and use in source and binary forms, with or without | ||
11 | modification, are permitted provided that the following conditions are | ||
12 | met: | ||
13 | |||
14 | * Redistributions of source code must retain the above copyright | ||
15 | notice, this list of conditions and the following disclaimer. | ||
16 | |||
17 | * Redistributions in binary form must reproduce the above copyright | ||
18 | notice, this list of conditions and the following disclaimer in the | ||
19 | documentation and/or other materials provided with the distribution. | ||
20 | |||
21 | * The name of the author may not be used to endorse or promote | ||
22 | products derived from this software without specific prior written | ||
23 | permission. | ||
24 | |||
25 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
26 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
28 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
29 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
32 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
33 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
34 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
35 | POSSIBILITY 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 | ||
68 | using System; | ||
69 | using System.Collections; | ||
70 | using System.Collections.Generic; | ||
71 | using System.Collections.Specialized; | ||
72 | using System.IO; | ||
73 | using System.Reflection; | ||
74 | using System.Text; | ||
75 | using System.Text.RegularExpressions; | ||
76 | using System.Xml; | ||
77 | using System.Xml.Xsl; | ||
78 | using System.Net; | ||
79 | using System.Diagnostics; | ||
80 | |||
81 | using Prebuild.Core.Attributes; | ||
82 | using Prebuild.Core.Interfaces; | ||
83 | using Prebuild.Core.Nodes; | ||
84 | using Prebuild.Core.Parse; | ||
85 | using Prebuild.Core.Utilities; | ||
86 | |||
87 | namespace 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 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | #region CVS Information | ||
27 | /* | ||
28 | * $Source$ | ||
29 | * $Author: jendave $ | ||
30 | * $Date: 2006-09-20 09:42:51 +0200 (on, 20 sep 2006) $ | ||
31 | * $Revision: 164 $ | ||
32 | */ | ||
33 | #endregion | ||
34 | |||
35 | using System; | ||
36 | |||
37 | using Prebuild.Core.Attributes; | ||
38 | using Prebuild.Core.Interfaces; | ||
39 | using Prebuild.Core.Nodes; | ||
40 | |||
41 | #if (DEBUG && _DEBUG_TARGET) | ||
42 | namespace 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 | /* | ||
3 | Copyright (c) 2004 Crestez Leonard (cleonard@go.ro) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | using System.Text.RegularExpressions; | ||
31 | |||
32 | using Prebuild.Core.Attributes; | ||
33 | using Prebuild.Core.Interfaces; | ||
34 | using Prebuild.Core.Nodes; | ||
35 | using Prebuild.Core.Utilities; | ||
36 | |||
37 | namespace 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 | /* | ||
3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text.RegularExpressions; | ||
32 | |||
33 | using Prebuild.Core.Attributes; | ||
34 | using Prebuild.Core.Interfaces; | ||
35 | using Prebuild.Core.Nodes; | ||
36 | using Prebuild.Core.Utilities; | ||
37 | |||
38 | namespace Prebuild.Core.Targets | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// | ||
42 | /// </summary> | ||
43 | [Target("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 | /* | ||
3 | Copyright (c) 2004 - 2008 | ||
4 | Matthew Holmes (matthew@wildfiregames.com), | ||
5 | Dan Moorehead (dan05a@gmail.com), | ||
6 | C.J. Adams-Collier (cjac@colliertech.org), | ||
7 | |||
8 | Redistribution and use in source and binary forms, with or without | ||
9 | modification, are permitted provided that the following conditions are | ||
10 | met: | ||
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 | |||
23 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
24 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
25 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
26 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
27 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
28 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
29 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
32 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
33 | POSSIBILITY OF SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | #endregion | ||
37 | |||
38 | using System; | ||
39 | using System.Collections; | ||
40 | using System.Collections.Specialized; | ||
41 | using System.IO; | ||
42 | using System.Reflection; | ||
43 | using System.Text.RegularExpressions; | ||
44 | |||
45 | using Prebuild.Core.Attributes; | ||
46 | using Prebuild.Core.Interfaces; | ||
47 | using Prebuild.Core.Nodes; | ||
48 | using Prebuild.Core.Utilities; | ||
49 | |||
50 | namespace 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 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | |||
28 | using Prebuild.Core.Attributes; | ||
29 | |||
30 | namespace 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 | /* | ||
3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | using System.Text.RegularExpressions; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using Prebuild.Core.Attributes; | ||
34 | using Prebuild.Core.Interfaces; | ||
35 | using Prebuild.Core.Nodes; | ||
36 | using Prebuild.Core.Utilities; | ||
37 | |||
38 | namespace Prebuild.Core.Targets | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// | ||
42 | /// </summary> | ||
43 | [Target("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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace 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 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | |||
28 | using Prebuild.Core.Attributes; | ||
29 | |||
30 | namespace 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 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using Prebuild.Core.Nodes; | ||
34 | using Prebuild.Core.Utilities; | ||
35 | |||
36 | namespace 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 | /* | ||
3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | using System.Text; | ||
31 | |||
32 | using Prebuild.Core.Attributes; | ||
33 | using Prebuild.Core.Interfaces; | ||
34 | using Prebuild.Core.Nodes; | ||
35 | using Prebuild.Core.Utilities; | ||
36 | |||
37 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Specialized; | ||
4 | using System.IO; | ||
5 | using System.Text; | ||
6 | |||
7 | using Prebuild.Core.Attributes; | ||
8 | using Prebuild.Core.Interfaces; | ||
9 | using Prebuild.Core.Nodes; | ||
10 | using Prebuild.Core.Utilities; | ||
11 | using System.CodeDom.Compiler; | ||
12 | |||
13 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Specialized; | ||
4 | using System.IO; | ||
5 | using System.Text; | ||
6 | |||
7 | using Prebuild.Core.Attributes; | ||
8 | using Prebuild.Core.Interfaces; | ||
9 | using Prebuild.Core.Nodes; | ||
10 | using Prebuild.Core.Utilities; | ||
11 | using System.CodeDom.Compiler; | ||
12 | |||
13 | namespace 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 | /* | ||
3 | Copyright (c) 2008 Matthew Holmes (matthew@wildfiregames.com), John Anderson (sontek@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Collections.Specialized; | ||
30 | using System.IO; | ||
31 | using System.Text; | ||
32 | |||
33 | using Prebuild.Core.Attributes; | ||
34 | using Prebuild.Core.Interfaces; | ||
35 | using Prebuild.Core.Nodes; | ||
36 | using Prebuild.Core.Utilities; | ||
37 | using System.CodeDom.Compiler; | ||
38 | |||
39 | namespace 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 | /* | ||
3 | Copyright (c) 2008-2009 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com), John Anderson (sontek@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | namespace 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 | /* | ||
3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text.RegularExpressions; | ||
32 | |||
33 | using Prebuild.Core.Attributes; | ||
34 | using Prebuild.Core.Interfaces; | ||
35 | using Prebuild.Core.Nodes; | ||
36 | using Prebuild.Core.Utilities; | ||
37 | |||
38 | namespace Prebuild.Core.Targets | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// | ||
42 | /// </summary> | ||
43 | [Target("xcode")] | ||
44 | public class XcodeTarget : ITarget | ||
45 | { | ||
46 | #region Fields | ||
47 | |||
48 | private Kernel m_Kernel; | ||
49 | |||
50 | #endregion | ||
51 | |||
52 | #region Private Methods | ||
53 | |||
54 | private static string PrependPath(string path) | ||
55 | { | ||
56 | string tmpPath = Helper.NormalizePath(path, '/'); | ||
57 | Regex regex = new Regex(@"(\w):/(\w+)"); | ||
58 | Match match = regex.Match(tmpPath); | ||
59 | //if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | ||
60 | //{ | ||
61 | tmpPath = Helper.NormalizePath(tmpPath); | ||
62 | //} | ||
63 | // else | ||
64 | // { | ||
65 | // tmpPath = Helper.NormalizePath("./" + tmpPath); | ||
66 | // } | ||
67 | |||
68 | return tmpPath; | ||
69 | } | ||
70 | |||
71 | private static string BuildReference(SolutionNode solution, ReferenceNode refr) | ||
72 | { | ||
73 | string ret = ""; | ||
74 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | ||
75 | { | ||
76 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
77 | string fileRef = FindFileReference(refr.Name, project); | ||
78 | string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/'); | ||
79 | ret += finalPath; | ||
80 | return ret; | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | ProjectNode project = (ProjectNode)refr.Parent; | ||
85 | string fileRef = FindFileReference(refr.Name, project); | ||
86 | |||
87 | if (refr.Path != null || fileRef != null) | ||
88 | { | ||
89 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; | ||
90 | ret += finalPath; | ||
91 | return ret; | ||
92 | } | ||
93 | |||
94 | try | ||
95 | { | ||
96 | //Assembly assem = Assembly.Load(refr.Name); | ||
97 | //if (assem != null) | ||
98 | //{ | ||
99 | //ret += (refr.Name + ".dll"); | ||
100 | //} | ||
101 | //else | ||
102 | //{ | ||
103 | ret += (refr.Name + ".dll"); | ||
104 | //} | ||
105 | } | ||
106 | catch (System.NullReferenceException e) | ||
107 | { | ||
108 | e.ToString(); | ||
109 | ret += refr.Name + ".dll"; | ||
110 | } | ||
111 | } | ||
112 | return ret; | ||
113 | } | ||
114 | |||
115 | private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) | ||
116 | { | ||
117 | string ret = ""; | ||
118 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | ||
119 | { | ||
120 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
121 | string fileRef = FindFileReference(refr.Name, project); | ||
122 | string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); | ||
123 | ret += finalPath; | ||
124 | return ret; | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | ProjectNode project = (ProjectNode)refr.Parent; | ||
129 | string fileRef = FindFileReference(refr.Name, project); | ||
130 | |||
131 | if (refr.Path != null || fileRef != null) | ||
132 | { | ||
133 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; | ||
134 | ret += finalPath; | ||
135 | return ret; | ||
136 | } | ||
137 | |||
138 | try | ||
139 | { | ||
140 | Assembly assem = Assembly.Load(refr.Name); | ||
141 | if (assem != null) | ||
142 | { | ||
143 | ret += ""; | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | ret += ""; | ||
148 | } | ||
149 | } | ||
150 | catch (System.NullReferenceException e) | ||
151 | { | ||
152 | e.ToString(); | ||
153 | ret += ""; | ||
154 | } | ||
155 | } | ||
156 | return ret; | ||
157 | } | ||
158 | |||
159 | private static string FindFileReference(string refName, ProjectNode project) | ||
160 | { | ||
161 | foreach (ReferencePathNode refPath in project.ReferencePaths) | ||
162 | { | ||
163 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | ||
164 | |||
165 | if (File.Exists(fullPath)) | ||
166 | { | ||
167 | return fullPath; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | return null; | ||
172 | } | ||
173 | |||
174 | /// <summary> | ||
175 | /// Gets the XML doc file. | ||
176 | /// </summary> | ||
177 | /// <param name="project">The project.</param> | ||
178 | /// <param name="conf">The conf.</param> | ||
179 | /// <returns></returns> | ||
180 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) | ||
181 | { | ||
182 | if (conf == null) | ||
183 | { | ||
184 | throw new ArgumentNullException("conf"); | ||
185 | } | ||
186 | if (project == null) | ||
187 | { | ||
188 | throw new ArgumentNullException("project"); | ||
189 | } | ||
190 | string docFile = (string)conf.Options["XmlDocFile"]; | ||
191 | // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | ||
192 | // { | ||
193 | // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; | ||
194 | // } | ||
195 | return docFile; | ||
196 | } | ||
197 | |||
198 | private void WriteProject(SolutionNode solution, ProjectNode project) | ||
199 | { | ||
200 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); | ||
201 | StreamWriter ss = new StreamWriter(projFile); | ||
202 | |||
203 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
204 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | ||
205 | bool hasDoc = false; | ||
206 | |||
207 | using (ss) | ||
208 | { | ||
209 | ss.WriteLine("<?xml version=\"1.0\" ?>"); | ||
210 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name); | ||
211 | ss.WriteLine(" <target name=\"{0}\">", "build"); | ||
212 | ss.WriteLine(" <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />"); | ||
213 | ss.WriteLine(" <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />"); | ||
214 | ss.WriteLine(" <copy todir=\"${project::get-base-directory()}/${build.dir}\">"); | ||
215 | ss.WriteLine(" <fileset basedir=\"${project::get-base-directory()}\">"); | ||
216 | foreach (ReferenceNode refr in project.References) | ||
217 | { | ||
218 | if (refr.LocalCopy) | ||
219 | { | ||
220 | ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/')); | ||
221 | } | ||
222 | } | ||
223 | ss.WriteLine(" </fileset>"); | ||
224 | ss.WriteLine(" </copy>"); | ||
225 | ss.Write(" <csc"); | ||
226 | ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower()); | ||
227 | ss.Write(" debug=\"{0}\"", "${build.debug}"); | ||
228 | foreach (ConfigurationNode conf in project.Configurations) | ||
229 | { | ||
230 | if (conf.Options.KeyFile != "") | ||
231 | { | ||
232 | ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile); | ||
233 | break; | ||
234 | } | ||
235 | } | ||
236 | foreach (ConfigurationNode conf in project.Configurations) | ||
237 | { | ||
238 | ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe); | ||
239 | break; | ||
240 | } | ||
241 | foreach (ConfigurationNode conf in project.Configurations) | ||
242 | { | ||
243 | ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines); | ||
244 | break; | ||
245 | } | ||
246 | foreach (ConfigurationNode conf in project.Configurations) | ||
247 | { | ||
248 | if (GetXmlDocFile(project, conf) != "") | ||
249 | { | ||
250 | ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf)); | ||
251 | hasDoc = true; | ||
252 | } | ||
253 | break; | ||
254 | } | ||
255 | ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}"); | ||
256 | if (project.Type == ProjectType.Library) | ||
257 | { | ||
258 | ss.Write(".dll\""); | ||
259 | } | ||
260 | else | ||
261 | { | ||
262 | ss.Write(".exe\""); | ||
263 | } | ||
264 | if (project.AppIcon != null && project.AppIcon.Length != 0) | ||
265 | { | ||
266 | ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/')); | ||
267 | } | ||
268 | ss.WriteLine(">"); | ||
269 | ss.WriteLine(" <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace); | ||
270 | foreach (string file in project.Files) | ||
271 | { | ||
272 | switch (project.Files.GetBuildAction(file)) | ||
273 | { | ||
274 | case BuildAction.EmbeddedResource: | ||
275 | ss.WriteLine(" {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
276 | break; | ||
277 | default: | ||
278 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
279 | { | ||
280 | ss.WriteLine(" <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
281 | } | ||
282 | break; | ||
283 | } | ||
284 | } | ||
285 | //if (project.Files.GetSubType(file).ToString() != "Code") | ||
286 | //{ | ||
287 | // ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); | ||
288 | |||
289 | ss.WriteLine(" </resources>"); | ||
290 | ss.WriteLine(" <sources failonempty=\"true\">"); | ||
291 | foreach (string file in project.Files) | ||
292 | { | ||
293 | switch (project.Files.GetBuildAction(file)) | ||
294 | { | ||
295 | case BuildAction.Compile: | ||
296 | ss.WriteLine(" <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />"); | ||
297 | break; | ||
298 | default: | ||
299 | break; | ||
300 | } | ||
301 | } | ||
302 | ss.WriteLine(" </sources>"); | ||
303 | ss.WriteLine(" <references basedir=\"${project::get-base-directory()}\">"); | ||
304 | ss.WriteLine(" <lib>"); | ||
305 | ss.WriteLine(" <include name=\"${project::get-base-directory()}\" />"); | ||
306 | ss.WriteLine(" <include name=\"${project::get-base-directory()}/${build.dir}\" />"); | ||
307 | ss.WriteLine(" </lib>"); | ||
308 | foreach (ReferenceNode refr in project.References) | ||
309 | { | ||
310 | ss.WriteLine(" <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/')); | ||
311 | } | ||
312 | ss.WriteLine(" </references>"); | ||
313 | |||
314 | ss.WriteLine(" </csc>"); | ||
315 | ss.WriteLine(" </target>"); | ||
316 | |||
317 | ss.WriteLine(" <target name=\"clean\">"); | ||
318 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); | ||
319 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); | ||
320 | ss.WriteLine(" </target>"); | ||
321 | |||
322 | ss.WriteLine(" <target name=\"doc\" description=\"Creates documentation.\">"); | ||
323 | if (hasDoc) | ||
324 | { | ||
325 | ss.WriteLine(" <property name=\"doc.target\" value=\"\" />"); | ||
326 | ss.WriteLine(" <if test=\"${platform::is-unix()}\">"); | ||
327 | ss.WriteLine(" <property name=\"doc.target\" value=\"Web\" />"); | ||
328 | ss.WriteLine(" </if>"); | ||
329 | ss.WriteLine(" <ndoc failonerror=\"false\" verbose=\"true\">"); | ||
330 | ss.WriteLine(" <assemblies basedir=\"${project::get-base-directory()}\">"); | ||
331 | ss.Write(" <include name=\"${build.dir}/${project::get-name()}"); | ||
332 | if (project.Type == ProjectType.Library) | ||
333 | { | ||
334 | ss.WriteLine(".dll\" />"); | ||
335 | } | ||
336 | else | ||
337 | { | ||
338 | ss.WriteLine(".exe\" />"); | ||
339 | } | ||
340 | |||
341 | ss.WriteLine(" </assemblies>"); | ||
342 | ss.WriteLine(" <summaries basedir=\"${project::get-base-directory()}\">"); | ||
343 | ss.WriteLine(" <include name=\"${build.dir}/${project::get-name()}.xml\"/>"); | ||
344 | ss.WriteLine(" </summaries>"); | ||
345 | ss.WriteLine(" <referencepaths basedir=\"${project::get-base-directory()}\">"); | ||
346 | ss.WriteLine(" <include name=\"${build.dir}\" />"); | ||
347 | // foreach(ReferenceNode refr in project.References) | ||
348 | // { | ||
349 | // string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/'); | ||
350 | // if (path != "") | ||
351 | // { | ||
352 | // ss.WriteLine(" <include name=\"{0}\" />", path); | ||
353 | // } | ||
354 | // } | ||
355 | ss.WriteLine(" </referencepaths>"); | ||
356 | ss.WriteLine(" <documenters>"); | ||
357 | ss.WriteLine(" <documenter name=\"MSDN\">"); | ||
358 | ss.WriteLine(" <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />"); | ||
359 | ss.WriteLine(" <property name=\"OutputTarget\" value=\"${doc.target}\" />"); | ||
360 | ss.WriteLine(" <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />"); | ||
361 | ss.WriteLine(" <property name=\"IncludeFavorites\" value=\"False\" />"); | ||
362 | ss.WriteLine(" <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />"); | ||
363 | ss.WriteLine(" <property name=\"SplitTOCs\" value=\"False\" />"); | ||
364 | ss.WriteLine(" <property name=\"DefaulTOC\" value=\"\" />"); | ||
365 | ss.WriteLine(" <property name=\"ShowVisualBasic\" value=\"True\" />"); | ||
366 | ss.WriteLine(" <property name=\"AutoDocumentConstructors\" value=\"True\" />"); | ||
367 | ss.WriteLine(" <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />"); | ||
368 | ss.WriteLine(" <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />"); | ||
369 | ss.WriteLine(" <property name=\"ShowMissingParams\" value=\"${build.debug}\" />"); | ||
370 | ss.WriteLine(" <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />"); | ||
371 | ss.WriteLine(" <property name=\"ShowMissingValues\" value=\"${build.debug}\" />"); | ||
372 | ss.WriteLine(" <property name=\"DocumentInternals\" value=\"False\" />"); | ||
373 | ss.WriteLine(" <property name=\"DocumentPrivates\" value=\"False\" />"); | ||
374 | ss.WriteLine(" <property name=\"DocumentProtected\" value=\"True\" />"); | ||
375 | ss.WriteLine(" <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />"); | ||
376 | ss.WriteLine(" <property name=\"IncludeAssemblyVersion\" value=\"True\" />"); | ||
377 | ss.WriteLine(" </documenter>"); | ||
378 | ss.WriteLine(" </documenters>"); | ||
379 | ss.WriteLine(" </ndoc>"); | ||
380 | } | ||
381 | ss.WriteLine(" </target>"); | ||
382 | ss.WriteLine("</project>"); | ||
383 | } | ||
384 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
385 | } | ||
386 | |||
387 | private void WriteCombine(SolutionNode solution) | ||
388 | { | ||
389 | m_Kernel.Log.Write("Creating Xcode build files"); | ||
390 | foreach (ProjectNode project in solution.Projects) | ||
391 | { | ||
392 | if (m_Kernel.AllowProject(project.FilterGroups)) | ||
393 | { | ||
394 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | ||
395 | WriteProject(solution, project); | ||
396 | } | ||
397 | } | ||
398 | |||
399 | m_Kernel.Log.Write(""); | ||
400 | DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj")); | ||
401 | if (!directoryInfo.Exists) | ||
402 | { | ||
403 | directoryInfo.Create(); | ||
404 | } | ||
405 | string combFile = Helper.MakeFilePath(Path.Combine(solution.FullPath, solution.Name + ".xcodeproj"), "project", "pbxproj"); | ||
406 | StreamWriter ss = new StreamWriter(combFile); | ||
407 | |||
408 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
409 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | ||
410 | |||
411 | using (ss) | ||
412 | { | ||
413 | ss.WriteLine("<?xml version=\"1.0\" ?>"); | ||
414 | ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name); | ||
415 | ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>"); | ||
416 | ss.WriteLine(); | ||
417 | |||
418 | //ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />"); | ||
419 | //ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />"); | ||
420 | ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />"); | ||
421 | ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />"); | ||
422 | ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />"); | ||
423 | ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />"); | ||
424 | |||
425 | foreach (ConfigurationNode conf in solution.Configurations) | ||
426 | { | ||
427 | // Set the project.config to a non-debug configuration | ||
428 | if (conf.Options["DebugInformation"].ToString().ToLower() != "true") | ||
429 | { | ||
430 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); | ||
431 | } | ||
432 | ss.WriteLine(); | ||
433 | ss.WriteLine(" <target name=\"{0}\" description=\"\">", conf.Name); | ||
434 | ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name); | ||
435 | ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower()); | ||
436 | ss.WriteLine(" </target>"); | ||
437 | ss.WriteLine(); | ||
438 | } | ||
439 | |||
440 | ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">"); | ||
441 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />"); | ||
442 | ss.WriteLine(" </target>"); | ||
443 | ss.WriteLine(); | ||
444 | |||
445 | ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">"); | ||
446 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />"); | ||
447 | ss.WriteLine(" </target>"); | ||
448 | ss.WriteLine(); | ||
449 | |||
450 | ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">"); | ||
451 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />"); | ||
452 | ss.WriteLine(" </target>"); | ||
453 | ss.WriteLine(); | ||
454 | |||
455 | ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">"); | ||
456 | ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />"); | ||
457 | ss.WriteLine(" </target>"); | ||
458 | ss.WriteLine(); | ||
459 | |||
460 | ss.WriteLine(" <target name=\"init\" description=\"\">"); | ||
461 | ss.WriteLine(" <call target=\"${project.config}\" />"); | ||
462 | ss.WriteLine(" <sysinfo />"); | ||
463 | ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />"); | ||
464 | ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />"); | ||
465 | ss.WriteLine(" </target>"); | ||
466 | ss.WriteLine(); | ||
467 | |||
468 | ss.WriteLine(" <target name=\"clean\" description=\"\">"); | ||
469 | ss.WriteLine(" <echo message=\"Deleting all builds from all configurations\" />"); | ||
470 | //ss.WriteLine(" <delete dir=\"${dist.dir}\" failonerror=\"false\" />"); | ||
471 | ss.WriteLine(" <delete dir=\"${bin.dir}\" failonerror=\"false\" />"); | ||
472 | ss.WriteLine(" <delete dir=\"${obj.dir}\" failonerror=\"false\" />"); | ||
473 | //foreach(ProjectNode project in solution.Projects) | ||
474 | //{ | ||
475 | // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
476 | // ss.Write(" <nant buildfile=\"{0}\"", | ||
477 | // Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"),'/')); | ||
478 | // ss.WriteLine(" target=\"clean\" />"); | ||
479 | //} | ||
480 | ss.WriteLine(" </target>"); | ||
481 | ss.WriteLine(); | ||
482 | |||
483 | ss.WriteLine(" <target name=\"build\" depends=\"init\" description=\"\">"); | ||
484 | |||
485 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
486 | { | ||
487 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
488 | ss.Write(" <nant buildfile=\"{0}\"", | ||
489 | Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); | ||
490 | ss.WriteLine(" target=\"build\" />"); | ||
491 | } | ||
492 | ss.WriteLine(" </target>"); | ||
493 | ss.WriteLine(); | ||
494 | |||
495 | ss.WriteLine(" <target name=\"build-release\" depends=\"Release, init, build\" description=\"Builds in Release mode\" />"); | ||
496 | ss.WriteLine(); | ||
497 | ss.WriteLine(" <target name=\"build-debug\" depends=\"Debug, init, build\" description=\"Builds in Debug mode\" />"); | ||
498 | ss.WriteLine(); | ||
499 | //ss.WriteLine(" <target name=\"package\" depends=\"clean, doc, copyfiles, zip\" description=\"Builds in Release mode\" />"); | ||
500 | ss.WriteLine(" <target name=\"package\" depends=\"clean, doc\" description=\"Builds all\" />"); | ||
501 | ss.WriteLine(); | ||
502 | |||
503 | ss.WriteLine(" <target name=\"doc\" depends=\"build-release\">"); | ||
504 | ss.WriteLine(" <echo message=\"Generating all documentation from all builds\" />"); | ||
505 | foreach (ProjectNode project in solution.Projects) | ||
506 | { | ||
507 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
508 | ss.Write(" <nant buildfile=\"{0}\"", | ||
509 | Helper.NormalizePath(Helper.MakeFilePath(path, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"), '/')); | ||
510 | ss.WriteLine(" target=\"doc\" />"); | ||
511 | } | ||
512 | ss.WriteLine(" </target>"); | ||
513 | ss.WriteLine(); | ||
514 | ss.WriteLine("</project>"); | ||
515 | } | ||
516 | |||
517 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
518 | } | ||
519 | |||
520 | private void CleanProject(ProjectNode project) | ||
521 | { | ||
522 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | ||
523 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build"); | ||
524 | Helper.DeleteIfExists(projectFile); | ||
525 | } | ||
526 | |||
527 | private void CleanSolution(SolutionNode solution) | ||
528 | { | ||
529 | m_Kernel.Log.Write("Cleaning Xcode build files for", solution.Name); | ||
530 | |||
531 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build"); | ||
532 | Helper.DeleteIfExists(slnFile); | ||
533 | |||
534 | foreach (ProjectNode project in solution.Projects) | ||
535 | { | ||
536 | CleanProject(project); | ||
537 | } | ||
538 | |||
539 | m_Kernel.Log.Write(""); | ||
540 | } | ||
541 | |||
542 | #endregion | ||
543 | |||
544 | #region ITarget Members | ||
545 | |||
546 | /// <summary> | ||
547 | /// Writes the specified kern. | ||
548 | /// </summary> | ||
549 | /// <param name="kern">The kern.</param> | ||
550 | public void Write(Kernel kern) | ||
551 | { | ||
552 | if (kern == null) | ||
553 | { | ||
554 | throw new ArgumentNullException("kern"); | ||
555 | } | ||
556 | m_Kernel = kern; | ||
557 | foreach (SolutionNode solution in kern.Solutions) | ||
558 | { | ||
559 | WriteCombine(solution); | ||
560 | } | ||
561 | m_Kernel = null; | ||
562 | } | ||
563 | |||
564 | /// <summary> | ||
565 | /// Cleans the specified kern. | ||
566 | /// </summary> | ||
567 | /// <param name="kern">The kern.</param> | ||
568 | public virtual void Clean(Kernel kern) | ||
569 | { | ||
570 | if (kern == null) | ||
571 | { | ||
572 | throw new ArgumentNullException("kern"); | ||
573 | } | ||
574 | m_Kernel = kern; | ||
575 | foreach (SolutionNode sol in kern.Solutions) | ||
576 | { | ||
577 | CleanSolution(sol); | ||
578 | } | ||
579 | m_Kernel = null; | ||
580 | } | ||
581 | |||
582 | /// <summary> | ||
583 | /// Gets the name. | ||
584 | /// </summary> | ||
585 | /// <value>The name.</value> | ||
586 | public string Name | ||
587 | { | ||
588 | get | ||
589 | { | ||
590 | return "xcode"; | ||
591 | } | ||
592 | } | ||
593 | |||
594 | #endregion | ||
595 | } | ||
596 | } | ||
diff --git a/Prebuild/src/Core/UnknownLanguageException.cs b/Prebuild/src/Core/UnknownLanguageException.cs deleted file mode 100644 index 607b66c..0000000 --- a/Prebuild/src/Core/UnknownLanguageException.cs +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* | ||
2 | * $RCSfile$ | ||
3 | * Copyright (C) 2004, 2005 David Hudson (jendave@yahoo.com) | ||
4 | * | ||
5 | * This library is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU Lesser General Public | ||
7 | * License as published by the Free Software Foundation; either | ||
8 | * version 2.1 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This library is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * Lesser General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | using System; | ||
21 | using System.Runtime.Serialization; | ||
22 | |||
23 | namespace Prebuild.Core | ||
24 | { | ||
25 | /// <summary> | ||
26 | /// </summary> | ||
27 | [Serializable()] | ||
28 | public class UnknownLanguageException : Exception | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// Basic exception. | ||
32 | /// </summary> | ||
33 | public UnknownLanguageException() | ||
34 | { | ||
35 | } | ||
36 | |||
37 | /// <summary> | ||
38 | /// Exception with specified string | ||
39 | /// </summary> | ||
40 | /// <param name="message">Exception message</param> | ||
41 | public UnknownLanguageException(string message): base(message) | ||
42 | { | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// | ||
47 | /// </summary> | ||
48 | /// <param name="message"></param> | ||
49 | /// <param name="exception"></param> | ||
50 | public UnknownLanguageException(string message, Exception exception) : base(message, exception) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// | ||
56 | /// </summary> | ||
57 | /// <param name="info"></param> | ||
58 | /// <param name="context"></param> | ||
59 | protected UnknownLanguageException(SerializationInfo info, StreamingContext context) : base( info, context ) | ||
60 | { | ||
61 | } | ||
62 | } | ||
63 | } | ||
diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs deleted file mode 100644 index 22752aa..0000000 --- a/Prebuild/src/Core/Utilities/CommandLineCollection.cs +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Diagnostics; | ||
30 | |||
31 | namespace Prebuild.Core.Utilities | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// The CommandLine class parses and interprets the command-line arguments passed to | ||
35 | /// prebuild. | ||
36 | /// </summary> | ||
37 | public class CommandLineCollection | ||
38 | { | ||
39 | #region Fields | ||
40 | |||
41 | // The raw OS arguments | ||
42 | private string[] m_RawArgs; | ||
43 | |||
44 | // Command-line argument storage | ||
45 | private Hashtable m_Arguments; | ||
46 | |||
47 | #endregion | ||
48 | |||
49 | #region Constructors | ||
50 | |||
51 | /// <summary> | ||
52 | /// Create a new CommandLine instance and set some internal variables. | ||
53 | /// </summary> | ||
54 | public CommandLineCollection(string[] args) | ||
55 | { | ||
56 | m_RawArgs = args; | ||
57 | m_Arguments = new Hashtable(); | ||
58 | |||
59 | Parse(); | ||
60 | } | ||
61 | |||
62 | #endregion | ||
63 | |||
64 | #region Private Methods | ||
65 | |||
66 | private void Parse() | ||
67 | { | ||
68 | if(m_RawArgs.Length < 1) | ||
69 | return; | ||
70 | |||
71 | int idx = 0; | ||
72 | string arg = null, lastArg = null; | ||
73 | |||
74 | while(idx <m_RawArgs.Length) | ||
75 | { | ||
76 | arg = m_RawArgs[idx]; | ||
77 | |||
78 | if(arg.Length > 2 && arg[0] == '/') | ||
79 | { | ||
80 | arg = arg.Substring(1); | ||
81 | lastArg = arg; | ||
82 | m_Arguments[arg] = ""; | ||
83 | } | ||
84 | else | ||
85 | { | ||
86 | if(lastArg != null) | ||
87 | { | ||
88 | m_Arguments[lastArg] = arg; | ||
89 | lastArg = null; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | idx++; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | #endregion | ||
98 | |||
99 | #region Public Methods | ||
100 | |||
101 | /// <summary> | ||
102 | /// Wases the passed. | ||
103 | /// </summary> | ||
104 | /// <param name="arg">The arg.</param> | ||
105 | /// <returns></returns> | ||
106 | public bool WasPassed(string arg) | ||
107 | { | ||
108 | return (m_Arguments.ContainsKey(arg)); | ||
109 | } | ||
110 | |||
111 | #endregion | ||
112 | |||
113 | #region Properties | ||
114 | |||
115 | /// <summary> | ||
116 | /// Gets the parameter associated with the command line option | ||
117 | /// </summary> | ||
118 | /// <remarks>Returns null if option was not specified, | ||
119 | /// null string if no parameter was specified, and the value if a parameter was specified</remarks> | ||
120 | public string this[string index] | ||
121 | { | ||
122 | get | ||
123 | { | ||
124 | if(m_Arguments.ContainsKey(index)) | ||
125 | { | ||
126 | return (string)(m_Arguments[index]); | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | return null; | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | #endregion | ||
136 | |||
137 | #region IEnumerable Members | ||
138 | |||
139 | /// <summary> | ||
140 | /// Returns an enumerator that can iterate through a collection. | ||
141 | /// </summary> | ||
142 | /// <returns> | ||
143 | /// An <see cref="T:System.Collections.IDictionaryEnumerator"/> | ||
144 | /// that can be used to iterate through the collection. | ||
145 | /// </returns> | ||
146 | public IDictionaryEnumerator GetEnumerator() | ||
147 | { | ||
148 | return m_Arguments.GetEnumerator(); | ||
149 | } | ||
150 | |||
151 | #endregion | ||
152 | } | ||
153 | } | ||
diff --git a/Prebuild/src/Core/Utilities/CurrentDirectory.cs b/Prebuild/src/Core/Utilities/CurrentDirectory.cs deleted file mode 100644 index 5fabdf0..0000000 --- a/Prebuild/src/Core/Utilities/CurrentDirectory.cs +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | |||
29 | namespace Prebuild.Core.Utilities | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// | ||
33 | /// </summary> | ||
34 | public class CurrentDirectory | ||
35 | { | ||
36 | #region Fields | ||
37 | |||
38 | private Stack m_Stack; | ||
39 | |||
40 | #endregion | ||
41 | |||
42 | #region Constructors | ||
43 | |||
44 | /// <summary> | ||
45 | /// Initializes a new instance of the <see cref="CurrentDirectory"/> class. | ||
46 | /// </summary> | ||
47 | public CurrentDirectory() | ||
48 | { | ||
49 | m_Stack = new Stack(); | ||
50 | } | ||
51 | |||
52 | #endregion | ||
53 | |||
54 | #region Public Methods | ||
55 | |||
56 | /// <summary> | ||
57 | /// Pushes this instance. | ||
58 | /// </summary> | ||
59 | public void Push() | ||
60 | { | ||
61 | m_Stack.Push(Environment.CurrentDirectory); | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// Pops this instance. | ||
66 | /// </summary> | ||
67 | public void Pop() | ||
68 | { | ||
69 | if(m_Stack.Count < 1) | ||
70 | { | ||
71 | return; | ||
72 | } | ||
73 | |||
74 | string cwd = (string)m_Stack.Pop(); | ||
75 | Helper.SetCurrentDir(cwd); | ||
76 | } | ||
77 | |||
78 | #endregion | ||
79 | } | ||
80 | } | ||
diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs deleted file mode 100644 index 9a0d131..0000000 --- a/Prebuild/src/Core/Utilities/Helper.cs +++ /dev/null | |||
@@ -1,654 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Collections; | ||
28 | using System.Diagnostics; | ||
29 | using System.IO; | ||
30 | using System.Runtime.InteropServices; | ||
31 | using System.Text.RegularExpressions; | ||
32 | using System.Collections.Specialized; | ||
33 | using System.Xml; | ||
34 | using Prebuild.Core.Nodes; | ||
35 | |||
36 | namespace Prebuild.Core.Utilities | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// | ||
40 | /// </summary> | ||
41 | public class Helper | ||
42 | { | ||
43 | #region Fields | ||
44 | |||
45 | private static Stack dirStack; | ||
46 | private static Regex varRegex; | ||
47 | static bool checkForOSVariables; | ||
48 | |||
49 | /// <summary> | ||
50 | /// | ||
51 | /// </summary> | ||
52 | public static bool CheckForOSVariables | ||
53 | { | ||
54 | get | ||
55 | { | ||
56 | return checkForOSVariables; | ||
57 | } | ||
58 | set | ||
59 | { | ||
60 | checkForOSVariables = value; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | #endregion | ||
65 | |||
66 | #region Constructors | ||
67 | |||
68 | /// <summary> | ||
69 | /// Initializes the <see cref="Helper"/> class. | ||
70 | /// </summary> | ||
71 | static Helper() | ||
72 | { | ||
73 | dirStack = new Stack(); | ||
74 | //m_VarRegex = new Regex(@"\${(?<var>[\w|_]+)}"); | ||
75 | } | ||
76 | |||
77 | #endregion | ||
78 | |||
79 | #region Properties | ||
80 | |||
81 | /// <summary> | ||
82 | /// | ||
83 | /// </summary> | ||
84 | public static Stack DirStack | ||
85 | { | ||
86 | get | ||
87 | { | ||
88 | return dirStack; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | public static Regex VarRegex | ||
96 | { | ||
97 | get | ||
98 | { | ||
99 | return varRegex; | ||
100 | } | ||
101 | set | ||
102 | { | ||
103 | varRegex = value; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | #endregion | ||
108 | |||
109 | #region Public Methods | ||
110 | |||
111 | #region String Parsing | ||
112 | #region Inner Classes and Delegates | ||
113 | /// <summary> | ||
114 | /// | ||
115 | /// </summary> | ||
116 | public delegate string StringLookup(string key); | ||
117 | |||
118 | #endregion | ||
119 | |||
120 | /// <summary> | ||
121 | /// Gets a collection of StringLocationPair objects that represent the matches | ||
122 | /// </summary> | ||
123 | /// <param name="target">The target.</param> | ||
124 | /// <param name="beforeGroup">The before group.</param> | ||
125 | /// <param name="afterGroup">The after group.</param> | ||
126 | /// <param name="includeDelimitersInSubstrings">if set to <c>true</c> [include delimiters in substrings].</param> | ||
127 | /// <returns></returns> | ||
128 | public static StringCollection FindGroups(string target, string beforeGroup, string afterGroup, bool includeDelimitersInSubstrings) | ||
129 | { | ||
130 | if( beforeGroup == null ) | ||
131 | { | ||
132 | throw new ArgumentNullException("beforeGroup"); | ||
133 | } | ||
134 | if( afterGroup == null ) | ||
135 | { | ||
136 | throw new ArgumentNullException("afterGroup"); | ||
137 | } | ||
138 | StringCollection results = new StringCollection(); | ||
139 | if(target == null || target.Length == 0) | ||
140 | { | ||
141 | return results; | ||
142 | } | ||
143 | |||
144 | int beforeMod = 0; | ||
145 | int afterMod = 0; | ||
146 | if(includeDelimitersInSubstrings) | ||
147 | { | ||
148 | //be sure to not exlude the delims | ||
149 | beforeMod = beforeGroup.Length; | ||
150 | afterMod = afterGroup.Length; | ||
151 | } | ||
152 | int startIndex = 0; | ||
153 | while((startIndex = target.IndexOf(beforeGroup,startIndex)) != -1) { | ||
154 | int endIndex = target.IndexOf(afterGroup,startIndex);//the index of the char after it | ||
155 | if(endIndex == -1) | ||
156 | { | ||
157 | break; | ||
158 | } | ||
159 | int length = endIndex - startIndex - beforeGroup.Length;//move to the first char in the string | ||
160 | string substring = substring = target.Substring(startIndex + beforeGroup.Length - beforeMod, | ||
161 | length - afterMod); | ||
162 | |||
163 | results.Add(substring); | ||
164 | //results.Add(new StringLocationPair(substring,startIndex)); | ||
165 | startIndex = endIndex + 1; | ||
166 | //the Interpolate*() methods will not work if expressions are expandded inside expression due to an optimization | ||
167 | //so start after endIndex | ||
168 | |||
169 | } | ||
170 | return results; | ||
171 | } | ||
172 | |||
173 | /// <summary> | ||
174 | /// Replaces the groups. | ||
175 | /// </summary> | ||
176 | /// <param name="target">The target.</param> | ||
177 | /// <param name="beforeGroup">The before group.</param> | ||
178 | /// <param name="afterGroup">The after group.</param> | ||
179 | /// <param name="lookup">The lookup.</param> | ||
180 | /// <returns></returns> | ||
181 | public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup) { | ||
182 | if( target == null ) | ||
183 | { | ||
184 | throw new ArgumentNullException("target"); | ||
185 | } | ||
186 | //int targetLength = target.Length; | ||
187 | StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false); | ||
188 | if( lookup == null ) | ||
189 | { | ||
190 | throw new ArgumentNullException("lookup"); | ||
191 | } | ||
192 | foreach(string substring in strings) | ||
193 | { | ||
194 | target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) ); | ||
195 | } | ||
196 | return target; | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// Replaces ${var} statements in a string with the corresonding values as detirmined by the lookup delegate | ||
201 | /// </summary> | ||
202 | /// <param name="target">The target.</param> | ||
203 | /// <param name="lookup">The lookup.</param> | ||
204 | /// <returns></returns> | ||
205 | public static string InterpolateForVariables(string target, StringLookup lookup) | ||
206 | { | ||
207 | return ReplaceGroups(target, "${" , "}" , lookup); | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Replaces ${var} statements in a string with the corresonding environment variable with name var | ||
212 | /// </summary> | ||
213 | /// <param name="target"></param> | ||
214 | /// <returns></returns> | ||
215 | public static string InterpolateForEnvironmentVariables(string target) | ||
216 | { | ||
217 | return InterpolateForVariables(target, new StringLookup(Environment.GetEnvironmentVariable)); | ||
218 | } | ||
219 | |||
220 | #endregion | ||
221 | |||
222 | /// <summary> | ||
223 | /// Translates the value. | ||
224 | /// </summary> | ||
225 | /// <param name="translateType">Type of the translate.</param> | ||
226 | /// <param name="translationItem">The translation item.</param> | ||
227 | /// <returns></returns> | ||
228 | public static object TranslateValue(Type translateType, string translationItem) | ||
229 | { | ||
230 | if(translationItem == null) | ||
231 | { | ||
232 | return null; | ||
233 | } | ||
234 | |||
235 | try | ||
236 | { | ||
237 | string lowerVal = translationItem.ToLower(); | ||
238 | if(translateType == typeof(bool)) | ||
239 | { | ||
240 | return (lowerVal == "true" || lowerVal == "1" || lowerVal == "y" || lowerVal == "yes" || lowerVal == "on"); | ||
241 | } | ||
242 | else if(translateType == typeof(int)) | ||
243 | { | ||
244 | return (Int32.Parse(translationItem)); | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | return translationItem; | ||
249 | } | ||
250 | } | ||
251 | catch(FormatException) | ||
252 | { | ||
253 | return null; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | /// <summary> | ||
258 | /// Deletes if exists. | ||
259 | /// </summary> | ||
260 | /// <param name="file">The file.</param> | ||
261 | /// <returns></returns> | ||
262 | public static bool DeleteIfExists(string file) | ||
263 | { | ||
264 | string resFile = null; | ||
265 | try | ||
266 | { | ||
267 | resFile = ResolvePath(file); | ||
268 | } | ||
269 | catch(ArgumentException) | ||
270 | { | ||
271 | return false; | ||
272 | } | ||
273 | |||
274 | if(!File.Exists(resFile)) | ||
275 | { | ||
276 | return false; | ||
277 | } | ||
278 | |||
279 | File.Delete(resFile); | ||
280 | return true; | ||
281 | } | ||
282 | |||
283 | static readonly char seperator = Path.DirectorySeparatorChar; | ||
284 | |||
285 | // This little gem was taken from the NeL source, thanks guys! | ||
286 | /// <summary> | ||
287 | /// Makes a relative path | ||
288 | /// </summary> | ||
289 | /// <param name="startPath">Path to start from</param> | ||
290 | /// <param name="endPath">Path to end at</param> | ||
291 | /// <returns>Path that will get from startPath to endPath</returns> | ||
292 | public static string MakePathRelativeTo(string startPath, string endPath) | ||
293 | { | ||
294 | string tmp = NormalizePath(startPath, seperator); | ||
295 | string src = NormalizePath(endPath, seperator); | ||
296 | string prefix = ""; | ||
297 | |||
298 | while(true) | ||
299 | { | ||
300 | if((String.Compare(tmp, 0, src, 0, tmp.Length) == 0)) | ||
301 | { | ||
302 | string ret; | ||
303 | int size = tmp.Length; | ||
304 | if(size == src.Length) | ||
305 | { | ||
306 | return "./"; | ||
307 | } | ||
308 | if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator) | ||
309 | { | ||
310 | } | ||
311 | else | ||
312 | { | ||
313 | ret = prefix + endPath.Substring(size, endPath.Length - size); | ||
314 | ret = ret.Trim(); | ||
315 | if(ret[0] == seperator) | ||
316 | { | ||
317 | ret = "." + ret; | ||
318 | } | ||
319 | |||
320 | return NormalizePath(ret); | ||
321 | } | ||
322 | |||
323 | } | ||
324 | |||
325 | if(tmp.Length < 2) | ||
326 | { | ||
327 | break; | ||
328 | } | ||
329 | |||
330 | int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2); | ||
331 | int prevPos = tmp.IndexOf(seperator); | ||
332 | |||
333 | if((lastPos == prevPos) || (lastPos == -1)) | ||
334 | { | ||
335 | break; | ||
336 | } | ||
337 | |||
338 | tmp = tmp.Substring(0, lastPos + 1); | ||
339 | prefix += ".." + seperator.ToString(); | ||
340 | } | ||
341 | |||
342 | return endPath; | ||
343 | } | ||
344 | |||
345 | /// <summary> | ||
346 | /// Resolves the path. | ||
347 | /// </summary> | ||
348 | /// <param name="path">The path.</param> | ||
349 | /// <returns></returns> | ||
350 | public static string ResolvePath(string path) | ||
351 | { | ||
352 | string tmpPath = NormalizePath(path); | ||
353 | if(tmpPath.Length < 1) | ||
354 | { | ||
355 | tmpPath = "."; | ||
356 | } | ||
357 | |||
358 | tmpPath = Path.GetFullPath(tmpPath); | ||
359 | if(!File.Exists(tmpPath) && !Directory.Exists(tmpPath)) | ||
360 | { | ||
361 | throw new ArgumentException("Path could not be resolved: " + tmpPath); | ||
362 | } | ||
363 | |||
364 | return tmpPath; | ||
365 | } | ||
366 | |||
367 | /// <summary> | ||
368 | /// Normalizes the path. | ||
369 | /// </summary> | ||
370 | /// <param name="path">The path.</param> | ||
371 | /// <param name="separatorCharacter">The separator character.</param> | ||
372 | /// <returns></returns> | ||
373 | public static string NormalizePath(string path, char separatorCharacter) | ||
374 | { | ||
375 | if(path == null || path == "" || path.Length < 1) | ||
376 | { | ||
377 | return ""; | ||
378 | } | ||
379 | |||
380 | string tmpPath = path.Replace('\\', '/'); | ||
381 | tmpPath = tmpPath.Replace('/', separatorCharacter); | ||
382 | return tmpPath; | ||
383 | } | ||
384 | |||
385 | /// <summary> | ||
386 | /// Normalizes the path. | ||
387 | /// </summary> | ||
388 | /// <param name="path">The path.</param> | ||
389 | /// <returns></returns> | ||
390 | public static string NormalizePath(string path) | ||
391 | { | ||
392 | return NormalizePath(path, Path.DirectorySeparatorChar); | ||
393 | } | ||
394 | |||
395 | /// <summary> | ||
396 | /// Ends the path. | ||
397 | /// </summary> | ||
398 | /// <param name="path">The path.</param> | ||
399 | /// <param name="separatorCharacter">The separator character.</param> | ||
400 | /// <returns></returns> | ||
401 | public static string EndPath(string path, char separatorCharacter) | ||
402 | { | ||
403 | if(path == null || path == "" || path.Length < 1) | ||
404 | { | ||
405 | return ""; | ||
406 | } | ||
407 | |||
408 | if(!path.EndsWith(separatorCharacter.ToString())) | ||
409 | { | ||
410 | return (path + separatorCharacter); | ||
411 | } | ||
412 | |||
413 | return path; | ||
414 | } | ||
415 | |||
416 | /// <summary> | ||
417 | /// Ends the path. | ||
418 | /// </summary> | ||
419 | /// <param name="path">The path.</param> | ||
420 | /// <returns></returns> | ||
421 | public static string EndPath(string path) | ||
422 | { | ||
423 | return EndPath(path, Path.DirectorySeparatorChar); | ||
424 | } | ||
425 | |||
426 | /// <summary> | ||
427 | /// Makes the file path. | ||
428 | /// </summary> | ||
429 | /// <param name="path">The path.</param> | ||
430 | /// <param name="name">The name.</param> | ||
431 | /// <param name="ext">The ext.</param> | ||
432 | /// <returns></returns> | ||
433 | public static string MakeFilePath(string path, string name, string ext) | ||
434 | { | ||
435 | string ret = EndPath(NormalizePath(path)); | ||
436 | |||
437 | if( name == null ) | ||
438 | { | ||
439 | throw new ArgumentNullException("name"); | ||
440 | } | ||
441 | |||
442 | ret += name; | ||
443 | if(!name.EndsWith("." + ext)) | ||
444 | { | ||
445 | ret += "." + ext; | ||
446 | } | ||
447 | |||
448 | //foreach(char c in Path.GetInvalidPathChars()) | ||
449 | //{ | ||
450 | // ret = ret.Replace(c, '_'); | ||
451 | //} | ||
452 | |||
453 | return ret; | ||
454 | } | ||
455 | |||
456 | /// <summary> | ||
457 | /// Makes the file path. | ||
458 | /// </summary> | ||
459 | /// <param name="path">The path.</param> | ||
460 | /// <param name="name">The name.</param> | ||
461 | /// <returns></returns> | ||
462 | public static string MakeFilePath(string path, string name) | ||
463 | { | ||
464 | string ret = EndPath(NormalizePath(path)); | ||
465 | |||
466 | if( name == null ) | ||
467 | { | ||
468 | throw new ArgumentNullException("name"); | ||
469 | } | ||
470 | |||
471 | ret += name; | ||
472 | |||
473 | //foreach (char c in Path.GetInvalidPathChars()) | ||
474 | //{ | ||
475 | // ret = ret.Replace(c, '_'); | ||
476 | //} | ||
477 | |||
478 | return ret; | ||
479 | } | ||
480 | |||
481 | /// <summary> | ||
482 | /// | ||
483 | /// </summary> | ||
484 | /// <param name="path"></param> | ||
485 | /// <returns></returns> | ||
486 | public static string MakeReferencePath(string path) | ||
487 | { | ||
488 | string ret = EndPath(NormalizePath(path)); | ||
489 | |||
490 | //foreach (char c in Path.GetInvalidPathChars()) | ||
491 | //{ | ||
492 | // ret = ret.Replace(c, '_'); | ||
493 | //} | ||
494 | |||
495 | return ret; | ||
496 | } | ||
497 | |||
498 | /// <summary> | ||
499 | /// Sets the current dir. | ||
500 | /// </summary> | ||
501 | /// <param name="path">The path.</param> | ||
502 | public static void SetCurrentDir(string path) | ||
503 | { | ||
504 | if( path == null ) | ||
505 | { | ||
506 | throw new ArgumentNullException("path"); | ||
507 | } | ||
508 | if(path.Length < 1) | ||
509 | { | ||
510 | return; | ||
511 | } | ||
512 | |||
513 | Environment.CurrentDirectory = path; | ||
514 | } | ||
515 | |||
516 | /// <summary> | ||
517 | /// Checks the type. | ||
518 | /// </summary> | ||
519 | /// <param name="typeToCheck">The type to check.</param> | ||
520 | /// <param name="attr">The attr.</param> | ||
521 | /// <param name="inter">The inter.</param> | ||
522 | /// <returns></returns> | ||
523 | public static object CheckType(Type typeToCheck, Type attr, Type inter) | ||
524 | { | ||
525 | if(typeToCheck == null || attr == null) | ||
526 | { | ||
527 | return null; | ||
528 | } | ||
529 | |||
530 | object[] attrs = typeToCheck.GetCustomAttributes(attr, false); | ||
531 | if(attrs == null || attrs.Length < 1) | ||
532 | { | ||
533 | return null; | ||
534 | } | ||
535 | if( inter == null ) | ||
536 | { | ||
537 | throw new ArgumentNullException("inter"); | ||
538 | } | ||
539 | |||
540 | if(typeToCheck.GetInterface(inter.FullName) == null) | ||
541 | { | ||
542 | return null; | ||
543 | } | ||
544 | |||
545 | return attrs[0]; | ||
546 | } | ||
547 | |||
548 | /* A bit of overhead for simple group parsing, there are problems with Regex in Mono | ||
549 | public static string ParseValue(string val) | ||
550 | { | ||
551 | if(val == null || val.Length < 1 || !CheckForOSVariables) | ||
552 | return val; | ||
553 | |||
554 | string tmp = val; | ||
555 | Match m = m_VarRegex.Match(val); | ||
556 | while(m.Success) | ||
557 | { | ||
558 | if(m.Groups["var"] == null) | ||
559 | continue; | ||
560 | |||
561 | Capture c = m.Groups["var"].Captures[0]; | ||
562 | if(c == null) | ||
563 | continue; | ||
564 | |||
565 | string var = c.Value; | ||
566 | string envVal = Environment.GetEnvironmentVariable(var); | ||
567 | if(envVal == null) | ||
568 | envVal = ""; | ||
569 | |||
570 | tmp = tmp.Replace("${" + var + "}", envVal); | ||
571 | m = m.NextMatch(); | ||
572 | } | ||
573 | |||
574 | return tmp; | ||
575 | }*/ | ||
576 | |||
577 | /// <summary> | ||
578 | /// Attributes the value. | ||
579 | /// </summary> | ||
580 | /// <param name="node">The node.</param> | ||
581 | /// <param name="attr">The attr.</param> | ||
582 | /// <param name="def">The def.</param> | ||
583 | /// <returns></returns> | ||
584 | public static string AttributeValue(XmlNode node, string attr, string def) | ||
585 | { | ||
586 | if( node == null ) | ||
587 | { | ||
588 | throw new ArgumentNullException("node"); | ||
589 | } | ||
590 | if(node.Attributes[attr] == null) | ||
591 | { | ||
592 | return def; | ||
593 | } | ||
594 | string val = node.Attributes[attr].Value; | ||
595 | if(!CheckForOSVariables) | ||
596 | { | ||
597 | return val; | ||
598 | } | ||
599 | |||
600 | return InterpolateForEnvironmentVariables(val); | ||
601 | } | ||
602 | |||
603 | /// <summary> | ||
604 | /// Parses the boolean. | ||
605 | /// </summary> | ||
606 | /// <param name="node">The node.</param> | ||
607 | /// <param name="attr">The attr.</param> | ||
608 | /// <param name="defaultValue">if set to <c>true</c> [default value].</param> | ||
609 | /// <returns></returns> | ||
610 | public static bool ParseBoolean(XmlNode node, string attr, bool defaultValue) | ||
611 | { | ||
612 | if( node == null ) | ||
613 | { | ||
614 | throw new ArgumentNullException("node"); | ||
615 | } | ||
616 | if(node.Attributes[attr] == null) | ||
617 | { | ||
618 | return defaultValue; | ||
619 | } | ||
620 | return bool.Parse(node.Attributes[attr].Value); | ||
621 | } | ||
622 | |||
623 | /// <summary> | ||
624 | /// Enums the attribute value. | ||
625 | /// </summary> | ||
626 | /// <param name="node">The node.</param> | ||
627 | /// <param name="attr">The attr.</param> | ||
628 | /// <param name="enumType">Type of the enum.</param> | ||
629 | /// <param name="def">The def.</param> | ||
630 | /// <returns></returns> | ||
631 | public static object EnumAttributeValue(XmlNode node, string attr, Type enumType, object def) | ||
632 | { | ||
633 | if( def == null ) | ||
634 | { | ||
635 | throw new ArgumentNullException("def"); | ||
636 | } | ||
637 | string val = AttributeValue(node, attr, def.ToString()); | ||
638 | return Enum.Parse(enumType, val, true); | ||
639 | } | ||
640 | |||
641 | /// <summary> | ||
642 | /// | ||
643 | /// </summary> | ||
644 | /// <param name="assemblyName"></param> | ||
645 | /// <param name="projectType"></param> | ||
646 | /// <returns></returns> | ||
647 | public static string AssemblyFullName(string assemblyName, ProjectType projectType) | ||
648 | { | ||
649 | return assemblyName + (projectType == ProjectType.Library ? ".dll" : ".exe"); | ||
650 | } | ||
651 | |||
652 | #endregion | ||
653 | } | ||
654 | } | ||
diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs deleted file mode 100644 index 548e987..0000000 --- a/Prebuild/src/Core/Utilities/Log.cs +++ /dev/null | |||
@@ -1,270 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.IO; | ||
28 | |||
29 | namespace Prebuild.Core.Utilities | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// | ||
33 | /// </summary> | ||
34 | public enum LogType | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// | ||
38 | /// </summary> | ||
39 | None, | ||
40 | /// <summary> | ||
41 | /// | ||
42 | /// </summary> | ||
43 | Info, | ||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | Warning, | ||
48 | /// <summary> | ||
49 | /// | ||
50 | /// </summary> | ||
51 | Error | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// | ||
56 | /// </summary> | ||
57 | [Flags] | ||
58 | public enum LogTargets | ||
59 | { | ||
60 | /// <summary> | ||
61 | /// | ||
62 | /// </summary> | ||
63 | None = 0, | ||
64 | /// <summary> | ||
65 | /// | ||
66 | /// </summary> | ||
67 | Null = 1, | ||
68 | /// <summary> | ||
69 | /// | ||
70 | /// </summary> | ||
71 | File = 2, | ||
72 | /// <summary> | ||
73 | /// | ||
74 | /// </summary> | ||
75 | Console = 4 | ||
76 | } | ||
77 | |||
78 | /// <summary> | ||
79 | /// Summary description for Log. | ||
80 | /// </summary> | ||
81 | public class Log : IDisposable | ||
82 | { | ||
83 | #region Fields | ||
84 | |||
85 | private StreamWriter m_Writer; | ||
86 | private LogTargets m_Target = LogTargets.Null; | ||
87 | bool disposed; | ||
88 | |||
89 | #endregion | ||
90 | |||
91 | #region Constructors | ||
92 | |||
93 | /// <summary> | ||
94 | /// Initializes a new instance of the <see cref="Log"/> class. | ||
95 | /// </summary> | ||
96 | /// <param name="target">The target.</param> | ||
97 | /// <param name="fileName">Name of the file.</param> | ||
98 | public Log(LogTargets target, string fileName) | ||
99 | { | ||
100 | m_Target = target; | ||
101 | |||
102 | if((m_Target & LogTargets.File) != 0) | ||
103 | { | ||
104 | m_Writer = new StreamWriter(fileName, false); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | #endregion | ||
109 | |||
110 | #region Public Methods | ||
111 | |||
112 | /// <summary> | ||
113 | /// Writes this instance. | ||
114 | /// </summary> | ||
115 | public void Write() | ||
116 | { | ||
117 | Write(string.Empty); | ||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// Writes the specified MSG. | ||
122 | /// </summary> | ||
123 | /// <param name="msg">The MSG.</param> | ||
124 | public void Write(string msg) | ||
125 | { | ||
126 | if((m_Target & LogTargets.Null) != 0) | ||
127 | { | ||
128 | return; | ||
129 | } | ||
130 | |||
131 | if((m_Target & LogTargets.Console) != 0) | ||
132 | { | ||
133 | Console.WriteLine(msg); | ||
134 | } | ||
135 | if((m_Target & LogTargets.File) != 0 && m_Writer != null) | ||
136 | { | ||
137 | m_Writer.WriteLine(msg); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | /// <summary> | ||
142 | /// Writes the specified format. | ||
143 | /// </summary> | ||
144 | /// <param name="format">The format.</param> | ||
145 | /// <param name="args">The args.</param> | ||
146 | public void Write(string format, params object[] args) | ||
147 | { | ||
148 | Write(string.Format(format,args)); | ||
149 | } | ||
150 | |||
151 | /// <summary> | ||
152 | /// Writes the specified type. | ||
153 | /// </summary> | ||
154 | /// <param name="type">The type.</param> | ||
155 | /// <param name="format">The format.</param> | ||
156 | /// <param name="args">The args.</param> | ||
157 | public void Write(LogType type, string format, params object[] args) | ||
158 | { | ||
159 | if((m_Target & LogTargets.Null) != 0) | ||
160 | { | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | string str = ""; | ||
165 | switch(type) | ||
166 | { | ||
167 | case LogType.Info: | ||
168 | str = "[I] "; | ||
169 | break; | ||
170 | case LogType.Warning: | ||
171 | str = "[!] "; | ||
172 | break; | ||
173 | case LogType.Error: | ||
174 | str = "[X] "; | ||
175 | break; | ||
176 | } | ||
177 | |||
178 | Write(str + format,args); | ||
179 | } | ||
180 | |||
181 | /// <summary> | ||
182 | /// Writes the exception. | ||
183 | /// </summary> | ||
184 | /// <param name="type">The type.</param> | ||
185 | /// <param name="ex">The ex.</param> | ||
186 | public void WriteException(LogType type, Exception ex) | ||
187 | { | ||
188 | if(ex != null) | ||
189 | { | ||
190 | Write(type, ex.Message); | ||
191 | //#if DEBUG | ||
192 | m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name); | ||
193 | m_Writer.WriteLine(ex.StackTrace); | ||
194 | m_Writer.WriteLine("]]"); | ||
195 | //#endif | ||
196 | } | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// Flushes this instance. | ||
201 | /// </summary> | ||
202 | public void Flush() | ||
203 | { | ||
204 | if(m_Writer != null) | ||
205 | { | ||
206 | m_Writer.Flush(); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | #endregion | ||
211 | |||
212 | #region IDisposable Members | ||
213 | |||
214 | /// <summary> | ||
215 | /// Performs application-defined tasks associated with freeing, releasing, or | ||
216 | /// resetting unmanaged resources. | ||
217 | /// </summary> | ||
218 | public void Dispose() | ||
219 | { | ||
220 | Dispose(true); | ||
221 | GC.SuppressFinalize(this); | ||
222 | } | ||
223 | |||
224 | /// <summary> | ||
225 | /// Dispose objects | ||
226 | /// </summary> | ||
227 | /// <param name="disposing"> | ||
228 | /// If true, it will dispose close the handle | ||
229 | /// </param> | ||
230 | /// <remarks> | ||
231 | /// Will dispose managed and unmanaged resources. | ||
232 | /// </remarks> | ||
233 | protected virtual void Dispose(bool disposing) | ||
234 | { | ||
235 | if (!this.disposed) | ||
236 | { | ||
237 | if (disposing) | ||
238 | { | ||
239 | if (m_Writer != null) | ||
240 | { | ||
241 | m_Writer.Close(); | ||
242 | m_Writer = null; | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | this.disposed = true; | ||
247 | } | ||
248 | |||
249 | /// <summary> | ||
250 | /// | ||
251 | /// </summary> | ||
252 | ~Log() | ||
253 | { | ||
254 | this.Dispose(false); | ||
255 | } | ||
256 | |||
257 | /// <summary> | ||
258 | /// Closes and destroys this object | ||
259 | /// </summary> | ||
260 | /// <remarks> | ||
261 | /// Same as Dispose(true) | ||
262 | /// </remarks> | ||
263 | public void Close() | ||
264 | { | ||
265 | Dispose(); | ||
266 | } | ||
267 | |||
268 | #endregion | ||
269 | } | ||
270 | } | ||
diff --git a/Prebuild/src/Core/WarningException.cs b/Prebuild/src/Core/WarningException.cs deleted file mode 100644 index df90dc8..0000000 --- a/Prebuild/src/Core/WarningException.cs +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | #region BSD License | ||
2 | /* | ||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | ||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | ||
6 | provided that the following conditions are met: | ||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | ||
9 | and the following disclaimer. | ||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
11 | and the following disclaimer in the documentation and/or other materials provided with the | ||
12 | distribution. | ||
13 | * The name of the author may not be used to endorse or promote products derived from this software | ||
14 | without specific prior written permission. | ||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | ||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | #endregion | ||
25 | |||
26 | using System; | ||
27 | using System.Runtime.Serialization; | ||
28 | |||
29 | namespace Prebuild.Core | ||
30 | { | ||
31 | /// <summary> | ||
32 | /// | ||
33 | /// </summary> | ||
34 | [Serializable()] | ||
35 | public class WarningException : Exception | ||
36 | { | ||
37 | #region Constructors | ||
38 | |||
39 | /// <summary> | ||
40 | /// | ||
41 | /// </summary> | ||
42 | public WarningException() | ||
43 | { | ||
44 | } | ||
45 | |||
46 | /// <summary> | ||
47 | /// | ||
48 | /// </summary> | ||
49 | /// <param name="format"></param> | ||
50 | /// <param name="args"></param> | ||
51 | public WarningException(string format, params object[] args) | ||
52 | : base(String.Format(format, args)) | ||
53 | { | ||
54 | } | ||
55 | |||
56 | /// <summary> | ||
57 | /// Exception with specified string | ||
58 | /// </summary> | ||
59 | /// <param name="message">Exception message</param> | ||
60 | public WarningException(string message): base(message) | ||
61 | { | ||
62 | } | ||
63 | |||
64 | /// <summary> | ||
65 | /// | ||
66 | /// </summary> | ||
67 | /// <param name="message"></param> | ||
68 | /// <param name="exception"></param> | ||
69 | public WarningException(string message, Exception exception) : base(message, exception) | ||
70 | { | ||
71 | } | ||
72 | |||
73 | /// <summary> | ||
74 | /// | ||
75 | /// </summary> | ||
76 | /// <param name="info"></param> | ||
77 | /// <param name="context"></param> | ||
78 | protected WarningException(SerializationInfo info, StreamingContext context) : base( info, context ) | ||
79 | { | ||
80 | } | ||
81 | |||
82 | #endregion | ||
83 | } | ||
84 | } | ||