diff options
author | Jeff Ames | 2008-03-17 20:55:21 +0000 |
---|---|---|
committer | Jeff Ames | 2008-03-17 20:55:21 +0000 |
commit | 79209c429705beb57ad9b787718856ab2c9fd37c (patch) | |
tree | 6f459e172985bce8ffbfc09a5b9a4594dd881a62 /Prebuild/src/Core/Targets/AutotoolsTarget.cs | |
parent | * More almost completely unproductive log message fiddling (diff) | |
download | opensim-SC-79209c429705beb57ad9b787718856ab2c9fd37c.zip opensim-SC-79209c429705beb57ad9b787718856ab2c9fd37c.tar.gz opensim-SC-79209c429705beb57ad9b787718856ab2c9fd37c.tar.bz2 opensim-SC-79209c429705beb57ad9b787718856ab2c9fd37c.tar.xz |
Merged changes in Prebuild trunk up to r258 into OpenSim's Prebuild.
Hopefully this should make merging upstream easier.
Building with NAnt should still work, but Visual Studio is untested.
Diffstat (limited to 'Prebuild/src/Core/Targets/AutotoolsTarget.cs')
-rw-r--r-- | Prebuild/src/Core/Targets/AutotoolsTarget.cs | 2408 |
1 files changed, 1643 insertions, 765 deletions
diff --git a/Prebuild/src/Core/Targets/AutotoolsTarget.cs b/Prebuild/src/Core/Targets/AutotoolsTarget.cs index cf575e3..f102038 100644 --- a/Prebuild/src/Core/Targets/AutotoolsTarget.cs +++ b/Prebuild/src/Core/Targets/AutotoolsTarget.cs | |||
@@ -1,11 +1,11 @@ | |||
1 | #region BSD License | 1 | #region BSD License |
2 | /* | 2 | /* |
3 | 3 | ||
4 | Copyright (c) 2004 - 2006 | 4 | Copyright (c) 2004 - 2008 |
5 | Matthew Holmes (matthew@wildfiregames.com), | 5 | Matthew Holmes (matthew@wildfiregames.com), |
6 | Dan Moorehead (dan05a@gmail.com), | 6 | Dan Moorehead (dan05a@gmail.com), |
7 | Dave Hudson (jendave@yahoo.com), | 7 | Dave Hudson (jendave@yahoo.com), |
8 | C.J. Adams-Collier (cjcollier@colliertech.org), | 8 | C.J. Adams-Collier (cjac@colliertech.org), |
9 | 9 | ||
10 | Redistribution and use in source and binary forms, with or without | 10 | Redistribution and use in source and binary forms, with or without |
11 | modification, are permitted provided that the following conditions are | 11 | modification, are permitted provided that the following conditions are |
@@ -37,6 +37,35 @@ POSSIBILITY OF SUCH DAMAGE. | |||
37 | */ | 37 | */ |
38 | #endregion | 38 | #endregion |
39 | 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 | |||
40 | #region CVS Information | 69 | #region CVS Information |
41 | /* | 70 | /* |
42 | * $Source$ | 71 | * $Source$ |
@@ -53,6 +82,10 @@ using System.IO; | |||
53 | using System.Reflection; | 82 | using System.Reflection; |
54 | using System.Text; | 83 | using System.Text; |
55 | using System.Text.RegularExpressions; | 84 | using System.Text.RegularExpressions; |
85 | using System.Xml; | ||
86 | using System.Xml.Xsl; | ||
87 | using System.Net; | ||
88 | using System.Diagnostics; | ||
56 | 89 | ||
57 | using Prebuild.Core.Attributes; | 90 | using Prebuild.Core.Attributes; |
58 | using Prebuild.Core.Interfaces; | 91 | using Prebuild.Core.Interfaces; |
@@ -62,63 +95,500 @@ using Prebuild.Core.Utilities; | |||
62 | 95 | ||
63 | namespace Prebuild.Core.Targets | 96 | namespace Prebuild.Core.Targets |
64 | { | 97 | { |
65 | /// <summary> | 98 | public enum ClrVersion |
66 | /// | 99 | { |
67 | /// </summary> | 100 | Default, |
68 | [Target("autotools")] | 101 | Net_1_1, |
69 | public class AutotoolsTarget : ITarget | 102 | Net_2_0 |
70 | { | 103 | } |
71 | #region Fields | 104 | |
72 | 105 | public class SystemPackage | |
73 | private Kernel m_Kernel; | 106 | { |
74 | 107 | string name; | |
75 | #endregion | 108 | string version; |
76 | 109 | string description; | |
77 | #region Private Methods | 110 | string[] assemblies; |
78 | 111 | bool isInternal; | |
79 | private static string PrependPath(string path) | 112 | ClrVersion targetVersion; |
80 | { | 113 | |
81 | string tmpPath = Helper.NormalizePath(path, '/'); | 114 | public void Initialize(string name, |
82 | Regex regex = new Regex(@"(\w):/(\w+)"); | 115 | string version, |
83 | Match match = regex.Match(tmpPath); | 116 | string description, |
84 | if(match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | 117 | string[] assemblies, |
85 | { | 118 | ClrVersion targetVersion, |
86 | tmpPath = Helper.NormalizePath(tmpPath); | 119 | bool isInternal) |
87 | } | 120 | { |
88 | else | 121 | this.isInternal = isInternal; |
89 | { | 122 | this.name = name; |
90 | tmpPath = Helper.NormalizePath("./" + tmpPath); | 123 | this.version = version; |
91 | } | 124 | this.assemblies = assemblies; |
92 | 125 | this.description = description; | |
93 | return tmpPath; | 126 | this.targetVersion = targetVersion; |
94 | } | 127 | } |
95 | 128 | ||
96 | private static string BuildReference(SolutionNode solution, ReferenceNode refr) | 129 | public string Name |
97 | { | 130 | { |
98 | string ret = ""; | 131 | get { return name; } |
99 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | 132 | } |
100 | { | 133 | |
101 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | 134 | public string Version |
102 | string fileRef = FindFileReference(refr.Name, project); | 135 | { |
103 | string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/$(BUILD_DIR)/$(CONFIG)/", refr.Name, "dll"), '/'); | 136 | get { return version; } |
104 | ret += finalPath; | 137 | } |
105 | return ret; | 138 | |
106 | } | 139 | public string Description |
107 | else | 140 | { |
108 | { | 141 | get { return description; } |
109 | ProjectNode project = (ProjectNode)refr.Parent; | 142 | } |
110 | string fileRef = FindFileReference(refr.Name, project); | 143 | |
111 | 144 | public ClrVersion TargetVersion | |
112 | if(refr.Path != null || fileRef != null) | 145 | { |
113 | { | 146 | get { return targetVersion; } |
114 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef; | 147 | } |
115 | ret += Path.Combine(project.Path, finalPath); | 148 | |
116 | return ret; | 149 | // The package is part of the mono SDK |
117 | } | 150 | public bool IsCorePackage |
118 | 151 | { | |
119 | try | 152 | get { return name == "mono"; } |
120 | { | 153 | } |
121 | //Assembly assem = Assembly.Load(refr.Name); | 154 | |
155 | // The package has been registered by an add-in, and is not installed | ||
156 | // in the system. | ||
157 | public bool IsInternalPackage | ||
158 | { | ||
159 | get { return isInternal; } | ||
160 | } | ||
161 | |||
162 | public string[] Assemblies | ||
163 | { | ||
164 | get { return assemblies; } | ||
165 | } | ||
166 | |||
167 | } | ||
168 | |||
169 | |||
170 | /// <summary> | ||
171 | /// | ||
172 | /// </summary> | ||
173 | [Target("autotools")] | ||
174 | public class AutotoolsTarget : ITarget | ||
175 | { | ||
176 | #region Fields | ||
177 | |||
178 | Kernel m_Kernel; | ||
179 | XmlDocument autotoolsDoc; | ||
180 | XmlUrlResolver xr; | ||
181 | System.Security.Policy.Evidence e; | ||
182 | Hashtable assemblyPathToPackage = new Hashtable(); | ||
183 | Hashtable assemblyFullNameToPath = new Hashtable(); | ||
184 | Hashtable packagesHash = new Hashtable(); | ||
185 | ArrayList packages = new ArrayList(); | ||
186 | ClrVersion currentVersion; | ||
187 | |||
188 | #endregion | ||
189 | |||
190 | #region Private Methods | ||
191 | |||
192 | private void mkdirDashP(string dirName) | ||
193 | { | ||
194 | DirectoryInfo di = new DirectoryInfo(dirName); | ||
195 | if (di.Exists) | ||
196 | return; | ||
197 | |||
198 | string parentDirName = System.IO.Path.GetDirectoryName(dirName); | ||
199 | DirectoryInfo parentDi = new DirectoryInfo(parentDirName); | ||
200 | if (!parentDi.Exists) | ||
201 | mkdirDashP(parentDirName); | ||
202 | |||
203 | di.Create(); | ||
204 | } | ||
205 | |||
206 | private void mkStubFiles(string dirName, ArrayList fileNames) | ||
207 | { | ||
208 | for (int i = 0; i < fileNames.Count; i++) | ||
209 | { | ||
210 | string tmpFile = dirName + "/" + (string)fileNames[i]; | ||
211 | |||
212 | FileStream tmpFileStream = | ||
213 | new FileStream(tmpFile, FileMode.Create); | ||
214 | |||
215 | StreamWriter sw = new StreamWriter(tmpFileStream); | ||
216 | sw.WriteLine("These are not the files you are looking for."); | ||
217 | sw.Flush(); | ||
218 | tmpFileStream.Close(); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | private void chkMkDir(string dirName) | ||
223 | { | ||
224 | System.IO.DirectoryInfo di = | ||
225 | new System.IO.DirectoryInfo(dirName); | ||
226 | |||
227 | if (!di.Exists) | ||
228 | di.Create(); | ||
229 | } | ||
230 | |||
231 | private void transformToFile(string filename, XsltArgumentList argList, string nodeName) | ||
232 | { | ||
233 | // Create an XslTransform for this file | ||
234 | XslTransform templateTransformer = | ||
235 | new XslTransform(); | ||
236 | |||
237 | // Load up the template | ||
238 | XmlNode templateNode = | ||
239 | autotoolsDoc.SelectSingleNode(nodeName + "/*"); | ||
240 | templateTransformer.Load(templateNode.CreateNavigator(), xr, e); | ||
241 | |||
242 | // Create a writer for the transformed template | ||
243 | XmlTextWriter templateWriter = | ||
244 | new XmlTextWriter(filename, null); | ||
245 | |||
246 | // Perform transformation, writing the file | ||
247 | templateTransformer.Transform | ||
248 | (m_Kernel.CurrentDoc, argList, templateWriter, xr); | ||
249 | } | ||
250 | |||
251 | string NormalizeAsmName(string name) | ||
252 | { | ||
253 | int i = name.IndexOf(", PublicKeyToken=null"); | ||
254 | if (i != -1) | ||
255 | return name.Substring(0, i).Trim(); | ||
256 | else | ||
257 | return name; | ||
258 | } | ||
259 | |||
260 | private void AddAssembly(string assemblyfile, SystemPackage package) | ||
261 | { | ||
262 | if (!File.Exists(assemblyfile)) | ||
263 | return; | ||
264 | |||
265 | try | ||
266 | { | ||
267 | System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(assemblyfile); | ||
268 | assemblyFullNameToPath[NormalizeAsmName(an.FullName)] = assemblyfile; | ||
269 | assemblyPathToPackage[assemblyfile] = package; | ||
270 | } | ||
271 | catch | ||
272 | { | ||
273 | } | ||
274 | } | ||
275 | |||
276 | private ArrayList GetAssembliesWithLibInfo(string line, string file) | ||
277 | { | ||
278 | ArrayList references = new ArrayList(); | ||
279 | ArrayList libdirs = new ArrayList(); | ||
280 | ArrayList retval = new ArrayList(); | ||
281 | foreach (string piece in line.Split(' ')) | ||
282 | { | ||
283 | if (piece.ToLower().Trim().StartsWith("/r:") || piece.ToLower().Trim().StartsWith("-r:")) | ||
284 | { | ||
285 | references.Add(ProcessPiece(piece.Substring(3).Trim(), file)); | ||
286 | } | ||
287 | else if (piece.ToLower().Trim().StartsWith("/lib:") || piece.ToLower().Trim().StartsWith("-lib:")) | ||
288 | { | ||
289 | libdirs.Add(ProcessPiece(piece.Substring(5).Trim(), file)); | ||
290 | } | ||
291 | } | ||
292 | |||
293 | foreach (string refrnc in references) | ||
294 | { | ||
295 | foreach (string libdir in libdirs) | ||
296 | { | ||
297 | if (File.Exists(libdir + Path.DirectorySeparatorChar + refrnc)) | ||
298 | { | ||
299 | retval.Add(libdir + Path.DirectorySeparatorChar + refrnc); | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | |||
304 | return retval; | ||
305 | } | ||
306 | |||
307 | private ArrayList GetAssembliesWithoutLibInfo(string line, string file) | ||
308 | { | ||
309 | ArrayList references = new ArrayList(); | ||
310 | foreach (string reference in line.Split(' ')) | ||
311 | { | ||
312 | if (reference.ToLower().Trim().StartsWith("/r:") || reference.ToLower().Trim().StartsWith("-r:")) | ||
313 | { | ||
314 | string final_ref = reference.Substring(3).Trim(); | ||
315 | references.Add(ProcessPiece(final_ref, file)); | ||
316 | } | ||
317 | } | ||
318 | return references; | ||
319 | } | ||
320 | |||
321 | private string ProcessPiece(string piece, string pcfile) | ||
322 | { | ||
323 | int start = piece.IndexOf("${"); | ||
324 | if (start == -1) | ||
325 | return piece; | ||
326 | |||
327 | int end = piece.IndexOf("}"); | ||
328 | if (end == -1) | ||
329 | return piece; | ||
330 | |||
331 | string variable = piece.Substring(start + 2, end - start - 2); | ||
332 | string interp = GetVariableFromPkgConfig(variable, Path.GetFileNameWithoutExtension(pcfile)); | ||
333 | return ProcessPiece(piece.Replace("${" + variable + "}", interp), pcfile); | ||
334 | } | ||
335 | |||
336 | private string GetVariableFromPkgConfig(string var, string pcfile) | ||
337 | { | ||
338 | ProcessStartInfo psi = new ProcessStartInfo("pkg-config"); | ||
339 | psi.RedirectStandardOutput = true; | ||
340 | psi.UseShellExecute = false; | ||
341 | psi.Arguments = String.Format("--variable={0} {1}", var, pcfile); | ||
342 | Process p = new Process(); | ||
343 | p.StartInfo = psi; | ||
344 | p.Start(); | ||
345 | string ret = p.StandardOutput.ReadToEnd().Trim(); | ||
346 | p.WaitForExit(); | ||
347 | if (String.IsNullOrEmpty(ret)) | ||
348 | return String.Empty; | ||
349 | return ret; | ||
350 | } | ||
351 | |||
352 | private void ParsePCFile(string pcfile) | ||
353 | { | ||
354 | // Don't register the package twice | ||
355 | string pname = Path.GetFileNameWithoutExtension(pcfile); | ||
356 | if (packagesHash.Contains(pname)) | ||
357 | return; | ||
358 | |||
359 | ArrayList fullassemblies = null; | ||
360 | string version = ""; | ||
361 | string desc = ""; | ||
362 | |||
363 | SystemPackage package = new SystemPackage(); | ||
364 | |||
365 | using (StreamReader reader = new StreamReader(pcfile)) | ||
366 | { | ||
367 | string line; | ||
368 | while ((line = reader.ReadLine()) != null) | ||
369 | { | ||
370 | string lowerLine = line.ToLower(); | ||
371 | if (lowerLine.StartsWith("libs:") && lowerLine.IndexOf(".dll") != -1) | ||
372 | { | ||
373 | string choppedLine = line.Substring(5).Trim(); | ||
374 | if (choppedLine.IndexOf("-lib:") != -1 || choppedLine.IndexOf("/lib:") != -1) | ||
375 | { | ||
376 | fullassemblies = GetAssembliesWithLibInfo(choppedLine, pcfile); | ||
377 | } | ||
378 | else | ||
379 | { | ||
380 | fullassemblies = GetAssembliesWithoutLibInfo(choppedLine, pcfile); | ||
381 | } | ||
382 | } | ||
383 | else if (lowerLine.StartsWith("version:")) | ||
384 | { | ||
385 | // "version:".Length == 8 | ||
386 | version = line.Substring(8).Trim(); | ||
387 | } | ||
388 | else if (lowerLine.StartsWith("description:")) | ||
389 | { | ||
390 | // "description:".Length == 12 | ||
391 | desc = line.Substring(12).Trim(); | ||
392 | } | ||
393 | } | ||
394 | } | ||
395 | |||
396 | if (fullassemblies == null) | ||
397 | return; | ||
398 | |||
399 | foreach (string assembly in fullassemblies) | ||
400 | { | ||
401 | AddAssembly(assembly, package); | ||
402 | } | ||
403 | |||
404 | package.Initialize(pname, | ||
405 | version, | ||
406 | desc, | ||
407 | (string[])fullassemblies.ToArray(typeof(string)), | ||
408 | ClrVersion.Default, | ||
409 | false); | ||
410 | packages.Add(package); | ||
411 | packagesHash[pname] = package; | ||
412 | } | ||
413 | |||
414 | void RegisterSystemAssemblies(string prefix, string version, ClrVersion ver) | ||
415 | { | ||
416 | SystemPackage package = new SystemPackage(); | ||
417 | ArrayList list = new ArrayList(); | ||
418 | |||
419 | string dir = Path.Combine(prefix, version); | ||
420 | if (!Directory.Exists(dir)) | ||
421 | { | ||
422 | return; | ||
423 | } | ||
424 | |||
425 | foreach (string assembly in Directory.GetFiles(dir, "*.dll")) | ||
426 | { | ||
427 | AddAssembly(assembly, package); | ||
428 | list.Add(assembly); | ||
429 | } | ||
430 | |||
431 | package.Initialize("mono", | ||
432 | version, | ||
433 | "The Mono runtime", | ||
434 | (string[])list.ToArray(typeof(string)), | ||
435 | ver, | ||
436 | false); | ||
437 | packages.Add(package); | ||
438 | } | ||
439 | |||
440 | void RunInitialization() | ||
441 | { | ||
442 | string versionDir; | ||
443 | |||
444 | if (Environment.Version.Major == 1) | ||
445 | { | ||
446 | versionDir = "1.0"; | ||
447 | currentVersion = ClrVersion.Net_1_1; | ||
448 | } | ||
449 | else | ||
450 | { | ||
451 | versionDir = "2.0"; | ||
452 | currentVersion = ClrVersion.Net_2_0; | ||
453 | } | ||
454 | |||
455 | //Pull up assemblies from the installed mono system. | ||
456 | string prefix = Path.GetDirectoryName(typeof(int).Assembly.Location); | ||
457 | |||
458 | if (prefix.IndexOf(Path.Combine("mono", versionDir)) == -1) | ||
459 | prefix = Path.Combine(prefix, "mono"); | ||
460 | else | ||
461 | prefix = Path.GetDirectoryName(prefix); | ||
462 | |||
463 | RegisterSystemAssemblies(prefix, "1.0", ClrVersion.Net_1_1); | ||
464 | RegisterSystemAssemblies(prefix, "2.0", ClrVersion.Net_2_0); | ||
465 | |||
466 | string search_dirs = Environment.GetEnvironmentVariable("PKG_CONFIG_PATH"); | ||
467 | string libpath = Environment.GetEnvironmentVariable("PKG_CONFIG_LIBPATH"); | ||
468 | |||
469 | if (String.IsNullOrEmpty(libpath)) | ||
470 | { | ||
471 | string path_dirs = Environment.GetEnvironmentVariable("PATH"); | ||
472 | foreach (string pathdir in path_dirs.Split(Path.PathSeparator)) | ||
473 | { | ||
474 | if (pathdir == null) | ||
475 | continue; | ||
476 | if (File.Exists(pathdir + Path.DirectorySeparatorChar + "pkg-config")) | ||
477 | { | ||
478 | libpath = Path.Combine(pathdir, ".."); | ||
479 | libpath = Path.Combine(libpath, "lib"); | ||
480 | libpath = Path.Combine(libpath, "pkgconfig"); | ||
481 | break; | ||
482 | } | ||
483 | } | ||
484 | } | ||
485 | search_dirs += Path.PathSeparator + libpath; | ||
486 | if (search_dirs != null && search_dirs.Length > 0) | ||
487 | { | ||
488 | ArrayList scanDirs = new ArrayList(); | ||
489 | foreach (string potentialDir in search_dirs.Split(Path.PathSeparator)) | ||
490 | { | ||
491 | if (!scanDirs.Contains(potentialDir)) | ||
492 | scanDirs.Add(potentialDir); | ||
493 | } | ||
494 | foreach (string pcdir in scanDirs) | ||
495 | { | ||
496 | if (pcdir == null) | ||
497 | continue; | ||
498 | |||
499 | if (Directory.Exists(pcdir)) | ||
500 | { | ||
501 | foreach (string pcfile in Directory.GetFiles(pcdir, "*.pc")) | ||
502 | { | ||
503 | ParsePCFile(pcfile); | ||
504 | } | ||
505 | } | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | |||
510 | private void WriteCombine(SolutionNode solution) | ||
511 | { | ||
512 | #region "Create Solution directory if it doesn't exist" | ||
513 | string solutionDir = Path.Combine(solution.FullPath, | ||
514 | Path.Combine("autotools", | ||
515 | solution.Name)); | ||
516 | chkMkDir(solutionDir); | ||
517 | #endregion | ||
518 | |||
519 | #region "Write Solution-level files" | ||
520 | XsltArgumentList argList = new XsltArgumentList(); | ||
521 | argList.AddParam("solutionName", "", solution.Name); | ||
522 | // $solutionDir is $rootDir/$solutionName/ | ||
523 | transformToFile(Path.Combine(solutionDir, "configure.ac"), | ||
524 | argList, "/Autotools/SolutionConfigureAc"); | ||
525 | transformToFile(Path.Combine(solutionDir, "Makefile.am"), | ||
526 | argList, "/Autotools/SolutionMakefileAm"); | ||
527 | transformToFile(Path.Combine(solutionDir, "autogen.sh"), | ||
528 | argList, "/Autotools/SolutionAutogenSh"); | ||
529 | #endregion | ||
530 | |||
531 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
532 | { | ||
533 | m_Kernel.Log.Write(String.Format("Writing project: {0}", | ||
534 | project.Name)); | ||
535 | WriteProject(solution, project); | ||
536 | } | ||
537 | } | ||
538 | private static string PrependPath(string path) | ||
539 | { | ||
540 | string tmpPath = Helper.NormalizePath(path, '/'); | ||
541 | Regex regex = new Regex(@"(\w):/(\w+)"); | ||
542 | Match match = regex.Match(tmpPath); | ||
543 | if (match.Success || tmpPath[0] == '.' || tmpPath[0] == '/') | ||
544 | { | ||
545 | tmpPath = Helper.NormalizePath(tmpPath); | ||
546 | } | ||
547 | else | ||
548 | { | ||
549 | tmpPath = Helper.NormalizePath("./" + tmpPath); | ||
550 | } | ||
551 | |||
552 | return tmpPath; | ||
553 | } | ||
554 | |||
555 | private static string BuildReference(SolutionNode solution, | ||
556 | ReferenceNode refr) | ||
557 | { | ||
558 | string ret = ""; | ||
559 | if (solution.ProjectsTable.ContainsKey(refr.Name)) | ||
560 | { | ||
561 | ProjectNode project = | ||
562 | (ProjectNode)solution.ProjectsTable[refr.Name]; | ||
563 | string fileRef = FindFileReference(refr.Name, project); | ||
564 | string finalPath = | ||
565 | Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + | ||
566 | "/$(BUILD_DIR)/$(CONFIG)/", | ||
567 | refr.Name, "dll"), | ||
568 | '/'); | ||
569 | ret += finalPath; | ||
570 | return ret; | ||
571 | } | ||
572 | else | ||
573 | { | ||
574 | ProjectNode project = (ProjectNode)refr.Parent; | ||
575 | string fileRef = FindFileReference(refr.Name, project); | ||
576 | |||
577 | if (refr.Path != null || fileRef != null) | ||
578 | { | ||
579 | string finalPath = ((refr.Path != null) ? | ||
580 | Helper.NormalizePath(refr.Path + "/" + | ||
581 | refr.Name + ".dll", | ||
582 | '/') : | ||
583 | fileRef | ||
584 | ); | ||
585 | ret += Path.Combine(project.Path, finalPath); | ||
586 | return ret; | ||
587 | } | ||
588 | |||
589 | try | ||
590 | { | ||
591 | //Assembly assem = Assembly.Load(refr.Name); | ||
122 | //if (assem != null) | 592 | //if (assem != null) |
123 | //{ | 593 | //{ |
124 | // int index = refr.Name.IndexOf(","); | 594 | // int index = refr.Name.IndexOf(","); |
@@ -135,629 +605,971 @@ namespace Prebuild.Core.Targets | |||
135 | //} | 605 | //} |
136 | //else | 606 | //else |
137 | //{ | 607 | //{ |
138 | int index = refr.Name.IndexOf(","); | 608 | int index = refr.Name.IndexOf(","); |
139 | if ( index > 0) | 609 | if (index > 0) |
140 | { | 610 | { |
141 | ret += refr.Name.Substring(0, index) + ".dll"; | 611 | ret += refr.Name.Substring(0, index) + ".dll"; |
142 | //Console.WriteLine("Location3: " + assem.Location); | 612 | //Console.WriteLine("Location3: " + assem.Location); |
143 | } | 613 | } |
144 | else | 614 | else |
145 | { | 615 | { |
146 | ret += (refr.Name + ".dll"); | 616 | ret += (refr.Name + ".dll"); |
147 | //Console.WriteLine("Location4: " + assem.Location); | 617 | //Console.WriteLine("Location4: " + assem.Location); |
148 | } | 618 | } |
149 | //} | 619 | //} |
150 | } | 620 | } |
151 | catch (System.NullReferenceException e) | 621 | catch (System.NullReferenceException e) |
152 | { | 622 | { |
153 | e.ToString(); | 623 | e.ToString(); |
154 | int index = refr.Name.IndexOf(","); | 624 | int index = refr.Name.IndexOf(","); |
155 | if ( index > 0) | 625 | if (index > 0) |
156 | { | 626 | { |
157 | ret += refr.Name.Substring(0, index) + ".dll"; | 627 | ret += refr.Name.Substring(0, index) + ".dll"; |
158 | //Console.WriteLine("Location5: " + assem.Location); | 628 | //Console.WriteLine("Location5: " + assem.Location); |
159 | } | 629 | } |
160 | else | 630 | else |
161 | { | 631 | { |
162 | ret += (refr.Name + ".dll"); | 632 | ret += (refr.Name + ".dll"); |
163 | //Console.WriteLine("Location6: " + assem.Location); | 633 | //Console.WriteLine("Location6: " + assem.Location); |
164 | } | 634 | } |
165 | } | 635 | } |
166 | } | 636 | } |
167 | return ret; | 637 | return ret; |
168 | } | 638 | } |
169 | 639 | ||
170 | private static string BuildReferencePath(SolutionNode solution, ReferenceNode refr) | 640 | private static string BuildReferencePath(SolutionNode solution, |
171 | { | 641 | ReferenceNode refr) |
172 | string ret = ""; | 642 | { |
173 | if(solution.ProjectsTable.ContainsKey(refr.Name)) | 643 | string ret = ""; |
174 | { | 644 | if (solution.ProjectsTable.ContainsKey(refr.Name)) |
175 | ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name]; | 645 | { |
176 | string finalPath = Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + "/${build.dir}/"), '/'); | 646 | ProjectNode project = |
177 | ret += finalPath; | 647 | (ProjectNode)solution.ProjectsTable[refr.Name]; |
178 | return ret; | 648 | string finalPath = |
179 | } | 649 | Helper.NormalizePath(Helper.MakeReferencePath(project.FullPath + |
180 | else | 650 | "/${build.dir}/"), |
181 | { | 651 | '/'); |
182 | ProjectNode project = (ProjectNode)refr.Parent; | 652 | ret += finalPath; |
183 | string fileRef = FindFileReference(refr.Name, project); | 653 | return ret; |
184 | 654 | } | |
185 | 655 | else | |
186 | if(refr.Path != null || fileRef != null) | 656 | { |
187 | { | 657 | ProjectNode project = (ProjectNode)refr.Parent; |
188 | string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path, '/') : fileRef; | 658 | string fileRef = FindFileReference(refr.Name, project); |
189 | ret += finalPath; | 659 | |
190 | return ret; | 660 | if (refr.Path != null || fileRef != null) |
191 | } | 661 | { |
192 | 662 | string finalPath = ((refr.Path != null) ? | |
193 | try | 663 | Helper.NormalizePath(refr.Path, '/') : |
194 | { | 664 | fileRef |
195 | Assembly assem = Assembly.Load(refr.Name); | 665 | ); |
196 | if (assem != null) | 666 | ret += finalPath; |
197 | { | 667 | return ret; |
198 | ret += ""; | 668 | } |
199 | } | 669 | |
200 | else | 670 | try |
201 | { | 671 | { |
202 | ret += ""; | 672 | Assembly assem = Assembly.Load(refr.Name); |
203 | } | 673 | if (assem != null) |
204 | } | 674 | { |
205 | catch (System.NullReferenceException e) | 675 | ret += ""; |
206 | { | 676 | } |
207 | e.ToString(); | 677 | else |
208 | ret += ""; | 678 | { |
209 | } | 679 | ret += ""; |
210 | } | 680 | } |
211 | return ret; | 681 | } |
212 | } | 682 | catch (System.NullReferenceException e) |
213 | 683 | { | |
214 | private static string FindFileReference(string refName, ProjectNode project) | 684 | e.ToString(); |
215 | { | 685 | ret += ""; |
216 | foreach(ReferencePathNode refPath in project.ReferencePaths) | 686 | } |
217 | { | 687 | } |
218 | string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll"); | 688 | return ret; |
219 | 689 | } | |
220 | if(File.Exists(fullPath)) | 690 | |
221 | { | 691 | private static string FindFileReference(string refName, |
222 | return fullPath; | 692 | ProjectNode project) |
223 | } | 693 | { |
224 | } | 694 | foreach (ReferencePathNode refPath in project.ReferencePaths) |
225 | 695 | { | |
226 | return null; | 696 | string fullPath = |
227 | } | 697 | Helper.MakeFilePath(refPath.Path, refName, "dll"); |
228 | 698 | ||
229 | /// <summary> | 699 | if (File.Exists(fullPath)) { |
230 | /// Gets the XML doc file. | 700 | return fullPath; |
231 | /// </summary> | 701 | } |
232 | /// <param name="project">The project.</param> | 702 | } |
233 | /// <param name="conf">The conf.</param> | 703 | |
234 | /// <returns></returns> | 704 | return null; |
235 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) | 705 | } |
236 | { | 706 | |
237 | if( conf == null ) | 707 | /// <summary> |
238 | { | 708 | /// Gets the XML doc file. |
239 | throw new ArgumentNullException("conf"); | 709 | /// </summary> |
240 | } | 710 | /// <param name="project">The project.</param> |
241 | if( project == null ) | 711 | /// <param name="conf">The conf.</param> |
242 | { | 712 | /// <returns></returns> |
243 | throw new ArgumentNullException("project"); | 713 | public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf) |
244 | } | 714 | { |
245 | string docFile = (string)conf.Options["XmlDocFile"]; | 715 | if (conf == null) |
246 | // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified | 716 | { |
247 | // { | 717 | throw new ArgumentNullException("conf"); |
248 | // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; | 718 | } |
249 | // } | 719 | if (project == null) |
250 | return docFile; | 720 | { |
251 | } | 721 | throw new ArgumentNullException("project"); |
252 | 722 | } | |
253 | /// <summary> | 723 | string docFile = (string)conf.Options["XmlDocFile"]; |
254 | /// Normalizes the path. | 724 | // if(docFile != null && docFile.Length == 0)//default to assembly name if not specified |
255 | /// </summary> | 725 | // { |
256 | /// <param name="path">The path.</param> | 726 | // return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml"; |
257 | /// <returns></returns> | 727 | // } |
258 | public static string NormalizePath(string path) | 728 | return docFile; |
259 | { | 729 | } |
260 | if(path == null) | 730 | |
261 | { | 731 | /// <summary> |
262 | return ""; | 732 | /// Normalizes the path. |
263 | } | 733 | /// </summary> |
264 | 734 | /// <param name="path">The path.</param> | |
265 | StringBuilder tmpPath; | 735 | /// <returns></returns> |
266 | 736 | public static string NormalizePath(string path) | |
267 | if (Core.Parse.Preprocessor.GetOS() == "Win32") | 737 | { |
268 | { | 738 | if (path == null) |
269 | tmpPath = new StringBuilder(path.Replace('\\', '/')); | 739 | { |
270 | tmpPath.Replace("/", @"\\"); | 740 | return ""; |
271 | } | 741 | } |
272 | else | 742 | |
273 | { | 743 | StringBuilder tmpPath; |
274 | tmpPath = new StringBuilder(path.Replace('\\', '/')); | 744 | |
275 | tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); | 745 | if (Core.Parse.Preprocessor.GetOS() == "Win32") |
276 | } | 746 | { |
277 | return tmpPath.ToString(); | 747 | tmpPath = new StringBuilder(path.Replace('\\', '/')); |
278 | } | 748 | tmpPath.Replace("/", @"\\"); |
279 | 749 | } | |
280 | private void WriteProject(SolutionNode solution, ProjectNode project) | 750 | else |
281 | { | 751 | { |
282 | string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); | 752 | tmpPath = new StringBuilder(path.Replace('\\', '/')); |
283 | StreamWriter ss = new StreamWriter(projFile); | 753 | tmpPath = tmpPath.Replace('/', Path.DirectorySeparatorChar); |
284 | ss.NewLine = "\n"; | 754 | } |
285 | 755 | return tmpPath.ToString(); | |
286 | m_Kernel.CurrentWorkingDirectory.Push(); | 756 | } |
287 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | 757 | |
288 | 758 | private void WriteProject(SolutionNode solution, ProjectNode project) | |
289 | using(ss) | 759 | { |
290 | { | 760 | string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name)); |
291 | ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":"); | 761 | string projectDir = Path.Combine(solutionDir, project.Name); |
292 | ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/"); | 762 | string projectVersion = project.Version; |
293 | foreach(string file in project.Files) | 763 | bool hasAssemblyConfig = false; |
294 | { | 764 | chkMkDir(projectDir); |
295 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | 765 | |
296 | { | 766 | ArrayList |
297 | ss.Write("\tresgen "); | 767 | compiledFiles = new ArrayList(), |
298 | ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/')); | 768 | contentFiles = new ArrayList(), |
299 | if (project.Files.GetResourceName(file) != "") | 769 | embeddedFiles = new ArrayList(), |
300 | { | 770 | |
301 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/')); | 771 | binaryLibs = new ArrayList(), |
302 | } | 772 | pkgLibs = new ArrayList(), |
303 | else | 773 | systemLibs = new ArrayList(), |
304 | { | 774 | runtimeLibs = new ArrayList(), |
305 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/')); | 775 | |
306 | } | 776 | extraDistFiles = new ArrayList(), |
307 | } | 777 | localCopyTargets = new ArrayList(); |
308 | } | 778 | |
309 | ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\"); | 779 | // If there exists a .config file for this assembly, copy it to the project folder |
310 | ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\"); | 780 | // TODO: Support copying .config.osx files |
311 | if (project.References.Count > 0) | 781 | // TODO: support processing the .config file for native library deps |
312 | { | 782 | string projectAssemblyName = project.Name; |
313 | ss.Write("\t\t/reference:"); | 783 | if (project.AssemblyName != null) |
314 | bool firstref = true; | 784 | projectAssemblyName = project.AssemblyName; |
315 | foreach(ReferenceNode refr in project.References) | 785 | |
316 | { | 786 | if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config")) |
317 | if (firstref) | 787 | { |
318 | { | 788 | hasAssemblyConfig = true; |
319 | firstref = false; | 789 | System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true); |
320 | } | 790 | extraDistFiles.Add(project.AssemblyName + ".dll.config"); |
321 | else | 791 | } |
322 | { | 792 | |
323 | ss.Write(","); | 793 | foreach (ConfigurationNode conf in project.Configurations) |
324 | } | 794 | { |
325 | ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/')); | 795 | if (conf.Options.KeyFile != string.Empty) |
326 | } | 796 | { |
327 | ss.WriteLine(" \\"); | 797 | // Copy snk file into the project's directory |
328 | } | 798 | // Use the snk from the project directory directly |
329 | //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\"); | 799 | string source = Path.Combine(project.FullPath, conf.Options.KeyFile); |
330 | 800 | string keyFile = conf.Options.KeyFile; | |
331 | foreach(string file in project.Files) | 801 | Regex re = new Regex(".*/"); |
332 | { | 802 | keyFile = re.Replace(keyFile, ""); |
333 | switch(project.Files.GetBuildAction(file)) | 803 | |
334 | { | 804 | string dest = Path.Combine(projectDir, keyFile); |
335 | case BuildAction.EmbeddedResource: | 805 | // Tell the user if there's a problem copying the file |
336 | ss.Write("\t\t/resource:"); | 806 | try |
337 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\"); | 807 | { |
338 | break; | 808 | mkdirDashP(System.IO.Path.GetDirectoryName(dest)); |
339 | default: | 809 | System.IO.File.Copy(source, dest, true); |
340 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | 810 | } |
341 | { | 811 | catch (System.IO.IOException e) |
342 | ss.Write("\t\t/resource:"); | 812 | { |
343 | if (project.Files.GetResourceName(file) != "") | 813 | Console.WriteLine(e.Message); |
344 | { | 814 | } |
345 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\"); | 815 | } |
346 | } | 816 | } |
347 | else | 817 | |
348 | { | 818 | // Copy compiled, embedded and content files into the project's directory |
349 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\"); | 819 | foreach (string filename in project.Files) |
350 | } | 820 | { |
351 | } | 821 | string source = Path.Combine(project.FullPath, filename); |
352 | break; | 822 | string dest = Path.Combine(projectDir, filename); |
353 | } | 823 | |
354 | } | 824 | if (filename.Contains("AssemblyInfo.cs")) |
355 | 825 | { | |
356 | foreach(ConfigurationNode conf in project.Configurations) | 826 | // If we've got an AssemblyInfo.cs, pull the version number from it |
357 | { | 827 | string[] sources = { source }; |
358 | if (conf.Options.KeyFile !="") | 828 | string[] args = { "" }; |
359 | { | 829 | Microsoft.CSharp.CSharpCodeProvider cscp = |
360 | ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\"); | 830 | new Microsoft.CSharp.CSharpCodeProvider(); |
361 | break; | 831 | |
362 | } | 832 | string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll"); |
363 | } | 833 | System.CodeDom.Compiler.CompilerParameters cparam = |
364 | foreach(ConfigurationNode conf in project.Configurations) | 834 | new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile); |
365 | { | 835 | |
366 | if (conf.Options.AllowUnsafe) | 836 | System.CodeDom.Compiler.CompilerResults cr = |
367 | { | 837 | cscp.CompileAssemblyFromFile(cparam, sources); |
368 | ss.WriteLine("\t\t/unsafe \\"); | 838 | |
369 | break; | 839 | foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors) |
370 | } | 840 | Console.WriteLine("Error! '{0}'", error.ErrorText); |
371 | } | 841 | |
372 | if (project.AppIcon != "") | 842 | string projectFullName = cr.CompiledAssembly.FullName; |
373 | { | 843 | Regex verRegex = new Regex("Version=([\\d\\.]+)"); |
374 | ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\"); | 844 | Match verMatch = verRegex.Match(projectFullName); |
375 | } | 845 | if (verMatch.Success) |
376 | 846 | projectVersion = verMatch.Groups[1].Value; | |
377 | foreach(ConfigurationNode conf in project.Configurations) | 847 | |
378 | { | 848 | // Clean up the temp file |
379 | ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\"); | 849 | try |
380 | break; | 850 | { |
381 | } | 851 | if (File.Exists(tempAssemblyFile)) |
382 | 852 | File.Delete(tempAssemblyFile); | |
383 | foreach(ConfigurationNode conf in project.Configurations) | 853 | } |
384 | { | 854 | catch |
385 | if (GetXmlDocFile(project, conf) !="") | 855 | { |
386 | { | 856 | //Console.WriteLine("Error! '{0}'", e.ToString()); |
387 | ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\"); | 857 | } |
388 | break; | 858 | |
389 | } | 859 | } |
390 | } | 860 | |
391 | foreach(string file in project.Files) | 861 | // Tell the user if there's a problem copying the file |
392 | { | 862 | try |
393 | switch(project.Files.GetBuildAction(file)) | 863 | { |
394 | { | 864 | mkdirDashP(System.IO.Path.GetDirectoryName(dest)); |
395 | case BuildAction.Compile: | 865 | System.IO.File.Copy(source, dest, true); |
396 | ss.WriteLine("\t\t\\"); | 866 | } |
397 | ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file))); | 867 | catch (System.IO.IOException e) |
398 | break; | 868 | { |
399 | default: | 869 | Console.WriteLine(e.Message); |
400 | break; | 870 | } |
401 | } | 871 | |
402 | } | 872 | switch (project.Files.GetBuildAction(filename)) |
403 | ss.WriteLine(); | 873 | { |
404 | ss.WriteLine(); | 874 | case BuildAction.Compile: |
405 | 875 | compiledFiles.Add(filename); | |
406 | if (project.Type == ProjectType.Library) | 876 | break; |
407 | { | 877 | case BuildAction.Content: |
408 | ss.WriteLine("install-data-local:"); | 878 | contentFiles.Add(filename); |
409 | ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\"); | 879 | extraDistFiles.Add(filename); |
410 | ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;"); | 880 | break; |
411 | ss.WriteLine(); | 881 | case BuildAction.EmbeddedResource: |
412 | ss.WriteLine("uninstall-local:"); | 882 | embeddedFiles.Add(filename); |
413 | ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\"); | 883 | break; |
414 | ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;"); | 884 | } |
415 | ss.WriteLine(); | 885 | } |
416 | } | 886 | |
417 | 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"); | 887 | // Set up references |
418 | ss.WriteLine("EXTRA_DIST = \\"); | 888 | for (int refNum = 0; refNum < project.References.Count; refNum++) |
419 | ss.Write(" $(FILES)"); | 889 | { |
420 | foreach(ConfigurationNode conf in project.Configurations) | 890 | ReferenceNode refr = (ReferenceNode)project.References[refNum]; |
421 | { | 891 | Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name); |
422 | if (conf.Options.KeyFile != "") | 892 | |
423 | { | 893 | /* Determine which pkg-config (.pc) file refers to |
424 | ss.Write(" \\"); | 894 | this assembly */ |
425 | ss.WriteLine("\t" + conf.Options.KeyFile); | 895 | |
426 | } | 896 | SystemPackage package = null; |
427 | break; | 897 | |
428 | } | 898 | if (packagesHash.Contains(refr.Name)){ |
429 | } | 899 | package = (SystemPackage)packagesHash[refr.Name]; |
430 | m_Kernel.CurrentWorkingDirectory.Pop(); | 900 | |
431 | } | 901 | }else{ |
432 | bool hasLibrary = false; | 902 | string assemblyFullName = string.Empty; |
433 | 903 | if (refAssembly != null) | |
434 | private void WriteCombine(SolutionNode solution) | 904 | assemblyFullName = refAssembly.FullName; |
435 | { | 905 | |
436 | 906 | string assemblyFileName = string.Empty; | |
437 | /* TODO: These vars should be pulled from the prebuild.xml file */ | 907 | if (assemblyFullName != string.Empty && |
438 | string releaseVersion = "2.0.0"; | 908 | assemblyFullNameToPath.Contains(assemblyFullName) |
439 | string assemblyVersion = "2.1.0.0"; | 909 | ) |
440 | string description = | 910 | assemblyFileName = |
441 | "Tao Framework " + solution.Name + " Binding For .NET"; | 911 | (string)assemblyFullNameToPath[assemblyFullName]; |
442 | 912 | ||
443 | hasLibrary = false; | 913 | if (assemblyFileName != string.Empty && |
444 | m_Kernel.Log.Write("Creating Autotools make files"); | 914 | assemblyPathToPackage.Contains(assemblyFileName) |
445 | foreach(ProjectNode project in solution.Projects) | 915 | ) |
446 | { | 916 | package = (SystemPackage)assemblyPathToPackage[assemblyFileName]; |
447 | if(m_Kernel.AllowProject(project.FilterGroups)) | 917 | |
448 | { | 918 | } |
449 | m_Kernel.Log.Write("...Creating makefile: {0}", project.Name); | 919 | |
450 | WriteProject(solution, project); | 920 | /* If we know the .pc file and it is not "mono" |
451 | } | 921 | (already in the path), add a -pkg: argument */ |
452 | } | 922 | |
453 | 923 | if (package != null && | |
454 | m_Kernel.Log.Write(""); | 924 | package.Name != "mono" && |
455 | string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); | 925 | !pkgLibs.Contains(package.Name) |
456 | StreamWriter ss = new StreamWriter(combFile); | 926 | ) |
457 | ss.NewLine = "\n"; | 927 | pkgLibs.Add(package.Name); |
458 | 928 | ||
459 | m_Kernel.CurrentWorkingDirectory.Push(); | 929 | string fileRef = |
460 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | 930 | FindFileReference(refr.Name, (ProjectNode)refr.Parent); |
461 | 931 | ||
462 | using(ss) | 932 | if (refr.LocalCopy || |
463 | { | 933 | solution.ProjectsTable.ContainsKey(refr.Name) || |
464 | foreach(ProjectNode project in solution.ProjectsTableOrder) | 934 | fileRef != null || |
465 | { | 935 | refr.Path != null |
466 | if (project.Type == ProjectType.Library) | 936 | ) |
467 | { | 937 | { |
468 | hasLibrary = true; | 938 | |
469 | break; | 939 | /* Attempt to copy the referenced lib to the |
470 | } | 940 | project's directory */ |
471 | } | 941 | |
472 | 942 | string filename = refr.Name + ".dll"; | |
473 | if (hasLibrary) | 943 | string source = filename; |
474 | { | 944 | if (refr.Path != null) |
475 | ss.Write("pkgconfig_in_files = "); | 945 | source = Path.Combine(refr.Path, source); |
476 | foreach(ProjectNode project in solution.ProjectsTableOrder) | 946 | source = Path.Combine(project.FullPath, source); |
477 | { | 947 | string dest = Path.Combine(projectDir, filename); |
478 | if (project.Type == ProjectType.Library) | 948 | |
479 | { | 949 | /* Since we depend on this binary dll to build, we |
480 | string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in"); | 950 | * will add a compile- time dependency on the |
481 | ss.Write(" " + project.Name + ".pc.in "); | 951 | * copied dll, and add the dll to the list of |
482 | StreamWriter sspc = new StreamWriter(combFilepc); | 952 | * files distributed with this package |
483 | sspc.NewLine = "\n"; | 953 | */ |
484 | using(sspc) | 954 | |
485 | { | 955 | binaryLibs.Add(refr.Name + ".dll"); |
486 | sspc.WriteLine("prefix=@prefix@"); | 956 | extraDistFiles.Add(refr.Name + ".dll"); |
487 | sspc.WriteLine("exec_prefix=${prefix}"); | 957 | |
488 | sspc.WriteLine("libdir=${exec_prefix}/lib"); | 958 | // TODO: Support copying .config.osx files |
489 | sspc.WriteLine(); | 959 | // TODO: Support for determining native dependencies |
490 | sspc.WriteLine("Name: @PACKAGE_NAME@"); | 960 | if (File.Exists(source + ".config")) |
491 | sspc.WriteLine("Description: @DESCRIPTION@"); | 961 | { |
492 | sspc.WriteLine("Version: @ASSEMBLY_VERSION@"); | 962 | System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true); |
493 | sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll"); | 963 | extraDistFiles.Add(refr.Name + ".dll.config"); |
494 | } | 964 | } |
495 | } | 965 | |
496 | } | 966 | try |
497 | 967 | { | |
498 | ss.WriteLine(); | 968 | System.IO.File.Copy(source, dest, true); |
499 | ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig"); | 969 | } |
500 | ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)"); | 970 | catch (System.IO.IOException) |
501 | } | 971 | { |
502 | ss.WriteLine(); | 972 | if (solution.ProjectsTable.ContainsKey(refr.Name)){ |
503 | foreach(ProjectNode project in solution.ProjectsTableOrder) | 973 | |
504 | { | 974 | /* If an assembly is referenced, marked for |
505 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | 975 | * local copy, in the list of projects for |
506 | ss.WriteLine("-include x {0}", | 976 | * this solution, but does not exist, put a |
507 | Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"),'/')); | 977 | * target into the Makefile.am to build the |
508 | } | 978 | * assembly and copy it to this project's |
509 | ss.WriteLine(); | 979 | * directory |
510 | ss.WriteLine("all: \\"); | 980 | */ |
511 | ss.Write("\t"); | 981 | |
512 | foreach(ProjectNode project in solution.ProjectsTableOrder) | 982 | ProjectNode sourcePrj = |
513 | { | 983 | ((ProjectNode)(solution.ProjectsTable[refr.Name])); |
514 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | 984 | |
515 | ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " "); | 985 | string target = |
516 | 986 | String.Format("{0}:\n" + | |
517 | } | 987 | "\t$(MAKE) -C ../{1}\n" + |
518 | ss.WriteLine(); | 988 | "\tln ../{2}/$@ $@\n", |
519 | if (hasLibrary) | 989 | filename, |
520 | { | 990 | sourcePrj.Name, |
521 | ss.WriteLine("EXTRA_DIST = \\"); | 991 | sourcePrj.Name ); |
522 | ss.WriteLine("\t$(pkgconfig_in_files)"); | 992 | |
523 | } | 993 | localCopyTargets.Add(target); |
524 | else | 994 | } |
525 | { | 995 | } |
526 | ss.WriteLine("EXTRA_DIST = "); | 996 | } |
527 | } | 997 | else if( !pkgLibs.Contains(refr.Name) ) |
528 | ss.WriteLine(); | 998 | { |
529 | ss.WriteLine("DISTCLEANFILES = \\"); | 999 | // Else, let's assume it's in the GAC or the lib path |
530 | ss.WriteLine("\tconfigure \\"); | 1000 | string assemName = string.Empty; |
531 | ss.WriteLine("\tMakefile.in \\"); | 1001 | int index = refr.Name.IndexOf(","); |
532 | ss.WriteLine("\taclocal.m4"); | 1002 | |
533 | } | 1003 | if (index > 0) |
534 | combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); | 1004 | assemName = refr.Name.Substring(0, index); |
535 | StreamWriter ts = new StreamWriter(combFile); | 1005 | else |
536 | ts.NewLine = "\n"; | 1006 | assemName = refr.Name; |
537 | using(ts) | 1007 | |
538 | { | 1008 | m_Kernel.Log.Write(String.Format( |
539 | if (this.hasLibrary) | 1009 | "Warning: Couldn't find an appropriate assembly " + |
540 | { | 1010 | "for reference:\n'{0}'", refr.Name |
541 | foreach(ProjectNode project in solution.ProjectsTableOrder) | 1011 | )); |
542 | { | 1012 | systemLibs.Add(assemName); |
543 | if (project.Type == ProjectType.Library) | 1013 | } |
544 | { | 1014 | } |
545 | ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)"); | 1015 | |
546 | break; | 1016 | string lineSep = " \\\n\t"; |
547 | } | 1017 | string compiledFilesString = string.Empty; |
548 | } | 1018 | if (compiledFiles.Count > 0) |
549 | } | 1019 | compiledFilesString = |
550 | else | 1020 | lineSep + string.Join(lineSep, (string[])compiledFiles.ToArray(typeof(string))); |
551 | { | 1021 | |
552 | ts.WriteLine("AC_INIT(Makefile.am)"); | 1022 | string embeddedFilesString = ""; |
553 | } | 1023 | if (embeddedFiles.Count > 0) |
554 | ts.WriteLine("AC_PREREQ(2.53)"); | 1024 | embeddedFilesString = |
555 | ts.WriteLine("AC_CANONICAL_SYSTEM"); | 1025 | lineSep + string.Join(lineSep, (string[])embeddedFiles.ToArray(typeof(string))); |
556 | 1026 | ||
557 | ts.WriteLine("PACKAGE_NAME={0}", solution.Name); | 1027 | string contentFilesString = ""; |
558 | ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion); | 1028 | if (contentFiles.Count > 0) |
559 | ts.WriteLine("DESCRIPTION=\"{0}\"", description); | 1029 | contentFilesString = |
560 | ts.WriteLine("AC_SUBST(DESCRIPTION)"); | 1030 | lineSep + string.Join(lineSep, (string[])contentFiles.ToArray(typeof(string))); |
561 | ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])"); | 1031 | |
562 | 1032 | string extraDistFilesString = ""; | |
563 | ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion); | 1033 | if (extraDistFiles.Count > 0) |
564 | ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)"); | 1034 | extraDistFilesString = |
565 | 1035 | lineSep + string.Join(lineSep, (string[])extraDistFiles.ToArray(typeof(string))); | |
566 | ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`"); | 1036 | |
567 | ts.WriteLine("AC_SUBST(PUBKEY)"); | 1037 | string pkgLibsString = ""; |
568 | 1038 | if (pkgLibs.Count > 0) | |
569 | ts.WriteLine(); | 1039 | pkgLibsString = |
570 | ts.WriteLine("AM_MAINTAINER_MODE"); | 1040 | lineSep + string.Join(lineSep, (string[])pkgLibs.ToArray(typeof(string))); |
571 | ts.WriteLine(); | 1041 | |
572 | ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])"); | 1042 | string binaryLibsString = ""; |
573 | ts.WriteLine(); | 1043 | if (binaryLibs.Count > 0) |
574 | ts.WriteLine("AC_PROG_INSTALL"); | 1044 | binaryLibsString = |
575 | ts.WriteLine(); | 1045 | lineSep + string.Join(lineSep, (string[])binaryLibs.ToArray(typeof(string))); |
576 | ts.WriteLine("MONO_REQUIRED_VERSION=1.1"); | 1046 | |
577 | ts.WriteLine(); | 1047 | string systemLibsString = ""; |
578 | ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])"); | 1048 | if (systemLibs.Count > 0) |
579 | ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then"); | 1049 | systemLibsString = |
580 | ts.WriteLine(" from_cvs=yes"); | 1050 | lineSep + string.Join(lineSep, (string[])systemLibs.ToArray(typeof(string))); |
581 | ts.WriteLine("else"); | 1051 | |
582 | ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then"); | 1052 | string localCopyTargetsString = ""; |
583 | ts.WriteLine(" from_cvs=yes"); | 1053 | if (localCopyTargets.Count > 0) |
584 | ts.WriteLine(" else"); | 1054 | localCopyTargetsString = |
585 | ts.WriteLine(" from_cvs=no"); | 1055 | string.Join("\n", (string[])localCopyTargets.ToArray(typeof(string))); |
586 | ts.WriteLine(" fi"); | 1056 | |
587 | ts.WriteLine("fi"); | 1057 | string monoPath = ""; |
588 | ts.WriteLine(); | 1058 | foreach (string runtimeLib in runtimeLibs) |
589 | ts.WriteLine("AC_MSG_RESULT($from_cvs)"); | 1059 | { |
590 | ts.WriteLine(); | 1060 | monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`"; |
591 | ts.WriteLine("AC_PATH_PROG(MONO, mono)"); | 1061 | } |
592 | ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)"); | 1062 | |
593 | ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)"); | 1063 | // Add the project name to the list of transformation |
594 | ts.WriteLine(); | 1064 | // parameters |
595 | ts.WriteLine("AC_MSG_CHECKING([for mono])"); | 1065 | XsltArgumentList argList = new XsltArgumentList(); |
596 | ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then"); | 1066 | argList.AddParam("projectName", "", project.Name); |
597 | ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])"); | 1067 | argList.AddParam("solutionName", "", solution.Name); |
598 | ts.WriteLine("dnl else"); | 1068 | argList.AddParam("assemblyName", "", projectAssemblyName); |
599 | ts.WriteLine(" AC_MSG_RESULT([found])"); | 1069 | argList.AddParam("compiledFiles", "", compiledFilesString); |
600 | ts.WriteLine("dnl fi"); | 1070 | argList.AddParam("embeddedFiles", "", embeddedFilesString); |
601 | ts.WriteLine(); | 1071 | argList.AddParam("contentFiles", "", contentFilesString); |
602 | ts.WriteLine("AC_MSG_CHECKING([for gmcs])"); | 1072 | argList.AddParam("extraDistFiles", "", extraDistFilesString); |
603 | ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then"); | 1073 | argList.AddParam("pkgLibs", "", pkgLibsString); |
604 | ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])"); | 1074 | argList.AddParam("binaryLibs", "", binaryLibsString); |
605 | ts.WriteLine("dnl else"); | 1075 | argList.AddParam("systemLibs", "", systemLibsString); |
606 | ts.WriteLine(" AC_MSG_RESULT([found])"); | 1076 | argList.AddParam("monoPath", "", monoPath); |
607 | ts.WriteLine("dnl fi"); | 1077 | argList.AddParam("localCopyTargets", "", localCopyTargetsString); |
608 | ts.WriteLine(); | 1078 | argList.AddParam("projectVersion", "", projectVersion); |
1079 | argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : ""); | ||
1080 | |||
1081 | // Transform the templates | ||
1082 | transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc"); | ||
1083 | transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm"); | ||
1084 | transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh"); | ||
1085 | |||
1086 | if (project.Type == Core.Nodes.ProjectType.Library) | ||
1087 | transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn"); | ||
1088 | if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe) | ||
1089 | transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn"); | ||
1090 | } | ||
1091 | |||
1092 | private void WriteProjectOld(SolutionNode solution, ProjectNode project) | ||
1093 | { | ||
1094 | string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); | ||
1095 | StreamWriter ss = new StreamWriter(projFile); | ||
1096 | ss.NewLine = "\n"; | ||
1097 | |||
1098 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
1099 | Helper.SetCurrentDir(Path.GetDirectoryName(projFile)); | ||
1100 | |||
1101 | using (ss) | ||
1102 | { | ||
1103 | ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":"); | ||
1104 | ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/"); | ||
1105 | foreach (string file in project.Files) | ||
1106 | { | ||
1107 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
1108 | { | ||
1109 | ss.Write("\tresgen "); | ||
1110 | ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/')); | ||
1111 | if (project.Files.GetResourceName(file) != "") | ||
1112 | { | ||
1113 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/')); | ||
1114 | } | ||
1115 | else | ||
1116 | { | ||
1117 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/')); | ||
1118 | } | ||
1119 | } | ||
1120 | } | ||
1121 | ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\"); | ||
1122 | ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\"); | ||
1123 | if (project.References.Count > 0) | ||
1124 | { | ||
1125 | ss.Write("\t\t/reference:"); | ||
1126 | bool firstref = true; | ||
1127 | foreach (ReferenceNode refr in project.References) | ||
1128 | { | ||
1129 | if (firstref) | ||
1130 | { | ||
1131 | firstref = false; | ||
1132 | } | ||
1133 | else | ||
1134 | { | ||
1135 | ss.Write(","); | ||
1136 | } | ||
1137 | ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/')); | ||
1138 | } | ||
1139 | ss.WriteLine(" \\"); | ||
1140 | } | ||
1141 | //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\"); | ||
1142 | |||
1143 | foreach (string file in project.Files) | ||
1144 | { | ||
1145 | switch (project.Files.GetBuildAction(file)) | ||
1146 | { | ||
1147 | case BuildAction.EmbeddedResource: | ||
1148 | ss.Write("\t\t/resource:"); | ||
1149 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\"); | ||
1150 | break; | ||
1151 | default: | ||
1152 | if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) | ||
1153 | { | ||
1154 | ss.Write("\t\t/resource:"); | ||
1155 | if (project.Files.GetResourceName(file) != "") | ||
1156 | { | ||
1157 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\"); | ||
1158 | } | ||
1159 | else | ||
1160 | { | ||
1161 | ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\"); | ||
1162 | } | ||
1163 | } | ||
1164 | break; | ||
1165 | } | ||
1166 | } | ||
1167 | |||
1168 | foreach (ConfigurationNode conf in project.Configurations) | ||
1169 | { | ||
1170 | if (conf.Options.KeyFile != "") | ||
1171 | { | ||
1172 | ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\"); | ||
1173 | break; | ||
1174 | } | ||
1175 | } | ||
1176 | foreach (ConfigurationNode conf in project.Configurations) | ||
1177 | { | ||
1178 | if (conf.Options.AllowUnsafe) | ||
1179 | { | ||
1180 | ss.WriteLine("\t\t/unsafe \\"); | ||
1181 | break; | ||
1182 | } | ||
1183 | } | ||
1184 | if (project.AppIcon != "") | ||
1185 | { | ||
1186 | ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\"); | ||
1187 | } | ||
1188 | |||
1189 | foreach (ConfigurationNode conf in project.Configurations) | ||
1190 | { | ||
1191 | ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\"); | ||
1192 | break; | ||
1193 | } | ||
1194 | |||
1195 | foreach (ConfigurationNode conf in project.Configurations) | ||
1196 | { | ||
1197 | if (GetXmlDocFile(project, conf) != "") | ||
1198 | { | ||
1199 | ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\"); | ||
1200 | break; | ||
1201 | } | ||
1202 | } | ||
1203 | foreach (string file in project.Files) | ||
1204 | { | ||
1205 | switch (project.Files.GetBuildAction(file)) | ||
1206 | { | ||
1207 | case BuildAction.Compile: | ||
1208 | ss.WriteLine("\t\t\\"); | ||
1209 | ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file))); | ||
1210 | break; | ||
1211 | default: | ||
1212 | break; | ||
1213 | } | ||
1214 | } | ||
1215 | ss.WriteLine(); | ||
1216 | ss.WriteLine(); | ||
1217 | |||
1218 | if (project.Type == ProjectType.Library) | ||
1219 | { | ||
1220 | ss.WriteLine("install-data-local:"); | ||
1221 | ss.WriteLine(" echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\"; \\"); | ||
1222 | ss.WriteLine(" $(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;"); | ||
1223 | ss.WriteLine(); | ||
1224 | ss.WriteLine("uninstall-local:"); | ||
1225 | ss.WriteLine(" echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\"); | ||
1226 | ss.WriteLine(" $(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;"); | ||
1227 | ss.WriteLine(); | ||
1228 | } | ||
1229 | 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"); | ||
1230 | ss.WriteLine("EXTRA_DIST = \\"); | ||
1231 | ss.Write(" $(FILES)"); | ||
1232 | foreach (ConfigurationNode conf in project.Configurations) | ||
1233 | { | ||
1234 | if (conf.Options.KeyFile != "") | ||
1235 | { | ||
1236 | ss.Write(" \\"); | ||
1237 | ss.WriteLine("\t" + conf.Options.KeyFile); | ||
1238 | } | ||
1239 | break; | ||
1240 | } | ||
1241 | } | ||
1242 | m_Kernel.CurrentWorkingDirectory.Pop(); | ||
1243 | } | ||
1244 | bool hasLibrary = false; | ||
1245 | |||
1246 | private void WriteCombineOld(SolutionNode solution) | ||
1247 | { | ||
1248 | |||
1249 | /* TODO: These vars should be pulled from the prebuild.xml file */ | ||
1250 | string releaseVersion = "2.0.0"; | ||
1251 | string assemblyVersion = "2.1.0.0"; | ||
1252 | string description = | ||
1253 | "Tao Framework " + solution.Name + " Binding For .NET"; | ||
1254 | |||
1255 | hasLibrary = false; | ||
1256 | m_Kernel.Log.Write("Creating Autotools make files"); | ||
1257 | foreach (ProjectNode project in solution.Projects) | ||
1258 | { | ||
1259 | if (m_Kernel.AllowProject(project.FilterGroups)) | ||
1260 | { | ||
1261 | m_Kernel.Log.Write("...Creating makefile: {0}", project.Name); | ||
1262 | WriteProject(solution, project); | ||
1263 | } | ||
1264 | } | ||
1265 | |||
1266 | m_Kernel.Log.Write(""); | ||
1267 | string combFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); | ||
1268 | StreamWriter ss = new StreamWriter(combFile); | ||
1269 | ss.NewLine = "\n"; | ||
1270 | |||
1271 | m_Kernel.CurrentWorkingDirectory.Push(); | ||
1272 | Helper.SetCurrentDir(Path.GetDirectoryName(combFile)); | ||
1273 | |||
1274 | using (ss) | ||
1275 | { | ||
1276 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
1277 | { | ||
1278 | if (project.Type == ProjectType.Library) | ||
1279 | { | ||
1280 | hasLibrary = true; | ||
1281 | break; | ||
1282 | } | ||
1283 | } | ||
1284 | |||
1285 | if (hasLibrary) | ||
1286 | { | ||
1287 | ss.Write("pkgconfig_in_files = "); | ||
1288 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
1289 | { | ||
1290 | if (project.Type == ProjectType.Library) | ||
1291 | { | ||
1292 | string combFilepc = Helper.MakeFilePath(solution.FullPath, project.Name, "pc.in"); | ||
1293 | ss.Write(" " + project.Name + ".pc.in "); | ||
1294 | StreamWriter sspc = new StreamWriter(combFilepc); | ||
1295 | sspc.NewLine = "\n"; | ||
1296 | using (sspc) | ||
1297 | { | ||
1298 | sspc.WriteLine("prefix=@prefix@"); | ||
1299 | sspc.WriteLine("exec_prefix=${prefix}"); | ||
1300 | sspc.WriteLine("libdir=${exec_prefix}/lib"); | ||
1301 | sspc.WriteLine(); | ||
1302 | sspc.WriteLine("Name: @PACKAGE_NAME@"); | ||
1303 | sspc.WriteLine("Description: @DESCRIPTION@"); | ||
1304 | sspc.WriteLine("Version: @ASSEMBLY_VERSION@"); | ||
1305 | sspc.WriteLine("Libs: -r:${libdir}/mono/gac/@PACKAGE_NAME@/@ASSEMBLY_VERSION@__@PUBKEY@/@PACKAGE_NAME@.dll"); | ||
1306 | } | ||
1307 | } | ||
1308 | } | ||
1309 | |||
1310 | ss.WriteLine(); | ||
1311 | ss.WriteLine("pkgconfigdir=$(prefix)/lib/pkgconfig"); | ||
1312 | ss.WriteLine("pkgconfig_DATA=$(pkgconfig_in_files:.pc.in=.pc)"); | ||
1313 | } | ||
1314 | ss.WriteLine(); | ||
1315 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
1316 | { | ||
1317 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
1318 | ss.WriteLine("-include x {0}", | ||
1319 | Helper.NormalizePath(Helper.MakeFilePath(path, "Include", "am"), '/')); | ||
1320 | } | ||
1321 | ss.WriteLine(); | ||
1322 | ss.WriteLine("all: \\"); | ||
1323 | ss.Write("\t"); | ||
1324 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
1325 | { | ||
1326 | string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | ||
1327 | ss.Write(Helper.AssemblyFullName(project.AssemblyName, project.Type) + " "); | ||
1328 | |||
1329 | } | ||
1330 | ss.WriteLine(); | ||
1331 | if (hasLibrary) | ||
1332 | { | ||
1333 | ss.WriteLine("EXTRA_DIST = \\"); | ||
1334 | ss.WriteLine("\t$(pkgconfig_in_files)"); | ||
1335 | } | ||
1336 | else | ||
1337 | { | ||
1338 | ss.WriteLine("EXTRA_DIST = "); | ||
1339 | } | ||
1340 | ss.WriteLine(); | ||
1341 | ss.WriteLine("DISTCLEANFILES = \\"); | ||
1342 | ss.WriteLine("\tconfigure \\"); | ||
1343 | ss.WriteLine("\tMakefile.in \\"); | ||
1344 | ss.WriteLine("\taclocal.m4"); | ||
1345 | } | ||
1346 | combFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); | ||
1347 | StreamWriter ts = new StreamWriter(combFile); | ||
1348 | ts.NewLine = "\n"; | ||
1349 | using (ts) | ||
1350 | { | ||
1351 | if (this.hasLibrary) | ||
1352 | { | ||
1353 | foreach (ProjectNode project in solution.ProjectsTableOrder) | ||
1354 | { | ||
1355 | if (project.Type == ProjectType.Library) | ||
1356 | { | ||
1357 | ts.WriteLine("AC_INIT(" + project.Name + ".pc.in)"); | ||
1358 | break; | ||
1359 | } | ||
1360 | } | ||
1361 | } | ||
1362 | else | ||
1363 | { | ||
1364 | ts.WriteLine("AC_INIT(Makefile.am)"); | ||
1365 | } | ||
1366 | ts.WriteLine("AC_PREREQ(2.53)"); | ||
1367 | ts.WriteLine("AC_CANONICAL_SYSTEM"); | ||
1368 | |||
1369 | ts.WriteLine("PACKAGE_NAME={0}", solution.Name); | ||
1370 | ts.WriteLine("PACKAGE_VERSION={0}", releaseVersion); | ||
1371 | ts.WriteLine("DESCRIPTION=\"{0}\"", description); | ||
1372 | ts.WriteLine("AC_SUBST(DESCRIPTION)"); | ||
1373 | ts.WriteLine("AM_INIT_AUTOMAKE([$PACKAGE_NAME],[$PACKAGE_VERSION],[$DESCRIPTION])"); | ||
1374 | |||
1375 | ts.WriteLine("ASSEMBLY_VERSION={0}", assemblyVersion); | ||
1376 | ts.WriteLine("AC_SUBST(ASSEMBLY_VERSION)"); | ||
1377 | |||
1378 | ts.WriteLine("PUBKEY=`sn -t $PACKAGE_NAME.snk | grep 'Public Key Token' | awk -F: '{print $2}' | sed -e 's/^ //'`"); | ||
1379 | ts.WriteLine("AC_SUBST(PUBKEY)"); | ||
1380 | |||
1381 | ts.WriteLine(); | ||
1382 | ts.WriteLine("AM_MAINTAINER_MODE"); | ||
1383 | ts.WriteLine(); | ||
1384 | ts.WriteLine("dnl AC_PROG_INTLTOOL([0.25])"); | ||
1385 | ts.WriteLine(); | ||
1386 | ts.WriteLine("AC_PROG_INSTALL"); | ||
1387 | ts.WriteLine(); | ||
1388 | ts.WriteLine("MONO_REQUIRED_VERSION=1.1"); | ||
1389 | ts.WriteLine(); | ||
1390 | ts.WriteLine("AC_MSG_CHECKING([whether we're compiling from CVS])"); | ||
1391 | ts.WriteLine("if test -f \"$srcdir/.cvs_version\" ; then"); | ||
1392 | ts.WriteLine(" from_cvs=yes"); | ||
1393 | ts.WriteLine("else"); | ||
1394 | ts.WriteLine(" if test -f \"$srcdir/.svn\" ; then"); | ||
1395 | ts.WriteLine(" from_cvs=yes"); | ||
1396 | ts.WriteLine(" else"); | ||
1397 | ts.WriteLine(" from_cvs=no"); | ||
1398 | ts.WriteLine(" fi"); | ||
1399 | ts.WriteLine("fi"); | ||
1400 | ts.WriteLine(); | ||
1401 | ts.WriteLine("AC_MSG_RESULT($from_cvs)"); | ||
1402 | ts.WriteLine(); | ||
1403 | ts.WriteLine("AC_PATH_PROG(MONO, mono)"); | ||
1404 | ts.WriteLine("AC_PATH_PROG(GMCS, gmcs)"); | ||
1405 | ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil)"); | ||
1406 | ts.WriteLine(); | ||
1407 | ts.WriteLine("AC_MSG_CHECKING([for mono])"); | ||
1408 | ts.WriteLine("dnl if test \"x$MONO\" = \"x\" ; then"); | ||
1409 | ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"mono\" in your PATH])"); | ||
1410 | ts.WriteLine("dnl else"); | ||
1411 | ts.WriteLine(" AC_MSG_RESULT([found])"); | ||
1412 | ts.WriteLine("dnl fi"); | ||
1413 | ts.WriteLine(); | ||
1414 | ts.WriteLine("AC_MSG_CHECKING([for gmcs])"); | ||
1415 | ts.WriteLine("dnl if test \"x$GMCS\" = \"x\" ; then"); | ||
1416 | ts.WriteLine("dnl AC_MSG_ERROR([Can't find \"gmcs\" in your PATH])"); | ||
1417 | ts.WriteLine("dnl else"); | ||
1418 | ts.WriteLine(" AC_MSG_RESULT([found])"); | ||
1419 | ts.WriteLine("dnl fi"); | ||
1420 | ts.WriteLine(); | ||
609 | //ts.WriteLine("AC_MSG_CHECKING([for gacutil])"); | 1421 | //ts.WriteLine("AC_MSG_CHECKING([for gacutil])"); |
610 | //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then"); | 1422 | //ts.WriteLine("if test \"x$GACUTIL\" = \"x\" ; then"); |
611 | //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])"); | 1423 | //ts.WriteLine(" AC_MSG_ERROR([Can't find \"gacutil\" in your PATH])"); |
612 | //ts.WriteLine("else"); | 1424 | //ts.WriteLine("else"); |
613 | //ts.WriteLine(" AC_MSG_RESULT([found])"); | 1425 | //ts.WriteLine(" AC_MSG_RESULT([found])"); |
614 | //ts.WriteLine("fi"); | 1426 | //ts.WriteLine("fi"); |
615 | ts.WriteLine(); | 1427 | ts.WriteLine(); |
616 | ts.WriteLine("AC_SUBST(PATH)"); | 1428 | ts.WriteLine("AC_SUBST(PATH)"); |
617 | ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)"); | 1429 | ts.WriteLine("AC_SUBST(LD_LIBRARY_PATH)"); |
618 | ts.WriteLine(); | 1430 | ts.WriteLine(); |
619 | ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\""); | 1431 | ts.WriteLine("dnl CSFLAGS=\"-debug -nowarn:1574\""); |
620 | ts.WriteLine("CSFLAGS=\"\""); | 1432 | ts.WriteLine("CSFLAGS=\"\""); |
621 | ts.WriteLine("AC_SUBST(CSFLAGS)"); | 1433 | ts.WriteLine("AC_SUBST(CSFLAGS)"); |
622 | ts.WriteLine(); | 1434 | ts.WriteLine(); |
623 | // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)"); | 1435 | // ts.WriteLine("AC_MSG_CHECKING(--disable-sdl argument)"); |
624 | // ts.WriteLine("AC_ARG_ENABLE(sdl,"); | 1436 | // ts.WriteLine("AC_ARG_ENABLE(sdl,"); |
625 | // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],"); | 1437 | // ts.WriteLine(" [ --disable-sdl Disable Sdl interface.],"); |
626 | // ts.WriteLine(" [disable_sdl=$disableval],"); | 1438 | // ts.WriteLine(" [disable_sdl=$disableval],"); |
627 | // ts.WriteLine(" [disable_sdl=\"no\"])"); | 1439 | // ts.WriteLine(" [disable_sdl=\"no\"])"); |
628 | // ts.WriteLine("AC_MSG_RESULT($disable_sdl)"); | 1440 | // ts.WriteLine("AC_MSG_RESULT($disable_sdl)"); |
629 | // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then"); | 1441 | // ts.WriteLine("if test \"$disable_sdl\" = \"yes\"; then"); |
630 | // ts.WriteLine(" AC_DEFINE(FEAT_SDL)"); | 1442 | // ts.WriteLine(" AC_DEFINE(FEAT_SDL)"); |
631 | // ts.WriteLine("fi"); | 1443 | // ts.WriteLine("fi"); |
632 | ts.WriteLine(); | 1444 | ts.WriteLine(); |
633 | ts.WriteLine("dnl Find pkg-config"); | 1445 | ts.WriteLine("dnl Find pkg-config"); |
634 | ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)"); | 1446 | ts.WriteLine("AC_PATH_PROG(PKGCONFIG, pkg-config, no)"); |
635 | ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then"); | 1447 | ts.WriteLine("if test \"x$PKG_CONFIG\" = \"xno\"; then"); |
636 | ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])"); | 1448 | ts.WriteLine(" AC_MSG_ERROR([You need to install pkg-config])"); |
637 | ts.WriteLine("fi"); | 1449 | ts.WriteLine("fi"); |
638 | ts.WriteLine(); | 1450 | ts.WriteLine(); |
639 | ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)"); | 1451 | ts.WriteLine("PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)"); |
640 | ts.WriteLine("BUILD_DIR=\"bin\""); | 1452 | ts.WriteLine("BUILD_DIR=\"bin\""); |
641 | ts.WriteLine("AC_SUBST(BUILD_DIR)"); | 1453 | ts.WriteLine("AC_SUBST(BUILD_DIR)"); |
642 | ts.WriteLine("CONFIG=\"Release\""); | 1454 | ts.WriteLine("CONFIG=\"Release\""); |
643 | ts.WriteLine("AC_SUBST(CONFIG)"); | 1455 | ts.WriteLine("AC_SUBST(CONFIG)"); |
644 | ts.WriteLine(); | 1456 | ts.WriteLine(); |
645 | ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then"); | 1457 | ts.WriteLine("if test \"x$has_mono\" = \"xtrue\"; then"); |
646 | ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)"); | 1458 | ts.WriteLine(" AC_PATH_PROG(RUNTIME, mono, no)"); |
647 | ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)"); | 1459 | ts.WriteLine(" AC_PATH_PROG(CSC, gmcs, no)"); |
648 | ts.WriteLine(" if test `uname -s` = \"Darwin\"; then"); | 1460 | ts.WriteLine(" if test `uname -s` = \"Darwin\"; then"); |
649 | ts.WriteLine(" LIB_PREFIX="); | 1461 | ts.WriteLine(" LIB_PREFIX="); |
650 | ts.WriteLine(" LIB_SUFFIX=.dylib"); | 1462 | ts.WriteLine(" LIB_SUFFIX=.dylib"); |
651 | ts.WriteLine(" else"); | 1463 | ts.WriteLine(" else"); |
652 | ts.WriteLine(" LIB_PREFIX=.so"); | 1464 | ts.WriteLine(" LIB_PREFIX=.so"); |
653 | ts.WriteLine(" LIB_SUFFIX="); | 1465 | ts.WriteLine(" LIB_SUFFIX="); |
654 | ts.WriteLine(" fi"); | 1466 | ts.WriteLine(" fi"); |
655 | ts.WriteLine("else"); | 1467 | ts.WriteLine("else"); |
656 | ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)"); | 1468 | ts.WriteLine(" AC_PATH_PROG(CSC, csc.exe, no)"); |
657 | ts.WriteLine(" if test x$CSC = \"xno\"; then"); | 1469 | ts.WriteLine(" if test x$CSC = \"xno\"; then"); |
658 | ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])"); | 1470 | ts.WriteLine(" AC_MSG_ERROR([You need to install either mono or .Net])"); |
659 | ts.WriteLine(" else"); | 1471 | ts.WriteLine(" else"); |
660 | ts.WriteLine(" RUNTIME="); | 1472 | ts.WriteLine(" RUNTIME="); |
661 | ts.WriteLine(" LIB_PREFIX="); | 1473 | ts.WriteLine(" LIB_PREFIX="); |
662 | ts.WriteLine(" LIB_SUFFIX=.dylib"); | 1474 | ts.WriteLine(" LIB_SUFFIX=.dylib"); |
663 | ts.WriteLine(" fi"); | 1475 | ts.WriteLine(" fi"); |
664 | ts.WriteLine("fi"); | 1476 | ts.WriteLine("fi"); |
665 | ts.WriteLine(); | 1477 | ts.WriteLine(); |
666 | ts.WriteLine("AC_SUBST(LIB_PREFIX)"); | 1478 | ts.WriteLine("AC_SUBST(LIB_PREFIX)"); |
667 | ts.WriteLine("AC_SUBST(LIB_SUFFIX)"); | 1479 | ts.WriteLine("AC_SUBST(LIB_SUFFIX)"); |
668 | ts.WriteLine(); | 1480 | ts.WriteLine(); |
669 | ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)"); | 1481 | ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_CFLAGS)"); |
670 | ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)"); | 1482 | ts.WriteLine("AC_SUBST(BASE_DEPENDENCIES_LIBS)"); |
671 | ts.WriteLine(); | 1483 | ts.WriteLine(); |
672 | ts.WriteLine("dnl Find monodoc"); | 1484 | ts.WriteLine("dnl Find monodoc"); |
673 | ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0"); | 1485 | ts.WriteLine("MONODOC_REQUIRED_VERSION=1.0"); |
674 | ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)"); | 1486 | ts.WriteLine("AC_SUBST(MONODOC_REQUIRED_VERSION)"); |
675 | ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)"); | 1487 | ts.WriteLine("PKG_CHECK_MODULES(MONODOC_DEPENDENCY, monodoc >= $MONODOC_REQUIRED_VERSION, enable_monodoc=yes, enable_monodoc=no)"); |
676 | ts.WriteLine(); | 1488 | ts.WriteLine(); |
677 | ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then"); | 1489 | ts.WriteLine("if test \"x$enable_monodoc\" = \"xyes\"; then"); |
678 | ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)"); | 1490 | ts.WriteLine(" AC_PATH_PROG(MONODOC, monodoc, no)"); |
679 | ts.WriteLine(" if test x$MONODOC = xno; then"); | 1491 | ts.WriteLine(" if test x$MONODOC = xno; then"); |
680 | ts.WriteLine(" enable_monodoc=no"); | 1492 | ts.WriteLine(" enable_monodoc=no"); |
681 | ts.WriteLine(" fi"); | 1493 | ts.WriteLine(" fi"); |
682 | ts.WriteLine("else"); | 1494 | ts.WriteLine("else"); |
683 | ts.WriteLine(" MONODOC="); | 1495 | ts.WriteLine(" MONODOC="); |
684 | ts.WriteLine("fi"); | 1496 | ts.WriteLine("fi"); |
685 | ts.WriteLine(); | 1497 | ts.WriteLine(); |
686 | ts.WriteLine("AC_SUBST(MONODOC)"); | 1498 | ts.WriteLine("AC_SUBST(MONODOC)"); |
687 | ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")"); | 1499 | ts.WriteLine("AM_CONDITIONAL(ENABLE_MONODOC, test \"x$enable_monodoc\" = \"xyes\")"); |
688 | ts.WriteLine(); | 1500 | ts.WriteLine(); |
689 | ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)"); | 1501 | ts.WriteLine("AC_PATH_PROG(GACUTIL, gacutil, no)"); |
690 | ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then"); | 1502 | ts.WriteLine("if test \"x$GACUTIL\" = \"xno\" ; then"); |
691 | ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])"); | 1503 | ts.WriteLine(" AC_MSG_ERROR([No gacutil tool found])"); |
692 | ts.WriteLine("fi"); | 1504 | ts.WriteLine("fi"); |
693 | ts.WriteLine(); | 1505 | ts.WriteLine(); |
694 | // foreach(ProjectNode project in solution.ProjectsTableOrder) | 1506 | // foreach(ProjectNode project in solution.ProjectsTableOrder) |
695 | // { | 1507 | // { |
696 | // if (project.Type == ProjectType.Library) | 1508 | // if (project.Type == ProjectType.Library) |
697 | // { | 1509 | // { |
698 | // } | 1510 | // } |
699 | // } | 1511 | // } |
700 | ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'"); | 1512 | ts.WriteLine("GACUTIL_FLAGS='/package $(PACKAGE_NAME) /gacdir $(DESTDIR)$(prefix)'"); |
701 | ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)"); | 1513 | ts.WriteLine("AC_SUBST(GACUTIL_FLAGS)"); |
702 | ts.WriteLine(); | 1514 | ts.WriteLine(); |
703 | ts.WriteLine("winbuild=no"); | 1515 | ts.WriteLine("winbuild=no"); |
704 | ts.WriteLine("case \"$host\" in"); | 1516 | ts.WriteLine("case \"$host\" in"); |
705 | ts.WriteLine(" *-*-mingw*|*-*-cygwin*)"); | 1517 | ts.WriteLine(" *-*-mingw*|*-*-cygwin*)"); |
706 | ts.WriteLine(" winbuild=yes"); | 1518 | ts.WriteLine(" winbuild=yes"); |
707 | ts.WriteLine(" ;;"); | 1519 | ts.WriteLine(" ;;"); |
708 | ts.WriteLine("esac"); | 1520 | ts.WriteLine("esac"); |
709 | ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)"); | 1521 | ts.WriteLine("AM_CONDITIONAL(WINBUILD, test x$winbuild = xyes)"); |
710 | ts.WriteLine(); | 1522 | ts.WriteLine(); |
711 | // ts.WriteLine("dnl Check for SDL"); | 1523 | // ts.WriteLine("dnl Check for SDL"); |
712 | // ts.WriteLine(); | 1524 | // ts.WriteLine(); |
713 | // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])"); | 1525 | // ts.WriteLine("AC_PATH_PROG([SDL_CONFIG], [sdl-config])"); |
714 | // ts.WriteLine("have_sdl=no"); | 1526 | // ts.WriteLine("have_sdl=no"); |
715 | // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then"); | 1527 | // ts.WriteLine("if test -n \"${SDL_CONFIG}\"; then"); |
716 | // ts.WriteLine(" have_sdl=yes"); | 1528 | // ts.WriteLine(" have_sdl=yes"); |
717 | // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`"); | 1529 | // ts.WriteLine(" SDL_CFLAGS=`$SDL_CONFIG --cflags`"); |
718 | // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`"); | 1530 | // ts.WriteLine(" SDL_LIBS=`$SDL_CONFIG --libs`"); |
719 | // ts.WriteLine(" #"); | 1531 | // ts.WriteLine(" #"); |
720 | // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library"); | 1532 | // ts.WriteLine(" # sdl-config sometimes emits an rpath flag pointing at its library"); |
721 | // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from"); | 1533 | // ts.WriteLine(" # installation directory. We don't want this, as it prevents users from"); |
722 | // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a"); | 1534 | // ts.WriteLine(" # linking sdl-viewer against, for example, a locally compiled libGL when a"); |
723 | // ts.WriteLine(" # version of the library also exists in SDL's library installation"); | 1535 | // ts.WriteLine(" # version of the library also exists in SDL's library installation"); |
724 | // ts.WriteLine(" # directory, typically /usr/lib."); | 1536 | // ts.WriteLine(" # directory, typically /usr/lib."); |
725 | // ts.WriteLine(" #"); | 1537 | // ts.WriteLine(" #"); |
726 | // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`"); | 1538 | // ts.WriteLine(" SDL_LIBS=`echo $SDL_LIBS | sed 's/-Wl,-rpath,[[^ ]]* //'`"); |
727 | // ts.WriteLine("fi"); | 1539 | // ts.WriteLine("fi"); |
728 | // ts.WriteLine("AC_SUBST([SDL_CFLAGS])"); | 1540 | // ts.WriteLine("AC_SUBST([SDL_CFLAGS])"); |
729 | // ts.WriteLine("AC_SUBST([SDL_LIBS])"); | 1541 | // ts.WriteLine("AC_SUBST([SDL_LIBS])"); |
730 | ts.WriteLine(); | 1542 | ts.WriteLine(); |
731 | ts.WriteLine("AC_OUTPUT(["); | 1543 | ts.WriteLine("AC_OUTPUT(["); |
732 | ts.WriteLine("Makefile"); | 1544 | ts.WriteLine("Makefile"); |
733 | // TODO: this does not work quite right. | 1545 | // TODO: this does not work quite right. |
734 | //ts.WriteLine("Properties/AssemblyInfo.cs"); | 1546 | //ts.WriteLine("Properties/AssemblyInfo.cs"); |
735 | foreach(ProjectNode project in solution.ProjectsTableOrder) | 1547 | foreach (ProjectNode project in solution.ProjectsTableOrder) |
736 | { | 1548 | { |
737 | if (project.Type == ProjectType.Library) | 1549 | if (project.Type == ProjectType.Library) |
738 | { | 1550 | { |
739 | ts.WriteLine(project.Name + ".pc"); | 1551 | ts.WriteLine(project.Name + ".pc"); |
740 | } | 1552 | } |
741 | // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); | 1553 | // string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); |
742 | // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/')); | 1554 | // ts.WriteLine(Helper.NormalizePath(Helper.MakeFilePath(path, "Include"),'/')); |
743 | } | 1555 | } |
744 | ts.WriteLine("])"); | 1556 | ts.WriteLine("])"); |
745 | ts.WriteLine(); | 1557 | ts.WriteLine(); |
746 | ts.WriteLine("#po/Makefile.in"); | 1558 | ts.WriteLine("#po/Makefile.in"); |
747 | ts.WriteLine(); | 1559 | ts.WriteLine(); |
748 | ts.WriteLine("echo \"---\""); | 1560 | ts.WriteLine("echo \"---\""); |
749 | ts.WriteLine("echo \"Configuration summary\""); | 1561 | ts.WriteLine("echo \"Configuration summary\""); |
750 | ts.WriteLine("echo \"\""); | 1562 | ts.WriteLine("echo \"\""); |
751 | ts.WriteLine("echo \" * Installation prefix: $prefix\""); | 1563 | ts.WriteLine("echo \" * Installation prefix: $prefix\""); |
752 | ts.WriteLine("echo \" * compiler: $CSC\""); | 1564 | ts.WriteLine("echo \" * compiler: $CSC\""); |
753 | ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\""); | 1565 | ts.WriteLine("echo \" * Documentation: $enable_monodoc ($MONODOC)\""); |
754 | ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\""); | 1566 | ts.WriteLine("echo \" * Package Name: $PACKAGE_NAME\""); |
755 | ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\""); | 1567 | ts.WriteLine("echo \" * Version: $PACKAGE_VERSION\""); |
756 | ts.WriteLine("echo \" * Public Key: $PUBKEY\""); | 1568 | ts.WriteLine("echo \" * Public Key: $PUBKEY\""); |
757 | ts.WriteLine("echo \"\""); | 1569 | ts.WriteLine("echo \"\""); |
758 | ts.WriteLine("echo \"---\""); | 1570 | ts.WriteLine("echo \"---\""); |
759 | ts.WriteLine(); | 1571 | ts.WriteLine(); |
760 | } | 1572 | } |
761 | 1573 | ||
762 | ts.NewLine = "\n"; | 1574 | ts.NewLine = "\n"; |
763 | foreach (ProjectNode project in solution.ProjectsTableOrder) | 1575 | foreach (ProjectNode project in solution.ProjectsTableOrder) |
@@ -767,14 +1579,14 @@ namespace Prebuild.Core.Targets | |||
767 | GenerateAssemblyInfoFile(solution, combFile); | 1579 | GenerateAssemblyInfoFile(solution, combFile); |
768 | } | 1580 | } |
769 | } | 1581 | } |
770 | } | 1582 | } |
771 | 1583 | ||
772 | private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile) | 1584 | private static void GenerateAssemblyInfoFile(SolutionNode solution, string combFile) |
773 | { | 1585 | { |
774 | System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties")); | 1586 | System.IO.Directory.CreateDirectory(Helper.MakePathRelativeTo(solution.FullPath, "Properties")); |
775 | combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in"); | 1587 | combFile = Helper.MakeFilePath(solution.FullPath + "/Properties/", "AssemblyInfo.cs", "in"); |
776 | StreamWriter ai = new StreamWriter(combFile); | 1588 | StreamWriter ai = new StreamWriter(combFile); |
777 | 1589 | ||
778 | using (ai) | 1590 | using (ai) |
779 | { | 1591 | { |
780 | ai.WriteLine("#region License"); | 1592 | ai.WriteLine("#region License"); |
@@ -835,92 +1647,158 @@ namespace Prebuild.Core.Targets | |||
835 | //return combFile; | 1647 | //return combFile; |
836 | } | 1648 | } |
837 | 1649 | ||
838 | private void CleanProject(ProjectNode project) | 1650 | private void CleanProject(ProjectNode project) |
839 | { | 1651 | { |
840 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); | 1652 | m_Kernel.Log.Write("...Cleaning project: {0}", project.Name); |
841 | string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); | 1653 | string projectFile = Helper.MakeFilePath(project.FullPath, "Include", "am"); |
842 | Helper.DeleteIfExists(projectFile); | 1654 | Helper.DeleteIfExists(projectFile); |
843 | } | 1655 | } |
844 | 1656 | ||
845 | private void CleanSolution(SolutionNode solution) | 1657 | private void CleanSolution(SolutionNode solution) |
846 | { | 1658 | { |
847 | m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); | 1659 | m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name); |
848 | 1660 | ||
849 | string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); | 1661 | string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am"); |
850 | Helper.DeleteIfExists(slnFile); | 1662 | Helper.DeleteIfExists(slnFile); |
851 | 1663 | ||
852 | slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); | 1664 | slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in"); |
853 | Helper.DeleteIfExists(slnFile); | 1665 | Helper.DeleteIfExists(slnFile); |
854 | 1666 | ||
855 | slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); | 1667 | slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac"); |
856 | Helper.DeleteIfExists(slnFile); | 1668 | Helper.DeleteIfExists(slnFile); |
857 | 1669 | ||
858 | slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); | 1670 | slnFile = Helper.MakeFilePath(solution.FullPath, "configure"); |
859 | Helper.DeleteIfExists(slnFile); | 1671 | Helper.DeleteIfExists(slnFile); |
860 | 1672 | ||
861 | slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); | 1673 | slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile"); |
862 | Helper.DeleteIfExists(slnFile); | 1674 | Helper.DeleteIfExists(slnFile); |
863 | 1675 | ||
864 | foreach(ProjectNode project in solution.Projects) | 1676 | foreach (ProjectNode project in solution.Projects) |
865 | { | 1677 | { |
866 | CleanProject(project); | 1678 | CleanProject(project); |
867 | } | 1679 | } |
868 | 1680 | ||
869 | m_Kernel.Log.Write(""); | 1681 | m_Kernel.Log.Write(""); |
870 | } | 1682 | } |
871 | 1683 | ||
872 | #endregion | 1684 | #endregion |
873 | 1685 | ||
874 | #region ITarget Members | 1686 | #region ITarget Members |
875 | 1687 | ||
876 | /// <summary> | 1688 | /// <summary> |
877 | /// Writes the specified kern. | 1689 | /// Writes the specified kern. |
878 | /// </summary> | 1690 | /// </summary> |
879 | /// <param name="kern">The kern.</param> | 1691 | /// <param name="kern">The kern.</param> |
880 | public void Write(Kernel kern) | 1692 | public void Write(Kernel kern) |
881 | { | 1693 | { |
882 | if( kern == null ) | 1694 | if (kern == null) |
883 | { | 1695 | { |
884 | throw new ArgumentNullException("kern"); | 1696 | throw new ArgumentNullException("kern"); |
885 | } | 1697 | } |
886 | m_Kernel = kern; | 1698 | m_Kernel = kern; |
887 | foreach(SolutionNode solution in kern.Solutions) | 1699 | m_Kernel.Log.Write("Parsing system pkg-config files"); |
888 | { | 1700 | RunInitialization(); |
889 | WriteCombine(solution); | 1701 | |
890 | } | 1702 | string streamName = "autotools.xml"; |
891 | m_Kernel = null; | 1703 | string fqStreamName = String.Format("Prebuild.data.{0}", |
892 | } | 1704 | streamName |
893 | 1705 | ); | |
894 | /// <summary> | 1706 | |
895 | /// Cleans the specified kern. | 1707 | // Retrieve stream for the autotools template XML |
896 | /// </summary> | 1708 | Stream autotoolsStream = Assembly.GetExecutingAssembly() |
897 | /// <param name="kern">The kern.</param> | 1709 | .GetManifestResourceStream(fqStreamName); |
898 | public virtual void Clean(Kernel kern) | 1710 | |
899 | { | 1711 | if(autotoolsStream == null) { |
900 | if( kern == null ) | 1712 | |
901 | { | 1713 | /* |
902 | throw new ArgumentNullException("kern"); | 1714 | * try without the default namespace prepended, in |
903 | } | 1715 | * case prebuild.exe assembly was compiled with |
904 | m_Kernel = kern; | 1716 | * something other than Visual Studio .NET |
905 | foreach(SolutionNode sol in kern.Solutions) | 1717 | */ |
906 | { | 1718 | |
907 | CleanSolution(sol); | 1719 | autotoolsStream = Assembly.GetExecutingAssembly() |
908 | } | 1720 | .GetManifestResourceStream(streamName); |
909 | m_Kernel = null; | 1721 | if(autotoolsStream == null){ |
910 | } | 1722 | string errStr = |
911 | 1723 | String.Format("Could not find embedded resource file:\n" + | |
912 | /// <summary> | 1724 | "'{0}' or '{1}'", |
913 | /// Gets the name. | 1725 | streamName, fqStreamName |
914 | /// </summary> | 1726 | ); |
915 | /// <value>The name.</value> | 1727 | |
916 | public string Name | 1728 | m_Kernel.Log.Write(errStr); |
917 | { | 1729 | |
918 | get | 1730 | throw new System.Reflection.TargetException(errStr); |
919 | { | 1731 | } |
920 | return "autotools"; | 1732 | } |
921 | } | 1733 | |
922 | } | 1734 | // Create an XML URL Resolver with default credentials |
923 | 1735 | xr = new System.Xml.XmlUrlResolver(); | |
924 | #endregion | 1736 | xr.Credentials = CredentialCache.DefaultCredentials; |
925 | } | 1737 | |
1738 | // Create a default evidence - no need to limit access | ||
1739 | e = new System.Security.Policy.Evidence(); | ||
1740 | |||
1741 | // Load the autotools XML | ||
1742 | autotoolsDoc = new XmlDocument(); | ||
1743 | autotoolsDoc.Load(autotoolsStream); | ||
1744 | |||
1745 | /* rootDir is the filesystem location where the Autotools | ||
1746 | * build tree will be created - for now we'll make it | ||
1747 | * $PWD/autotools | ||
1748 | */ | ||
1749 | |||
1750 | string pwd = Directory.GetCurrentDirectory(); | ||
1751 | //string pwd = System.Environment.GetEnvironmentVariable("PWD"); | ||
1752 | string rootDir = ""; | ||
1753 | //if (pwd.Length != 0) | ||
1754 | //{ | ||
1755 | rootDir = Path.Combine(pwd, "autotools"); | ||
1756 | //} | ||
1757 | //else | ||
1758 | //{ | ||
1759 | // pwd = Assembly.GetExecutingAssembly() | ||
1760 | //} | ||
1761 | chkMkDir(rootDir); | ||
1762 | |||
1763 | foreach (SolutionNode solution in kern.Solutions) | ||
1764 | { | ||
1765 | m_Kernel.Log.Write(String.Format("Writing solution: {0}", | ||
1766 | solution.Name)); | ||
1767 | WriteCombine(solution); | ||
1768 | } | ||
1769 | m_Kernel = null; | ||
1770 | } | ||
1771 | |||
1772 | /// <summary> | ||
1773 | /// Cleans the specified kern. | ||
1774 | /// </summary> | ||
1775 | /// <param name="kern">The kern.</param> | ||
1776 | public virtual void Clean(Kernel kern) | ||
1777 | { | ||
1778 | if (kern == null) | ||
1779 | { | ||
1780 | throw new ArgumentNullException("kern"); | ||
1781 | } | ||
1782 | m_Kernel = kern; | ||
1783 | foreach (SolutionNode sol in kern.Solutions) | ||
1784 | { | ||
1785 | CleanSolution(sol); | ||
1786 | } | ||
1787 | m_Kernel = null; | ||
1788 | } | ||
1789 | |||
1790 | /// <summary> | ||
1791 | /// Gets the name. | ||
1792 | /// </summary> | ||
1793 | /// <value>The name.</value> | ||
1794 | public string Name | ||
1795 | { | ||
1796 | get | ||
1797 | { | ||
1798 | return "autotools"; | ||
1799 | } | ||
1800 | } | ||
1801 | |||
1802 | #endregion | ||
1803 | } | ||
926 | } | 1804 | } |