protected override void OnReadSolution(ProgressMonitor monitor, MonoDevelop.Projects.MSBuild.SlnFile file) { base.OnReadSolution(monitor, file); //Resolve project references try { MakefileData.ResolveProjectReferences(Solution.RootFolder, monitor); } catch (Exception e) { LoggingService.LogError(GettextCatalog.GetString( "Error resolving Makefile based project references for solution {0}", Solution.Name), e); monitor.ReportError(GettextCatalog.GetString( "Error resolving Makefile based project references for solution {0}", Solution.Name), e); } // All done, dispose myself Dispose(); }
protected override void Execute(IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration) { Project project = entry as Project; if (project == null) { base.Execute(monitor, entry, context, configuration); return; } MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.ExecuteTargetName)) { base.Execute(monitor, entry, context, configuration); return; } IConsole console = context.ConsoleFactory.CreateConsole(true); monitor.BeginTask(GettextCatalog.GetString("Executing {0}", project.Name), 1); try { ProcessWrapper process = Runtime.ProcessService.StartProcess("make", data.ExecuteTargetName, project.BaseDirectory, console.Out, console.Error, null); process.WaitForOutput(); monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", process.ExitCode)); monitor.Step(1); } catch (Exception e) { monitor.ReportError(GettextCatalog.GetString("Project could not be executed: "), e); return; } finally { monitor.EndTask(); console.Dispose(); } }
public override List<FilePath> GetItemFiles (SolutionEntityItem entry, bool includeReferencedFiles) { List<FilePath> col = base.GetItemFiles (entry, includeReferencedFiles); MakefileData data = entry.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; if (data == null || !data.SupportsIntegration || string.IsNullOrEmpty (data.AbsoluteMakefileName)) return col; col.Add (data.AbsoluteMakefileName); if (!string.IsNullOrEmpty (data.RelativeConfigureInPath)) { string file = Path.Combine (data.AbsoluteConfigureInPath, "configure.in"); if (!File.Exists (file)) file = Path.Combine (data.AbsoluteConfigureInPath, "configure.ac"); if (File.Exists (file)) col.Add (file); } return col; }
protected override void Clean(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration) { Project proj = entry as Project; if (proj == null) { base.Clean(monitor, entry, configuration); return; } MakefileData data = proj.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.CleanTargetName)) { base.Clean(monitor, entry, configuration); return; } monitor.BeginTask(GettextCatalog.GetString("Cleaning project"), 1); try { string baseDir = proj.BaseDirectory; ProcessWrapper process = Runtime.ProcessService.StartProcess(data.AbsoluteMakeCommand, data.CleanTargetName, baseDir, monitor.Log, monitor.Log, null); process.WaitForOutput(); if (process.ExitCode > 0) { throw new Exception(GettextCatalog.GetString("An unspecified error occurred while running '{0} {1}'", data.AbsoluteMakeCommand, data.CleanTargetName)); } monitor.Step(1); } catch (Exception e) { monitor.ReportError(GettextCatalog.GetString("Project could not be cleaned: "), e); return; } finally { monitor.EndTask(); } monitor.ReportSuccess(GettextCatalog.GetString("Project successfully cleaned")); }
public override WorkspaceItem LoadWorkspaceItem (IProgressMonitor monitor, string fileName) { WorkspaceItem item = base.LoadWorkspaceItem (monitor, fileName); Solution sol = item as Solution; if (sol != null) { //Resolve project references try { MakefileData.ResolveProjectReferences (sol.RootFolder, monitor); } catch (Exception e) { LoggingService.LogError (GettextCatalog.GetString ( "Error resolving Makefile based project references for solution {0}", sol.Name), e); monitor.ReportError (GettextCatalog.GetString ( "Error resolving Makefile based project references for solution {0}", sol.Name), e); } } return item; }
public ImportMakefileDialog(Project project, MakefileData tmpData, string name) { this.TransientFor = IdeApp.Workbench.RootWindow; this.project = project; Title = GettextCatalog.GetString("Makefile Project Import"); Modal = true; VBox box = new VBox(); box.Spacing = 6; Gtk.Label lab = new Gtk.Label(); lab.Wrap = true; lab.Xalign = 0; lab.WidthRequest = 500; lab.Text = GettextCatalog.GetString("MonoDevelop is going to create a project bound to a Makefile. Please enter the name you want to give to the new project."); box.PackStart(lab, false, false, 0); HBox hb = new HBox(); hb.Spacing = 6; hb.PackStart(new Gtk.Label(GettextCatalog.GetString("Project Name:")), false, false, 0); nameEntry = new Gtk.Entry(); nameEntry.Text = name; hb.PackStart(nameEntry, true, true, 0); box.PackStart(hb, false, false, 0); box.PackStart(new Gtk.HSeparator(), false, false, 0); optionsWidget = new MakefileOptionPanelWidget(this, project, tmpData); box.PackStart(optionsWidget, false, false, 0); box.BorderWidth = 6; this.VBox.PackStart(box, true, true, 0); this.AddButton(Gtk.Stock.Cancel, ResponseType.Cancel); this.AddButton(Gtk.Stock.Ok, ResponseType.Ok); ShowAll(); optionsWidget.SetImportMode(); }
protected override SolutionEntityItem LoadSolutionItem(IProgressMonitor monitor, string fileName) { SolutionEntityItem entry = base.LoadSolutionItem(monitor, fileName); if (entry == null) { return(null); } Project project = entry as Project; if (project == null) { return(entry); } //Project MakefileData data = entry.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; if (data == null) { return(entry); } monitor.BeginTask(GettextCatalog.GetString("Updating project from Makefile"), 1); try { data.OwnerProject = project; if (data.SupportsIntegration) { data.UpdateProject(monitor, false); } monitor.Step(1); } catch (Exception e) { monitor.ReportError(GettextCatalog.GetString( "Error loading Makefile for project {0}", project.Name), e); } finally { monitor.EndTask(); } entry.SetNeedsBuilding(false); return(entry); }
public void OnExclude() { //if all of the selection is already checked, then toggle checks them off //else it turns them on. hence we need to find if they're all checked, bool allChecked = true; foreach (ITreeNavigator node in CurrentNodes) { ProjectFile file = (ProjectFile)node.DataItem; if (file.Project != null) { MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData; if (data != null && data.IsFileIntegrationEnabled(file.BuildAction)) { if (data.IsFileExcluded(file.FilePath)) { allChecked = false; break; } } } } Set <SolutionEntityItem> projects = new Set <SolutionEntityItem> (); foreach (ITreeNavigator node in CurrentNodes) { ProjectFile file = (ProjectFile)node.DataItem; if (file.Project != null) { projects.Add(file.Project); MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData; if (data != null && data.IntegrationEnabled) { data.SetFileExcluded(file.FilePath, allChecked); } } } IdeApp.ProjectOperations.Save(projects); }
public override void Save (IProgressMonitor monitor, SolutionEntityItem entry) { base.Save (monitor, entry); Project project = entry as Project; if (project == null) return; MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; if (data == null || !data.SupportsIntegration) return; try { data.UpdateMakefile (monitor); } catch (Exception e) { LoggingService.LogError (GettextCatalog.GetString ("Error saving to Makefile ({0}) for project {1}", data.AbsoluteMakefileName, project.Name, e)); monitor.ReportError (GettextCatalog.GetString ( "Error saving to Makefile ({0}) for project {1}", data.AbsoluteMakefileName, project.Name), e); } }
public void OnUpdateExclude(CommandInfo cinfo) { bool anyChecked = false; bool allChecked = true; bool anyEnabled = false; bool allEnabled = true; foreach (ITreeNavigator node in CurrentNodes) { ProjectFile file = (ProjectFile)node.DataItem; if (file.Project != null) { MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData; if (data != null && data.IsFileIntegrationEnabled(file.BuildAction)) { anyEnabled = true; if (!data.IsFileExcluded(file.FilePath)) { anyChecked = true; } else { allChecked = false; } } else { allEnabled = false; } } } cinfo.Visible = anyEnabled; cinfo.Enabled = anyEnabled && allEnabled; cinfo.Checked = anyChecked; cinfo.CheckedInconsistent = anyChecked && !allChecked; }
public MakefileOptionPanelWidget(Window parentDialog, Project project, MakefileData tmpData) : this() { this.data = tmpData; this.parentDialog = parentDialog; isDotNetProject = (project is DotNetProject); if (!isDotNetProject) { // Disable all References combos etc for non-dotnet projects cbKeepRefSync.Sensitive = false; HandleKeepRefSyncClicked(cbKeepRefSync); } if (data == null) { //Use defaults data = new MakefileData(); data.OwnerProject = project; this.cbEnableMakefileIntegration.Active = false; FindExistingMakefile(project); this.fileEntryMakefilePath.DefaultPath = project.BaseDirectory; FillCompilerMessageCombo(); HandleEnableMakefileIntegrationClicked(false); //FIXME: Look for configure.in in parent dirs } else { this.fileEntryMakefilePath.Path = data.AbsoluteMakefileName; this.fileEntryMakefilePath.DefaultPath = data.AbsoluteMakefileName; this.cbEnableMakefileIntegration.Active = data.IntegrationEnabled; FillCompilerMessageCombo(); SetActiveVar(comboMessageType, data.MessageRegexName); HandleEnableMakefileIntegrationClicked(cbEnableMakefileIntegration.Active); } //FIXME: ResetAll : use for new data, use for new makefile //Load values this.fileEntryMakefilePath.BrowserTitle = GettextCatalog.GetString("Makefile"); this.cbKeepFilesSync.Active = data.BuildFilesVar.Sync; this.entryFilesPattern.Text = data.BuildFilesVar.Prefix; this.cbKeepDeployFilesSync.Active = data.DeployFilesVar.Sync; this.entryDeployFilesPattern.Text = data.DeployFilesVar.Prefix; this.cbKeepResourcesSync.Active = data.ResourcesVar.Sync; this.entryResourcesPattern.Text = data.ResourcesVar.Prefix; this.cbKeepOthersSync.Active = data.OthersVar.Sync; this.entryOthersPattern.Text = data.OthersVar.Prefix; if (data.BuildFilesVar.Sync || data.DeployFilesVar.Sync || data.ResourcesVar.Sync || data.OthersVar.Sync) { // Enable File sync if any of the filevars are set to sync this.cbFileSync.Active = true; HandleFileSyncClicked(cbFileSync); } //References this.cbKeepRefSync.Active = data.SyncReferences; this.entryPackageRefPattern.Text = data.PackageRefVar.Prefix; this.entryAsmRefPattern.Text = data.AsmRefVar.Prefix; this.entryProjectRefPattern.Text = data.ProjectRefVar.Prefix; this.cbAutotoolsProject.Active = data.IsAutotoolsProject; HandleCbAutotoolsProjectClicked(cbAutotoolsProject); this.fileEntryConfigureInPath.Path = data.AbsoluteConfigureInPath; if (String.IsNullOrEmpty(data.AbsoluteConfigureInPath)) { this.fileEntryConfigureInPath.DefaultPath = project.ParentSolution.BaseDirectory; } else { this.fileEntryConfigureInPath.DefaultPath = data.AbsoluteConfigureInPath; } this.BuildTargetName.Text = data.BuildTargetName; this.ExecuteTargetName.Text = data.ExecuteTargetName; this.CleanTargetName.Text = data.CleanTargetName; spinProcesses.Value = data.ParallelProcesses; cbBuildTarget.Active = BuildTargetName.Sensitive = data.BuildTargetName != string.Empty; cbRunTarget.Active = ExecuteTargetName.Sensitive = data.ExecuteTargetName != string.Empty; cbCleanTarget.Active = CleanTargetName.Sensitive = data.CleanTargetName != string.Empty; HandleComboMessageTypeChanged(comboMessageType); this.fileEntryMakefilePath.FocusChildSet += new FocusChildSetHandler(OnMakefilePathFocusChildSet); ((Gtk.Container)comboAssemblyName.Parent).Remove(comboAssemblyName); ((Gtk.Container)lblAssemblyNameVar.Parent).Remove(lblAssemblyNameVar); ((Gtk.Container)comboOutputDir.Parent).Remove(comboOutputDir); ((Gtk.Container)lblOutputDirVar.Parent).Remove(lblOutputDirVar); loading = false; }
// Handle unique deploy files, emits non-perconfig stuff, like targets for deploy files, // un/install commands void HandleDeployFile(DeployFileData data, string targetDeployVar, Project project, AutotoolsContext ctx) { DeployFile dfile = data.File; string dependencyDeployFile = null; //Dependency for the deployfile target if (dfile.ContainsPathReferences) { // Template file, copy to .in file string full_fname = Path.Combine(project.BaseDirectory, Path.GetFileName(dfile.RelativeTargetPath)); string fname = full_fname; string infname = fname + ".in"; if (File.Exists(infname) && project.IsFileInProject(infname)) { string datadir = Path.Combine(project.BaseDirectory, "data"); if (!Directory.Exists(datadir)) { Directory.CreateDirectory(datadir); } infname = Path.Combine(datadir, Path.GetFileName(dfile.RelativeTargetPath) + ".in"); } //Absolute path required File.Copy(dfile.SourcePath, infname, true); //Path relative to TargetCombine fname = FileService.NormalizeRelativePath( FileService.AbsoluteToRelativePath(ctx.TargetSolution.BaseDirectory, full_fname)); infname = fname + ".in"; ctx.AddAutoconfFile(MakefileData.ToMakefilePath(fname)); ctx.AddGeneratedFile(full_fname + ".in"); //Path relative to project fname = FileService.NormalizeRelativePath( FileService.AbsoluteToRelativePath(project.BaseDirectory, full_fname)); infname = fname + ".in"; extras.AppendFormat("\\\n\t{0} ", MakefileData.ToMakefilePath(infname)); //dependencyDeployFile here should be filename relative to the project dependencyDeployFile = fname; } else { dependencyDeployFile = String.Format("$({0}_SOURCE)", targetDeployVar); } builtFiles.Add(Path.GetFileName(dfile.RelativeTargetPath)); if (dfile.ContainsPathReferences) { deployFileCopyTargets.AppendFormat("$(eval $(call emit-deploy-wrapper,{0},{1}{2}))\n", targetDeployVar, MakefileData.ToMakefilePath(dependencyDeployFile), (dfile.FileAttributes & DeployFileAttributes.Executable) != 0 ? ",x" : String.Empty); } else { // The emit-deploy-target macro copies the deployable file to the output directory. // This is not needed if the file is already there (e.g. for an .mdb file) if (Path.GetFullPath(dfile.SourcePath) != Path.GetFullPath(Path.Combine(data.Configuration.OutputDirectory, dfile.RelativeTargetPath))) { deployFileCopyTargets.AppendFormat("$(eval $(call emit-deploy-target,{0}))\n", targetDeployVar); } } switch (dfile.TargetDirectoryID) { case TargetDirectory.Gac: // TODO break; default: string var; if (dfile.TargetDirectoryID != TargetDirectory.Binaries) { string ddir = FileService.NormalizeRelativePath(dfile.RelativeTargetPath.ParentDirectory.ToString().Trim('/', ' ')); if (ddir.Length > 0) { ddir = "/" + ddir; } var = ctx.GetDeployDirectoryVar(dfile.TargetDirectoryID + ddir); } else { var = "BINARIES"; } StringBuilder sb; if (!deployDirs.TryGetValue(var, out sb)) { sb = new StringBuilder(); deployDirs [var] = sb; } sb.AppendFormat("\\\n\t$({0}) ", targetDeployVar); break; } if (!generateAutotools) { string installDir = Path.GetDirectoryName(ctx.DeployContext.GetResolvedPath(dfile.TargetDirectoryID, dfile.RelativeTargetPath)); //FIXME: temp installDir = TranslateDir(installDir); if (!installDirs.Contains(installDir)) { installTarget.AppendFormat("\tmkdir -p '$(DESTDIR){0}'\n", installDir); installDirs.Add(installDir); } installTarget.AppendFormat("\t$(call cp,$({0}),$(DESTDIR){1})\n", targetDeployVar, installDir); uninstallTarget.AppendFormat("\t$(call rm,$({1}),$(DESTDIR){0})\n", installDir, targetDeployVar); } }
void ProcessProjectReferences(DotNetProject project, out string references, out string dllReferences, AutotoolsContext ctx) { StringWriter refWriter = new StringWriter(); StringWriter dllRefWriter = new StringWriter(); pkgs = new Set <SystemPackage> (); // grab pkg-config references foreach (ProjectReference reference in project.References) { if (reference.ReferenceType == ReferenceType.Package) { // Get pkg-config keys SystemPackage pkg = reference.Package; if (pkg != null && !pkg.IsCorePackage) { if (pkgs.Contains(pkg)) { continue; } pkgs.Add(pkg); refWriter.WriteLine(" \\"); if (generateAutotools) { refWriter.Write("\t$("); refWriter.Write(AutotoolsContext.GetPkgConfigVariable(pkg.Name)); refWriter.Write("_LIBS)"); } else { refWriter.Write("\t-pkg:{0}", pkg.Name); } pkgs.Add(pkg); } else { refWriter.WriteLine(" \\"); // store all refs for easy access AssemblyName assembly = SystemAssemblyService.ParseAssemblyName(reference.Reference); refWriter.Write("\t" + assembly.Name); refWriter.Write(""); } } else if (reference.ReferenceType == ReferenceType.Assembly) { string assemblyPath = Path.GetFullPath(reference.Reference); dllRefWriter.WriteLine(" \\"); dllRefWriter.Write("\t"); ctx.AddGlobalReferencedFile(MakefileData.ToMakefilePath(FileService.AbsoluteToRelativePath( Path.GetFullPath(ctx.BaseDirectory), assemblyPath))); dllRefWriter.Write(MakefileData.ToMakefilePath(FileService.AbsoluteToRelativePath( project.BaseDirectory, assemblyPath))); } else if (reference.ReferenceType == ReferenceType.Project) { continue; // handled per-config } else { throw new Exception(GettextCatalog.GetString("Project reference type '{0}' not supported yet", reference.ReferenceType.ToString())); } } references = refWriter.ToString(); dllReferences = dllRefWriter.ToString(); }
public Makefile Deploy(AutotoolsContext ctx, SolutionFolderItem entry, ProgressMonitor monitor) { generateAutotools = ctx.MakefileType == MakefileType.AutotoolsMakefile; monitor.BeginTask(GettextCatalog.GetString( "Creating {0} for Project {1}", generateAutotools ? "Makefile.am" : "Makefile", entry.Name), 1); Makefile makefile = new Makefile(); try { if (!CanDeploy(entry, generateAutotools ? MakefileType.AutotoolsMakefile : MakefileType.SimpleMakefile)) { throw new Exception(GettextCatalog.GetString("Not a deployable project.")); } Project project = entry as Project; TemplateEngine templateEngine = new TemplateEngine(); ISimpleAutotoolsSetup setup = FindSetupForProject(project); // Handle files to be deployed deployDirs = new Dictionary <string, StringBuilder> (); deployFileVars = new Dictionary <string, string> (); builtFiles = new List <string> (); deployFileCopyVars = new StringBuilder(); deployFileCopyTargets = new StringBuilder(); //used only for simple makefile generation templateFilesTargets = null; installTarget = null; installDeps = null; installDirs = null; uninstallTarget = null; // handle configuration specific variables conf_vars = new StringBuilder(); // grab all project files files = new StringBuilder(); res_files = new StringBuilder(); extras = new StringBuilder(); datafiles = new StringBuilder(); Set <string> extraFiles = new Set <string> (); string includes = String.Empty; string references, dllReferences; DotNetProject netProject = project as DotNetProject; ProcessProjectReferences(netProject, out references, out dllReferences, ctx); templateEngine.Variables["REFERENCES"] = references; templateEngine.Variables["DLL_REFERENCES"] = dllReferences; templateEngine.Variables["WARNING"] = "Warning: This is an automatically generated file, do not edit!"; if (entry is DotNetProject dotnetProject) { templateEngine.Variables ["RESGEN"] = "resgen"; } string pfpath = null; foreach (ProjectFile projectFile in project.Files) { pfpath = FileService.NormalizeRelativePath(projectFile.FilePath.ToRelative(project.BaseDirectory)); switch (projectFile.BuildAction) { case BuildAction.Compile: if (projectFile.Subtype != Subtype.Code) { continue; } files.AppendFormat("\\\n\t{0} ", MakefileData.ToMakefilePath(pfpath)); break; case BuildAction.Content: case BuildAction.None: extraFiles.Add(MakefileData.ToMakefilePath(pfpath)); break; case BuildAction.EmbeddedResource: if (!projectFile.FilePath.IsChildPathOf(ctx.BaseDirectory)) { // file is not within directory hierarchy, copy it in string rdir = Path.Combine(Path.GetDirectoryName(project.FileName), resourcedir); if (!Directory.Exists(rdir)) { Directory.CreateDirectory(rdir); } string newPath = Path.Combine(rdir, Path.GetFileName(projectFile.FilePath)); FileService.CopyFile(projectFile.FilePath, newPath); pfpath = project.GetRelativeChildPath(newPath); pfpath = FileService.NormalizeRelativePath(pfpath); } if (!String.IsNullOrEmpty(projectFile.ResourceId) && projectFile.ResourceId != Path.GetFileName(pfpath)) { res_files.AppendFormat("\\\n\t{0},{1} ", MakefileData.ToMakefilePath(pfpath), MakefileData.EscapeString(projectFile.ResourceId)); } else { res_files.AppendFormat("\\\n\t{0} ", MakefileData.ToMakefilePath(pfpath)); } break; case "FileCopy": datafiles.AppendFormat("\\\n\t{0} ", MakefileData.ToMakefilePath(pfpath)); break; } } if (!generateAutotools) { templateFilesTargets = new StringBuilder(); installTarget = new StringBuilder(); uninstallTarget = new StringBuilder(); installDeps = new StringBuilder(); installDirs = new List <string> (); customCommands = new StringBuilder(); string programFilesDir = ctx.DeployContext.GetDirectory(TargetDirectory.ProgramFiles); //FIXME:temp programFilesDir = TranslateDir(programFilesDir); installDirs.Add(programFilesDir); installTarget.Append("\tmake pre-install-local-hook prefix=$(prefix)\n"); installTarget.Append("\tmake install-satellite-assemblies prefix=$(prefix)\n"); installTarget.AppendFormat("\tmkdir -p '$(DESTDIR){0}'\n", programFilesDir); installTarget.AppendFormat("\t$(call cp,$(ASSEMBLY),$(DESTDIR){0})\n", programFilesDir); installTarget.AppendFormat("\t$(call cp,$(ASSEMBLY_MDB),$(DESTDIR){0})\n", programFilesDir); //remove dir? uninstallTarget.Append("\tmake pre-uninstall-local-hook prefix=$(prefix)\n"); uninstallTarget.Append("\tmake uninstall-satellite-assemblies prefix=$(prefix)\n"); uninstallTarget.AppendFormat("\t$(call rm,$(ASSEMBLY),$(DESTDIR){0})\n", programFilesDir); uninstallTarget.AppendFormat("\t$(call rm,$(ASSEMBLY_MDB),$(DESTDIR){0})\n", programFilesDir); installDeps.Append(" $(ASSEMBLY) $(ASSEMBLY_MDB)"); conf_vars.AppendFormat("srcdir=.\n"); conf_vars.AppendFormat("top_srcdir={0}\n\n", FileService.AbsoluteToRelativePath(project.BaseDirectory, ctx.TargetSolution.BaseDirectory)); conf_vars.AppendFormat("include $(top_srcdir)/config.make\n\n"); // Don't emit for top level project makefile(eg. pdn.make), as it would be // included by top level solution makefile if (ctx.TargetSolution.BaseDirectory != project.BaseDirectory) { string customhooks = Path.Combine(project.BaseDirectory, "custom-hooks.make"); bool include = File.Exists(customhooks); includes = "include $(top_srcdir)/Makefile.include\n"; includes += String.Format("{0}include $(srcdir)/custom-hooks.make\n\n", include ? "" : "#"); if (include) { makefile.SetVariable("EXTRA_DIST", "$(srcdir)/custom-hooks.make"); } } } bool buildEnabled; List <ConfigSection> configSections = new List <ConfigSection> (); allDeployVars = new Dictionary <string, DeployFileData> (); foreach (SolutionConfiguration combineConfig in ctx.TargetSolution.Configurations) { DotNetProjectConfiguration config = GetProjectConfig(combineConfig.Id, project, out buildEnabled) as DotNetProjectConfiguration; if (config == null) { continue; } ConfigSection configSection = new ConfigSection(combineConfig.Id); string assembly = MakefileData.GetUnixPath(project.GetRelativeChildPath(config.CompiledOutputName)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY_COMPILER_COMMAND = {0}\n", setup.GetCompilerCommand(project, config.Id)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY_COMPILER_FLAGS = {0}\n", setup.GetCompilerFlags(project, config.Id)); // add check for compiler command in configure.ac ctx.AddCommandCheck(setup.GetCompilerCommand(project, config.Id)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY = {0}\n", AutotoolsContext.EscapeStringForAutomake(assembly)); configSection.BuildVariablesBuilder.AppendFormat("ASSEMBLY_MDB = {0}\n", config.DebugSymbols ? "$(ASSEMBLY).mdb" : String.Empty); string target; switch (config.CompileTarget) { case CompileTarget.Exe: target = "exe"; break; case CompileTarget.Library: target = "library"; break; case CompileTarget.WinExe: target = "winexe"; break; case CompileTarget.Module: target = "module"; break; default: throw new Exception(GettextCatalog.GetString("Unknown target {0}", config.CompileTarget)); } configSection.BuildVariablesBuilder.AppendFormat("COMPILE_TARGET = {0}\n", target); // for project references, we need a ref to the dll for the current configuration StringWriter projectReferences = new StringWriter(); string pref = null; foreach (ProjectReference reference in netProject.References) { if (reference.ReferenceType != ReferenceType.Project) { continue; } Project refp = reference.ResolveProject(ctx.TargetSolution); if (refp == null) { throw new Exception(GettextCatalog.GetString("Couldn't find referenced project '{0}'", reference.Reference)); } if (!(refp is DotNetProject)) { continue; } DotNetProjectConfiguration dnpc = GetProjectConfig(combineConfig.Id, refp, out buildEnabled) as DotNetProjectConfiguration; if (dnpc == null) { throw new Exception(GettextCatalog.GetString ("Could not add reference to project '{0}'", refp.Name)); } projectReferences.WriteLine(" \\"); projectReferences.Write("\t"); pref = project.GetRelativeChildPath(dnpc.CompiledOutputName); projectReferences.Write(MakefileData.ToMakefilePath(pref)); } configSection.BuildVariablesBuilder.AppendFormat("PROJECT_REFERENCES = {0}\n", projectReferences.ToString()); string buildDir = project.GetRelativeChildPath(config.OutputDirectory); configSection.BuildVariablesBuilder.AppendFormat("BUILD_DIR = {0}\n", MakefileData.ToMakefilePath(buildDir)); // Register files built by this configuration. // Built files won't be distributed. foreach (string bfile in builtFiles) { ctx.AddBuiltFile(Path.Combine(config.OutputDirectory, bfile)); } DeployFileCollection deployFiles = DeployService.GetDeployFiles( ctx.DeployContext, new SolutionFolderItem[] { project }, config.Selector); ProcessDeployFilesForConfig(deployFiles, project, configSection, ctx, config); configSections.Add(configSection); if (!generateAutotools) { EmitCustomCommandTargets(config.CustomCommands, project, customCommands, combineConfig.Id, new CustomCommandType [] { CustomCommandType.BeforeBuild, CustomCommandType.AfterBuild, CustomCommandType.BeforeClean, CustomCommandType.AfterClean }, monitor); } else { if (config.CustomCommands.Count > 0) { monitor.ReportWarning(GettextCatalog.GetString("Custom commands are not supported for autotools based makefiles. Ignoring.")); } } // Register files generated by the compiler ctx.AddBuiltFile(project.GetOutputFileName(combineConfig.Selector)); if (config.DebugSymbols) { ctx.AddBuiltFile(project.GetOutputFileName(combineConfig.Selector) + ".mdb"); } if (config.SignAssembly) { string spath = project.GetRelativeChildPath(config.AssemblyKeyFile); spath = FileService.NormalizeRelativePath(spath); extraFiles.Add(MakefileData.ToMakefilePath(spath)); } if (buildEnabled && pkgs.Count > 0) { ctx.AddRequiredPackages(combineConfig.Id, pkgs); } } foreach (string ef in extraFiles) { extras.AppendFormat("\\\n\t{0} ", ef); } Dictionary <string, DeployFileData> commonDeployVars = new Dictionary <string, DeployFileData> (allDeployVars); foreach (ConfigSection configSection in configSections) { List <string> toRemove = new List <string> (); foreach (KeyValuePair <string, DeployFileData> pair in commonDeployVars) { if (!configSection.DeployFileVars.ContainsKey(pair.Key)) { toRemove.Add(pair.Key); } } foreach (string s in toRemove) { commonDeployVars.Remove(s); } } //emit the config sections here.. to conf_vars foreach (ConfigSection configSection in configSections) { conf_vars.AppendFormat(generateAutotools ? "if ENABLE_{0}\n" : "ifeq ($(CONFIG),{0})\n", ctx.EscapeAndUpperConfigName(configSection.Name)); conf_vars.Append(configSection.BuildVariablesBuilder.ToString()); conf_vars.Append("\n"); if (ctx.Switches != null) { foreach (Switch s in ctx.Switches) { conf_vars.AppendLine(string.Format(@"if ENABLE_{0} ASSEMBLY_COMPILER_FLAGS += -define:{1} endif", s.SwitchName.Replace('-', '_').ToUpperInvariant(), s.Define)); } } foreach (KeyValuePair <string, DeployFileData> pair in allDeployVars) { string targetDeployVar = pair.Key; if (pair.Value.File.ContainsPathReferences) { //Template files are not handled per-config continue; } if (configSection.DeployFileVars.ContainsKey(targetDeployVar)) { //use the dfile from the config section DeployFile dfile = configSection.DeployFileVars [targetDeployVar]; string fname = MakefileData.ToMakefilePath( FileService.AbsoluteToRelativePath( Path.GetFullPath(project.BaseDirectory), Path.GetFullPath(dfile.SourcePath))); conf_vars.AppendFormat("{0}_SOURCE={1}\n", targetDeployVar, fname); if (!commonDeployVars.ContainsKey(targetDeployVar)) { //FOO_DLL=$(BUILD_DIR)/foo.dll conf_vars.AppendFormat("{0}=$(BUILD_DIR)/{1}\n", targetDeployVar, MakefileData.ToMakefilePath(dfile.RelativeTargetPath)); } } else { // not common and not part of @configSection conf_vars.AppendFormat("{0}=\n", pair.Key); } } conf_vars.Append("\nendif\n\n"); } conf_vars.AppendFormat("AL=al\n"); conf_vars.AppendFormat("SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll\n"); foreach (KeyValuePair <string, DeployFileData> pair in allDeployVars) { HandleDeployFile(pair.Value, pair.Key, project, ctx); if (commonDeployVars.ContainsKey(pair.Key)) { //FOO_DLL=$(BUILD_DIR)/foo.dll deployFileCopyVars.AppendFormat("{0} = $(BUILD_DIR)/{1}\n", pair.Key, MakefileData.ToMakefilePath(pair.Value.File.RelativeTargetPath)); } } conf_vars.Append('\n'); StringBuilder vars = new StringBuilder(); foreach (KeyValuePair <string, StringBuilder> pair in deployDirs) { //PROGRAM_FILES= .. etc conf_vars.AppendFormat("{0} = {1} \n\n", pair.Key, pair.Value.ToString()); //Build list of deploy dir variables vars.AppendFormat("$({0}) ", pair.Key); } if (!generateAutotools) { installTarget.Insert(0, String.Format("install-local:{0}\n", installDeps.ToString())); installTarget.Append("\tmake post-install-local-hook prefix=$(prefix)\n"); uninstallTarget.Insert(0, String.Format("uninstall-local:{0}\n", installDeps.ToString())); uninstallTarget.Append("\tmake post-uninstall-local-hook prefix=$(prefix)\n"); } if (!generateAutotools && customCommands.Length > 0) { customCommands.Insert(0, "# Targets for Custom commands\n"); } templateEngine.Variables["CONFIG_VARS"] = conf_vars.ToString(); templateEngine.Variables["DEPLOY_FILE_VARS"] = vars.ToString(); templateEngine.Variables["COPY_DEPLOY_FILES_VARS"] = deployFileCopyVars.ToString(); templateEngine.Variables["COPY_DEPLOY_FILES_TARGETS"] = deployFileCopyTargets.ToString(); templateEngine.Variables["ALL_TARGET"] = (ctx.TargetSolution.BaseDirectory == project.BaseDirectory) ? "all-local" : "all"; templateEngine.Variables["INCLUDES"] = includes; templateEngine.Variables["FILES"] = files.ToString(); templateEngine.Variables["RESOURCES"] = res_files.ToString(); templateEngine.Variables["EXTRAS"] = extras.ToString(); templateEngine.Variables["DATA_FILES"] = datafiles.ToString(); templateEngine.Variables["CLEANFILES"] = vars.ToString(); if (!generateAutotools) { templateEngine.Variables["TEMPLATE_FILES_TARGETS"] = templateFilesTargets.ToString(); templateEngine.Variables["INSTALL_TARGET"] = installTarget.ToString(); templateEngine.Variables["UNINSTALL_TARGET"] = uninstallTarget.ToString(); templateEngine.Variables["CUSTOM_COMMAND_TARGETS"] = customCommands.ToString(); } // Create project specific makefile Stream stream = ctx.GetTemplateStream( generateAutotools ? "Makefile.am.project.template" : "Makefile.noauto.project.template"); StreamReader reader = new StreamReader(stream); string txt = templateEngine.Process(reader); reader.Close(); makefile.Append(txt); monitor.Step(1); } finally { monitor.EndTask(); } return(makefile); }
public ProjectFileWrapper(ProjectFile file) { this.file = file; data = file.Project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; }
public ProjectFileWrapper(ProjectFile file) { this.file = file; data = file.Project.GetMakefileData(); }
//FIXME: Check whether autogen.sh is required or not protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration) { Project project = entry as Project; if (project == null) { return(base.Build(monitor, entry, configuration)); } MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty(data.BuildTargetName)) { return(base.Build(monitor, entry, configuration)); } //FIXME: Gen autofoo ? autoreconf? string output = String.Empty; int exitCode = 0; monitor.BeginTask(GettextCatalog.GetString("Building {0}", project.Name), 1); try { string baseDir = project.BaseDirectory; string args = string.Format("-j {0} {1}", data.ParallelProcesses, data.BuildTargetName); StringWriter swOutput = new StringWriter(); LogTextWriter chainedOutput = new LogTextWriter(); chainedOutput.ChainWriter(monitor.Log); chainedOutput.ChainWriter(swOutput); ProcessWrapper process = Runtime.ProcessService.StartProcess("make", args, baseDir, chainedOutput, chainedOutput, null); process.WaitForOutput(); exitCode = process.ExitCode; output = swOutput.ToString(); chainedOutput.Close(); swOutput.Close(); monitor.Step(1); } catch (Exception e) { monitor.ReportError(GettextCatalog.GetString("Project could not be built: "), e); return(null); } finally { monitor.EndTask(); } TempFileCollection tf = new TempFileCollection(); Regex regexError = data.GetErrorRegex(false); Regex regexWarning = data.GetWarningRegex(false); BuildResult cr = ParseOutput(tf, output, project.BaseDirectory, regexError, regexWarning); if (exitCode != 0 && cr.FailedBuildCount == 0) { cr.AddError(GettextCatalog.GetString("Build failed. See Build Output panel.")); } return(cr); }
public bool ValidateChanges(Project project) { data.IntegrationEnabled = this.cbEnableMakefileIntegration.Active; data.RelativeMakefileName = this.fileEntryMakefilePath.Path; data.BuildFilesVar.Sync = this.cbKeepFilesSync.Active; data.BuildFilesVar.Name = GetActiveVar(comboFilesVar); data.BuildFilesVar.Prefix = this.entryFilesPattern.Text.Trim(); data.DeployFilesVar.Sync = this.cbKeepDeployFilesSync.Active; data.DeployFilesVar.Name = GetActiveVar(comboDeployFilesVar); data.DeployFilesVar.Prefix = this.entryDeployFilesPattern.Text.Trim(); data.ResourcesVar.Sync = this.cbKeepResourcesSync.Active; data.ResourcesVar.Name = GetActiveVar(comboResourcesVar); data.ResourcesVar.Prefix = this.entryResourcesPattern.Text.Trim(); data.OthersVar.Sync = this.cbKeepOthersSync.Active; data.OthersVar.Name = GetActiveVar(comboOthersVar); data.OthersVar.Prefix = this.entryOthersPattern.Text.Trim(); if (!this.cbFileSync.Active) { // Files sync is unchecked, disable syncing of all files data.BuildFilesVar.Sync = false; data.DeployFilesVar.Sync = false; data.ResourcesVar.Sync = false; data.OthersVar.Sync = false; } // References data.SyncReferences = this.cbKeepRefSync.Active; data.PackageRefVar.Sync = this.cbKeepRefSync.Active; data.PackageRefVar.Name = GetActiveVar(comboPackageRefVar); data.PackageRefVar.Prefix = this.entryPackageRefPattern.Text.Trim(); data.AsmRefVar.Sync = this.cbKeepRefSync.Active; data.AsmRefVar.Name = GetActiveVar(comboAsmRefVar); data.AsmRefVar.Prefix = this.entryAsmRefPattern.Text.Trim(); data.ProjectRefVar.Sync = this.cbKeepRefSync.Active; data.ProjectRefVar.Name = GetActiveVar(comboProjectRefVar); data.ProjectRefVar.Prefix = this.entryProjectRefPattern.Text.Trim(); data.IsAutotoolsProject = this.cbAutotoolsProject.Active; if (this.cbAutotoolsProject.Active) { data.RelativeConfigureInPath = this.fileEntryConfigureInPath.Path; } //data.AssemblyNameVar = GetActiveVar (comboAssemblyName); //data.OutputDirVar = GetActiveVar (comboOutputDir); data.BuildTargetName = this.BuildTargetName.Text.Trim(); data.ExecuteTargetName = this.ExecuteTargetName.Text.Trim(); data.CleanTargetName = this.CleanTargetName.Text.Trim(); data.ParallelProcesses = this.spinProcesses.ValueAsInt; data.MessageRegexName = GetActiveVar(comboMessageType); if (data.MessageRegexName == "Custom") { data.CustomErrorRegex = this.entryErrorRegex.Text; data.CustomWarningRegex = this.entryWarningRegex.Text; } // Data validation MakefileData oldData = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData; MakefileData tmpData = data; if (tmpData.IntegrationEnabled) { //Validate try { tmpData.Makefile.GetVariables(); } catch (FileNotFoundException e) { ShowMakefileNotFoundError(e); return(false); } catch (Exception e) { MessageService.ShowException(parentDialog, e, GettextCatalog.GetString("Specified makefile is invalid: {0}", tmpData.AbsoluteMakefileName)); return(false); } if (tmpData.IsAutotoolsProject && !File.Exists(System.IO.Path.Combine(tmpData.AbsoluteConfigureInPath, "configure.in")) && !File.Exists(System.IO.Path.Combine(tmpData.AbsoluteConfigureInPath, "configure.ac"))) { MessageService.ShowError(parentDialog, GettextCatalog.GetString("Path specified for configure.in is invalid: {0}", tmpData.RelativeConfigureInPath)); return(false); } if (tmpData.SyncReferences && (String.IsNullOrEmpty(tmpData.PackageRefVar.Name) || String.IsNullOrEmpty(tmpData.AsmRefVar.Name) || String.IsNullOrEmpty(tmpData.ProjectRefVar.Name))) { MessageService.ShowError(parentDialog, GettextCatalog.GetString("'Sync References' is enabled, but one of Reference variables is not set. Please correct this.")); return(false); } if (!CheckNonEmptyFileVar(tmpData.BuildFilesVar, "Build")) { return(false); } if (!CheckNonEmptyFileVar(tmpData.DeployFilesVar, "Deploy")) { return(false); } if (!CheckNonEmptyFileVar(tmpData.ResourcesVar, "Resources")) { return(false); } if (!CheckNonEmptyFileVar(tmpData.OthersVar, "Others")) { return(false); } //FIXME: All file vars must be distinct try { tmpData.GetErrorRegex(true); } catch (Exception e) { MessageService.ShowError(parentDialog, GettextCatalog.GetString("Invalid regex for Error messages: {0}", e.Message)); return(false); } try { tmpData.GetWarningRegex(true); } catch (Exception e) { MessageService.ShowError(parentDialog, GettextCatalog.GetString( "Invalid regex for Warning messages: {0}", e.Message)); return(false); } //FIXME: Do this only if there are changes b/w tmpData and Data project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] = tmpData; IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor( GettextCatalog.GetString("Updating project"), "gtk-run", true); tmpData.UpdateProject(monitor, oldData == null || (!oldData.IntegrationEnabled && tmpData.IntegrationEnabled)); } else { if (oldData != null) { oldData.IntegrationEnabled = false; } } return(true); }