2006-03-18 Crestez Leonard <cdleonard@gmail.com>
authorMarek Sieradzki <msierad@mono-cvs.ximian.com>
Sat, 18 Mar 2006 12:03:06 +0000 (12:03 -0000)
committerMarek Sieradzki <msierad@mono-cvs.ximian.com>
Sat, 18 Mar 2006 12:03:06 +0000 (12:03 -0000)
* Project.cs: Cleaned up add.
* Expression.cs: Hacked to transform \ and / to path separators.
* BuildPropertyGroup.cs: Small cleanup.
* BuildTask.cs, TaskEngine.cs: Fix TaskEngine not getting a Project
reference.

svn path=/trunk/mcs/; revision=58135

mcs/class/Microsoft.Build.Engine/Assembly/AssemblyInfo.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildPropertyGroup.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Expression.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs

index e0db3565b7c8aa5997b270bc3a9d7c91d308b565..b59d965a1a36a55d26127fb953c5284ca1a8d75c 100644 (file)
@@ -52,7 +52,7 @@ using System.Runtime.InteropServices;
 [assembly: NeutralResourcesLanguage("en-US")]
 
 [assembly: ComVisible(false)]
-[assembly: AllowPartiallyTrustedCallers]
+//[assembly: AllowPartiallyTrustedCallers]
 
 [assembly: AssemblyDelaySign(true)]
 [assembly: AssemblyKeyFile("../msfinal.pub")]
