[Monodevelop-patches-list] r1834 - trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Fri Jun 25 20:43:13 EDT 2004


Author: pawel
Date: 2004-06-25 20:43:13 -0400 (Fri, 25 Jun 2004)
New Revision: 1834

Modified:
   trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/ChangeLog
   trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleBindingCompilerServices.cs
   trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleLanguageBinding.cs
Log:
Generate makefiles for Nemerle projects.


Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/ChangeLog	2004-06-26 00:06:14 UTC (rev 1833)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/ChangeLog	2004-06-26 00:43:13 UTC (rev 1834)
@@ -1,3 +1,8 @@
+2004-06-26  Pawel Rozanski  <tokugawa at afn.no-ip.org>
+
+	* NemerleBindingCompilerServices.cs: add GenerateMakefile method.
+	* NemerleLanguageBinding.cs: runs GenerateMakefile
+
 2004-06-23  Pawel Rozanski  <tokugawa at afn.no-ip.org>
 
 	* NemerleBindingCompilerServices.cs: one line fix for ProcessStartInfo.

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleBindingCompilerServices.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleBindingCompilerServices.cs	2004-06-26 00:06:14 UTC (rev 1833)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleBindingCompilerServices.cs	2004-06-26 00:43:13 UTC (rev 1834)
@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 using System.Diagnostics;
 using System.IO;
 using System.CodeDom.Compiler;
@@ -81,7 +82,7 @@
 
 		private string GetOptionsString(NemerleParameters cp)
 		{
-			string options = " -q -no-color";
+			string options = " ";
 			if (cp.Nostdmacros)
 				options += " -no-stdmacros";
 			if (cp.Nostdlib)
@@ -99,17 +100,17 @@
 				
 			return options;			
 		}
-		
+
 		public bool CanCompile(string fileName)
 		{
 			return Path.GetExtension(fileName) == ".n";
 		} 
-		
+
 		public ICompilerResult CompileFile(string fileName)
 		{
 			throw new ApplicationException("No CompileFile");
 		}
-		
+
 		public string GetCompiledOutputName(string fileName)
 		{
 			throw new ApplicationException("No CompileFile");
@@ -122,7 +123,7 @@
 			return fileUtilityService.GetDirectoryNameWithSeparator(cp.OutputDirectory)
 					+ cp.OutputAssembly + ((int)cp.Target == 0?".exe":".dll");
 		}
-		
+
 		public ICompilerResult CompileProject(IProject project)
 		{
 			NemerleParameters cp = (NemerleParameters)project.ActiveConfiguration;
@@ -145,7 +146,7 @@
 			if (!Directory.Exists(cp.OutputDirectory))
 				Directory.CreateDirectory(cp.OutputDirectory);
 			
-			string args = GetOptionsString(cp) + references + files  + " -o " + GetCompiledOutputName(project);
+			string args = "-q -no-color " + GetOptionsString(cp) + references + files  + " -o " + GetCompiledOutputName(project);
 			return DoCompilation (args);
 		}
 		
@@ -209,5 +210,214 @@
 			
 			return cr.GetResult();
 		}
