using System;
using System.Collections;
+using System.Collections.Generic;
+using System.IO;
using Microsoft.Build.Framework;
+using Mono.XBuild.Utilities;
namespace Microsoft.Build.BuildEngine {
public class Engine {
string binPath;
bool buildEnabled;
+ TaskDatabase defaultTasks;
+ bool defaultTasksRegistered;
+ const string defaultTasksProjectName = "Microsoft.Common.tasks";
EventSource eventSource;
bool buildStarted;
BuildPropertyGroup globalProperties;
- IDictionary importedProjects;
- IList loggers;
- bool onlyLogCriticalEvents;
- IDictionary projects;
+ //IDictionary importedProjects;
+ List <ILogger> loggers;
+ //bool onlyLogCriticalEvents;
+ Dictionary <string, Project> projects;
static Engine globalEngine;
static Version version;
{
this.binPath = binPath;
this.buildEnabled = true;
- this.projects = new Hashtable ();
+ this.projects = new Dictionary <string, Project> ();
this.eventSource = new EventSource ();
- this.loggers = new ArrayList ();
+ this.loggers = new List <ILogger> ();
this.buildStarted = false;
this.globalProperties = new BuildPropertyGroup ();
+
+ RegisterDefaultTasks ();
}
[MonoTODO]
bool result;
Project project;
- if (projects.Contains (projectFile)) {
+ if (projects.ContainsKey (projectFile)) {
project = (Project) projects [projectFile];
LogProjectStarted (project, targetNames);
result = project.Build (targetNames, targetOutputs);
+ } else {
+ project = CreateNewProject ();
+ project.Load (projectFile);
+ LogProjectStarted (project, targetNames);
+ result = project.Build (targetNames, targetOutputs);
}
- else
- return false;
LogProjectFinished (project, result);
public Project CreateNewProject ()
{
- CheckBinPath ();
+ if (defaultTasksRegistered)
+ CheckBinPath ();
// FIXME: I don't really know if it should be here
LogBuildStarted ();
return new Project (this);
if (projectFullFileName == null)
throw new ArgumentNullException ("projectFullFileName");
- return (Project) projects [projectFullFileName];
+ return projects [projectFullFileName];
}
internal void RemoveLoadedProject (Project p)
public void UnloadAllProjects ()
{
- foreach (DictionaryEntry e in projects)
- UnloadProject ((Project) e.Value);
+ foreach (KeyValuePair <string, Project> e in projects)
+ UnloadProject (e.Value);
}
[MonoTODO]
bfea = new BuildFinishedEventArgs ("Build finished.", null, succeeded);
eventSource.FireBuildFinished (this, bfea);
}
+
+ private void RegisterDefaultTasks ()
+ {
+ this.defaultTasksRegistered = false;
+
+ Project defaultTasksProject = CreateNewProject ();
+
+ if (binPath != null) {
+ if (File.Exists (Path.Combine (binPath, defaultTasksProjectName))) {
+ defaultTasksProject.Load (Path.Combine (binPath, defaultTasksProjectName));
+ defaultTasks = defaultTasksProject.TaskDatabase;
+ } else {
+ defaultTasks = new TaskDatabase ();
+ }
+ } else {
+ defaultTasks = new TaskDatabase ();
+ }
+
+ this.defaultTasksRegistered = true;
+ }
public string BinPath {
get { return binPath; }
internal EventSource EventSource {
get { return eventSource; }
}
+
+ internal bool DefaultTasksRegistered {
+ get { return defaultTasksRegistered; }
+ }
+
+ internal TaskDatabase DefaultTasks {
+ get { return defaultTasks; }
+ }
}
}