Author: scotte
Date: 2006-06-15 14:46:29 -0400 (Thu, 15 Jun 2006)
New Revision: 61764

Modified:
   trunk/monodevelop/Extras/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs
   trunk/monodevelop/Extras/CSharpBinding/ChangeLog
   trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs
   trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog
   trunk/monodevelop/Extras/MonoDevelop.Autotools/ISimpleAutotoolsSetup.cs
   
trunk/monodevelop/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
   trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionDeployer.cs
   trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs
   
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.am.project.template
   trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.include
   
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/configure.ac.template
Log:
Implement support for project configurations in autotools


Modified: 
trunk/monodevelop/Extras/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs    
2006-06-15 18:12:07 UTC (rev 61763)
+++ trunk/monodevelop/Extras/CSharpBinding/Autotools/CSharpAutotoolsSetup.cs    
2006-06-15 18:46:29 UTC (rev 61764)
@@ -9,7 +9,7 @@
 {
        public class CSharpAutotoolsSetup : ISimpleAutotoolsSetup
        {
-               public string GetCompilerCommand ( Project project )
+               public string GetCompilerCommand ( Project project, string 
configuration )
                {
                        if ( !this.CanDeploy ( project ) )
                                throw new Exception ( "Not a deployable 
project." );
@@ -17,17 +17,16 @@
                        return "mcs";
                }
 
-               public string GetCompilerFlags ( Project project )
+               public string GetCompilerFlags ( Project project, string 
configuration )
                {
                        if ( !this.CanDeploy ( project ) )
                                throw new Exception ( "Not a deployable 
project." );
                        
-                       DotNetProject dotNetProject = (DotNetProject) project;
-                               
-                       DotNetProjectConfiguration config =
-                       (DotNetProjectConfiguration) 
dotNetProject.Configurations["Release"];
+                       DotNetProjectConfiguration config = 
+                               project.Configurations [configuration] as 
DotNetProjectConfiguration;
+
+                       if ( config == null ) return "";
                        
-                       //Console.WriteLine ( config.CompilationParameters );
                        CSharpCompilerParameters parameters = 
(CSharpCompilerParameters) config.CompilationParameters;
                        StringWriter writer = new StringWriter();
                        
@@ -76,7 +75,5 @@
                                if ( csproj.LanguageName == "C#" ) return true;
                        return false;
                }
-               
        }
-       
 }

Modified: trunk/monodevelop/Extras/CSharpBinding/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2006-06-15 18:12:07 UTC 
(rev 61763)
+++ trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2006-06-15 18:46:29 UTC 
(rev 61764)
@@ -1,3 +1,7 @@
+2006-06-15 Scott Ellington  <[EMAIL PROTECTED]>
+
+       * Autotools/CSharpAutotoolsSetup.cs:
+       
 2006-06-15 Lluis Sanchez Gual  <[EMAIL PROTECTED]>
 
        * CSharpBinding.addin.xml: Use the DataType element instead fof Class

Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs  
2006-06-15 18:12:07 UTC (rev 61763)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs  
2006-06-15 18:46:29 UTC (rev 61764)
@@ -33,9 +33,15 @@
                
                ArrayList autoconfConfigFiles = new ArrayList();
                Set referencedPackages = new Set();
-               //Set globalDllReferences = new Set();
+               Set globalDllReferences = new Set();
                Set compilers = new Set ();
-
+               string base_dir;
+               
+               public AutotoolsContext ( string base_directory )
+               {
+                       base_dir = base_directory;
+               }
+               
                public void AddRequiredPackage ( string pkg_name )
                {
                        referencedPackages.Add (pkg_name);
@@ -48,16 +54,14 @@
 
                public void AddCommandCheck ( string command_name )
                {
-                       //if ( !compilers.Contains ( setup ) ) 
                        compilers.Add ( command_name );
                }
 
-               /*
-               public void AddReferencedDll ( string dll_name )
+               public string AddReferencedDll ( string dll_name )
                {
                        globalDllReferences.Add ( dll_name );
+                       return base_dir + "/lib/" + Path.GetFileName (dll_name);
                }
-               */
 
                public IEnumerable GetAutoConfFiles ()
                {
@@ -74,12 +78,10 @@
                        return compilers;
                }
 
-               /*
                public IEnumerable GetReferencedDlls ()
                {
                        return globalDllReferences;
                }
-               */
                
                // TODO: add an extension point with which addins can implement 
                // autotools functionality.

Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog    2006-06-15 
18:12:07 UTC (rev 61763)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog    2006-06-15 
18:46:29 UTC (rev 61764)
@@ -1,3 +1,15 @@
+2006-06-15  Scott Ellington  <[EMAIL PROTECTED]> 
+
+       * SimpleProjectMakefileHandler.cs:
+       * SolutionDeployer.cs:
+       * templates/Makefile.include:
+       * templates/Makefile.am.project.template:
+       * templates/configure.ac.template:
+       * ISimpleAutotoolsSetup.cs:
+       * AutotoolsContext.cs:
+       * SolutionMakefileHandler.cs:
+       Handle project configurations
+
 2006-06-13  Scott Ellington  <[EMAIL PROTECTED]> 
 
        * SimpleProjectMakefileHandler.cs: 

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Autotools/ISimpleAutotoolsSetup.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/ISimpleAutotoolsSetup.cs     
2006-06-15 18:12:07 UTC (rev 61763)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/ISimpleAutotoolsSetup.cs     
2006-06-15 18:46:29 UTC (rev 61764)
@@ -28,9 +28,9 @@
 {
        public interface ISimpleAutotoolsSetup
        {
-               string GetCompilerCommand ( Project project );
+               string GetCompilerCommand ( Project project, string 
configuration );
 
-               string GetCompilerFlags ( Project project );
+               string GetCompilerFlags ( Project project, string configuration 
);
                
                bool CanDeploy ( Project project );
        }

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
===================================================================
--- 
trunk/monodevelop/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs  
    2006-06-15 18:12:07 UTC (rev 61763)
+++ 
trunk/monodevelop/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs  
    2006-06-15 18:46:29 UTC (rev 61764)
@@ -22,6 +22,7 @@
 using System.IO;
 using System.Collections;
 using System.Reflection;
+using System.Text;
 
 using MonoDevelop.Projects;
 using MonoDevelop.Core;
@@ -62,91 +63,107 @@
                                TemplateEngine templateEngine = new 
TemplateEngine();                   
                                ISimpleAutotoolsSetup setup = 
FindSetupForProject ( project );
                                
-                               // we are using the 'Release' configuration 
-                               AbstractProjectConfiguration config = 
project.Configurations["Release"] as AbstractProjectConfiguration;
-                               
-                               if (config == null)
-                                       throw new Exception( 
GettextCatalog.GetString ("No 'Release' configuration in project '{0}'", 
project.Name ) );
+                               Set wrapped_exes = new Set ();
+                               StringBuilder conf_vars = new StringBuilder ();
+                               foreach ( DotNetProjectConfiguration config in 
project.Configurations )
+                               {
+                                       conf_vars.AppendFormat ("if 
ENABLE_{0}\n", config.Name.ToUpper () );
+                                       string assembly = 
project.GetRelativeChildPath ( config.CompiledOutputName );
 
-                               // Process some .Net specific variables
-                               if ( config is DotNetProjectConfiguration )
-                               {
-                                       DotNetProjectConfiguration dnconfig = 
config as DotNetProjectConfiguration;
-                                       string assembly = 
project.GetRelativeChildPath ( GetProjectAssembly (project) );
+                                       conf_vars.AppendFormat 
("ASSEMBLY_COMPILER_COMMAND = {0}\n",
+                                                       
setup.GetCompilerCommand ( project, config.Name ) );
+                                       conf_vars.AppendFormat 
("ASSEMBLY_COMPILER_FLAGS = {0}\n",
+                                                       setup.GetCompilerFlags 
( project, config.Name ) );
+
+                                       // add check for compiler command in 
configure.ac
+                                       ctx.AddCommandCheck ( 
setup.GetCompilerCommand ( project, config.Name ) );
                                        
-                                       DotNetProject dnp = project as 
DotNetProject;
-                                       if ( dnp != null )
-                                               
templateEngine.Variables["LANGUAGE"] = 
AutotoolsContext.EscapeStringForAutomake( dnp.LanguageName);
-                                       templateEngine.Variables["ASSEMBLY"] = 
AutotoolsContext.EscapeStringForAutomake (assembly);
-                                       
-                                       switch (dnconfig.CompileTarget) 
+                                       conf_vars.AppendFormat ( "ASSEMBLY = 
{0}\n", 
+                                                       
AutotoolsContext.EscapeStringForAutomake (assembly) );
+
+                                       string target;
+                                       switch (config.CompileTarget) 
                                        {
                                                case CompileTarget.Exe:
-                                                       
templateEngine.Variables["COMPILE_TARGET"] = "exe";
+                                                       target = "exe";
                                                        break;
                                                case CompileTarget.Library:
-                                                       
templateEngine.Variables["COMPILE_TARGET"] = "library";
+                                                       target = "library";
                                                        break;
                                                case CompileTarget.WinExe:
-                                                       
templateEngine.Variables["COMPILE_TARGET"] = "winexe";
+                                                       target = "winexe";
                                                        break;
                                                case CompileTarget.Module:
-                                                       
templateEngine.Variables["COMPILE_TARGET"] = "module";
+                                                       target = "module";
                                                        break;
                                                default:
-                                                       throw new Exception( 
GettextCatalog.GetString ("Unknown target {0}", dnconfig.CompileTarget ) );
+                                                       throw new Exception( 
GettextCatalog.GetString ("Unknown target {0}", config.CompileTarget ) );
                                        }
+                                       conf_vars.AppendFormat ( 
"COMPILE_TARGET = {0}\n", target );
 
-                                       if (dnconfig.CompileTarget == 
CompileTarget.Exe || 
-                                                       dnconfig.CompileTarget 
== CompileTarget.WinExe) 
+                                       if ( config.CompileTarget == 
CompileTarget.Exe || 
+                                                               
config.CompileTarget == CompileTarget.WinExe  )
                                        {
-                                               string wrapper = 
CreateExeWrapper ( ctx, assembly,  Path.GetDirectoryName (project.FileName), 
monitor );
-                                               
templateEngine.Variables["ASSEMBLY_WRAPPER"] = wrapper;
-                                               
templateEngine.Variables["ASSEMBLY_WRAPPER_IN"] = wrapper + ".in";      
+                                               string assembly_name = 
Path.GetFileName ( assembly );
+                                               string wrapper;
+                                               if ( !wrapped_exes.Contains ( 
assembly_name ) )
+                                               {
+                                                       wrapper = 
CreateExeWrapper ( ctx, 
+                                                                       
assembly,  
+                                                                       
Path.GetDirectoryName (project.FileName), 
+                                                                       monitor 
);
+                                                       wrapped_exes.Add ( 
assembly_name );
+                                               }
+                                               else wrapper = 
GetExeWrapperFromAssembly ( assembly );
+
+                                               conf_vars.AppendFormat ( 
"ASSEMBLY_WRAPPER = {0}\n", wrapper );
+                                               conf_vars.AppendFormat ( 
"ASSEMBLY_WRAPPER_IN = {0}.in\n", wrapper );
                                        }
-                               }
 
-                               /* Collect file groups: Such as resources, code 
files, etc...
-                                * files are currently split into groups 
depending on their BuildAction setting
-                                * Each group will be outputted like this in 
the Makefile:
-                                *   GroupName = \
-                                *     FILE1 \
-                                *     FILE2 \
-                                *     ...
-                                */
-                               //TODO: this should probably be reorganized
-                               Hashtable groups = new Hashtable();
-                               foreach(ProjectFile projectFile in 
project.ProjectFiles) {
-                                       string fileGroup = 
projectFile.BuildAction.ToString();
+                                       // for project references, we need a 
ref to the dll for the current configuration
+                                       StringWriter projectReferences = new 
StringWriter();
+                                       foreach (ProjectReference reference in 
project.ProjectReferences) 
+                                       {
+                                               if (reference.ReferenceType == 
ReferenceType.Project) 
+                                               {
+                                                       Project refp = null;
+                                                       Combine c = 
project.RootCombine;
 
-                                       ArrayList list = (ArrayList) 
groups[fileGroup];
-                                       if(list == null) {
-                                               list = new ArrayList();
-                                               groups[fileGroup] = list;
-                                       }
+                                                       if (c != null) refp = 
c.FindProject (reference.Reference);
 
-                                       // exclude directories from compilation
-                                       if ( projectFile.BuildAction == 
BuildAction.Compile && 
-                                                       projectFile.Subtype != 
Subtype.Code ) 
-                                               continue;
+                                                       if (refp == null)
+                                                               throw new 
Exception ( GettextCatalog.GetString ("Couldn't find referenced project '{0}'", 
+                                                                               
        reference.Reference ) );
 
-                                       list.Add(projectFile.RelativePath);
+                                                       
DotNetProjectConfiguration dnpc = refp.Configurations[config.Name] as 
DotNetProjectConfiguration;
+                                                       if ( dnpc == null )
+                                                               throw new 
Exception ( GettextCatalog.GetString ("Could not add reference to project 
'{0}'", refp.Name) );
+                                                       
+                                                       
projectReferences.WriteLine (" \\");
+                                                       projectReferences.Write 
("\t");
+                                                       projectReferences.Write 
( project.GetRelativeChildPath ( dnpc.CompiledOutputName ) );
+                                               } 
+                                       }
+                                       conf_vars.AppendFormat ( 
"PROJECT_REFERENCES = {0}\n", projectReferences.ToString() );
+                                       conf_vars.AppendFormat ( "BUILD_DIR = 
{0}\n", project.GetRelativeChildPath ( config.OutputDirectory ) );
+                                       conf_vars.Append ( "endif\n" );
                                }
+                               templateEngine.Variables["CONFIG_VARS"] = 
conf_vars.ToString ();
 
-                               // Collect references
+                               // grab pkg-config references
                                StringWriter references = new StringWriter();
+                               Set pkgs = new Set();
+                               StringBuilder copy_dlls = new StringBuilder ();
                                StringWriter dllReferences = new StringWriter();
-                               StringWriter projectReferences = new 
StringWriter();
-                               Set pkgs = new Set();
                                foreach(ProjectReference reference in 
project.ProjectReferences) 
                                {
                                        if(reference.ReferenceType == 
ReferenceType.Gac) 
                                        {
                                                // Get pkg-config keys
                                                String pkg = 
Runtime.SystemAssemblyService.GetPackageFromFullName (reference.Reference);
-                                               if(pkg != "MONO-SYSTEM") 
+                                               if (pkg != "MONO-SYSTEM") 
                                                {
-                                                       if(pkgs.Contains(pkg)) 
continue;
+                                                       if ( pkgs.Contains(pkg) 
) continue;
                                                        pkgs.Add(pkg);
 
                                                        references.WriteLine (" 
\\");
@@ -164,59 +181,66 @@
                                                        references.Write ("");
                                                }
                                        } 
-                                       else if(reference.ReferenceType == 
ReferenceType.Assembly) 
+                                       else if (reference.ReferenceType == 
ReferenceType.Assembly) 
                                        {
-                                               if ( !reference.LocalCopy )
-                                                       throw new Exception ( 
"Referenced assemblies must have a local copy." );
-
                                                string assemblyPath = 
Path.GetFullPath (reference.Reference);
+                                               string libdll_path = 
ctx.AddReferencedDll ( assemblyPath );
 
                                                // use reference in local 
directory (make sure it is there)
-                                               string newPath = 
config.OutputDirectory + "/" + Path.GetFileName ( assemblyPath );
-                                               if ( !File.Exists ( newPath ) ) 
File.Copy ( assemblyPath , newPath );                           
-                                               newPath = 
project.GetRelativeChildPath ( newPath );
-                                               
+                                               //string newPath = 
config.OutputDirectory + "/" + Path.GetFileName ( assemblyPath );
+                                               //if ( !File.Exists ( newPath ) 
) File.Copy ( assemblyPath , newPath );                         
+                                               //newPath = 
project.GetRelativeChildPath ( newPath );
+
+                                               string newPath = 
"$(BUILD_DIR)/" + Path.GetFileName ( assemblyPath );
+                                               copy_dlls.AppendFormat ( "      
cp -f {0} {1}\n", project.GetRelativeChildPath (libdll_path), newPath );
+
                                                dllReferences.WriteLine (" \\");
                                                dllReferences.Write ("\t");
                                                dllReferences.Write ( newPath );
-                                               //ctx.AddReferencedDll ( 
newPath );
                                        } 
-                                       else if (reference.ReferenceType == 
ReferenceType.Project) 
-                                       {
-                                               Project refp = null;
-                                               Combine c = project.RootCombine;
-
-                                               if (c != null) refp = 
c.FindProject (reference.Reference);
-                                               
-                                               if (refp == null)
-                                                       throw new Exception ( 
GettextCatalog.GetString ("Couldn't find referenced project '{0}'", 
-                                                                               
reference.Reference ) );
-
-                                               projectReferences.WriteLine (" 
\\");
-                                               projectReferences.Write ("\t");
-                                               projectReferences.Write ( 
project.GetRelativeChildPath ( GetProjectAssembly (refp) ) );
-                                       } 
+                                       else if (reference.ReferenceType == 
ReferenceType.Project) continue; // handled above
                                        else throw new Exception ( 
GettextCatalog.GetString  ("Project Reference Type {0} not support yet", 
                                                                
reference.ReferenceType.ToString() ) );
                                }
                                templateEngine.Variables["REFERENCES"] = 
references.ToString();
-                               templateEngine.Variables["DLL_REFERENCES"] = 
dllReferences.ToString();
-                               templateEngine.Variables["PROJECT_REFERENCES"] 
= projectReferences.ToString();
+                               templateEngine.Variables["COPY_DLLS"] = 
copy_dlls.ToString();
+                               templateEngine.Variables["DLL_REFERENCES"] =  
dllReferences.ToString () ;
                                templateEngine.Variables["WARNING"] = "Warning: 
This is an automatically generated file, do not edit!";
-                               templateEngine.Variables["PROJECT_TYPE"] = 
AutotoolsContext.EscapeStringForAutomake(project.ProjectType); 
-                               
templateEngine.Variables["ASSEMBLY_COMPILER_COMMAND"] = 
setup.GetCompilerCommand (project);
-                               
templateEngine.Variables["ASSEMBLY_COMPILER_FLAGS"] = setup.GetCompilerFlags 
(project);
 
-                               // add check for compiler command in 
configure.ac
-                               ctx.AddCommandCheck ( setup.GetCompilerCommand 
( project ) );
+                               /* Collect file groups: Such as resources, code 
files, etc...
+                                * files are currently split into groups 
depending on their BuildAction setting
+                                * Each group will be outputted like this in 
the Makefile:
+                                *   GroupName = \
+                                *     FILE1 \
+                                *     FILE2 \
+                                *     ...
+                                */
+                               //TODO: this should probably be reorganized
+                               Hashtable groups = new Hashtable();
+                               foreach(ProjectFile projectFile in 
project.ProjectFiles) {
+                                       string fileGroup = 
projectFile.BuildAction.ToString();
 
+                                       ArrayList list = (ArrayList) 
groups[fileGroup];
+                                       if(list == null) {
+                                               list = new ArrayList();
+                                               groups[fileGroup] = list;
+                                       }
+
+                                       // exclude directories from compilation
+                                       if ( projectFile.BuildAction == 
BuildAction.Compile && 
+                                                       projectFile.Subtype != 
Subtype.Code ) 
+                                               continue;
+
+                                       list.Add(projectFile.RelativePath);
+                               }
+
                                // write out various variables ( RESOURCES, 
EXTRAS, ... )
-                               foreach(string group in groups.Keys) 
+                               foreach (string group in groups.Keys) 
                                {
-                                       ArrayList files = (ArrayList) 
groups[group];
-                                       StringWriter gwriter = new 
StringWriter();
+                                       ArrayList files = (ArrayList) groups 
[group];
+                                       StringWriter gwriter = new StringWriter 
();
 
-                                       if(files.Count > 2) 
+                                       if (files.Count > 2) 
                                        {
                                                gwriter.WriteLine("\\");
 
@@ -224,8 +248,8 @@
                                                {
                                                        string file = (string) 
files[i];
                                                        file = 
project.GetRelativeChildPath (file);
-                                                       gwriter.Write("\t" + 
AutotoolsContext.EscapeStringForAutomake(file));
-                                                       if(i+1 < files.Count)
+                                                       gwriter.Write ("\t" + 
AutotoolsContext.EscapeStringForAutomake (file));
+                                                       if (i+1 < files.Count)
                                                                gwriter.Write(" 
\\");
 
                                                        gwriter.WriteLine("");
@@ -253,24 +277,25 @@
 
                                monitor.Step (1);
                        }
-                       finally
-                       {
-                               monitor.EndTask ();
-                       }
-
+                       finally { monitor.EndTask (); }
                        return makefile;
                }
 
+               static string GetExeWrapperFromAssembly ( string assembly )
+               {
+                       string basename = assembly;
+                       if (basename.EndsWith(".exe"))
+                               basename = basename.Substring(0, 
basename.Length-4);
+
+                       return Path.GetFileName(basename).ToLower();            
        
+               }
+
                string CreateExeWrapper ( AutotoolsContext context , string 
assembly, string baseDir, IProgressMonitor monitor )
                {
                        monitor.Log.WriteLine ( GettextCatalog.GetString 
("Creating wrapper script for executable.") );
 
-                       string basename = assembly;
+                       string wrapperName = GetExeWrapperFromAssembly ( 
assembly );
 
-                       if(basename.EndsWith(".exe"))
-                               basename = basename.Substring(0, 
basename.Length-4);
-                       string wrapperName = 
Path.GetFileName(basename).ToLower();                      
-
                        TemplateEngine templateEngine = new TemplateEngine();
                        templateEngine.Variables["ASSEMBLY"] = 
Path.GetFileName(assembly);
 
@@ -289,27 +314,6 @@
                        context.AddAutoconfFile ( path );
                        return wrapperName;
                }
-
-               DotNetProjectConfiguration GetProjectConfig (Project project)
-               {
-                       if (! (project is DotNetProject))
-                               return null;
-
-                       DotNetProject dotNetProject = (DotNetProject) project;
-
-                       DotNetProjectConfiguration config =
-                               (DotNetProjectConfiguration) 
dotNetProject.Configurations["Release"];
-
-                       return config;
-               }
-
-               string GetProjectAssembly (Project project)
-               {
-                       DotNetProjectConfiguration config = GetProjectConfig 
(project);         
-                       //string assembly = project.GetRelativeChildPath 
(config.CompiledOutputName);
-                       string assembly = config.CompiledOutputName;
-                       return assembly;
-               }
        }
 }
 

Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionDeployer.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionDeployer.cs  
2006-06-15 18:12:07 UTC (rev 61763)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionDeployer.cs  
2006-06-15 18:46:29 UTC (rev 61764)
@@ -59,12 +59,13 @@
 
                        try
                        {
-                               context = new AutotoolsContext ( );
+                               solution_dir = 
Path.GetDirectoryName(combine.FileName);
+                               
+                               context = new AutotoolsContext ( solution_dir );
                                IMakefileHandler handler = 
AutotoolsContext.GetMakefileHandler ( combine );
                                if ( !handler.CanDeploy (combine) )
                                        throw new Exception ( 
GettextCatalog.GetString ("This solution cannot be deployed.") );
 
-                               solution_dir = 
Path.GetDirectoryName(combine.FileName);
                                solution_name = combine.Name;
                                // FIXME: pull version out of AssemblyInfo.cs?
                                // or wait for 
http://bugzilla.ximian.com/show_bug.cgi?id=77889
@@ -75,10 +76,10 @@
                                context.AddAutoconfFile ( path );
 
                                CreateAutoGenDotSH ( monitor );
-                               CreateConfigureDotAC ( monitor );
+                               CreateConfigureDotAC ( combine, monitor );
                                CreateMakefileInclude ( monitor );
 
-                               //AddTopLevelMakefileVars ( makefile, monitor );
+                               AddTopLevelMakefileVars ( makefile, monitor );
 
                                StreamWriter writer = new StreamWriter ( path + 
".am" );
                                makefile.Write ( writer );
@@ -112,7 +113,6 @@
                        }
                }
 
-               /*
                void AddTopLevelMakefileVars ( Makefile makefile, 
IProgressMonitor monitor)
                {
                        monitor.Log.WriteLine ( GettextCatalog.GetString 
("Adding variables to top-level Makefile.am") );
@@ -120,16 +120,24 @@
                        StringBuilder sb = new StringBuilder ();
                        foreach ( string dll in context.GetReferencedDlls() )
                        {
+                               string dll_name = Path.GetFileName  ( dll );
+
+                               string libdir = solution_dir + "/lib/";
+                               if ( !Directory.Exists ( libdir ) ) 
Directory.CreateDirectory ( libdir );
+                                       
+                               string newPath = libdir + dll_name;
+                               File.Copy ( dll, newPath , true );
+                               
+                               newPath = 
Runtime.FileUtilityService.AbsoluteToRelativePath ( solution_dir, newPath );
                                sb.Append (' ');
-                               sb.Append ( dll );
+                               sb.Append ( newPath );
                        }
                        string vals = sb.ToString ();
 
-                       //makefile.SetVariable ( "DLL_REFERENCES", vals );
-                       //makefile.SetVariable ( "EXTRA_DIST", vals );
-                       //makefile.SetVariable ( "pkglib_DATA", vals );
+                       makefile.SetVariable ( "DLL_REFERENCES", vals );
+                       makefile.SetVariable ( "EXTRA_DIST", 
"$(DLL_REFERENCES)" );
+                       makefile.SetVariable ( "pkglib_DATA", 
"$(DLL_REFERENCES)" );
                }
-               */
 
                void CreateAutoGenDotSH (IProgressMonitor monitor)
                {
@@ -155,11 +163,34 @@
                        Syscall.chmod ( fileName , FilePermissions.S_IXOTH | 
FilePermissions.S_IROTH | FilePermissions.S_IRWXU | FilePermissions.S_IRWXG );
                }
 
-               void CreateConfigureDotAC (IProgressMonitor monitor)
+               void CreateConfigureDotAC ( Combine combine, IProgressMonitor 
monitor )
                {
                        monitor.Log.WriteLine ( GettextCatalog.GetString 
("Creating configure.ac") );
                        TemplateEngine templateEngine = new TemplateEngine();   
                
                        templateEngine.Variables["WARNING"] = "Warning: This is 
an automatically generated file, do not edit!";                 
+                       // add solution configuration options
+                       StringBuilder config_options = new StringBuilder ();
+                       foreach ( IConfiguration config in 
combine.Configurations )
+                       {
+                               string name = config.Name.ToLower();
+                               string def = config == 
combine.ActiveConfiguration ? "YES" : "NO";
+                               string ac_var = "enable_" + name;
+                               config_options.AppendFormat ( 
"AC_ARG_ENABLE({0},\n", name );
+                               config_options.AppendFormat ("  
AC_HELP_STRING([--enable-{0}],\n", name );
+                               config_options.AppendFormat ("          [Use 
'{0}' Configuration [default={1}]]),\n", config.Name, def );
+                               config_options.AppendFormat ( "         
{0}=yes, {0}=no)\n", ac_var );
+                               config_options.AppendFormat ( 
"AM_CONDITIONAL({0}, test x${1} = xyes)\n", ac_var.ToUpper(), ac_var );
+                               config_options.AppendFormat ( "if test 
\"x${0}\" = \"xyes\" ; then\n", ac_var );
+                               config_options.Append ( "       
CONFIG_REQUESTED=\"yes\"\nfi\n" );
+                       }
+                       config_options.Append ( "if test -z 
\"$CONFIG_REQUESTED\" ; then\n" );
+                       config_options.AppendFormat ( "AM_CONDITIONAL({0}, 
true)\nfi\n", "ENABLE_"
+                                       + 
combine.ActiveConfiguration.Name.ToUpper()  );
+                       
+                       
+                       templateEngine.Variables ["CONFIG_OPTIONS"] = 
config_options.ToString();
+                       
+                       
                        // build compiler checks
                        StringBuilder compiler_checks = new StringBuilder();
                        foreach (string compiler in context.GetCommandChecks () 
) 

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs   
2006-06-15 18:12:07 UTC (rev 61763)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs   
2006-06-15 18:46:29 UTC (rev 61764)
@@ -58,21 +58,37 @@
 
                                StringBuilder subdirs = new StringBuilder();
                                subdirs.Append ("#Warning: This is an 
automatically generated file, do not edit!\n");
-                               subdirs.Append ("SUBDIRS = ");
-                               foreach ( CombineEntry ce in 
CalculateSubDirOrder ( combine ) )
+
+                               Set children = new Set ();
+                               foreach ( CombineConfiguration config in 
combine.Configurations )
                                {
-                                       if ( combine.BaseDirectory == 
ce.BaseDirectory )
-                                               throw new Exception ( 
GettextCatalog.GetString ("Child projects / solutions cannot be in the same 
directory as their parent") );
+                                       subdirs.AppendFormat ( "if {0}\n", 
"ENABLE_" + config.Name.ToUpper () );
+                                       subdirs.Append (" SUBDIRS = ");
                                        
-                                       if ( !ce.BaseDirectory.StartsWith 
(combine.BaseDirectory) )
-                                               throw new Exception ( 
GettextCatalog.GetString ("Child projects / solutions must be in 
sub-directories of their parent") );
+                                       foreach ( CombineEntry ce in 
CalculateSubDirOrder ( config ) )
+                                       {
+                                               if ( combine.BaseDirectory == 
ce.BaseDirectory )
+                                                       throw new Exception ( 
GettextCatalog.GetString ("Child projects / solutions cannot be in the same 
directory as their parent") );
 
-                                       string path = Path.GetDirectoryName 
(ce.RelativeFileName);
-                                       if (path.StartsWith ("./") )
-                                               path = path.Substring (2);
-                                       subdirs.Append (" ");
-                                       subdirs.Append ( 
AutotoolsContext.EscapeStringForAutomake (path) );
+                                               if ( 
!ce.BaseDirectory.StartsWith (combine.BaseDirectory) )
+                                                       throw new Exception ( 
GettextCatalog.GetString ("Child projects / solutions must be in 
sub-directories of their parent") );
+                                               
+                                               // add the subdirectory to the 
list
+                                               string path = 
Path.GetDirectoryName (ce.RelativeFileName);
+                                               if (path.StartsWith ("./") )
+                                                       path = path.Substring 
(2);
+                                               subdirs.Append (" ");
+                                               subdirs.Append ( 
AutotoolsContext.EscapeStringForAutomake (path) );
 
+                                               children.Add ( ce );
+                                       }
+                                       subdirs.Append ( "\nendif\n" );
+                               }
+                               mfile.Append ( subdirs.ToString () );
+
+                               // deploy recursively
+                               foreach ( CombineEntry ce in children )
+                               {
                                        IMakefileHandler handler = 
AutotoolsContext.GetMakefileHandler ( ce );
                                        Makefile makefile;
                                        if ( handler.CanDeploy ( ce ) )
@@ -86,8 +102,6 @@
                                        }
                                }
 
-                               mfile.Append ( subdirs.ToString () );
-
                                monitor.Step (1);
                        }
                        finally
@@ -98,7 +112,7 @@
                }
 
                // utility function for finding the correct order to process 
directories
-               ArrayList CalculateSubDirOrder ( Combine combine )
+               ArrayList CalculateSubDirOrder ( CombineConfiguration config )
                {
                        ArrayList resultOrder = new ArrayList();
                        Set dependenciesMet = new Set();
@@ -110,13 +124,17 @@
                        {
                                added = false;
                                notMet = null;
-                               
-                               foreach (CombineEntry entry in combine.Entries) 
+
+                               foreach (CombineConfigurationEntry centry in 
config.Entries) 
                                {
-                                       if (inResult.Contains(entry)) continue;
+                                       if ( !centry.Build ) continue;
+                                       
+                                       CombineEntry entry = centry.Entry;
+                                       
+                                       if ( inResult.Contains (entry) ) 
continue;
 
                                        Set references, provides;
-                                       if(entry is Project)
+                                       if (entry is Project)
                                        {
                                                Project project = entry as 
Project;
 
@@ -125,9 +143,13 @@
                                                provides.Add(project.Name);
                                        } 
                                        else if (entry is Combine) 
-                                               GetAllProjects ( entry as 
Combine, out provides, out references);
+                                       {
+                                               CombineConfiguration cc = 
(entry as Combine).Configurations[config.Name] as CombineConfiguration;
+                                               if ( cc == null ) continue;
+                                               GetAllProjects ( cc, out 
provides, out references);
+                                       }
                                        else continue;
-                                       
+
                                        if (dependenciesMet.ContainsSet 
(references) ) 
                                        {
                                                resultOrder.Add (entry);
@@ -144,7 +166,7 @@
 
                        return resultOrder;
                }
-               
+
                // cache references
                Hashtable projectReferences = new Hashtable();          
                /**
@@ -153,7 +175,7 @@
                 */
                Set GetReferencedProjects (Project project)
                {
-                       Set set = (Set) projectReferences[project];
+                       Set set = (Set) projectReferences [project];
                        if (set != null) return set;
 
                        set = new Set();
@@ -161,7 +183,7 @@
                        foreach (ProjectReference reference in 
project.ProjectReferences) 
                        {
                                if (reference.ReferenceType == 
ReferenceType.Project)
-                                       set.Add(reference.Reference);
+                                       set.Add (reference.Reference);
                        }
 
                        projectReferences[project] = set;
@@ -175,38 +197,46 @@
                 * returns a set of projects that a combine contains and a set 
of projects
                 * that are referenced from combine projects but not part of 
the combine
                 */
-               void GetAllProjects (Combine combine, out Set projects, out Set 
references)
+               void GetAllProjects (CombineConfiguration config, out Set 
projects, out Set references)
                {
-                       projects = (Set) combineProjects[combine];
+                       projects = (Set) combineProjects [config];
                        if(projects != null) 
                        {
-                               references = (Set) combineReferences[combine];
+                               references = (Set) combineReferences [config];
                                return;
                        }
 
                        projects = new Set();
                        references = new Set();
-                       foreach (CombineEntry entry in combine.Entries) 
+                       
+                       foreach (CombineConfigurationEntry centry in 
config.Entries) 
                        {
+                               if ( !centry.Build ) continue;
+                               
+                               CombineEntry entry = centry.Entry;
                                if (entry is Project) 
                                {
                                        Project project = entry as Project;
                                        projects.Add (project.Name);
-                                       references.Union ( 
GetReferencedProjects(project) );
+                                       references.Union ( 
GetReferencedProjects (project) );
                                } 
                                else if (entry is Combine) 
                                {
                                        Set subProjects;
                                        Set subReferences;
-                                       GetAllProjects ( entry as Combine, out 
subProjects, out subReferences);
                                        
+                                       CombineConfiguration cc = (entry as 
Combine).Configurations[config.Name] as CombineConfiguration;
+                                       if ( cc == null ) continue;
+                                       GetAllProjects ( cc, out subProjects, 
out subReferences);
+
                                        projects.Union (subProjects);
                                        references.Union (subReferences);
                                }
                        }
+                       
                        references.Without (projects);
-                       combineProjects [combine] = projects;
-                       combineReferences [combine] = references;
+                       combineProjects [config] = projects;
+                       combineReferences [config] = references;
                }
        }
 }

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.am.project.template
===================================================================
--- 
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.am.project.template
       2006-06-15 18:12:07 UTC (rev 61763)
+++ 
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.am.project.template
       2006-06-15 18:46:29 UTC (rev 61764)
@@ -1,14 +1,7 @@
 # %%WARNING%%
 
-LANGUAGE = %%LANGUAGE%%
-ASSEMBLY = %%ASSEMBLY%%
-ASSEMBLY_WRAPPER = %%ASSEMBLY_WRAPPER%%
-ASSEMBLY_WRAPPER_IN = %%ASSEMBLY_WRAPPER_IN%%
-COMPILE_TARGET = %%COMPILE_TARGET%%
-
-ASSEMBLY_COMPILER_COMMAND = %%ASSEMBLY_COMPILER_COMMAND%%
-ASSEMBLY_COMPILER_FLAGS = %%ASSEMBLY_COMPILER_FLAGS%%
-
+%%CONFIG_VARS%%
+       
 all: $(ASSEMBLY)
 
 FILES = %%GROUP_Compile%%
@@ -21,6 +14,9 @@
 
 DLL_REFERENCES = %%DLL_REFERENCES%%
 
-PROJECT_REFERENCES = %%PROJECT_REFERENCES%%
+$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) 
+       mkdir -p $(dir $(ASSEMBLY))             
+%%COPY_DLLS%%
+       $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ 
-target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) 
$(build_references_ref)
 
 include $(top_srcdir)/Makefile.include

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.include
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.include   
2006-06-15 18:12:07 UTC (rev 61763)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.include   
2006-06-15 18:46:29 UTC (rev 61764)
@@ -7,13 +7,9 @@
 build_references_ref += $(foreach ref, $(build_references), -r:$(ref))
 build_references_ref += $(foreach ref, $(PROJECT_REFERENCES), -r:$(ref))  
 
-$(ASSEMBLY) $(ASSEMBLY).mdb: $(build_sources) $(build_resources) 
$(build_references)
-       mkdir -p $(dir $(ASSEMBLY))             
-       $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$@ 
-target:$(COMPILE_TARGET) $(build_sources) $(build_resources_embed) 
$(build_references_ref)
-
-EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) 
$(DLL_REFERENCES)
-CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
+EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) 
+CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES)
 DISTCLEANFILES = $(GENERATED_FILES)
 
-pkglib_SCRIPTS = $(ASSEMBLY) $(DLL_REFERENCES)
+pkglib_SCRIPTS = $(ASSEMBLY) 
 bin_SCRIPTS = $(ASSEMBLY_WRAPPER)

Modified: 
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/configure.ac.template
===================================================================
--- 
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/configure.ac.template  
    2006-06-15 18:12:07 UTC (rev 61763)
+++ 
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/configure.ac.template  
    2006-06-15 18:46:29 UTC (rev 61764)
@@ -16,6 +16,8 @@
 
 %%PACKAGE_CHECKS%%
 
+%%CONFIG_OPTIONS%%
+
 AC_CONFIG_FILES([
 %%CONFIG_FILES%%
 ])

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to