Author: scotte
Date: 2006-06-09 14:31:40 -0400 (Fri, 09 Jun 2006)
New Revision: 61601
Modified:
trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs
trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog
trunk/monodevelop/Extras/MonoDevelop.Autotools/DeployHandler.cs
trunk/monodevelop/Extras/MonoDevelop.Autotools/IMakefileHandler.cs
trunk/monodevelop/Extras/MonoDevelop.Autotools/Set.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
Log:
2006-06-09 Scott Ellington <[EMAIL PROTECTED]>
* SimpleProjectMakefileHandler.cs:
* SolutionDeployer.cs:
* IMakefileHandler.cs:
* DeployHandler.cs:
* templates/Makefile.include:
* templates/Makefile.am.project.template:
* Set.cs:
* AutotoolsContext.cs:
* SolutionMakefileHandler.cs:
Add a IProgressMonitor and fixes for various project types.
Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs
2006-06-09 17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/AutotoolsContext.cs
2006-06-09 18:31:40 UTC (rev 61601)
@@ -33,7 +33,7 @@
ArrayList autoconfConfigFiles = new ArrayList();
Set referencedPackages = new Set();
- Set globalDllReferences = new Set();
+ //Set globalDllReferences = new Set();
Set compilers = new Set ();
public void AddRequiredPackage ( string pkg_name )
@@ -52,10 +52,12 @@
compilers.Add ( command_name );
}
+ /*
public void AddReferencedDll ( string dll_name )
{
globalDllReferences.Add ( dll_name );
}
+ */
public IEnumerable GetAutoConfFiles ()
{
@@ -72,10 +74,12 @@
return compilers;
}
+ /*
public IEnumerable GetReferencedDlls ()
{
return globalDllReferences;
}
+ */
// TODO: add an extension point with which addins can implement
// autotools functionality.
@@ -89,56 +93,6 @@
throw new Exception ( "No known
IMakefileHandler for type.");
}
- // utility function for finding the correct order to process
directories
- public ArrayList CalculateSubDirOrder ( Combine combine )
- {
- ArrayList resultOrder = new ArrayList();
- Set dependenciesMet = new Set();
- Set inResult = new Set();
-
- bool added;
- string notMet;
- do
- {
- added = false;
- notMet = null;
-
- foreach (CombineEntry entry in combine.Entries)
- {
- if (inResult.Contains(entry))
- continue;
-
- Set references;
- Set provides;
- if(entry is Project)
- {
- Project project = (Project)
entry;
-
- references =
GetReferencedProjects (project);
- provides = new Set();
- provides.Add(project.Name);
- }
- else if (entry is Combine)
- GetAllProjects ( (Combine)
entry, out provides, out references);
- else continue;
-
- if (dependenciesMet.ContainsSet
(references) )
- {
- resultOrder.Add (entry);
- dependenciesMet.Union(provides);
- inResult.Add(entry);
- added = true;
- }
- else notMet = entry.Name;
- }
- } while (added == true);
-
- if (notMet != null)
- throw new Exception("Impossible to find a
solution order that satisfies project references for '" + notMet + "'");
-
- return resultOrder;
- }
-
public static string EscapeStringForAutomake (string Str)
{
StringBuilder result = new StringBuilder();
@@ -168,89 +122,5 @@
}
return sb.ToString ();
}
-
- // cache references
- Hashtable projectReferences = new Hashtable();
- /**
- * returns a set of all (monodevelop) projects that a give
- * projects references
- */
- Set GetReferencedProjects (Project project)
- {
- Set set = (Set) projectReferences[project];
- if(set != null)
- return set;
-
- set = new Set();
-
- foreach(ProjectReference reference in
project.ProjectReferences) {
- if(reference.ReferenceType ==
ReferenceType.Project)
- set.Add(reference.Reference);
- }
-
- projectReferences[project] = set;
- return set;
- }
-
- // cache references
- Hashtable combineProjects = new Hashtable();
- Hashtable combineReferences = new Hashtable();
- /**
- * 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)
- {
- projects = (Set) combineProjects[combine];
- if(projects != null) {
- references = (Set) combineReferences[combine];
- return;
- }
-
- projects = new Set();
- references = new Set();
- foreach(CombineEntry entry in combine.Entries)
- {
- if(entry is Project)
- {
- Project project = (Project) entry;
- projects.Add(project.Name);
-
references.Add(GetReferencedProjects(project));
- }
- else if(entry is Combine)
- {
- Set subProjects;
- Set subReferences;
- GetAllProjects((Combine) entry,
- out subProjects,
- out subReferences);
- projects.Union(subProjects);
- references.Union(subReferences);
- }
- }
- references.Without(projects);
- combineProjects[combine] = projects;
- combineReferences[combine] = references;
- }
-
- DotNetProjectConfiguration GetProjectConfig (Project project)
- {
- if (! (project is DotNetProject))
- return null;
-
- DotNetProject dotNetProject = (DotNetProject) project;
-
- DotNetProjectConfiguration config =
- (DotNetProjectConfiguration)
dotNetProject.Configurations["Release"];
-
- return config;
- }
-
- public string GetProjectAssembly (Project project)
- {
- DotNetProjectConfiguration config = GetProjectConfig
(project);
- string assembly = project.GetRelativeChildPath
(config.CompiledOutputName);
- return assembly;
- }
}
}
Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog 2006-06-09
17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/ChangeLog 2006-06-09
18:31:40 UTC (rev 61601)
@@ -1,3 +1,16 @@
+2006-06-09 Scott Ellington <[EMAIL PROTECTED]>
+
+ * SimpleProjectMakefileHandler.cs:
+ * SolutionDeployer.cs:
+ * IMakefileHandler.cs:
+ * DeployHandler.cs:
+ * templates/Makefile.include:
+ * templates/Makefile.am.project.template:
+ * Set.cs:
+ * AutotoolsContext.cs:
+ * SolutionMakefileHandler.cs:
+ Add a IProgressMonitor and fixes for various project types.
+
2006-06-08 Scott Ellington <[EMAIL PROTECTED]>
* AutotoolsContext.cs: fix loading of templates to allow readonly
Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/DeployHandler.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/DeployHandler.cs
2006-06-09 17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/DeployHandler.cs
2006-06-09 18:31:40 UTC (rev 61601)
@@ -21,8 +21,6 @@
using System;
using System.Collections;
using System.IO;
-using System.Text;
-using System.Xml;
using MonoDevelop.Core;
using MonoDevelop.Projects;
using MonoDevelop.Components.Commands;
@@ -53,8 +51,6 @@
public class AddinCommandHandler : NodeCommandHandler
{
- //private static readonly log4net.ILog log =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
[CommandHandler (Commands.Deploy)]
protected void OnDeploy()
{
@@ -74,9 +70,13 @@
return;
}
- //TODO: try/catch this. various exceptions may occur
in the process
- deployer.Deploy(combine);
+ //using (IProgressMonitor monitor =
IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (
GettextCatalog.GetString("Autotools Output"), "md-package", false, true))
+ using (IProgressMonitor monitor =
IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor (
GettextCatalog.GetString("Autotools Output"), "md-package", true, true))
+ {
+ deployer.Deploy (combine, monitor);
+ }
}
}
}
+
Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/IMakefileHandler.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/IMakefileHandler.cs
2006-06-09 17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/IMakefileHandler.cs
2006-06-09 18:31:40 UTC (rev 61601)
@@ -22,6 +22,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+using MonoDevelop.Core;
using MonoDevelop.Projects;
namespace MonoDevelop.Autotools
@@ -30,6 +31,7 @@
{
bool CanDeploy ( CombineEntry entry );
- Makefile Deploy ( AutotoolsContext ctx, CombineEntry entry );
+ Makefile Deploy ( AutotoolsContext ctx, CombineEntry entry,
IProgressMonitor monitor );
}
}
+
Modified: trunk/monodevelop/Extras/MonoDevelop.Autotools/Set.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/Set.cs 2006-06-09
17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/Set.cs 2006-06-09
18:31:40 UTC (rev 61601)
@@ -26,10 +26,6 @@
{
private Hashtable hashtable = new Hashtable();
- public Set()
- {
- }
-
public void Add(object o)
{
hashtable[o] = true;
@@ -78,6 +74,6 @@
get {
return hashtable.Count == 0;
}
- }
+ }
}
}
Modified:
trunk/monodevelop/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
2006-06-09 17:41:55 UTC (rev 61600)
+++
trunk/monodevelop/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs
2006-06-09 18:31:40 UTC (rev 61601)
@@ -30,8 +30,6 @@
{
public class SimpleProjectMakefileHandler : IMakefileHandler
{
- private static readonly log4net.ILog log =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
public bool CanDeploy ( CombineEntry entry )
{
Project project = entry as Project;
@@ -50,208 +48,238 @@
return null;
}
- public Makefile Deploy ( AutotoolsContext ctx, CombineEntry
entry )
+ public Makefile Deploy ( AutotoolsContext ctx, CombineEntry
entry, IProgressMonitor monitor )
{
- if ( !CanDeploy ( entry ) )
- throw new Exception ("Not a deployable
project.");
+ monitor.BeginTask ( GettextCatalog.GetString ("Creating
Makefile.am for Project {0}", entry.Name), 1 );
- Project project = entry as Project;
- ISimpleAutotoolsSetup setup = FindSetupForProject (
project );
+ Makefile makefile = new Makefile ();
+ try
+ {
+ if ( !CanDeploy ( entry ) )
+ throw new Exception (
GettextCatalog.GetString ("Not a deployable project.") );
- Console.WriteLine("Exporting project: " +
project.FileName);
- 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 \
- * ...
- */
- Hashtable groups = new Hashtable();
- foreach(ProjectFile projectFile in
project.ProjectFiles) {
- string fileGroup =
projectFile.BuildAction.ToString();
+ Project project = entry as Project;
+ 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 ) );
- ArrayList list = (ArrayList) groups[fileGroup];
- if(list == null) {
- list = new ArrayList();
- groups[fileGroup] = list;
+ // Process some .Net specific variables
+ if ( config is DotNetProjectConfiguration )
+ {
+ DotNetProjectConfiguration dnconfig =
config as DotNetProjectConfiguration;
+ string assembly =
project.GetRelativeChildPath ( GetProjectAssembly (project) );
+
+ DotNetProject dnp = project as
DotNetProject;
+ if ( dnp != null )
+
templateEngine.Variables["LANGUAGE"] =
AutotoolsContext.EscapeStringForAutomake( dnp.LanguageName);
+ templateEngine.Variables["ASSEMBLY"] =
AutotoolsContext.EscapeStringForAutomake (assembly);
+
+ switch (dnconfig.CompileTarget)
+ {
+ case CompileTarget.Exe:
+
templateEngine.Variables["COMPILE_TARGET"] = "exe";
+ break;
+ case CompileTarget.Library:
+
templateEngine.Variables["COMPILE_TARGET"] = "library";
+ break;
+ case CompileTarget.WinExe:
+
templateEngine.Variables["COMPILE_TARGET"] = "winexe";
+ break;
+ case CompileTarget.Module:
+
templateEngine.Variables["COMPILE_TARGET"] = "module";
+ break;
+ default:
+ throw new Exception(
GettextCatalog.GetString ("Unknown target {0}", dnconfig.CompileTarget ) );
+ }
+
+ if (dnconfig.CompileTarget ==
CompileTarget.Exe ||
+ dnconfig.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";
+ }
}
- list.Add(projectFile.RelativePath);
- }
+ /* 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();
- TemplateEngine templateEngine = new TemplateEngine();
+ ArrayList list = (ArrayList)
groups[fileGroup];
+ if(list == null) {
+ list = new ArrayList();
+ groups[fileGroup] = list;
+ }
- // Collect references
- StringWriter references = new StringWriter();
- StringWriter dllReferences = new StringWriter();
- StringWriter projectReferences = new StringWriter();
- Set pkgs = new Set();
-
- foreach(ProjectReference reference in
project.ProjectReferences)
- {
- if(reference.ReferenceType ==
ReferenceType.Gac)
+ // exclude directories from compilation
+ if ( projectFile.BuildAction ==
BuildAction.Compile &&
+ projectFile.Subtype !=
Subtype.Code )
+ continue;
+
+ list.Add(projectFile.RelativePath);
+ }
+
+ // Collect references
+ StringWriter references = new StringWriter();
+ StringWriter dllReferences = new StringWriter();
+ StringWriter projectReferences = new
StringWriter();
+ Set pkgs = new Set();
+ foreach(ProjectReference reference in
project.ProjectReferences)
{
- String pkg =
Runtime.SystemAssemblyService.GetPackageFromFullName (reference.Reference);
- if(pkg != "MONO-SYSTEM")
+ if(reference.ReferenceType ==
ReferenceType.Gac)
{
- if(pkgs.Contains(pkg))
- continue;
- pkgs.Add(pkg);
+ // Get pkg-config keys
+ String pkg =
Runtime.SystemAssemblyService.GetPackageFromFullName (reference.Reference);
+ if(pkg != "MONO-SYSTEM")
+ {
+ if(pkgs.Contains(pkg))
continue;
+ pkgs.Add(pkg);
- references.WriteLine (" \\");
- references.Write ("\t$(");
- references.Write
(AutotoolsContext.GetPkgVar(pkg));
- references.Write ("_LIBS)");
- ctx.AddRequiredPackage (pkg);
+ references.WriteLine ("
\\");
+ references.Write
("\t$(");
+ references.Write
(AutotoolsContext.GetPkgVar(pkg));
+ references.Write
("_LIBS)");
+ ctx.AddRequiredPackage
(pkg);
+ }
+ else
+ {
+ references.WriteLine ("
\\");
+ references.Write
("\t-r:");
+ AssemblyName assembly =
Runtime.SystemAssemblyService.ParseAssemblyName (reference.Reference);
+ references.Write
(assembly.Name);
+ references.Write ("");
+ }
}
- else
+ else if(reference.ReferenceType ==
ReferenceType.Assembly)
{
- references.WriteLine (" \\");
- references.Write ("\t-r:");
- AssemblyName assembly =
Runtime.SystemAssemblyService.ParseAssemblyName (reference.Reference);
- references.Write
(assembly.Name);
- references.Write ("");
- }
- }
- else if(reference.ReferenceType ==
ReferenceType.Assembly)
- {
- dllReferences.WriteLine (" \\");
- dllReferences.Write ("\t");
- string assemblyPath = Path.GetFullPath
(reference.Reference);
- assemblyPath =
project.GetRelativeChildPath (assemblyPath);
- dllReferences.Write (assemblyPath);
- ctx.AddReferencedDll (assemblyPath);
- }
- 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 ("Couldn't
find referenced project '" + reference.Reference + "'");
-
- projectReferences.WriteLine (" \\");
- projectReferences.Write ("\t");
- projectReferences.Write (
ctx.GetProjectAssembly (refp) );
- }
- else log.Info("ProjectReferenceType " +
reference.ReferenceType.ToString() + " not handled yet");
- }
- templateEngine.Variables["REFERENCES"] =
references.ToString();
- templateEngine.Variables["DLL_REFERENCES"] =
dllReferences.ToString();
- templateEngine.Variables["PROJECT_REFERENCES"] =
projectReferences.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);
+ if ( !reference.LocalCopy )
+ throw new Exception (
"Referenced assemblies must have a local copy." );
- // .Net-specific stuff
- if(project is DotNetProject)
- {
- DotNetProject dotNetProject = (DotNetProject)
project;
+ string assemblyPath =
Path.GetFullPath (reference.Reference);
- templateEngine.Variables["LANGUAGE"] =
AutotoolsContext.EscapeStringForAutomake(dotNetProject.LanguageName);
+ // 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 );
+
+ dllReferences.WriteLine (" \\");
+ dllReferences.Write ("\t");
+ dllReferences.Write ( newPath );
+ //ctx.AddReferencedDll (
newPath );
+ }
+ else if (reference.ReferenceType ==
ReferenceType.Project)
+ {
+ Project refp = null;
+ Combine c = project.RootCombine;
- //FIXME: does not need to be DotNetProject?
- DotNetProjectConfiguration config =
- (DotNetProjectConfiguration)
dotNetProject.Configurations["Release"];
- if(config == null)
- throw new Exception("No 'Release'
configuration in project '"
- + project.Name + "'");
+ if (c != null) refp =
c.FindProject (reference.Reference);
+
+ if (refp == null)
+ throw new Exception (
GettextCatalog.GetString ("Couldn't find referenced project '{0}'",
+
reference.Reference ) );
- string assembly =
ctx.GetProjectAssembly(project);
- templateEngine.Variables["ASSEMBLY"] =
AutotoolsContext.EscapeStringForAutomake (assembly);
- switch(config.CompileTarget)
- {
- case CompileTarget.Exe:
-
templateEngine.Variables["COMPILE_TARGET"] = "exe";
- break;
- case CompileTarget.Library:
-
templateEngine.Variables["COMPILE_TARGET"] = "library";
- break;
- case CompileTarget.WinExe:
-
templateEngine.Variables["COMPILE_TARGET"] = "winexe";
- break;
- case CompileTarget.Module:
-
templateEngine.Variables["COMPILE_TARGET"] = "module";
- break;
- default:
- throw new Exception("Unknown
target " + config.CompileTarget);
+ Console.WriteLine (
project.GetRelativeChildPath ( GetProjectAssembly (refp) ) );
+
+ projectReferences.WriteLine ("
\\");
+ projectReferences.Write ("\t");
+ projectReferences.Write (
project.GetRelativeChildPath ( GetProjectAssembly (refp) ) );
+ }
+ 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["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);
- if(config.CompileTarget == CompileTarget.Exe ||
- config.CompileTarget ==
CompileTarget.WinExe)
- {
- string wrapper = CreateExeWrapper (
ctx, assembly, Path.GetDirectoryName(project.FileName) );
-
templateEngine.Variables["ASSEMBLY_WRAPPER"] = wrapper;
-
templateEngine.Variables["ASSEMBLY_WRAPPER_IN"] = wrapper + ".in";
- }
- }
+ // add check for compiler command in
configure.ac
+ ctx.AddCommandCheck ( setup.GetCompilerCommand
( project ) );
- // write out various variables ( RESOURCES, EXTRAS, ...
)
- foreach(string group in groups.Keys)
- {
- ArrayList files = (ArrayList) groups[group];
- StringWriter gwriter = new StringWriter();
-
- if(files.Count > 2)
+ // write out various variables ( RESOURCES,
EXTRAS, ... )
+ foreach(string group in groups.Keys)
{
- gwriter.WriteLine("\\");
+ ArrayList files = (ArrayList)
groups[group];
+ StringWriter gwriter = new
StringWriter();
- for(int i = 0; i < files.Count; ++i)
+ if(files.Count > 2)
{
- string file = (string) files[i];
- file =
project.GetRelativeChildPath (file);
- gwriter.Write("\t" +
AutotoolsContext.EscapeStringForAutomake(file));
- if(i+1 < files.Count)
- gwriter.Write(" \\");
+ gwriter.WriteLine("\\");
+ for(int i = 0; i < files.Count;
++i)
+ {
+ string file = (string)
files[i];
+ file =
project.GetRelativeChildPath (file);
+ gwriter.Write("\t" +
AutotoolsContext.EscapeStringForAutomake(file));
+ if(i+1 < files.Count)
+ gwriter.Write("
\\");
+
+ gwriter.WriteLine("");
+ }
gwriter.WriteLine("");
- }
- gwriter.WriteLine("");
- }
- else
- {
- foreach(string file in files)
+ }
+ else
{
- string nfile =
project.GetRelativeChildPath (file);
- gwriter.Write(" " +
AutotoolsContext.EscapeStringForAutomake(nfile));
+ foreach(string file in files)
+ {
+ string nfile =
project.GetRelativeChildPath (file);
+ gwriter.Write(" " +
AutotoolsContext.EscapeStringForAutomake(nfile));
+ }
}
+
+ templateEngine.Variables["GROUP_" +
group] = gwriter.ToString();
}
- templateEngine.Variables["GROUP_" + group] =
gwriter.ToString();
+ // Create makefile
+ Stream stream = ctx.GetTemplateStream
("Makefile.am.project.template");
+ StreamReader reader = new StreamReader
(stream);
+ string txt = templateEngine.Process ( reader );
+ reader.Close();
+ makefile.Append ( txt );
+
+ monitor.Step (1);
}
+ finally
+ {
+ monitor.EndTask ();
+ }
- Stream stream = ctx.GetTemplateStream
("Makefile.am.project.template");
- StreamReader reader = new StreamReader (stream);
- string txt = templateEngine.Process ( reader );
-
- reader.Close();
-
- Makefile makefile = new Makefile ();
- makefile.Append ( txt );
return makefile;
}
- string CreateExeWrapper ( AutotoolsContext context , string
assembly, string baseDir )
+ string CreateExeWrapper ( AutotoolsContext context , string
assembly, string baseDir, IProgressMonitor monitor )
{
+ monitor.Log.WriteLine ( GettextCatalog.GetString
("Creating wrapper script for executable.") );
+
string basename = 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);
Stream stream = context.GetTemplateStream
("exe.wrapper.in.template");
string path = baseDir + "/" + wrapperName;
-
+
StreamReader reader = new StreamReader ( stream );
StreamWriter writer = new StreamWriter ( path + ".in");
@@ -259,9 +287,31 @@
writer.Close();
reader.Close();
-
+
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-09 17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionDeployer.cs
2006-06-09 18:31:40 UTC (rev 61601)
@@ -37,10 +37,6 @@
AutotoolsContext context;
- public SolutionDeployer ()
- {
- }
-
public bool CanDeploy ( Combine combine )
{
IMakefileHandler handler =
AutotoolsContext.GetMakefileHandler ( combine );
@@ -48,39 +44,55 @@
return true;
}
- public void Deploy (Combine combine)
+ public void Deploy (Combine combine, IProgressMonitor monitor )
{
- context = new AutotoolsContext ( );
- IMakefileHandler handler =
AutotoolsContext.GetMakefileHandler ( combine );
- if ( !handler.CanDeploy (combine) )
+ monitor.BeginTask ( GettextCatalog.GetString
("Deploying Solution {0}", combine.Name), 1 );
+
+ try
{
- // TODO: throw exception?
- return;
- }
+ context = new AutotoolsContext ( );
+ 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
- solution_version = "0.1";
-
- Makefile makefile = handler.Deploy ( context, combine );
- string path = solution_dir + "/Makefile";
- context.AddAutoconfFile ( path );
+ 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
+ solution_version = "0.1";
- CreateAutoGenDotSH ();
- CreateConfigureDotAC ();
- CreateMakefileInclude ();
+ Makefile makefile = handler.Deploy ( context,
combine, monitor );
+ string path = solution_dir + "/Makefile";
+ context.AddAutoconfFile ( path );
- AddTopLevelMakefileVars ( makefile );
-
- StreamWriter writer = new StreamWriter ( path + ".am" );
- makefile.Write ( writer );
- writer.Close ();
+ CreateAutoGenDotSH ( monitor );
+ CreateConfigureDotAC ( monitor );
+ CreateMakefileInclude ( monitor );
+
+ //AddTopLevelMakefileVars ( makefile, monitor );
+
+ StreamWriter writer = new StreamWriter ( path +
".am" );
+ makefile.Write ( writer );
+ writer.Close ();
+
+ monitor.ReportSuccess (
GettextCatalog.GetString ("Autotools files were successfully generated.") );
+ monitor.Step (1);
+ }
+ catch ( Exception e )
+ {
+ monitor.ReportError ( GettextCatalog.GetString
("Solution could not be deployed: "), e );
+ }
+ finally
+ {
+ monitor.EndTask ();
+ }
}
- void AddTopLevelMakefileVars ( Makefile makefile )
+ /*
+ void AddTopLevelMakefileVars ( Makefile makefile,
IProgressMonitor monitor)
{
+ monitor.Log.WriteLine ( GettextCatalog.GetString
("Adding variables to top-level Makefile.am") );
+
StringBuilder sb = new StringBuilder ();
foreach ( string dll in context.GetReferencedDlls() )
{
@@ -89,15 +101,18 @@
}
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", vals );
+ //makefile.SetVariable ( "pkglib_DATA", vals );
}
-
- void CreateAutoGenDotSH ()
+ */
+
+ void CreateAutoGenDotSH (IProgressMonitor monitor)
{
+ monitor.Log.WriteLine ( GettextCatalog.GetString
("Creating autogen.sh") );
+
TemplateEngine templateEngine = new TemplateEngine();
-
+
templateEngine.Variables["NAME"] = solution_name;
string fileName = solution_dir + "/autogen.sh";
@@ -115,9 +130,10 @@
// make autogen.sh executable
Syscall.chmod ( fileName , FilePermissions.S_IXOTH |
FilePermissions.S_IROTH | FilePermissions.S_IRWXU | FilePermissions.S_IRWXG );
}
-
- void CreateConfigureDotAC ()
+
+ void CreateConfigureDotAC (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!";
// build compiler checks
@@ -130,7 +146,7 @@
compiler_checks.Append("fi\n");
}
templateEngine.Variables["COMPILER_CHECKS"] =
compiler_checks.ToString();
-
+
// build list of *.in files
StringBuilder configFiles = new StringBuilder();
foreach (string makefile in context.GetAutoConfFiles ()
)
@@ -166,9 +182,11 @@
reader.Close();
writer.Close();
}
-
- void CreateMakefileInclude ()
+
+ void CreateMakefileInclude (IProgressMonitor monitor)
{
+ monitor.Log.WriteLine ( GettextCatalog.GetString
("Creating Makefile.include") );
+
string fileName = solution_dir + "/Makefile.include";
Stream stream = context.GetTemplateStream
("Makefile.include");
@@ -183,3 +201,4 @@
}
}
}
+
Modified:
trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs
2006-06-09 17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs
2006-06-09 18:31:40 UTC (rev 61601)
@@ -21,7 +21,9 @@
using System;
using System.IO;
using System.Text;
+using System.Collections;
using MonoDevelop.Projects;
+using MonoDevelop.Core;
namespace MonoDevelop.Autotools
{
@@ -42,41 +44,171 @@
return true;
}
- public Makefile Deploy ( AutotoolsContext ctx, CombineEntry
entry )
+ public Makefile Deploy ( AutotoolsContext ctx, CombineEntry
entry, IProgressMonitor monitor )
{
- if ( !CanDeploy ( entry ) )
- throw new Exception ( "Not a deployable
combine." );
+ monitor.BeginTask ( GettextCatalog.GetString
("Creating Makefile.am for Solution {0}", entry.Name), 1 );
+ Makefile mfile = new Makefile ();
- Combine combine = entry as Combine;
+ try
+ {
+ if ( !CanDeploy ( entry ) )
+ throw new Exception (
GettextCatalog.GetString ("Not a deployable solution.") );
- StringBuilder subdirs = new StringBuilder();
- subdirs.Append ("#Warning: This is an automatically
generated file, do not edit!\n");
- subdirs.Append ("SUBDIRS = ");
- foreach ( CombineEntry ce in ctx.CalculateSubDirOrder (
combine ) )
+ Combine combine = entry as Combine;
+
+ 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 ) )
+ {
+ if ( combine.BaseDirectory ==
ce.BaseDirectory )
+ throw new Exception (
GettextCatalog.GetString ("Child projects / solutions cannot be in the same
directory as their parent") );
+
+ if ( !ce.BaseDirectory.StartsWith
(combine.BaseDirectory) )
+ throw new Exception (
GettextCatalog.GetString ("Child projects / solutions must be in
sub-directories of their parent") );
+
+ string path = Path.GetDirectoryName
(ce.RelativeFileName);
+ if (path.StartsWith ("./") )
+ path = path.Substring (2);
+ subdirs.Append (" ");
+ subdirs.Append (
AutotoolsContext.EscapeStringForAutomake (path) );
+
+ IMakefileHandler handler =
AutotoolsContext.GetMakefileHandler ( ce );
+ Makefile makefile;
+ if ( handler.CanDeploy ( ce ) )
+ {
+ makefile = handler.Deploy (
ctx, ce, monitor );
+ string outpath =
Path.GetDirectoryName(ce.FileName) + "/Makefile";
+ StreamWriter writer = new
StreamWriter ( outpath + ".am" );
+ makefile.Write ( writer );
+ writer.Close ();
+ ctx.AddAutoconfFile ( outpath );
+ }
+ }
+
+ mfile.Append ( subdirs.ToString () );
+
+ monitor.Step (1);
+ }
+ finally
{
- string path = Path.GetDirectoryName
(ce.RelativeFileName);
- if (path.StartsWith ("./") )
- path = path.Substring (2);
- subdirs.Append (" ");
- subdirs.Append (
AutotoolsContext.EscapeStringForAutomake (path) );
+ monitor.EndTask ();
+ }
+ return mfile;
+ }
- IMakefileHandler handler =
AutotoolsContext.GetMakefileHandler ( ce );
- Makefile makefile;
- if ( handler.CanDeploy ( ce ) )
+ // utility function for finding the correct order to process
directories
+ ArrayList CalculateSubDirOrder ( Combine combine )
+ {
+ ArrayList resultOrder = new ArrayList();
+ Set dependenciesMet = new Set();
+ Set inResult = new Set();
+
+ bool added;
+ string notMet;
+ do
+ {
+ added = false;
+ notMet = null;
+
+ foreach (CombineEntry entry in combine.Entries)
{
- makefile = handler.Deploy ( ctx, ce );
- string outpath =
Path.GetDirectoryName(ce.FileName) + "/Makefile";
- StreamWriter writer = new StreamWriter
( outpath + ".am" );
- makefile.Write ( writer );
- writer.Close ();
- ctx.AddAutoconfFile ( outpath );
+ if (inResult.Contains(entry)) continue;
+
+ Set references, provides;
+ if(entry is Project)
+ {
+ Project project = entry as
Project;
+
+ references =
GetReferencedProjects (project);
+ provides = new Set();
+ provides.Add(project.Name);
+ }
+ else if (entry is Combine)
+ GetAllProjects ( entry as
Combine, out provides, out references);
+ else continue;
+
+ if (dependenciesMet.ContainsSet
(references) )
+ {
+ resultOrder.Add (entry);
+ dependenciesMet.Union(provides);
+ inResult.Add(entry);
+ added = true;
+ }
+ else notMet = entry.Name;
}
+ } while (added == true);
+
+ if (notMet != null)
+ throw new Exception("Impossible to find a
solution order that satisfies project references for '" + notMet + "'");
+
+ return resultOrder;
+ }
+
+ // cache references
+ Hashtable projectReferences = new Hashtable();
+ /**
+ * returns a set of all monodevelop projects that a give
+ * projects references
+ */
+ Set GetReferencedProjects (Project project)
+ {
+ Set set = (Set) projectReferences[project];
+ if (set != null) return set;
+
+ set = new Set();
+
+ foreach (ProjectReference reference in
project.ProjectReferences)
+ {
+ if (reference.ReferenceType ==
ReferenceType.Project)
+ set.Add(reference.Reference);
}
- Makefile mfile = new Makefile ();
- mfile.Append ( subdirs.ToString () );
- return mfile;
+ projectReferences[project] = set;
+ return set;
}
+
+ // cache references
+ Hashtable combineProjects = new Hashtable();
+ Hashtable combineReferences = new Hashtable();
+ /**
+ * 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)
+ {
+ projects = (Set) combineProjects[combine];
+ if(projects != null)
+ {
+ references = (Set) combineReferences[combine];
+ return;
+ }
+
+ projects = new Set();
+ references = new Set();
+ foreach (CombineEntry entry in combine.Entries)
+ {
+ if (entry is Project)
+ {
+ Project project = entry as Project;
+ projects.Add (project.Name);
+ references.Union (
GetReferencedProjects(project) );
+ }
+ else if (entry is Combine)
+ {
+ Set subProjects;
+ Set subReferences;
+ GetAllProjects ( entry as Combine, out
subProjects, out subReferences);
+
+ projects.Union (subProjects);
+ references.Union (subReferences);
+ }
+ }
+ references.Without (projects);
+ combineProjects [combine] = projects;
+ combineReferences [combine] = references;
+ }
}
}
+
Modified:
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.am.project.template
===================================================================
---
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.am.project.template
2006-06-09 17:41:55 UTC (rev 61600)
+++
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.am.project.template
2006-06-09 18:31:40 UTC (rev 61601)
@@ -1,7 +1,7 @@
# %%WARNING%%
LANGUAGE = %%LANGUAGE%%
-ASSEMBLY = $(top_builddir)/%%ASSEMBLY%%
+ASSEMBLY = %%ASSEMBLY%%
ASSEMBLY_WRAPPER = %%ASSEMBLY_WRAPPER%%
ASSEMBLY_WRAPPER_IN = %%ASSEMBLY_WRAPPER_IN%%
COMPILE_TARGET = %%COMPILE_TARGET%%
Modified:
trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.include
===================================================================
--- trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.include
2006-06-09 17:41:55 UTC (rev 61600)
+++ trunk/monodevelop/Extras/MonoDevelop.Autotools/templates/Makefile.include
2006-06-09 18:31:40 UTC (rev 61601)
@@ -2,18 +2,18 @@
build_resources = $(addprefix $(srcdir)/, $(RESOURCES))
build_resources_embed = $(foreach res,$(build_resources), $(addprefix
-resource:,$(res)),$(RESOURCES_PREFIX)$(notdir $(res)))
-build_references = $(foreach ref,$(DLL_REFERENCES), $(addprefix
$(top_srcdir)/,$(ref)))
+build_references = $(DLL_REFERENCES)
build_references_ref = $(REFERENCES)
build_references_ref += $(foreach ref, $(build_references), -r:$(ref))
-build_references_ref += $(foreach ref, $(PROJECT_REFERENCES), $(addprefix
-r:$(top_builddir)/,$(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)
+EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN)
$(DLL_REFERENCES)
CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
DISTCLEANFILES = $(GENERATED_FILES)
-pkglib_SCRIPTS = $(ASSEMBLY)
+pkglib_SCRIPTS = $(ASSEMBLY) $(DLL_REFERENCES)
bin_SCRIPTS = $(ASSEMBLY_WRAPPER)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches