commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r829785 - in /commons/sandbox/runtime/trunk: ./ src/main/native/ src/main/native/build/org/apache/commons/runtime/
Date Mon, 26 Oct 2009 13:14:46 GMT
Author: mturk
Date: Mon Oct 26 13:14:45 2009
New Revision: 829785

URL: http://svn.apache.org/viewvc?rev=829785&view=rev
Log:
Unset result properties before executing the task

Modified:
    commons/sandbox/runtime/trunk/build.xml
    commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalExecTask.java
    commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalTask.java
    commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/VolatileProperty.java
    commons/sandbox/runtime/trunk/src/main/native/configure.xml

Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=829785&r1=829784&r2=829785&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Mon Oct 26 13:14:45 2009
@@ -95,7 +95,7 @@
         <echo message="build.dir    = ${build.dir}"/>
         <echo message="build.src    = ${build.src}"/>
         <echo message="src.native   = ${src.native}"/>
-        
+
     </target>
 
     <target name="prepare" depends="env">
@@ -180,7 +180,7 @@
             <classpath refid="task.classpath"/>
         </taskdef>
         <taskdef name="conditional"
-            classname="${build.package.name}.ConditionTask">
+            classname="${build.package.name}.ConditionalTask">
             <classpath refid="task.classpath"/>
         </taskdef>
         <taskdef name="uuid"
@@ -191,6 +191,14 @@
             classname="${build.package.name}.VolatileProperty">
             <classpath refid="task.classpath"/>
         </taskdef>
+        <taskdef name="cexec"
+            classname="${build.package.name}.ConditionalExecTask">
+            <classpath refid="task.classpath"/>
+        </taskdef>
+        <taskdef name="print"
+            classname="${build.package.name}.FormattedEchoTask">
+            <classpath refid="task.classpath"/>
+        </taskdef>
         <uuid property="build.uuid" />
         <systemid prefix="systemid" />
     </target>

Modified: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalExecTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalExecTask.java?rev=829785&r1=829784&r2=829785&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalExecTask.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalExecTask.java
Mon Oct 26 13:14:45 2009
@@ -17,7 +17,7 @@
 
 import java.util.Iterator;
 import java.util.Properties;
-import java.util.Vector; 
+import java.util.Vector;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.taskdefs.ConditionTask;
 import org.apache.tools.ant.taskdefs.ExecTask;
@@ -34,12 +34,27 @@
 
     /** Optional Vector holding the nested tasks */
     private Vector<Condition> conditions = new Vector<Condition>();
+    private String resultProperty = null;
+    private String outputProp     = null;
     private Condition cond;
+
     public ConditionalExecTask()
     {
         super();
     }
 
+    @Override
+    public void setOutputproperty(String outputProp) {
+        this.outputProp = outputProp;
+        super.setOutputproperty(outputProp);
+    }
+
+    @Override
+    public void setResultProperty(String resultProperty) {
+        this.resultProperty = resultProperty;
+        super.setResultProperty(resultProperty);
+    }
+
     public void addAnd(And cond)
     {
         conditions.add(cond);
@@ -66,14 +81,18 @@
         setFailonerror(true);
         setFailIfExecutionFails(true);
         boolean perform = true;
-        
+        // Always unset result properties
+        if (resultProperty != null)
+            VolatileProperty.unset(getProject(), resultProperty);
+        if (outputProp != null)
+            VolatileProperty.unset(getProject(), outputProp);
         for (Iterator<Condition> i = conditions.iterator(); i.hasNext();) {
             Condition c = i.next();
             if (!c.eval())
                 perform = false;
-        } 
+        }
         if (!perform) {
-            return;    
+            return;
         }
         try {
             super.execute();

Modified: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalTask.java?rev=829785&r1=829784&r2=829785&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalTask.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalTask.java
Mon Oct 26 13:14:45 2009
@@ -104,7 +104,7 @@
             if (target != null)
                 getProject().executeTarget(alternative);
             else {
-                VolatileProperty.set(getProject(), property, alternative, add);         
      
+                VolatileProperty.set(getProject(), property, alternative, add);
             }
         }
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/VolatileProperty.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/VolatileProperty.java?rev=829785&r1=829784&r2=829785&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/VolatileProperty.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/VolatileProperty.java
Mon Oct 26 13:14:45 2009
@@ -105,6 +105,16 @@
         prop.execute();
     }
 
+    public static void unset(Project project, String name)
+        throws BuildException
+    {
+        VolatileProperty prop = new VolatileProperty();
+        prop.setProject(project);
+        prop.setName(name);
+        prop.setUnset(true);
+        prop.execute();
+    }
+
     public void execute()
         throws BuildException
     {
@@ -121,7 +131,7 @@
             Hashtable properties = (Hashtable)getFieldValue(ph, "properties");
             if (properties.containsKey(getName())) {
                 properties.remove(getName());
-            }            
+            }
             return;
         }
         else if (getValue() != null) {

Modified: commons/sandbox/runtime/trunk/src/main/native/configure.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure.xml?rev=829785&r1=829784&r2=829785&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure.xml (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure.xml Mon Oct 26 13:14:45 2009
@@ -111,22 +111,23 @@
 #include &lt;stdlib.h&gt;
 #include &lt;sys/types.h&gt;
 #include &lt;wctype.h&gt;
-int main() {printf("%d", (int)sizeof(@{check}));return 0;} 
+int main() {printf("%d", (int)sizeof(@{check}));return 0;}
         </echo>
-        <variable unset="true" name="@{result}"/>
-        <variable unset="true" name="sizeof.res"/>
-        <variable unset="true" name="sizeof.err"/>
-        <cexec executable="cl" dir="${src.native}" output="cc${build.tstamp}.log"
+        <cexec dir="${src.native}" executable="cl" output="cc${build.tstamp}.log"
               resultproperty="sizeof.err">
-            <systemid equals="windows"/>
+            <and>
+                <systemid equals="windows"/>
+                <equals arg1="${cc}" arg2="cl"/>
+            </and>
             <arg line="-nologo"/>
-            <arg line="cc${build.tstamp}.c"/>
-            <arg line="/link /out:cc${build.tstamp}.exe"/>
+            <arg line="cc${build.tstamp}.c /link /out:cc${build.tstamp}.exe"/>
         </cexec>
-        <variable unset="true" name="sizeof.err"/>
         <cexec dir="${src.native}" executable="cc${build.tstamp}" outputproperty="@{result}"
               resultproperty="sizeof.err" error="cc${build.tstamp}.err">
-            <systemid equals="windows"/>
+            <and>
+                <systemid equals="windows"/>
+                <equals arg1="${sizeof.err}" arg2="0"/>
+            </and>
         </cexec>
         <delete>
             <fileset dir="${src.native}">



Mime
View raw message