index f20c1e947cb8d436fe516b8a7cbace8399a04f66..a8a823040425b8a562cb829d2d5a92e22dbef83c 100644 (file)
@@ -38,8 +38,6 @@ namespace Microsoft.Build.BuildEngine {
        public class BuildPropertyGroup : IEnumerable {
        
                XmlElement              propertyGroup;
-               XmlAttribute            condition;
-               string                  importedFromFilename;
                bool                    isImported;
                GroupingCollection      parentCollection;
                Project                 parentProject;
@@ -47,21 +45,20 @@ namespace Microsoft.Build.BuildEngine {
                IDictionary             propertiesByName;
        
                public BuildPropertyGroup ()
-                       : this (true, null)
+                       : this (null, null)
                {
                }
-               
-               internal BuildPropertyGroup (bool forXml, Project project)
+
+               internal BuildPropertyGroup (XmlElement xmlElement, Project project)
                {
                        this.propertyGroup = null;
-                       this.condition = null;
-                       this.importedFromFilename = null;
                        this.isImported = false;
                        this.parentCollection = null;
                        this.parentProject = project;
-                       if (forXml == true)
+                       if (xmlElement != null) {
                                this.properties = new ArrayList ();
-                       else
+                               BindToXml(xmlElement);
+                       } else
                                this.propertiesByName = CollectionsUtil.CreateCaseInsensitiveHashtable ();
                }
 
@@ -183,14 +180,12 @@ namespace Microsoft.Build.BuildEngine {
                        ((BuildProperty) propertiesByName [propertyName]).Value = propertyValue;
                }
                
-               internal void BindToXml (XmlElement propertyGroupElement)
+               private void BindToXml (XmlElement propertyGroupElement)
                {
                        if (propertyGroupElement == null)
                                throw new ArgumentNullException ();
                        this.properties = new ArrayList ();
                        this.propertyGroup = propertyGroupElement;
-                       this.condition = propertyGroupElement.GetAttributeNode ("Condition");
-                       this.importedFromFilename = null;
                        this.isImported = false;
                        foreach (XmlElement xe in propertyGroupElement.ChildNodes) {
                                BuildProperty bp = AddNewProperty(xe.Name, xe.InnerText);
@@ -204,14 +199,10 @@ namespace Microsoft.Build.BuildEngine {
                
                public string Condition {
                        get {
-                               if (condition == null)
-                                       return null;
-                               else
-                                       return condition.Value;
+                               return propertyGroup.GetAttribute("Condition");
                        }
                        set {
-                               if (condition != null)
-                                       condition.Value = value;
+                               propertyGroup.SetAttribute("Condition", value);
                        }
                }
 
@@ -226,12 +217,6 @@ namespace Microsoft.Build.BuildEngine {
                        }
                }
 
-               internal string ImportedFromFilename {
-                       get {
-                               return importedFromFilename;
-                       }
-               }
-
                public bool IsImported {
                        get {
                                return isImported;
@@ -258,4 +243,4 @@ namespace Microsoft.Build.BuildEngine {
        }
 }
 
-#endif
\ No newline at end of file
+#endif
index 2d884350d30ba5543f9c9fa604dc0c0ec363b611..d9c3a5b171e151ceb10b04d441b1298a5b978df1 100644 (file)
@@ -82,7 +82,7 @@ namespace Microsoft.Build.BuildEngine {
 
                        LogTaskStarted ();
                        
-                       taskEngine = new TaskEngine ();
+                       taskEngine = new TaskEngine (parentTarget.Project);
                        
                        taskEngine.Prepare (InitializeTask (), this.taskElement,GetParameters (), this.Type);
                        
@@ -224,4 +224,4 @@ namespace Microsoft.Build.BuildEngine {
        }
 }
 
-#endif
\ No newline at end of file
+#endif
index c1acd4fdcdb32d2853ae6e05d56ae28f3bd8dfa6..637679a3d3dfc137d5113edbb5b6c1e395cf92eb 100644 (file)
@@ -1,3 +1,15 @@
+2006-03-18  Marek Sieradzki  <marek.sieradzki@gmail.com> 
+
+       * Engine.cs: API cleanup.
+
+2006-03-18  Crestez Leonard  <cdleonard@gmail.com>
+
+       * Project.cs: Cleaned up add.
+       * Expression.cs: Hacked to transform \ and / to path separators.
+       * BuildPropertyGroup.cs: Small cleanup.
+       * BuildTask.cs, TaskEngine.cs: Fix TaskEngine not getting a Project
+       reference.
+       
 2006-03-11  Marek Sieradzki  <marek.sieradzki@gmail.com> 
 
        * BatchingImpl.cs: Updated with BuildTask instead of TaskElement.
index 998b53f6840f0c6cd8aff2f76f645582bd80b817..f1d1dabf11dc550ac44113e7dc64d5a791f52924 100644 (file)
@@ -28,6 +28,7 @@
 #if NET_2_0
 
 using System;
+using System.IO;
 using System.Collections;
 using System.Text;
 using Microsoft.Build.Framework;
@@ -57,7 +58,10 @@ namespace Microsoft.Build.BuildEngine {
                        // FIXME: change StringBuilder to substrings 
                        if (source == null)
                                throw new ArgumentNullException ("source");                             
-                       
+
+                       // FIXME: hack
+                       source = source.Replace('/', Path.DirectorySeparatorChar);
+                       source = source.Replace('\\', Path.DirectorySeparatorChar);
                        StringBuilder temp = new StringBuilder ();
                        CharEnumerator it = source.GetEnumerator ();
                        EvaluationState eState = EvaluationState.Out;
@@ -374,4 +378,4 @@ namespace Microsoft.Build.BuildEngine {
        }
 }
 
-#endif
\ No newline at end of file
+#endif
index ee01bac55aa12f62f59ebda9030188da6a362c62..1489096cce6fca9cb729f468002bc0218face170 100644 (file)
@@ -61,6 +61,8 @@ namespace Microsoft.Build.BuildEngine {
                bool                            isReset;
                BuildItemGroupCollection        itemGroups;
                IDictionary                     importedProjects;
+               ImportCollection                imports;
+               string                          initialTargets;
                Engine                          parentEngine;
                BuildPropertyGroupCollection    propertyGroups;
                BuildPropertyGroup              reservedProperties;
@@ -68,9 +70,10 @@ namespace Microsoft.Build.BuildEngine {
                TaskDatabase                    taskDatabase;
                TargetCollection                targets;
                DateTime                        timeOfLastDirty;
+               UsingTaskCollection             usingTasks;
                IList                           usingTaskElements;
                XmlDocument                     xmlDocument;
-               XmlElement                      xmlElement;
+               //XmlElement                    xmlElement;
 
                public Project ()
                        : this (null)
@@ -85,7 +88,7 @@ namespace Microsoft.Build.BuildEngine {
                        evaluatedItemsByName = CollectionsUtil.CreateCaseInsensitiveHashtable ();
                        evaluatedItemsByNameIgnoringCondition = CollectionsUtil.CreateCaseInsensitiveHashtable ();
                        evaluatedItemsIgnoringCondition = new BuildItemGroup (this);
-                       evaluatedProperties = new BuildPropertyGroup (false, null);
+                       evaluatedProperties = new BuildPropertyGroup ();
                        groups = new GroupingCollection ();
                        itemGroups = new BuildItemGroupCollection (groups);
                        propertyGroups = new BuildPropertyGroupCollection (groups);
@@ -128,6 +131,20 @@ namespace Microsoft.Build.BuildEngine {
                        throw new NotImplementedException ();
                }
                
+               [MonoTODO]
+               public void AddNewUsingTaskFromAssemblyFile (string taskName,
+                                                            string assemblyFile)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public void AddNewUsingTaskFromAssemblyName (string taskName,
+                                                            string assemblyName)
+               {
+                       throw new NotImplementedException ();
+               }
+               
                [MonoTODO]
                public bool Build ()
                {
@@ -212,57 +229,44 @@ namespace Microsoft.Build.BuildEngine {
                        throw new NotImplementedException ();
                }
 
+               // Does the actual loading.
+               private void DoLoad (TextReader textReader)
+               {
+                       XmlReaderSettings settings = new XmlReaderSettings ();
+
+                       if (SchemaFile != null) {
+                               settings.Schemas.Add (null, SchemaFile);
+                               settings.ValidationType = ValidationType.Schema;
+                               settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);
+                       }
+
+                       XmlReader xmlReader = XmlReader.Create (textReader, settings);
+                       xmlDocument.Load (xmlReader);
+                       ProcessXml ();
+               }
+
                public void Load (string projectFileName)
                {
                        this.fullFileName = Path.GetFullPath (projectFileName);
-                       XmlSchemaCollection xmlSchemaCollection = null;
-                       XmlTextReader xmlTextReader = null;
-                       XmlValidatingReader xmlValidatingReader = null;
-                       
-                       if (this.schemaFile != null) {
-                               xmlSchemaCollection = new XmlSchemaCollection ();
-                               xmlSchemaCollection.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);
-                               xmlSchemaCollection.Add (null, this.schemaFile);
-                               if (xmlSchemaCollection.Count > 0) {
-                                       xmlTextReader = new XmlTextReader (projectFileName);
-                                       xmlValidatingReader = new XmlValidatingReader (xmlTextReader);
-                                       xmlValidatingReader.ValidationType = ValidationType.Schema;
-                                       xmlValidatingReader.Schemas.Add (xmlSchemaCollection);
-                                       xmlValidatingReader.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);
-                               }
-                       } else {
-                               xmlTextReader = new XmlTextReader (projectFileName);
-                       }
-                       if (xmlValidatingReader != null)
-                               xmlDocument.Load (xmlValidatingReader);
-                       else if (xmlTextReader != null)
-                               xmlDocument.Load (xmlTextReader);
-                       else
-                               throw new Exception ();
-                       xmlElement = xmlDocument.DocumentElement;
-                       if (xmlElement.Name != "Project")
-                               throw new InvalidProjectFileException ("Invalid root element.");
-                       if (xmlElement.GetAttributeNode ("DefaultTargets") != null)
-                               defaultTargets = xmlElement.GetAttribute ("DefaultTargets").Split (';');
-                       else
-                               defaultTargets = new string [0];
-                       
-                       ProcessElements (xmlElement, null);
-                       
-                       isDirty = false;
+                       DoLoad (new StreamReader (projectFileName));
                }
                
                [MonoTODO]
-               public void Load (TextWriter textWriter)
+               public void Load (TextReader textReader)
                {
                        throw new NotImplementedException ();
                }
 
-               public void LoadFromXml (XmlDocument projectXml)
+               [MonoTODO]
+               public void LoadXml (string projectXml)
+               {
+                       fullFileName = String.Empty;
+                       DoLoad  (new StringReader (projectXml));
+               }
+               
+               private void ProcessXml ()
                {
-                       fullFileName = "";
-                       xmlDocument = projectXml;
-                       xmlElement = xmlDocument.DocumentElement;
+                       XmlElement xmlElement = xmlDocument.DocumentElement;
                        if (xmlElement.Name != "Project")
                                throw new InvalidProjectFileException ("Invalid root element.");
                        if (xmlElement.GetAttributeNode ("DefaultTargets") != null)
@@ -292,12 +296,6 @@ namespace Microsoft.Build.BuildEngine {
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
-               public void RemoveAllPropertyGroupsByCondition (string condition)
-               {
-                       throw new NotImplementedException ();
-               }
-
                [MonoTODO]
                public void RemoveItem (BuildItem itemToRemove)
                {
@@ -394,6 +392,14 @@ namespace Microsoft.Build.BuildEngine {
                {
                        throw new NotImplementedException ();
                }
+               
+               [MonoTODO]
+               public void SetProperty (string propertyName,
+                                        string propertyValue)
+               {
+                       SetProperty (propertyName, propertyValue, "true",
+                               PropertyPosition.UseExistingOrCreateAfterLastPropertyGroup, false);
+               }
 
                [MonoTODO]
                public void SetProperty (string propertyName,
@@ -529,7 +535,6 @@ namespace Microsoft.Build.BuildEngine {
                        
                        string importedFile;
                        Expression importedFileExpr;
-                       ImportedProject ImportedProject;
 
                        importedFileExpr = new Expression (this, xmlElement.GetAttribute ("Project"));
                        importedFile = (string) importedFileExpr.ToNonArray (typeof (string));
@@ -567,8 +572,7 @@ namespace Microsoft.Build.BuildEngine {
                {
                        if (xmlElement == null)
                                throw new ArgumentNullException ("xmlElement");
-                       BuildPropertyGroup bpg = new BuildPropertyGroup (true, this);
-                       bpg.BindToXml (xmlElement);
+                       BuildPropertyGroup bpg = new BuildPropertyGroup (xmlElement, this);
                        propertyGroups.Add (bpg);
                }
                
@@ -597,9 +601,11 @@ namespace Microsoft.Build.BuildEngine {
                }
 
                public string DefaultTargets {
-                       get { return xmlElement.GetAttribute ("DefaultTargets"); }
+                       get {
+                               return xmlDocument.DocumentElement.GetAttribute ("DefaultTargets");
+                       }
                        set {
-                               xmlElement.SetAttribute ("DefaultTargets",value);
+                               xmlDocument.DocumentElement.SetAttribute ("DefaultTargets", value);
                                defaultTargets = value.Split (';');
                        }
                }
@@ -650,6 +656,15 @@ namespace Microsoft.Build.BuildEngine {
                public BuildItemGroupCollection ItemGroups {
                        get { return itemGroups; }
                }
+               
+               public ImportCollection Imports {
+                       get { return imports; }
+               }
+               
+               public string InitialTargets {
+                       get { return initialTargets; }
+                       set { initialTargets = value; }
+               }
 
                public Engine ParentEngine {
                        get { return parentEngine; }
@@ -671,6 +686,10 @@ namespace Microsoft.Build.BuildEngine {
                public DateTime TimeOfLastDirty {
                        get { return timeOfLastDirty; }
                }
+               
+               public UsingTaskCollection UsingTasks {
+                       get { return usingTasks; }
+               }
 
                [MonoTODO]
                public string Xml {
@@ -699,4 +718,4 @@ namespace Microsoft.Build.BuildEngine {
        }
 }
 
-#endif
\ No newline at end of file
+#endif
index 2f0337c9297136c5f8bff0c602ca622d775b9c89..e8f6065e64f31e611160539b4132ec8e31bb67de 100644 (file)
@@ -51,8 +51,9 @@ namespace Microsoft.Build.BuildEngine {
                        outputAttribute = typeof (Microsoft.Build.Framework.OutputAttribute);
                }
 
-               public TaskEngine ()
+               public TaskEngine (Project project)
                {
+                       parentProject = project;
                }
                
                public void Prepare (ITask task, XmlElement taskElement,
@@ -86,11 +87,7 @@ namespace Microsoft.Build.BuildEngine {
                
                public bool Execute ()
                {
-                       bool    result;
-                       
-                       result = task.Execute ();
-               
-                       return result;
+                       return task.Execute ();
                }
                
                public void PublishOutput ()
@@ -246,4 +243,4 @@ namespace Microsoft.Build.BuildEngine {
        }
 }
 
-#endif
\ No newline at end of file
+#endif