diff options
Diffstat (limited to 'Extras/MonoDevelop.Autotools')
17 files changed, 347 insertions, 124 deletions
diff --git a/Extras/MonoDevelop.Autotools/AutotoolsContext.cs b/Extras/MonoDevelop.Autotools/AutotoolsContext.cs index a7ac04f0cd..177519281b 100644 --- a/Extras/MonoDevelop.Autotools/AutotoolsContext.cs +++ b/Extras/MonoDevelop.Autotools/AutotoolsContext.cs @@ -24,11 +24,15 @@ using System.Text; using System.Collections; using MonoDevelop.Projects; +using MonoDevelop.Deployment; namespace MonoDevelop.Autotools { public class AutotoolsContext { + DeployContext deployContext; + Hashtable deployDirs = new Hashtable (); + string template_dir = Path.GetDirectoryName ( typeof ( AutotoolsContext ).Assembly.Location ) + "/"; Set autoconfConfigFiles = new Set (); @@ -36,6 +40,10 @@ namespace MonoDevelop.Autotools Set globalDllReferences = new Set(); Set compilers = new Set (); + public DeployContext DeployContext { + get { return deployContext; } + } + string base_dir; public string BaseDirectory { get { @@ -57,8 +65,9 @@ namespace MonoDevelop.Autotools } } - public AutotoolsContext ( string base_directory, string[] configs ) + public AutotoolsContext ( DeployContext deployContext, string base_directory, string[] configs ) { + this.deployContext = deployContext; base_dir = base_directory; configurations = configs; } @@ -72,6 +81,16 @@ namespace MonoDevelop.Autotools return false; } + public string GetDeployDirectoryVar (string folderId) + { + string dir = (string) deployDirs [folderId]; + if (dir != null) + return dir; + dir = folderId.ToUpper ().Replace (".","_").Replace ("/", "_"); + deployDirs [folderId] = dir; + return dir; + } + public void AddRequiredPackage ( string pkg_name ) { referencedPackages.Add (pkg_name); @@ -115,6 +134,11 @@ namespace MonoDevelop.Autotools return globalDllReferences; } + public IDictionary GetReferencedTargetDirectories () + { + return deployDirs; + } + // TODO: add an extension point with which addins can implement // autotools functionality. public static IMakefileHandler GetMakefileHandler ( CombineEntry entry ) @@ -124,7 +148,7 @@ namespace MonoDevelop.Autotools else if ( entry is Project ) return new SimpleProjectMakefileHandler (); else - throw new Exception ( "No known IMakefileHandler for type."); + return null; } public static string EscapeStringForAutomake (string str) diff --git a/Extras/MonoDevelop.Autotools/ChangeLog b/Extras/MonoDevelop.Autotools/ChangeLog index 28013bcea5..1e14204353 100644 --- a/Extras/MonoDevelop.Autotools/ChangeLog +++ b/Extras/MonoDevelop.Autotools/ChangeLog @@ -1,3 +1,22 @@ +2007-04-19 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Autotools.addin.xml, Commands.cs, + TarballTargetEditorWidget.cs: Track api changes in deployment api. + * MonoDevelop.Autotools.mdp, gtk-gui/gui.stetic, Makefile.am: Added + dependency to MonoDevelop.Deployment. + * SolutionMakefileHandler.cs: Allow generating makefiles a combine even + if it contains unsupported projects. Those will be ignored. + * SimpleProjectMakefileHandler.cs, Handler.cs, SolutionDeployer.cs, + templates/Makefile.include: Use the new deployment api to get the + list of files to deploy. + * FileNodeBuilderExtension.cs, MakefileData.cs: Moved makefile + integration check to MakefileData. + * AutotoolsContext.cs: Keep a list of directories to deploy. Store the + DeployContext in a field. + * PropertyProvider.cs: New property provider which allows setting the + makefile integration flag for each file. + * gtk-gui/objects.xml: Updated. + 2007-03-29 Lluis Sanchez Gual <lluis@novell.com> * Handler.cs: Remove unused namespace. diff --git a/Extras/MonoDevelop.Autotools/Commands.cs b/Extras/MonoDevelop.Autotools/Commands.cs index 6c627000b6..ae25b5ccf3 100644 --- a/Extras/MonoDevelop.Autotools/Commands.cs +++ b/Extras/MonoDevelop.Autotools/Commands.cs @@ -32,6 +32,7 @@ using MonoDevelop.Components.Commands; using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Gui.Pads; using MonoDevelop.Ide.Gui.Content; +using MonoDevelop.Deployment; using Gtk; @@ -70,9 +71,14 @@ namespace MonoDevelop.Autotools return; } - using (IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ( GettextCatalog.GetString("Autotools Output"), "md-package", true, true)) - { - deployer.GenerateFiles (combine, monitor); + DeployContext ctx = new DeployContext (new TarballDeployTarget (), "Linux", null); + IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ( GettextCatalog.GetString("Autotools Output"), "md-package", true, true); + try { + deployer.GenerateFiles (ctx, combine, monitor); + } + finally { + ctx.Dispose (); + monitor.Dispose (); } } } diff --git a/Extras/MonoDevelop.Autotools/FileNodeBuilderExtension.cs b/Extras/MonoDevelop.Autotools/FileNodeBuilderExtension.cs index 2876e3a2ca..e290c1db05 100644 --- a/Extras/MonoDevelop.Autotools/FileNodeBuilderExtension.cs +++ b/Extras/MonoDevelop.Autotools/FileNodeBuilderExtension.cs @@ -42,20 +42,9 @@ namespace MonoDevelop.Autotools Project project = file.Project; if (project != null) { MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; - if (data != null && data.IntegrationEnabled) { - bool sync; - if (file.BuildAction == BuildAction.Compile) - sync = data.BuildFilesVar.Sync; - else if (file.BuildAction == BuildAction.EmbedAsResource) - sync = data.ResourcesVar.Sync; - else if (file.BuildAction == BuildAction.FileCopy) - sync = data.DeployFilesVar.Sync; - else - sync = data.OthersVar.Sync; - if (sync) { - cinfo.Checked = !data.IsFileExcluded (file.FilePath); - return; - } + if (data != null && data.IsFileIntegrationEnabled (file.BuildAction)) { + cinfo.Checked = !data.IsFileExcluded (file.FilePath); + return; } } cinfo.Visible = false; diff --git a/Extras/MonoDevelop.Autotools/Handler.cs b/Extras/MonoDevelop.Autotools/Handler.cs index cb20ead21d..09b9c70186 100644 --- a/Extras/MonoDevelop.Autotools/Handler.cs +++ b/Extras/MonoDevelop.Autotools/Handler.cs @@ -5,14 +5,15 @@ using System.Collections; using System.IO; using MonoDevelop.Core; +using MonoDevelop.Core.ProgressMonitoring; using MonoDevelop.Projects; using MonoDevelop.Projects.Serialization; -using MonoDevelop.Projects.Deployment; -using MonoDevelop.Projects.Gui.Deployment; +using MonoDevelop.Deployment; +using MonoDevelop.Deployment.Gui; namespace MonoDevelop.Autotools { - public class TarballDeployTarget: DeployTarget + public class TarballDeployTarget: PackageBuilder { [ItemProperty ("TargetDirectory")] string targetDir; @@ -24,7 +25,7 @@ namespace MonoDevelop.Autotools get { return GettextCatalog.GetString ("Tarball"); } } - public override void CopyFrom (DeployTarget other) + public override void CopyFrom (PackageBuilder other) { base.CopyFrom (other); TarballDeployTarget target = other as TarballDeployTarget; @@ -42,11 +43,7 @@ namespace MonoDevelop.Autotools set { defaultConfig = value; } } - public Combine TargetCombine { - get { return base.CombineEntry as Combine; } - } - - public override bool CanDeploy (CombineEntry entry) + public override bool CanBuild (CombineEntry entry) { Combine combine = entry as Combine; if ( combine == null ) return false; @@ -54,7 +51,7 @@ namespace MonoDevelop.Autotools return deployer.CanDeploy ( combine ); } - protected override void OnInitialize (CombineEntry entry) + public override void InitializeSettings (CombineEntry entry) { if (string.IsNullOrEmpty (targetDir)) targetDir = entry.BaseDirectory; @@ -65,29 +62,62 @@ namespace MonoDevelop.Autotools } - protected override void OnDeploy (IProgressMonitor monitor) + protected override void OnBuild (IProgressMonitor monitor, CombineEntry entry) { - Combine combine = CombineEntry as Combine; - SolutionDeployer deployer = new SolutionDeployer (); + string tmpFolder = Runtime.FileService.CreateTempDirectory (); + Combine combine = null; + + try { + string efile = Services.ProjectService.Export (new NullProgressMonitor (), entry.FileName, tmpFolder, null, true); + combine = Services.ProjectService.ReadCombineEntry (efile, new NullProgressMonitor ()) as Combine; + combine.Build (monitor); + + if (monitor.IsCancelRequested || !monitor.AsyncOperation.Success) + return; - if (DefaultConfiguration == null || DefaultConfiguration == "") - deployer.Deploy ( combine, TargetDir, monitor ); - else - deployer.Deploy ( combine, DefaultConfiguration, TargetDir, monitor ); + SolutionDeployer deployer = new SolutionDeployer (); + + using (DeployContext ctx = new DeployContext (this, "Linux", null)) { + if (DefaultConfiguration == null || DefaultConfiguration == "") + deployer.Deploy ( ctx, combine, TargetDir, monitor ); + else + deployer.Deploy ( ctx, combine, DefaultConfiguration, TargetDir, monitor ); + } + } finally { + if (combine != null) + combine.Dispose (); + Directory.Delete (tmpFolder, true); + } } + protected override string OnResolveDirectory (DeployContext ctx, string folderId) + { + switch (folderId) { + case TargetDirectory.ProgramFilesRoot: + return "@prefix@/lib"; + case TargetDirectory.ProgramFiles: + return "@prefix@/lib/@PACKAGE@"; + case TargetDirectory.Binaries: + return "@prefix@/bin"; + case TargetDirectory.CommonApplicationDataRoot: + return "@prefix@/share"; + case TargetDirectory.CommonApplicationData: + return "@prefix@/share/@PACKAGE@"; + } + return null; + } } - public class TarballTargetEditor: IDeployTargetEditor + public class TarballTargetEditor: IPackageBuilderEditor { - public bool CanEdit (DeployTarget target) + public bool CanEdit (PackageBuilder target, CombineEntry entry) { return target is TarballDeployTarget; } - public Gtk.Widget CreateEditor (DeployTarget target) + public Gtk.Widget CreateEditor (PackageBuilder target, CombineEntry entry) { - return new TarballTargetEditorWidget ((TarballDeployTarget) target); + return new TarballTargetEditorWidget ((TarballDeployTarget) target, (Combine) entry); } } } diff --git a/Extras/MonoDevelop.Autotools/Makefile.am b/Extras/MonoDevelop.Autotools/Makefile.am index 7d52d5a4b7..87db1158e1 100644 --- a/Extras/MonoDevelop.Autotools/Makefile.am +++ b/Extras/MonoDevelop.Autotools/Makefile.am @@ -10,6 +10,7 @@ REFS = -r:Mono.Posix \ -r:$(top_builddir)/build/AddIns/MonoDevelop.Projects.Gui.dll \ -r:$(top_builddir)/build/AddIns/MonoDevelop.Components.dll \ -r:$(top_builddir)/build/AddIns/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Deployment.dll \ $(GNOME_SHARP_LIBS) \ $(GTK_SHARP_LIBS) diff --git a/Extras/MonoDevelop.Autotools/MakefileData.cs b/Extras/MonoDevelop.Autotools/MakefileData.cs index e6c3d107cd..6c6d980289 100644 --- a/Extras/MonoDevelop.Autotools/MakefileData.cs +++ b/Extras/MonoDevelop.Autotools/MakefileData.cs @@ -417,6 +417,21 @@ namespace MonoDevelop.Autotools } } + public bool IsFileIntegrationEnabled (BuildAction fileType) + { + if (IntegrationEnabled) { + if (fileType == BuildAction.Compile) + return BuildFilesVar.Sync; + else if (fileType == BuildAction.EmbedAsResource) + return ResourcesVar.Sync; + else if (fileType == BuildAction.FileCopy) + return DeployFilesVar.Sync; + else + return OthersVar.Sync; + } + return false; + } + public bool IsFileExcluded (string fileName) { return excludedFiles.Contains (fileName); diff --git a/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml b/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml index e32676b756..df2b457d50 100644 --- a/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml +++ b/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.addin.xml @@ -20,6 +20,8 @@ <AddIn id="MonoDevelop.Core.Gui" version="0.13.0"/> <AddIn id="MonoDevelop.Ide" version="0.13.0"/> <AddIn id="MonoDevelop.Projects" version="0.13.0"/> + <AddIn id="MonoDevelop.Deployment" version="0.13.0"/> + <AddIn id="MonoDevelop.DesignerSupport" version="0.13.0"/> </Dependencies> <Extension path = "/SharpDevelop/Workbench/Pads/MonoDevelop.Ide.Gui.Pads.ProjectPad"> @@ -39,12 +41,8 @@ _label = "Include in Synchronized Makefile" /> </Extension> - <Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/CombineBrowserNode"> - <ItemSet id = "CombineAutotoolsMenu" _label = "Autotools" - insertafter= "CombineBuildGroupSeparator"> - <CommandItem id = "MonoDevelop.Autotools.Commands.GenerateFiles"/> - </ItemSet> - <SeparatorItem id = "Separator1" /> + <Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/CombineBrowserNode/Tools"> + <CommandItem id = "MonoDevelop.Autotools.Commands.GenerateFiles" insertafter="ExportListSeparator"/> </Extension> <Extension path = "/SharpDevelop/Views/ProjectBrowser/ContextMenu/ProjectFileNode/Include"> @@ -58,11 +56,11 @@ <Extension path = "/Autotools/SimpleSetups" extension-nodes="Class" description="SimpleSetups.|Specified classes must implement ISimpleAutotoolsSetup"> </Extension> - <Extension path = "/SharpDevelop/Workbench/DeployHandlers"> + <Extension path = "/MonoDevelop/DeployService/PackageBuilders"> <Class class="MonoDevelop.Autotools.TarballDeployTarget" /> </Extension> - <Extension path = "/SharpDevelop/Workbench/DeployTargetEditors"> + <Extension path = "/MonoDevelop/DeployService/PackageBuilderEditors"> <Class class="MonoDevelop.Autotools.TarballTargetEditor" /> </Extension> @@ -89,4 +87,7 @@ name = "MonoDevelop.Autotools.MakefileInfo" type = "MonoDevelop.Autotools.MakefileData" /> </Extension> + <Extension path = "/MonoDevelop/DesignerSupport/PropertyProviders"> + <Class class = "MonoDevelop.Autotools.PropertyProvider"/> + </Extension> </AddIn> diff --git a/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.mdp b/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.mdp index ad952791e6..44e693bd64 100644 --- a/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.mdp +++ b/Extras/MonoDevelop.Autotools/MonoDevelop.Autotools.mdp @@ -45,6 +45,7 @@ <File name="./ChangeLog" subtype="Code" buildaction="Nothing" /> <File name="./templates" subtype="Directory" buildaction="Compile" /> <File name="./FileNodeBuilderExtension.cs" subtype="Code" buildaction="Compile" /> + <File name="./PropertyProvider.cs" subtype="Code" buildaction="Compile" /> <File name="./gtk-gui/MonoDevelop.Autotools.MakefileOptionPanelWidget.cs" subtype="Code" buildaction="Compile" /> </Contents> <References> @@ -56,11 +57,13 @@ <ProjectReference type="Gac" localcopy="False" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects.Gui" /> <ProjectReference type="Gac" localcopy="False" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> - <ProjectReference type="Gac" localcopy="False" refto="gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> - <ProjectReference type="Gac" localcopy="False" refto="gdk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> - <ProjectReference type="Gac" localcopy="False" refto="gnome-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <ProjectReference type="Gac" localcopy="False" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <ProjectReference type="Assembly" localcopy="False" refto="../../contrib/log4net.dll" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.DesignerSupport" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gnome-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Deployment" /> </References> <GtkDesignInfo partialTypes="True"> <ExportedWidgets> diff --git a/Extras/MonoDevelop.Autotools/PropertyProvider.cs b/Extras/MonoDevelop.Autotools/PropertyProvider.cs new file mode 100644 index 0000000000..ba8540c72f --- /dev/null +++ b/Extras/MonoDevelop.Autotools/PropertyProvider.cs @@ -0,0 +1,50 @@ + +using System; +using System.ComponentModel; +using MonoDevelop.Projects; +using MonoDevelop.DesignerSupport; + +namespace MonoDevelop.Autotools +{ + public class PropertyProvider: IPropertyProvider + { + public bool SupportsObject (object obj) + { + ProjectFile file = obj as ProjectFile; + if (file != null && file.Project != null) { + MakefileData data = file.Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; + if (data != null && data.IsFileIntegrationEnabled (file.BuildAction)) + return true; + } + return false; + } + + public object CreateProvider (object obj) + { + return new ProjectFileWrapper ((ProjectFile) obj); + } + } + + class ProjectFileWrapper + { + ProjectFile file; + MakefileData data; + + public ProjectFileWrapper (ProjectFile file) + { + this.file = file; + data = file.Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; + } + + [Category ("Makefile Integration")] + [Description ("Include in Synchronized Makefile")] + public bool IncludeInMakefile { + get { + return !data.IsFileExcluded (file.FilePath); + } + set { + data.SetFileExcluded (file.FilePath, !value); + } + } + } +} diff --git a/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs b/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs index 64f3e7c5cd..a89a4b802e 100644 --- a/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs +++ b/Extras/MonoDevelop.Autotools/SimpleProjectMakefileHandler.cs @@ -27,6 +27,7 @@ using System.Text; using MonoDevelop.Projects; using MonoDevelop.Projects.Serialization; using MonoDevelop.Core; +using MonoDevelop.Deployment; namespace MonoDevelop.Autotools { @@ -66,8 +67,6 @@ namespace MonoDevelop.Autotools TemplateEngine templateEngine = new TemplateEngine(); ISimpleAutotoolsSetup setup = FindSetupForProject ( project ); - bool pkgconfig = NeedsPCFile ( project ); - // store all refs for easy access Set pkgs = new Set(); Set dlls = new Set(); @@ -127,7 +126,7 @@ namespace MonoDevelop.Autotools 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!"; - + // grab all project files StringBuilder files = new StringBuilder (); StringBuilder res_files = new StringBuilder (); @@ -164,20 +163,81 @@ namespace MonoDevelop.Autotools } else res_files.AppendFormat ( "\\\n\t{0} ", pfpath ); break; + } + } + + // Handle files to be deployed + StringBuilder deployBinaries = new StringBuilder (); + Hashtable deployDirs = new Hashtable (); + + DeployFileCollection deployFiles = DeployService.GetDeployFiles (ctx.DeployContext, project); + foreach (DeployFile dfile in deployFiles) { + if (dfile.SourcePath == project.GetOutputFileName ()) + continue; + string fname = null; + if (dfile.ContainsPathReferences) { + // If the file is a template, create a .in file for it. + fname = Path.Combine (project.BaseDirectory, Path.GetFileName (dfile.RelativeTargetPath)); + string infname = fname + ".in"; + if (File.Exists (infname)) { + string datadir = Path.Combine (project.BaseDirectory, "data"); + if (!Directory.Exists (datadir)) + Directory.CreateDirectory (datadir); + infname = Path.Combine (datadir, Path.GetFileName (dfile.RelativeTargetPath) + ".in"); + } + File.Copy (dfile.SourcePath, infname); + extras.AppendFormat ( "\\\n\t{0} ", Path.GetFileName (infname)); + ctx.AddAutoconfFile (fname); + fname = Path.GetFileName (fname); + } else { + // If the file is not in the project directory, copy it there. + if (!Path.GetFullPath (dfile.SourcePath).StartsWith (Path.GetFullPath (project.BaseDirectory))) { + fname = Path.Combine (project.BaseDirectory, Path.GetFileName (dfile.RelativeTargetPath)); + File.Copy (dfile.SourcePath, fname); + fname = Path.GetFileName (fname); + } + else { + // If the target file name is different, rename it now + if (Path.GetFileName (dfile.RelativeTargetPath) != Path.GetFileName (dfile.SourcePath)) { + fname = Path.Combine (Path.GetDirectoryName (dfile.SourcePath), Path.GetFileName (dfile.RelativeTargetPath)); + File.Copy (dfile.SourcePath, fname, true); + } + else + fname = dfile.SourcePath; - case BuildAction.FileCopy: + fname = Runtime.FileService.AbsoluteToRelativePath (project.BaseDirectory, fname); + } - datafiles.AppendFormat ("\\\n\t{0} ", pfpath ); - break; + extras.AppendFormat ("\\\n\t{0} ", fname); + } + + switch (dfile.TargetDirectoryID) { + case TargetDirectory.Binaries: + deployBinaries.AppendFormat ("\\\n\t{0} ", fname); + break; + case TargetDirectory.Gac: + break; + default: + string ddir = NormalizeRelPath (Path.GetDirectoryName (dfile.RelativeTargetPath).Trim ('/',' ')); + if (ddir.Length > 0) + ddir = "/" + ddir; + string var = ctx.GetDeployDirectoryVar (dfile.TargetDirectoryID + ddir); + StringBuilder sb = (StringBuilder) deployDirs [var]; + if (sb == null) { + sb = new StringBuilder (); + deployDirs [var] = sb; + } + sb.AppendFormat ("\\\n\t{0} ", fname); + break; } } + templateEngine.Variables["FILES"] = files.ToString(); templateEngine.Variables["RESOURCES"] = res_files.ToString(); templateEngine.Variables["EXTRAS"] = extras.ToString(); templateEngine.Variables["DATA_FILES"] = datafiles.ToString(); // handle configuration specific variables - Set wrapped_exes = new Set (); StringBuilder conf_vars = new StringBuilder (); foreach ( DotNetProjectConfiguration config in project.Configurations ) { @@ -217,30 +277,6 @@ namespace MonoDevelop.Autotools } conf_vars.AppendFormat ( "COMPILE_TARGET = {0}\n", target ); - if ( config.CompileTarget == CompileTarget.Exe || - config.CompileTarget == CompileTarget.WinExe ) - { - string assembly_name = Path.GetFileName ( assembly ); - string wrapper; - if ( !wrapped_exes.Contains ( assembly_name ) ) - { - wrapper = CreateExeWrapper ( ctx, - assembly, - Path.GetDirectoryName (project.FileName), - config.CommandLineParameters, - 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 ); - } - else if ( pkgconfig && config.CompileTarget == CompileTarget.Library ) - { - conf_vars.AppendFormat ( "PC_FILES_IN = {0}.pc.in\n", GetUniqueName ( project ) ); - } - // for project references, we need a ref to the dll for the current configuration StringWriter projectReferences = new StringWriter(); string pref = null; @@ -266,9 +302,20 @@ namespace MonoDevelop.Autotools conf_vars.AppendFormat ( "BUILD_DIR = {0}\n", pref); conf_vars.Append ( "endif\n" ); } + + conf_vars.Append ('\n'); + + foreach (DictionaryEntry e in deployDirs) { + conf_vars.AppendFormat ("{0} = {1} \n", e.Key, e.Value); + } + + if (deployBinaries.Length > 0) { + conf_vars.AppendFormat ("BINARIES = {0} \n", deployBinaries); + } + templateEngine.Variables["CONFIG_VARS"] = conf_vars.ToString (); - if ( pkgconfig ) CreatePkgConfigFile ( project, pkgs, dlls, monitor, ctx ); +// if ( pkgconfig ) CreatePkgConfigFile ( project, pkgs, dlls, monitor, ctx ); // Create makefile Stream stream = ctx.GetTemplateStream ("Makefile.am.project.template"); @@ -282,6 +329,19 @@ namespace MonoDevelop.Autotools finally { monitor.EndTask (); } return makefile; } + + string NormalizeRelPath (string path) + { + path = path.Trim (Path.DirectorySeparatorChar,' '); + while (path.StartsWith ("." + Path.DirectorySeparatorChar)) { + path = path.Substring (2); + path = path.Trim (Path.DirectorySeparatorChar,' '); + } + if (path == ".") + return string.Empty; + else + return path; + } static string GetExeWrapperFromAssembly ( string assembly ) { diff --git a/Extras/MonoDevelop.Autotools/SolutionDeployer.cs b/Extras/MonoDevelop.Autotools/SolutionDeployer.cs index 4a25143912..c32e96b765 100644 --- a/Extras/MonoDevelop.Autotools/SolutionDeployer.cs +++ b/Extras/MonoDevelop.Autotools/SolutionDeployer.cs @@ -19,6 +19,7 @@ */ using System; +using System.Collections; using System.IO; using System.Text; @@ -27,6 +28,7 @@ using MonoDevelop.Core; using MonoDevelop.Core.Execution; using MonoDevelop.Core.ProgressMonitoring; using MonoDevelop.Projects.Serialization; +using MonoDevelop.Deployment; using Mono.Unix.Native; @@ -54,20 +56,20 @@ namespace MonoDevelop.Autotools public bool CanDeploy ( Combine combine ) { IMakefileHandler handler = AutotoolsContext.GetMakefileHandler ( combine ); - if ( !handler.CanDeploy (combine) ) return false; + if ( handler == null || !handler.CanDeploy (combine) ) return false; return true; } - public bool GenerateFiles (Combine combine, IProgressMonitor monitor ) + public bool GenerateFiles (DeployContext ctx, Combine combine, IProgressMonitor monitor ) { if (combine.ActiveConfiguration != null) - return GenerateFiles ( combine, combine.ActiveConfiguration.Name, monitor ); + return GenerateFiles ( ctx, combine, combine.ActiveConfiguration.Name, monitor ); else // Indicate with a null argument that there is no active configuration - return GenerateFiles ( combine, null, monitor ); + return GenerateFiles ( ctx, combine, null, monitor ); } - public bool GenerateFiles (Combine combine, string defaultConf, IProgressMonitor monitor ) + public bool GenerateFiles (DeployContext ctx, Combine combine, string defaultConf, IProgressMonitor monitor ) { monitor.BeginTask ( GettextCatalog.GetString ("Generating Autotools files for Solution {0}", combine.Name), 1 ); @@ -79,10 +81,10 @@ namespace MonoDevelop.Autotools for (int ii=0; ii < configs.Length; ii++ ) configs [ii] = combine.Configurations[ii].Name; - context = new AutotoolsContext ( solution_dir, configs ); + context = new AutotoolsContext ( ctx, solution_dir, configs ); IMakefileHandler handler = AutotoolsContext.GetMakefileHandler ( combine ); - if ( !handler.CanDeploy (combine) ) + if ( handler == null || !handler.CanDeploy (combine) ) throw new Exception ( GettextCatalog.GetString ("MonoDevelop does not currently support generating autotools files for one (or more) child projects.") ); solution_name = combine.Name; @@ -124,14 +126,14 @@ namespace MonoDevelop.Autotools return true; } - public void Deploy ( Combine combine, string targetDir, IProgressMonitor monitor ) + public void Deploy ( DeployContext ctx, Combine combine, string targetDir, IProgressMonitor monitor ) { - Deploy ( combine, combine.ActiveConfiguration.Name, targetDir, monitor ); + Deploy ( ctx, combine, combine.ActiveConfiguration.Name, targetDir, monitor ); } - public void Deploy ( Combine combine, string defaultConf, string targetDir, IProgressMonitor monitor ) + public void Deploy ( DeployContext ctx, Combine combine, string defaultConf, string targetDir, IProgressMonitor monitor ) { - if ( !GenerateFiles ( combine, defaultConf, monitor ) ) return; + if ( !GenerateFiles ( ctx, combine, defaultConf, monitor ) ) return; monitor.BeginTask ( GettextCatalog.GetString( "Deploying Solution to Tarball" ) , 3 ); try @@ -391,6 +393,31 @@ namespace MonoDevelop.Autotools void CreateMakefileInclude (IProgressMonitor monitor) { monitor.Log.WriteLine ( GettextCatalog.GetString ("Creating Makefile.include") ); + + TemplateEngine templateEngine = new TemplateEngine(); + + StringBuilder deployDirs = new StringBuilder (); + IDictionary dirs = context.GetReferencedTargetDirectories (); + foreach (DictionaryEntry e in dirs) { + // It may be a sub-path + string dir = (string) e.Key; + int i = dir.IndexOf ('/'); + if (i != -1) + dir = dir.Substring (0, i); + string resolved = context.DeployContext.GetDirectory (dir); + if (resolved == null) + throw new InvalidOperationException ("Unknown directory: " + e.Key); + + if (i != -1) + resolved += ((string)e.Key).Substring (i); + + string var = (string) e.Value; + string dname = var.ToLower ().Replace ("_",""); + deployDirs.AppendFormat ("{0}dir = {1}\n", dname, resolved); + deployDirs.AppendFormat ("{0}_DATA = $({1})\n", dname, var); + } + + templateEngine.Variables["DEPLOY_DIRS"] = deployDirs.ToString(); string fileName = solution_dir + "/Makefile.include"; @@ -399,7 +426,7 @@ namespace MonoDevelop.Autotools StreamReader reader = new StreamReader(stream); StreamWriter writer = new StreamWriter(fileName); - writer.Write(reader.ReadToEnd()); + templateEngine.Process(reader, writer); reader.Close(); writer.Close(); diff --git a/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs b/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs index ede801dcbc..2a7ce588ea 100644 --- a/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs +++ b/Extras/MonoDevelop.Autotools/SolutionMakefileHandler.cs @@ -32,16 +32,7 @@ namespace MonoDevelop.Autotools // Recurses into children and tests if they are deployable. public bool CanDeploy ( CombineEntry entry ) { - Combine combine = entry as Combine; - - if ( combine == null ) return false; - foreach ( CombineEntry ce in combine.Entries ) - { - IMakefileHandler handler = AutotoolsContext.GetMakefileHandler ( ce ); - if ( handler == null ) return false; - if ( !handler.CanDeploy ( ce ) ) return false; - } - return true; + return entry is Combine; } public Makefile Deploy ( AutotoolsContext ctx, CombineEntry entry, IProgressMonitor monitor ) @@ -93,7 +84,7 @@ namespace MonoDevelop.Autotools { IMakefileHandler handler = AutotoolsContext.GetMakefileHandler ( ce ); Makefile makefile; - if ( handler.CanDeploy ( ce ) ) + if ( handler != null && handler.CanDeploy ( ce ) ) { makefile = handler.Deploy ( ctx, ce, monitor ); string outpath = Path.Combine(Path.GetDirectoryName(ce.FileName), "Makefile"); @@ -102,6 +93,9 @@ namespace MonoDevelop.Autotools writer.Close (); ctx.AddAutoconfFile ( outpath ); } + else { + monitor.Log .WriteLine("Project '{0}' skipped.", ce.Name); + } } monitor.Step (1); diff --git a/Extras/MonoDevelop.Autotools/TarballTargetEditorWidget.cs b/Extras/MonoDevelop.Autotools/TarballTargetEditorWidget.cs index 4c1940357f..85a2c4367a 100644 --- a/Extras/MonoDevelop.Autotools/TarballTargetEditorWidget.cs +++ b/Extras/MonoDevelop.Autotools/TarballTargetEditorWidget.cs @@ -9,7 +9,7 @@ namespace MonoDevelop.Autotools { public class TarballTargetEditorWidget : VBox { - public TarballTargetEditorWidget (TarballDeployTarget target) + public TarballTargetEditorWidget (TarballDeployTarget target, Combine targetCombine) { HBox dir_entry = new HBox (); @@ -34,29 +34,23 @@ namespace MonoDevelop.Autotools Label conlab = new Label ( GettextCatalog.GetString ("Default configuration:") ); config_box.PackStart (conlab, false, false, 0); - if ((target.DefaultConfiguration == null || target.DefaultConfiguration == "") && target.TargetCombine.ActiveConfiguration != null) - target.DefaultConfiguration = target.TargetCombine.ActiveConfiguration.Name; + if ((target.DefaultConfiguration == null || target.DefaultConfiguration == "") && targetCombine.ActiveConfiguration != null) + target.DefaultConfiguration = targetCombine.ActiveConfiguration.Name; ComboBox configs = ComboBox.NewText (); - for ( int ii=0; ii < target.TargetCombine.Configurations.Count; ii++ ) + for ( int ii=0; ii < targetCombine.Configurations.Count; ii++ ) { - string cc = target.TargetCombine.Configurations [ii].Name; + string cc = targetCombine.Configurations [ii].Name; configs.AppendText ( cc ); if ( cc == target.DefaultConfiguration ) configs.Active = ii; } configs.Changed += delegate (object s, EventArgs args) { - target.DefaultConfiguration = target.TargetCombine.Configurations [configs.Active].Name; + target.DefaultConfiguration = targetCombine.Configurations [configs.Active].Name; }; config_box.PackStart ( configs, true, true, 6 ); PackStart ( config_box, false, false, 6 ); - Label warning = new Label (); - warning.LineWrap = true; - string msg = GettextCatalog.GetString ( "Note: Deploying to a tarball will create a set of autotools files in the solution directory. It will also overwrite any existing autotools files." ); - warning.Markup = "<i>" + msg + "</i>" ; - PackStart ( warning, false, false, 6 ); - ShowAll (); } } diff --git a/Extras/MonoDevelop.Autotools/gtk-gui/gui.stetic b/Extras/MonoDevelop.Autotools/gtk-gui/gui.stetic index 44de8f1fa0..0e29a0f720 100644 --- a/Extras/MonoDevelop.Autotools/gtk-gui/gui.stetic +++ b/Extras/MonoDevelop.Autotools/gtk-gui/gui.stetic @@ -3,6 +3,7 @@ <import> <widget-library name="../../../build/AddIns/MonoDevelop.Components.dll" /> <widget-library name="../../../build/AddIns/MonoDevelop.Projects.Gui.dll" /> + <widget-library name="../../../build/AddIns/MonoDevelop.Deployment.dll" /> <widget-library name="../../../build/AddIns/MonoDevelop.Autotools/MonoDevelop.Autotools.dll" /> </import> <widget class="Gtk.Bin" id="MonoDevelop.Autotools.MakefileOptionPanelWidget" design-size="589 368"> diff --git a/Extras/MonoDevelop.Autotools/gtk-gui/objects.xml b/Extras/MonoDevelop.Autotools/gtk-gui/objects.xml index 09505dd727..d5e0d5920b 100644 --- a/Extras/MonoDevelop.Autotools/gtk-gui/objects.xml +++ b/Extras/MonoDevelop.Autotools/gtk-gui/objects.xml @@ -2,9 +2,20 @@ <object type="MonoDevelop.Autotools.MakefileOptionPanelWidget" palette-category="widget" allow-children="false"> <itemgroups> <itemgroup ref="Gtk.Widget" /> + <itemgroup label="Container Properties"> + <property name="BorderWidth" /> + <property name="FocusHadjustment" /> + <property name="FocusVadjustment" /> + </itemgroup> </itemgroups> <signals> <itemgroup ref="Gtk.Widget" /> + <itemgroup label="Container Signals"> + <signal name="ResizeChecked" /> + <signal name="Removed" /> + <signal name="FocusChildSet" /> + <signal name="Added" /> + </itemgroup> </signals> </object> </objects>
\ No newline at end of file diff --git a/Extras/MonoDevelop.Autotools/templates/Makefile.include b/Extras/MonoDevelop.Autotools/templates/Makefile.include index 1209632c2a..700cbaaca8 100644 --- a/Extras/MonoDevelop.Autotools/templates/Makefile.include +++ b/Extras/MonoDevelop.Autotools/templates/Makefile.include @@ -6,19 +6,17 @@ build_references_ref = $(REFERENCES) build_references_ref += $(foreach ref, $(DLL_REFERENCES), -r:$(ref)) build_references_ref += $(foreach ref, $(PROJECT_REFERENCES), -r:$(ref)) -pc_files = $(PC_FILES_IN:.pc.in=.pc) - build_datafiles = $(addprefix $(BUILD_DIR)/, $(DATA_FILES)) $(build_datafiles): $(BUILD_DIR)/% : $(addprefix $(srcdir)/, %) mkdir -p $(dir $@) cp $< $@ -EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(PC_FILES_IN) +EXTRA_DIST = $(FILES) $(GENERATED_FILES) $(RESOURCES) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(DLL_REFERENCES) DISTCLEANFILES = $(GENERATED_FILES) $(build_datafiles) $(pc_files) pkglib_SCRIPTS = $(ASSEMBLY) $(build_datafiles) -bin_SCRIPTS = $(ASSEMBLY_WRAPPER) -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = $(pc_files) +bin_SCRIPTS = $(BINARIES) + +%%DEPLOY_DIRS%%
\ No newline at end of file |