diff options
Diffstat (limited to 'Prebuild/src/Core/Targets/MonoDevelopTarget.cs')
-rw-r--r-- | Prebuild/src/Core/Targets/MonoDevelopTarget.cs | 916 |
1 files changed, 458 insertions, 458 deletions
diff --git a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs index 8620e4b..7c0a1e2 100644 --- a/Prebuild/src/Core/Targets/MonoDevelopTarget.cs +++ b/Prebuild/src/Core/Targets/MonoDevelopTarget.cs | |||
@@ -1,458 +1,458 @@ | |||
1 | #region BSD License | 1 | #region BSD License |
2 | /* | 2 | /* |
3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) | 3 | Copyright (c) 2004 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) |
4 | 4 | ||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted |
6 | provided that the following conditions are met: | 6 | provided that the following conditions are met: |
7 | 7 | ||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | 8 | * Redistributions of source code must retain the above copyright notice, this list of conditions |
9 | and the following disclaimer. | 9 | and the following disclaimer. |
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | 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 | 11 | and the following disclaimer in the documentation and/or other materials provided with the |
12 | distribution. | 12 | distribution. |
13 | * The name of the author may not be used to endorse or promote products derived from this software | 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. | 14 | without specific prior written permission. |
15 | 15 | ||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | 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 | 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, | 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 | 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 | 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 | 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. | 22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 23 | */ |
24 | #endregion | 24 | #endregion |
25 | 25 | ||
26 | #region CVS Information | 26 | #region CVS Information |
27 | /* | 27 | /* |
28 | * $Source$ | 28 | * $Source$ |
29 | * $Author: jendave $ | 29 | * $Author: jendave $ |
30 | * $Date: 2007-02-13 22:07:07 +0100 (ti, 13 feb 2007) $ | 30 | * $Date: 2007-02-13 22:07:07 +0100 (ti, 13 feb 2007) $ |
31 | * $Revision: 206 $ | 31 | * $Revision: 206 $ |
32 | */ | 32 | */ |
33 | #endregion | 33 | #endregion |
34 | 34 | ||
35 | using System; | 35 | using System; |
36 | using System.Collections; | 36 | using System.Collections; |
37 | using System.Collections.Specialized; | 37 | using System.Collections.Specialized; |
38 | using System.IO; | 38 | using System.IO; |
39 | using System.Reflection; | 39 | using System.Reflection; |
40 | using System.Text.RegularExpressions; | 40 | using System.Text.RegularExpressions; |
41 | 41 | ||
42 | using Prebuild.Core.Attributes; | 42 | using Prebuild.Core.Attributes; |
43 | using Prebuild.Core.Interfaces; | 43 | using Prebuild.Core.Interfaces; |
44 | using Prebuild.Core.Nodes; | 44 | using Prebuild.Core.Nodes; |
45 | using Prebuild.Core.Utilities; | 45 | using Prebuild.Core.Utilities; |
46 | 46 | ||
47 | namespace Prebuild.Core.Targets | 47 | namespace Prebuild.Core.Targets |
48 | { | 48 | { |
49 | /// <summary> | 49 | /// <summary> |
50 | /// | 50 | /// |
51 | /// </summary> | 51 | /// </summary> |
52 | [Target("monodev")] | 52 | [Target("monodev")] |
53 | public class MonoDevelopTarget : ITarget | 53 | public class MonoDevelopTarget : ITarget |
54 | { | 54 | { |
55 | #region Fields | 55 | #region Fields |
56 | 56 | ||
57 | private Kernel m_Kernel; | 57 | private Kernel m_Kernel; |
58 | 58 | ||
59 | #endregion | 59 | #endregion |
60 | 60 | ||
61 | #region Private Methods | 61 | #region Private Methods |
62 | 62 | ||
63 | private static string PrependPath(string path) | 63 | private static string PrependPath(string path) |
64 | { | 64 | { |
65 | string tmpPath = Helper.NormalizePath(path, '/'); | 65 | string tmpPath = Helper.NormalizePath(path, '/'); |
66 | Regex regex = new Regex(@"(\w):/(\w+)"); | 66 | Regex regex = new Regex(@"(\w):/(\w+)"); |
67 | Match match = regex.Match(tmpPath); | 67 | Match match = regex.Match(tmpPath); |
68 | if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | 68 | if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') |
69 | { | 69 | { |
70 | tmpPath = Helper.NormalizePath(tmpPath); | 70 | tmpPath = Helper.NormalizePath(tmpPath); |
71 | } | 71 | } |
72 | else | 72 | else |
73 | { | 73 | { |
74 | tmpPath = Helper.NormalizePath("./" + tmpPath); | 74 | tmpPath = Helper.NormalizePath("./" + tmpPath); |
75 | } | 75 | } |
76 | 76 | ||
77 | return tmpPath; | 77 | return tmpPath; |
78 | } | 78 | } |
79 | 79 | ||
80 | private static string BuildReference(SolutionNode solution, ReferenceNode refr) | 80 | private static string BuildReference(SolutionNode solution, ReferenceNode refr) |
81 | { | 81 | { |
82 | string ret = "<ProjectReference type=\""; | 82 | string ret = "<ProjectReference type=\""; |
83 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | 83 | if(solution.ProjectsTable.ContainsKey(refr.Name)) |
84 | { | 84 | { |
85 | ret += "Project\""; | 85 | ret += "Project\""; |
86 | ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />"; | 86 | ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />"; |
87 | } | 87 | } |
88 | else | 88 | else |
89 | { | 89 | { |
90 | ProjectNode project = (ProjectNode)refr.Parent; | 90 | ProjectNode project = (ProjectNode)refr.Parent; |
91 | string fileRef = FindFileReference(refr.Name, project); | 91 | string fileRef = FindFileReference(refr.Name, project); |
92 | 92 | ||
93 | if(refr.Path != null || fileRef != null) | 93 | if(refr.Path != null || fileRef != null) |
94 | { | 94 | { |
95 | ret += "Assembly\" refto=\""; | 95 | ret += "Assembly\" refto=\""; |
96 | 96 | ||
97 | string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; | 97 | string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef; |
98 | 98 | ||
99 | ret += finalPath; | 99 | ret += finalPath; |
100 | ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; | 100 | ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />"; |
101 | return ret; | 101 | return ret; |
102 | } | 102 | } |
103 | 103 | ||
104 | ret += "Gac\""; | 104 | ret += "Gac\""; |
105 | ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; | 105 | ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\""; |
106 | ret += " refto=\""; | 106 | ret += " refto=\""; |
107 | try | 107 | try |
108 | { | 108 | { |
109 | //Assembly assem = Assembly.Load(refr.Name); | 109 | //Assembly assem = Assembly.Load(refr.Name); |
110 | //ret += assem.FullName; | 110 | //ret += assem.FullName; |
111 | ret += refr.Name; | 111 | ret += refr.Name; |
112 | } | 112 | } |
113 | catch (System.NullReferenceException e) | 113 | catch (System.NullReferenceException e) |
114 | { | 114 | { |
115 | e.ToString(); | 115 | e.ToString(); |
116 | ret += refr.Name; | 116 | ret += refr.Name; |
117 | } | 117 | } |
118 | ret += "\" />"; | 118 | ret += "\" />"; |
119 | } | 119 | } |
120 | 120 | ||
121 | return ret; | 121 | return ret; |
122 | } | 122 | } |
123 | 123 | ||
124 | private static string FindFileReference(string refName, ProjectNode project) | 124 | private static string FindFileReference(string refName, ProjectNode project) |
125 | { | 125 | { |
126 | foreach(ReferencePathNode refPath in project.ReferencePaths) | 126 | foreach(ReferencePathNode refPath in project.ReferencePaths) |
127 | { | 127 | { |
128 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | 128 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); |
129 | 129 | ||
130 | if(File.Exists(fullPath)) | 130 | if(File.Exists(fullPath)) |
131 | { | 131 | { |
132 | return fullPath; | 132 | return fullPath; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | return null; | 136 | return null; |
137 | } | 137 | } |
138 | 138 | ||
139 | /// <summary> | 139 | /// <summary> |
140 | /// Gets the XML doc file. | 140 | /// Gets the XML doc file. |
141 | /// </summary> | 141 | /// </summary> |
142 | /// <param name="project">The project.</param> | 142 | /// <param name="project">The project.</param> |
143 | /// <param name="conf">The conf.</param> | 143 | /// <param name="conf">The conf.</param> |
144 | /// <returns></returns> | 144 | /// <returns></returns> |
145 | public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) | 145 | public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf) |
146 | { | 146 | { |
147 | if( conf == null ) | 147 | if( conf == null ) |
148 | { | 148 | { |
149 | throw new ArgumentNullException("conf"); | 149 | throw new ArgumentNullException("conf"); |
150 | } | 150 | } |
151 | if( project == null ) | 151 | if( project == null ) |
152 | { | 152 | { |
153 | throw new ArgumentNullException("project"); | 153 | throw new ArgumentNullException("project"); |
154 | } | 154 | } |
155 | string docFile = (string)conf.Options["XmlDocFile"]; | 155 | string docFile = (string)conf.Options["XmlDocFile"]; |
156 | if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | 156 | if(docFile != null && docFile.Length == 0)//default to assembly name if not specified |
157 | { | 157 | { |
158 | return "False"; | 158 | return "False"; |
159 | } | 159 | } |
160 | return "True"; | 160 | return "True"; |
161 | } | 161 | } |
162 | 162 | ||
163 | private void WriteProject(SolutionNode solution, ProjectNode project) | 163 | private void WriteProject(SolutionNode solution, ProjectNode project) |
164 | { | 164 | { |
165 | string csComp = "Mcs"; | 165 | string csComp = "Mcs"; |
166 | string netRuntime = "Mono"; | 166 | string netRuntime = "Mono"; |
167 | if(project.Runtime == ClrRuntime.Microsoft) | 167 | if(project.Runtime == ClrRuntime.Microsoft) |
168 | { | 168 | { |
169 | csComp = "Csc"; | 169 | csComp = "Csc"; |
170 | netRuntime = "MsNet"; | 170 | netRuntime = "MsNet"; |
171 | } | 171 | } |
172 | 172 | ||
173 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); | 173 | string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); |
174 | StreamWriter ss = new StreamWriter(projFile); | 174 | StreamWriter ss = new StreamWriter(projFile); |
175 | 175 | ||
176 | m_Kernel.CurrentWorkingDirectory.Push(); | 176 | m_Kernel.CurrentWorkingDirectory.Push(); |
177 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | 177 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); |
178 | 178 | ||
179 | using(ss) | 179 | using(ss) |
180 | { | 180 | { |
181 | ss.WriteLine( | 181 | ss.WriteLine( |
182 | "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">", | 182 | "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">", |
183 | project.Name, | 183 | project.Name, |
184 | project.RootNamespace | 184 | project.RootNamespace |
185 | ); | 185 | ); |
186 | 186 | ||
187 | int count = 0; | 187 | int count = 0; |
188 | 188 | ||
189 | ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig); | 189 | ss.WriteLine(" <Configurations active=\"{0}\">", solution.ActiveConfig); |
190 | 190 | ||
191 | foreach(ConfigurationNode conf in project.Configurations) | 191 | foreach(ConfigurationNode conf in project.Configurations) |
192 | { | 192 | { |
193 | ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name); | 193 | ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name); |
194 | ss.Write(" <Output"); | 194 | ss.Write(" <Output"); |
195 | ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString()))); | 195 | ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString()))); |
196 | ss.Write(" assembly=\"{0}\"", project.AssemblyName); | 196 | ss.Write(" assembly=\"{0}\"", project.AssemblyName); |
197 | ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]); | 197 | ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]); |
198 | //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); | 198 | //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); |
199 | //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); | 199 | //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); |
200 | if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) | 200 | if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) |
201 | { | 201 | { |
202 | ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); | 202 | ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); |
203 | } | 203 | } |
204 | else | 204 | else |
205 | { | 205 | { |
206 | ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); | 206 | ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]); |
207 | } | 207 | } |
208 | if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) | 208 | if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) |
209 | { | 209 | { |
210 | ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); | 210 | ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); |
211 | } | 211 | } |
212 | else | 212 | else |
213 | { | 213 | { |
214 | ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); | 214 | ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]); |
215 | } | 215 | } |
216 | ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); | 216 | ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); |
217 | ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); | 217 | ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]); |
218 | ss.WriteLine(" />"); | 218 | ss.WriteLine(" />"); |
219 | 219 | ||
220 | ss.Write(" <Build"); | 220 | ss.Write(" <Build"); |
221 | ss.Write(" debugmode=\"True\""); | 221 | ss.Write(" debugmode=\"True\""); |
222 | if (project.Type == ProjectType.WinExe) | 222 | if (project.Type == ProjectType.WinExe) |
223 | { | 223 | { |
224 | ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString()); | 224 | ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString()); |
225 | } | 225 | } |
226 | else | 226 | else |
227 | { | 227 | { |
228 | ss.Write(" target=\"{0}\"", project.Type); | 228 | ss.Write(" target=\"{0}\"", project.Type); |
229 | } | 229 | } |
230 | ss.WriteLine(" />"); | 230 | ss.WriteLine(" />"); |
231 | 231 | ||
232 | ss.Write(" <Execution"); | 232 | ss.Write(" <Execution"); |
233 | ss.Write(" runwithwarnings=\"True\""); | 233 | ss.Write(" runwithwarnings=\"True\""); |
234 | ss.Write(" consolepause=\"True\""); | 234 | ss.Write(" consolepause=\"True\""); |
235 | ss.Write(" runtime=\"{0}\"", netRuntime); | 235 | ss.Write(" runtime=\"{0}\"", netRuntime); |
236 | ss.Write(" clr-version=\"Net_2_0\""); | 236 | ss.Write(" clr-version=\"Net_2_0\""); |
237 | ss.WriteLine(" />"); | 237 | ss.WriteLine(" />"); |
238 | 238 | ||
239 | ss.Write(" <CodeGeneration"); | 239 | ss.Write(" <CodeGeneration"); |
240 | ss.Write(" compiler=\"{0}\"", csComp); | 240 | ss.Write(" compiler=\"{0}\"", csComp); |
241 | ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]); | 241 | ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]); |
242 | ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]); | 242 | ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]); |
243 | ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]); | 243 | ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]); |
244 | ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]); | 244 | ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]); |
245 | ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]); | 245 | ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]); |
246 | ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]); | 246 | ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]); |
247 | ss.Write(" mainclass=\"{0}\"", project.StartupObject); | 247 | ss.Write(" mainclass=\"{0}\"", project.StartupObject); |
248 | ss.Write(" target=\"{0}\"", project.Type); | 248 | ss.Write(" target=\"{0}\"", project.Type); |
249 | ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]); | 249 | ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]); |
250 | ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf)); | 250 | ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf)); |
251 | ss.Write(" win32Icon=\"{0}\"", project.AppIcon); | 251 | ss.Write(" win32Icon=\"{0}\"", project.AppIcon); |
252 | ss.Write(" ctype=\"CSharpCompilerParameters\""); | 252 | ss.Write(" ctype=\"CSharpCompilerParameters\""); |
253 | ss.WriteLine(" />"); | 253 | ss.WriteLine(" />"); |
254 | ss.WriteLine(" </Configuration>"); | 254 | ss.WriteLine(" </Configuration>"); |
255 | 255 | ||
256 | count++; | 256 | count++; |
257 | } | 257 | } |
258 | ss.WriteLine(" </Configurations>"); | 258 | ss.WriteLine(" </Configurations>"); |
259 | 259 | ||
260 | ss.Write(" <DeploymentInformation"); | 260 | ss.Write(" <DeploymentInformation"); |
261 | ss.Write(" target=\"\""); | 261 | ss.Write(" target=\"\""); |
262 | ss.Write(" script=\"\""); | 262 | ss.Write(" script=\"\""); |
263 | ss.Write(" strategy=\"File\""); | 263 | ss.Write(" strategy=\"File\""); |
264 | ss.WriteLine(">"); | 264 | ss.WriteLine(">"); |
265 | ss.WriteLine(" <excludeFiles />"); | 265 | ss.WriteLine(" <excludeFiles />"); |
266 | ss.WriteLine(" </DeploymentInformation>"); | 266 | ss.WriteLine(" </DeploymentInformation>"); |
267 | 267 | ||
268 | ss.WriteLine(" <Contents>"); | 268 | ss.WriteLine(" <Contents>"); |
269 | foreach(string file in project.Files) | 269 | foreach(string file in project.Files) |
270 | { | 270 | { |
271 | string buildAction = "Compile"; | 271 | string buildAction = "Compile"; |
272 | switch(project.Files.GetBuildAction(file)) | 272 | switch(project.Files.GetBuildAction(file)) |
273 | { | 273 | { |
274 | case BuildAction.None: | 274 | case BuildAction.None: |
275 | buildAction = "Nothing"; | 275 | buildAction = "Nothing"; |
276 | break; | 276 | break; |
277 | 277 | ||
278 | case BuildAction.Content: | 278 | case BuildAction.Content: |
279 | buildAction = "Exclude"; | 279 | buildAction = "Exclude"; |
280 | break; | 280 | break; |
281 | 281 | ||
282 | case BuildAction.EmbeddedResource: | 282 | case BuildAction.EmbeddedResource: |
283 | buildAction = "EmbedAsResource"; | 283 | buildAction = "EmbedAsResource"; |
284 | break; | 284 | break; |
285 | 285 | ||
286 | default: | 286 | default: |
287 | buildAction = "Compile"; | 287 | buildAction = "Compile"; |
288 | break; | 288 | break; |
289 | } | 289 | } |
290 | 290 | ||
291 | // Sort of a hack, we try and resolve the path and make it relative, if we can. | 291 | // Sort of a hack, we try and resolve the path and make it relative, if we can. |
292 | string filePath = PrependPath(file); | 292 | string filePath = PrependPath(file); |
293 | ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction); | 293 | ss.WriteLine(" <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction); |
294 | } | 294 | } |
295 | ss.WriteLine(" </Contents>"); | 295 | ss.WriteLine(" </Contents>"); |
296 | 296 | ||
297 | ss.WriteLine(" <References>"); | 297 | ss.WriteLine(" <References>"); |
298 | foreach(ReferenceNode refr in project.References) | 298 | foreach(ReferenceNode refr in project.References) |
299 | { | 299 | { |
300 | ss.WriteLine(" {0}", BuildReference(solution, refr)); | 300 | ss.WriteLine(" {0}", BuildReference(solution, refr)); |
301 | } | 301 | } |
302 | ss.WriteLine(" </References>"); | 302 | ss.WriteLine(" </References>"); |
303 | 303 | ||
304 | 304 | ||
305 | ss.WriteLine("</Project>"); | 305 | ss.WriteLine("</Project>"); |
306 | } | 306 | } |
307 | 307 | ||
308 | m_Kernel.CurrentWorkingDirectory.Pop(); | 308 | m_Kernel.CurrentWorkingDirectory.Pop(); |
309 | } | 309 | } |
310 | 310 | ||
311 | private void WriteCombine(SolutionNode solution) | 311 | private void WriteCombine(SolutionNode solution) |
312 | { | 312 | { |
313 | m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); | 313 | m_Kernel.Log.Write("Creating MonoDevelop combine and project files"); |
314 | foreach(ProjectNode project in solution.Projects) | 314 | foreach(ProjectNode project in solution.Projects) |
315 | { | 315 | { |
316 | if(m_Kernel.AllowProject(project.FilterGroups)) | 316 | if(m_Kernel.AllowProject(project.FilterGroups)) |
317 | { | 317 | { |
318 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); | 318 | m_Kernel.Log.Write("...Creating project: {0}", project.Name); |
319 | WriteProject(solution, project); | 319 | WriteProject(solution, project); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | m_Kernel.Log.Write(""); | 323 | m_Kernel.Log.Write(""); |
324 | string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); | 324 | string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); |
325 | StreamWriter ss = new StreamWriter(combFile); | 325 | StreamWriter ss = new StreamWriter(combFile); |
326 | 326 | ||
327 | m_Kernel.CurrentWorkingDirectory.Push(); | 327 | m_Kernel.CurrentWorkingDirectory.Push(); |
328 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | 328 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); |
329 | 329 | ||
330 | int count = 0; | 330 | int count = 0; |
331 | 331 | ||
332 | using(ss) | 332 | using(ss) |
333 | { | 333 | { |
334 | ss.WriteLine("<Combine name=\"{0}\" fileversion=\"2.0\" description=\"\">", solution.Name); | 334 | ss.WriteLine("<Combine name=\"{0}\" fileversion=\"2.0\" description=\"\">", solution.Name); |
335 | 335 | ||
336 | count = 0; | 336 | count = 0; |
337 | foreach(ConfigurationNode conf in solution.Configurations) | 337 | foreach(ConfigurationNode conf in solution.Configurations) |
338 | { | 338 | { |
339 | if(count == 0) | 339 | if(count == 0) |
340 | { | 340 | { |
341 | ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name); | 341 | ss.WriteLine(" <Configurations active=\"{0}\">", conf.Name); |
342 | } | 342 | } |
343 | 343 | ||
344 | ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"CombineConfiguration\">", conf.Name); | 344 | ss.WriteLine(" <Configuration name=\"{0}\" ctype=\"CombineConfiguration\">", conf.Name); |
345 | foreach(ProjectNode project in solution.Projects) | 345 | foreach(ProjectNode project in solution.Projects) |
346 | { | 346 | { |
347 | ss.WriteLine(" <Entry configuration=\"{1}\" build=\"True\" name=\"{0}\" />", project.Name, conf.Name); | 347 | ss.WriteLine(" <Entry configuration=\"{1}\" build=\"True\" name=\"{0}\" />", project.Name, conf.Name); |
348 | } | 348 | } |
349 | ss.WriteLine(" </Configuration>"); | 349 | ss.WriteLine(" </Configuration>"); |
350 | 350 | ||
351 | count++; | 351 | count++; |
352 | } | 352 | } |
353 | ss.WriteLine(" </Configurations>"); | 353 | ss.WriteLine(" </Configurations>"); |
354 | 354 | ||
355 | count = 0; | 355 | count = 0; |
356 | 356 | ||
357 | foreach(ProjectNode project in solution.Projects) | 357 | foreach(ProjectNode project in solution.Projects) |
358 | { | 358 | { |
359 | if(count == 0) | 359 | if(count == 0) |
360 | ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name); | 360 | ss.WriteLine(" <StartMode startupentry=\"{0}\" single=\"True\">", project.Name); |
361 | 361 | ||
362 | ss.WriteLine(" <Execute type=\"None\" entry=\"{0}\" />", project.Name); | 362 | ss.WriteLine(" <Execute type=\"None\" entry=\"{0}\" />", project.Name); |
363 | count++; | 363 | count++; |
364 | } | 364 | } |
365 | ss.WriteLine(" </StartMode>"); | 365 | ss.WriteLine(" </StartMode>"); |
366 | 366 | ||
367 | ss.WriteLine(" <Entries>"); | 367 | ss.WriteLine(" <Entries>"); |
368 | foreach(ProjectNode project in solution.Projects) | 368 | foreach(ProjectNode project in solution.Projects) |
369 | { | 369 | { |
370 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | 370 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); |
371 | ss.WriteLine(" <Entry filename=\"{0}\" />", | 371 | ss.WriteLine(" <Entry filename=\"{0}\" />", |
372 | Helper.MakeFilePath(path, project.Name, "mdp")); | 372 | Helper.MakeFilePath(path, project.Name, "mdp")); |
373 | } | 373 | } |
374 | ss.WriteLine(" </Entries>"); | 374 | ss.WriteLine(" </Entries>"); |
375 | 375 | ||
376 | ss.WriteLine("</Combine>"); | 376 | ss.WriteLine("</Combine>"); |
377 | } | 377 | } |
378 | 378 | ||
379 | m_Kernel.CurrentWorkingDirectory.Pop(); | 379 | m_Kernel.CurrentWorkingDirectory.Pop(); |
380 | } | 380 | } |
381 | 381 | ||
382 | private void CleanProject(ProjectNode project) | 382 | private void CleanProject(ProjectNode project) |
383 | { | 383 | { |
384 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | 384 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); |
385 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); | 385 | string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp"); |
386 | Helper.DeleteIfExists(projectFile); | 386 | Helper.DeleteIfExists(projectFile); |
387 | } | 387 | } |
388 | 388 | ||
389 | private void CleanSolution(SolutionNode solution) | 389 | private void CleanSolution(SolutionNode solution) |
390 | { | 390 | { |
391 | m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name); | 391 | m_Kernel.Log.Write("Cleaning MonoDevelop combine and project files for", solution.Name); |
392 | 392 | ||
393 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); | 393 | string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "mds"); |
394 | Helper.DeleteIfExists(slnFile); | 394 | Helper.DeleteIfExists(slnFile); |
395 | 395 | ||
396 | foreach(ProjectNode project in solution.Projects) | 396 | foreach(ProjectNode project in solution.Projects) |
397 | { | 397 | { |
398 | CleanProject(project); | 398 | CleanProject(project); |
399 | } | 399 | } |
400 | 400 | ||
401 | m_Kernel.Log.Write(""); | 401 | m_Kernel.Log.Write(""); |
402 | } | 402 | } |
403 | 403 | ||
404 | #endregion | 404 | #endregion |
405 | 405 | ||
406 | #region ITarget Members | 406 | #region ITarget Members |
407 | 407 | ||
408 | /// <summary> | 408 | /// <summary> |
409 | /// Writes the specified kern. | 409 | /// Writes the specified kern. |
410 | /// </summary> | 410 | /// </summary> |
411 | /// <param name="kern">The kern.</param> | 411 | /// <param name="kern">The kern.</param> |
412 | public void Write(Kernel kern) | 412 | public void Write(Kernel kern) |
413 | { | 413 | { |
414 | if( kern == null ) | 414 | if( kern == null ) |
415 | { | 415 | { |
416 | throw new ArgumentNullException("kern"); | 416 | throw new ArgumentNullException("kern"); |
417 | } | 417 | } |
418 | m_Kernel = kern; | 418 | m_Kernel = kern; |
419 | foreach(SolutionNode solution in kern.Solutions) | 419 | foreach(SolutionNode solution in kern.Solutions) |
420 | { | 420 | { |
421 | WriteCombine(solution); | 421 | WriteCombine(solution); |
422 | } | 422 | } |
423 | m_Kernel = null; | 423 | m_Kernel = null; |
424 | } | 424 | } |
425 | 425 | ||
426 | /// <summary> | 426 | /// <summary> |
427 | /// Cleans the specified kern. | 427 | /// Cleans the specified kern. |
428 | /// </summary> | 428 | /// </summary> |
429 | /// <param name="kern">The kern.</param> | 429 | /// <param name="kern">The kern.</param> |
430 | public virtual void Clean(Kernel kern) | 430 | public virtual void Clean(Kernel kern) |
431 | { | 431 | { |
432 | if( kern == null ) | 432 | if( kern == null ) |
433 | { | 433 | { |
434 | throw new ArgumentNullException("kern"); | 434 | throw new ArgumentNullException("kern"); |
435 | } | 435 | } |
436 | m_Kernel = kern; | 436 | m_Kernel = kern; |
437 | foreach(SolutionNode sol in kern.Solutions) | 437 | foreach(SolutionNode sol in kern.Solutions) |
438 | { | 438 | { |
439 | CleanSolution(sol); | 439 | CleanSolution(sol); |
440 | } | 440 | } |
441 | m_Kernel = null; | 441 | m_Kernel = null; |
442 | } | 442 | } |
443 | 443 | ||
444 | /// <summary> | 444 | /// <summary> |
445 | /// Gets the name. | 445 | /// Gets the name. |
446 | /// </summary> | 446 | /// </summary> |
447 | /// <value>The name.</value> | 447 | /// <value>The name.</value> |
448 | public string Name | 448 | public string Name |
449 | { | 449 | { |
450 | get | 450 | get |
451 | { | 451 | { |
452 | return "sharpdev"; | 452 | return "sharpdev"; |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | #endregion | 456 | #endregion |
457 | } | 457 | } |
458 | } | 458 | } |