3 using System.Collections;
4 using System.Collections.Specialized;
6 using SysGen.BuildEngine.Attributes;
7 using SysGen.BuildEngine.Log;
9 namespace SysGen.BuildEngine.Tasks
12 public class IfTask : TaskContainer
14 protected string _propName = null;
15 protected string _propValue = null;
16 protected string _propNameTrue = null;
17 protected string _propNameExists = null;
20 /// Used to test whether a property is true.
22 [TaskAttribute("propertytrue")]
23 public string PropertyNameTrue {
24 set {_propNameTrue = value;}
28 /// Used to test whether a property exists.
30 [TaskAttribute("propertyexists")]
31 public string PropertyNameExists {
32 set {_propNameExists = value;}
36 /// Used to test whether a property exists.
38 [TaskAttribute("property")]
39 public string PropertyName
41 set { _propName = value; }
45 /// Used to test whether a property exists.
47 [TaskAttribute("value")]
48 public string PropertyValue
50 set { _propValue = value; }
53 protected override void PreExecuteTask()
57 m_ExecuteChilds = false;
62 protected override void ExecuteTask() {
64 m_ExecuteChilds = false;
68 protected virtual bool ConditionsTrue
74 if (_propName != null)
76 if (_propValue != null)
78 if (SysGen.Project.Properties.PropertyExists(_propName))
80 return (SysGen.Project.Properties[_propName].Value == _propValue);
87 ret = ret && SysGen.Project.Properties.PropertyExists(_propNameExists);
92 //if(_targetName != null) {
93 // ret = ret && (SysGen.Targets.Find(_targetName) != null);
94 // if (!ret) return false;
97 //Check for the Property value of true.
98 if (_propNameTrue != null)
102 ret = ret && bool.Parse(SysGen.Project.Properties[_propNameTrue].Value);
106 throw new BuildException("Property True test failed for '" + _propNameTrue + "'", Location, e);
110 //Check for Property existence
111 if(_propNameExists != null)
113 ret = ret && SysGen.Project.Properties.PropertyExists(_propNameExists);
116 ////check for uptodate file
117 //if(_uptodateFile != null) {
118 // FileInfo primaryFile = new FileInfo(_uptodateFile);
119 // if(primaryFile == null) {
123 // string newerFile = FileSet.FindMoreRecentLastWriteTime(_compareFiles.FileNames, primaryFile.LastWriteTime);
124 // bool bNeedsAnUpdate = (null == newerFile);
125 // BuildLog.WriteLineIf(SysGen.Verbose && bNeedsAnUpdate, "{0) is newer than {1}" , newerFile, primaryFile.Name);
126 // ret = !bNeedsAnUpdate;