~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Autotools/Handler.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
using System;
3
3
using System.Text;
4
4
using System.Collections;
 
5
using System.Collections.Generic;
5
6
using System.IO;
6
7
 
7
8
using MonoDevelop.Core;
8
9
using MonoDevelop.Core.ProgressMonitoring;
9
10
using MonoDevelop.Projects;
10
 
using MonoDevelop.Projects.Serialization;
 
11
using MonoDevelop.Core.Serialization;
11
12
using MonoDevelop.Deployment;
12
13
using MonoDevelop.Deployment.Gui;
13
14
 
70
71
                        set { defaultConfig = value; }
71
72
                }
72
73
 
73
 
                public override bool CanBuild (CombineEntry entry)
 
74
                public override bool CanBuild (SolutionItem entry)
74
75
                {
75
76
                        SolutionDeployer deployer = new SolutionDeployer (generateAutotools);
76
77
                        return deployer.CanDeploy ( entry );
77
78
                }
78
79
                
79
 
                public override void InitializeSettings (CombineEntry entry)
 
80
                public override void InitializeSettings (SolutionItem entry)
80
81
                {
81
82
                        if (string.IsNullOrEmpty (targetDir))
82
83
                                targetDir = entry.BaseDirectory;
83
84
                        if (string.IsNullOrEmpty (defaultConfig)) {
84
 
                                if (entry.ActiveConfiguration != null)
85
 
                                        defaultConfig = entry.ActiveConfiguration.Name;
 
85
                                SolutionEntityItem se = entry as SolutionEntityItem;
 
86
                                defaultConfig = se != null ? se.GetConfigurations () [0] : null;
86
87
                        }
87
88
                        if (File.Exists (Path.Combine (entry.BaseDirectory, "autogen.sh")) ||
88
89
                            File.Exists (Path.Combine (entry.BaseDirectory, "configure"))) {
93
94
                }
94
95
 
95
96
                
96
 
                protected override void OnBuild (IProgressMonitor monitor, DeployContext ctx)
 
97
                protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx)
97
98
                {
98
99
                        string tmpFolder = FileService.CreateTempDirectory ();
99
 
                        Combine combine = null;
100
 
                        CombineEntry entry = RootCombineEntry;
 
100
                        Solution solution = null;
 
101
                        SolutionItem entry = RootSolutionItem;
101
102
                        
102
103
                        try {
103
104
                                if (generateFiles) {
104
 
                                        string[] childEntries;
105
 
                                        if (entry is Combine) {
106
 
                                                CombineEntry[] ents = GetChildEntries ();
107
 
                                                childEntries = new string [ents.Length];
108
 
                                                for (int n=0; n<ents.Length; n++)
109
 
                                                        childEntries [n] = ents [n].FileName;
 
105
                                        List<string> childEntries = new List<string> ();
 
106
                                        if (entry is SolutionFolder) {
 
107
                                                SolutionItem[] ents = GetChildEntries ();
 
108
                                                foreach (SolutionItem it in ents)
 
109
                                                        childEntries.Add (it.ItemId);
110
110
                                        }
111
111
                                        else {
112
112
                                                // If the entry is not a combine, use the parent combine as base combine
113
 
                                                childEntries = new string [] { entry.FileName };
114
 
                                                entry = entry.ParentCombine;
 
113
                                                childEntries.Add (entry.ItemId);
 
114
                                                entry = entry.ParentFolder;
115
115
                                        }
 
116
                                                        
 
117
                                        string sourceFile;
 
118
                                        if (entry is SolutionFolder)
 
119
                                                sourceFile = entry.ParentSolution.FileName;
 
120
                                        else
 
121
                                                sourceFile = ((SolutionEntityItem)entry).FileName;
116
122
                                        
117
 
                                        string efile = Services.ProjectService.Export (new FilteredProgressMonitor (monitor), entry.FileName, childEntries, tmpFolder, null);
 
123
                                        string efile = Services.ProjectService.Export (new FilteredProgressMonitor (monitor), sourceFile, childEntries.ToArray (), tmpFolder, null);
118
124
                                        if (efile == null) {
119
125
                                                monitor.ReportError (GettextCatalog.GetString ("The project could not be exported."), null);
120
 
                                                return;
 
126
                                                return false;
121
127
                                        }
122
 
                                        combine = Services.ProjectService.ReadCombineEntry (efile, new NullProgressMonitor ()) as Combine;
 
128
                                        solution = Services.ProjectService.ReadWorkspaceItem (new NullProgressMonitor (), efile) as Solution;
123
129
                                }
124
130
                                else {
125
 
                                        if (entry is Combine)
126
 
                                                combine = (Combine) entry;
127
 
                                        else 
128
 
                                                combine = entry.ParentCombine;
 
131
                                        solution = entry.ParentSolution;
129
132
                                }
130
133
                                
131
 
                                combine.Build (monitor);
 
134
                                solution.Build (monitor, defaultConfig);
132
135
                        
133
136
                                if (monitor.IsCancelRequested || !monitor.AsyncOperation.Success)
134
 
                                        return;
 
137
                                        return false;
135
138
                        
136
139
                                SolutionDeployer deployer = new SolutionDeployer (generateAutotools);
137
 
                                
138
 
                                if (DefaultConfiguration == null || DefaultConfiguration == "")
139
 
                                        deployer.Deploy ( ctx, combine, TargetDir, generateFiles, monitor );
140
 
                                else
141
 
                                        deployer.Deploy ( ctx, combine, DefaultConfiguration, TargetDir, generateFiles, monitor );
 
140
                                if (!deployer.Deploy ( ctx, solution, DefaultConfiguration, TargetDir, generateFiles, monitor ))
 
141
                                        return false;
142
142
                                
143
143
                        } finally {
144
 
                                if (combine != null)
145
 
                                        combine.Dispose ();
 
144
                                if (solution != null)
 
145
                                        solution.Dispose ();
146
146
                                Directory.Delete (tmpFolder, true);
147
147
                        }
 
148
                        return true;
148
149
                }
149
150
 
150
151
                protected override string OnResolveDirectory (DeployContext ctx, string folderId)