+
+		public void GenerateMakefile (IProject project, Combine parentCombine)
+		{
+			StreamWriter stream = new StreamWriter (Path.Combine (project.BaseDirectory, "Makefile." + project.Name.Replace (" ", "")));
+
+			NemerleProject p = (NemerleProject)project;
+			NemerleParameters cp =(NemerleParameters)p.ActiveConfiguration;
+			
+			string outputName = Path.GetFileName(GetCompiledOutputName(project));
+
+			string relativeOutputDir = fileUtilityService.AbsoluteToRelativePath (project.BaseDirectory, parentCombine.OutputDirectory);
+
+			ArrayList compile_files = new ArrayList ();
+			ArrayList pkg_references = new ArrayList ();
+			ArrayList assembly_references = new ArrayList ();
+			ArrayList project_references = new ArrayList ();
+			ArrayList system_references = new ArrayList ();
+			
+			foreach (ProjectFile finfo in project.ProjectFiles) {
+				if (finfo.Subtype != Subtype.Directory) {
+					switch (finfo.BuildAction) {
+					case BuildAction.Compile:
+						string rel_path = fileUtilityService.AbsoluteToRelativePath (project.BaseDirectory, Path.GetDirectoryName (finfo.Name));
+						if (CanCompile (finfo.Name));
+						compile_files.Add (Path.Combine (rel_path, Path.GetFileName (finfo.Name)));
+						break;
+					}
+				}
+			}
+
+			SystemAssemblyService sas = (SystemAssemblyService)ServiceManager.GetService (typeof (SystemAssemblyService));
+			foreach (ProjectReference lib in project.ProjectReferences) {
+				switch (lib.ReferenceType) {
+				case ReferenceType.Gac:
+					string pkg = sas.GetPackageFromFullName (lib.Reference);
+					if (pkg == "MONO-SYSTEM") {
+						system_references.Add (Path.GetFileName (lib.GetReferencedFileName (project)));
+					} else if (!pkg_references.Contains (pkg)) {
+						pkg_references.Add (pkg);
+					}
+					break;
+				case ReferenceType.Assembly:
+					string assembly_fileName = lib.GetReferencedFileName (project);
+					string rel_path_to = fileUtilityService.AbsoluteToRelativePath (project.BaseDirectory, Path.GetDirectoryName (assembly_fileName));
+					assembly_references.Add (Path.Combine (rel_path_to, Path.GetFileName (assembly_fileName)));
+					break;
+				case ReferenceType.Project:
+					string project_fileName = lib.GetReferencedFileName (project);
+					IProjectService prjService = (IProjectService)ServiceManager.GetService (typeof (IProjectService));
+					ArrayList allProjects = Combine.GetAllProjects(prjService.CurrentOpenCombine);
+					
+					foreach (ProjectCombineEntry projectEntry in allProjects) {
+						if (projectEntry.Project.Name == lib.Reference) {
+							string project_base_dir = fileUtilityService.AbsoluteToRelativePath (project.BaseDirectory, projectEntry.Project.BaseDirectory);
+							
+							string project_output_fileName = prjService.GetOutputAssemblyName (projectEntry.Project);
+							project_references.Add (Path.Combine (project_base_dir, Path.GetFileName (project_output_fileName)));
+						}
+					}
+					break;
+				}
+			}
+
+			stream.WriteLine ("# This makefile is autogenerated by MonoDevelop");
+			stream.WriteLine ("# Do not modify this file");
+			stream.WriteLine ();
+			stream.WriteLine ("SOURCES = \\");
+			for (int i = 0; i < compile_files.Count; i++) {
+				stream.Write (((string)compile_files[i]).Replace (" ", "\\ "));
+				if (i != compile_files.Count - 1)
+					stream.WriteLine (" \\");
+				else
+					stream.WriteLine ();
+			}
+			stream.WriteLine ();
+
+			if (pkg_references.Count > 0) {
+				stream.WriteLine ("PKG_REFERENCES = \\");
+				for (int i = 0; i < pkg_references.Count; i++) {
+					stream.Write (pkg_references[i]);
+					if (i != pkg_references.Count - 1)
+						stream.WriteLine (" \\");
+					else
+						stream.WriteLine ();
+				}
+				
+				stream.WriteLine ();
+				stream.WriteLine ("PKG_REFERENCES_BUILD = $(addprefix -pkg:, $(PKG_REFERENCES))");
+				stream.WriteLine ();
+				stream.WriteLine ("PKG_REFERENCES_CHECK = $(addsuffix .pkgcheck, $(PKG_REFERENCES))");
+				stream.WriteLine ();
+			}
+			
+			if (system_references.Count > 0) {
+				stream.WriteLine ("SYSTEM_REFERENCES = \\");
+				for (int i = 0; i < system_references.Count; i++) {
+					stream.Write (system_references[i]);
+					if (i != system_references.Count - 1)
+						stream.WriteLine (" \\");
+					else
+						stream.WriteLine ();
+				}
+				stream.WriteLine ();
+				stream.WriteLine ("SYSTEM_REFERENCES_BUILD = $(addprefix -r:, $(SYSTEM_REFERENCES))");
+				stream.WriteLine ();
+				stream.WriteLine ("SYSTEM_REFERENCES_CHECK = $(addsuffix .check, $(SYSTEM_REFERENCES))");
+				stream.WriteLine ();
+			}
+
+			if (assembly_references.Count > 0) {
+				stream.WriteLine ("ASSEMBLY_REFERENCES = \\");
+				for (int i = 0; i < assembly_references.Count; i++) {
+					stream.Write ("\"" + assembly_references[i] + "\"");
+					if (i != assembly_references.Count - 1)
+						stream.WriteLine (" \\");
+					else
+						stream.WriteLine ();
+				}
+				
+				stream.WriteLine ();
+				stream.WriteLine ("ASSEMBLY_REFERENCES_BUILD = $(addprefix -r:, $(ASSEMBLY_REFERENCES))");
+				stream.WriteLine ();
+			}
+
+			if (project_references.Count > 0) {
+				stream.WriteLine ("PROJECT_REFERENCES = \\");
+				for (int i = 0; i < project_references.Count; i++) {
+					stream.Write ("\"" + project_references[i] + "\"");
+					if (i != project_references.Count - 1)
+						stream.WriteLine (" \\");
+					else
+						stream.WriteLine ();
+				}
+				
+				stream.WriteLine ();
+				stream.WriteLine ("PROJECT_REFERENCES_BUILD = $(addprefix -r:, $(PROJECT_REFERENCES))");
+				stream.WriteLine ();
+			}
+
+			stream.Write ("NCC_OPTIONS = " + GetOptionsString(cp));
+
+			stream.WriteLine ();
+			stream.WriteLine ();
+
+			stream.WriteLine ("all: " + outputName);
+			stream.WriteLine ();
+			
+			stream.WriteLine(outputName + ": $(SOURCES)");
+			
+			stream.Write ("\t{0} $(NCC_OPTIONS) -out:\"{1}\"", ncc, outputName);
+			if (pkg_references.Count > 0) {
+				stream.Write (" $(PKG_REFERENCES_BUILD)");
+			}
+			if (assembly_references.Count > 0) {
+				stream.Write (" $(ASSEMBLY_REFERENCES_BUILD)");
+			}
+			if (project_references.Count > 0) {
+				stream.Write (" $(PROJECT_REFERENCES_BUILD)");
+			}
+			if (system_references.Count > 0) {
+				stream.Write (" $(SYSTEM_REFERENCES_BUILD)");
+			}
+			stream.WriteLine (" $(SOURCES) \\");
+			stream.WriteLine ("\t&& cp \"{0}\" {1}/.", outputName, relativeOutputDir);
+			
+			stream.WriteLine ();
+			stream.WriteLine ("clean:");
+			stream.WriteLine ("\trm -f {0}", outputName);
+			stream.WriteLine ();
+			
+			stream.Write ("depcheck: ");
+			if (pkg_references.Count > 0) {
+				stream.Write ("PKG_depcheck ");
+			}
+			if (system_references.Count > 0) {
+				stream.Write ("SYSTEM_depcheck");
+			}
+			stream.WriteLine ();
+			stream.WriteLine ();
+			if (pkg_references.Count > 0) {
+				stream.WriteLine ("PKG_depcheck: $(PKG_REFERENCES_CHECK)");
+				stream.WriteLine ();
+				stream.WriteLine ("%.pkgcheck:");
+				stream.WriteLine ("\t at echo -n Checking for package $(subst .pkgcheck,,$@)...");
+				stream.WriteLine ("\t at if pkg-config --libs $(subst .pkgcheck,,$@) &> /dev/null; then \\");
+				stream.WriteLine ("\t\techo yes; \\");
+				stream.WriteLine ("\telse \\");
+				stream.WriteLine ("\t\techo no; \\");
+				stream.WriteLine ("\t\texit 1; \\");
+				stream.WriteLine ("\tfi");
+				stream.WriteLine ();
+			}
+
+			if (system_references.Count > 0) {
+				stream.WriteLine ("SYSTEM_depcheck: $(SYSTEM_REFERENCES_CHECK)");
+				stream.WriteLine ();
+				stream.WriteLine ("%.check:");
+				stream.WriteLine ("\t at echo -n Checking for $(subst .check,,$@)...");
+				stream.WriteLine ("\t at if [ ! -e `pkg-config --variable=libdir mono`/mono/1.0/$(subst .check,,$@) ]; then \\");
+				stream.WriteLine ("\t\techo no; \\");
+				stream.WriteLine ("\t\texit 1; \\");
+				stream.WriteLine ("\telse \\");
+				stream.WriteLine ("\t\techo yes; \\");
+				stream.WriteLine ("\tfi");
+			}
+			
+			stream.Flush ();
+			stream.Close ();
+		}		
 	}
 }

Modified: trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleLanguageBinding.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleLanguageBinding.cs	2004-06-26 00:06:14 UTC (rev 1833)
+++ trunk/MonoDevelop/src/AddIns/BackendBindings/NemerleBinding/NemerleLanguageBinding.cs	2004-06-26 00:43:13 UTC (rev 1834)
@@ -78,7 +78,7 @@
 
 		public void GenerateMakefile (IProject project, Combine parentCombine)
 		{
-			throw new NotImplementedException ();
+			compilerServices.GenerateMakefile(project, parentCombine);
 		}
 	}
 }




More information about the Monodevelop-patches-list mailing list