commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r829848 - in /commons/sandbox/runtime/trunk/src/main/native: ./ build/org/apache/commons/runtime/
Date Mon, 26 Oct 2009 16:12:06 GMT
Author: mturk
Date: Mon Oct 26 16:12:05 2009
New Revision: 829848

URL: http://svn.apache.org/viewvc?rev=829848&view=rev
Log:
Add sequence task (conditional sequential)

Added:
    commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalSequence.java
  (with props)
Modified:
    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/FormattedEchoTask.java
    commons/sandbox/runtime/trunk/src/main/native/configure.xml

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=829848&r1=829847&r2=829848&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 16:12:05 2009
@@ -57,22 +57,22 @@
 
     public void addAnd(And cond)
     {
-        conditions.add(cond);
+        conditions.addElement(cond);
     }
 
     public void addNot(Not cond)
     {
-        conditions.add(cond);
+        conditions.addElement(cond);
     }
 
     public void addOr(Or cond)
     {
-        conditions.add(cond);
+        conditions.addElement(cond);
     }
 
     public void addSystemId(SystemIdTask cond)
     {
-        conditions.add(cond);
+        conditions.addElement(cond);
     }
 
     public void execute()

Added: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalSequence.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalSequence.java?rev=829848&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalSequence.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalSequence.java
Mon Oct 26 16:12:05 2009
@@ -0,0 +1,92 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.runtime;
+
+import java.util.Properties;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.PropertyHelper;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Sequential;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.apache.tools.ant.taskdefs.condition.ConditionBase;
+
+/**
+ */
+public class ConditionalSequence extends Sequential
+{
+
+    private String            property;
+    private String            equals;
+    private String            not;
+
+    public ConditionalSequence()
+    {
+        super();
+        property    = null;
+        equals      = null;
+        not         = null;
+    }
+
+    public void setIf(String property)
+    {
+        this.property = property;
+    }
+
+    public void setEquals(String value)
+    {
+        equals = value;
+    }
+
+    public void setNot(String value)
+    {
+        not = value;
+    }
+
+    public void execute()
+        throws BuildException
+    {
+        int cnt = 0;
+        if (property != null)
+            cnt++;
+        if (equals != null)
+            cnt++;
+        if (not != null)
+            cnt++;
+        if (cnt == 0) {
+            super.execute();
+            return;
+        }
+        if (cnt == 1) {
+            throw new BuildException("Required attribute is missing");
+        }
+        if (cnt == 3) {
+            throw new BuildException("Too many attributes declared");
+        }
+        String val = getProject().getProperty(property);
+        if (val != null) {
+            if (equals != null) {
+                if (val.equals(equals))
+                    super.execute();
+            }
+            else if (not != null) {
+                if (!val.equals(not))
+                    super.execute();
+            }
+        }
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/ConditionalSequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/FormattedEchoTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/FormattedEchoTask.java?rev=829848&r1=829847&r2=829848&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/FormattedEchoTask.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/build/org/apache/commons/runtime/FormattedEchoTask.java
Mon Oct 26 16:12:05 2009
@@ -29,11 +29,13 @@
 {
 
     private String format;
+    private String defval;
 
     public FormattedEchoTask()
     {
         super();
         format = null;
+        defval = null;
     }
 
     public void setFormat(String format)
@@ -41,6 +43,11 @@
         this.format = format;
     }
 
+    public void setDefault(String defval)
+    {
+        this.defval = defval;
+    }
+
 
     public void execute()
         throws BuildException
@@ -50,6 +57,15 @@
                 StringBuilder sb = new StringBuilder();
                 Formatter    fmt = new Formatter(sb);
                 String []     ma = message.split(" : ");
+                for (int i = 0; i < ma.length; i++) {
+                    if (ma[i].startsWith("${")) {
+                        if (defval != null)
+                            ma[i] = defval;
+                         else
+                            ma[i] = "0";
+
+                    }
+                }
                 fmt.format(format, (Object [])ma);
                 message = sb.toString();
             }

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=829848&r1=829847&r2=829848&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure.xml (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure.xml Mon Oct 26 16:12:05 2009
@@ -82,6 +82,10 @@
             classname="${build.package.name}.ConditionalTask">
             <classpath refid="task.classpath"/>
         </taskdef>
+        <taskdef name="sequence"
+            classname="${build.package.name}.ConditionalSequence">
+            <classpath refid="task.classpath"/>
+        </taskdef>
         <taskdef name="uuid"
             classname="${build.package.name}.UuidTask">
             <classpath refid="task.classpath"/>
@@ -104,7 +108,7 @@
 
     <macrodef name="sizeof">
         <attribute name="check"/>
-        <attribute name="result" default="sizeof.@{check}"/>
+        <attribute name="result" default="config.sizeof.@{check}"/>
         <sequential>
         <echo file="${src.native}/cc${build.tstamp}.c" append="false">/* Created by
Apache Ant */
 #include &lt;stdio.h&gt;
@@ -135,9 +139,73 @@
             </fileset>
         </delete>
         <property name="@{result}" value="0"/>
-        <print format="%1$-35s %2$s" message="Checking for sizeof(@{check}) : ${@{result}}"/>
+        <print format="%1$-45s %2$s" message="Checking for sizeof(@{check}) : ${@{result}}"/>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="have-include">
+        <attribute name="check"/>
+        <attribute name="result" default="config.have.@{check}"/>
+        <sequential>
+        <echo file="${src.native}/cc${build.tstamp}.c" append="false">/* Created by
Apache Ant */
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;@{check}.h&gt;
+int main() {printf("1");return 0;}
+    </echo>
+        <cexec dir="${src.native}" executable="cl" output="cc${build.tstamp}.log"
+              resultproperty="have.err">
+            <and>
+                <systemid equals="windows"/>
+                <equals arg1="${cc}" arg2="cl"/>
+            </and>
+            <arg line="-nologo"/>
+            <arg line="cc${build.tstamp}.c /link /out:cc${build.tstamp}.exe"/>
+        </cexec>
+        <conditional variable="@{result}" value="ok" else="not found">
+            <equals arg1="${have.err}" arg2="0"/>
+        </conditional>
+        <delete>
+            <fileset dir="${src.native}">
+                <filename name="cc${build.tstamp}*" />
+            </fileset>
+        </delete>
+        <property name="@{result}" value="0"/>
+        <print format="%1$-45s %2$s" message="Checking for &lt;@{check}.h&gt;
: ${@{result}}"/>
+        </sequential>
+    </macrodef>
+
+    <macrodef name="have-library">
+        <attribute name="check"/>
+        <attribute name="result" default="have.lib.@{check}"/>
+        <sequential>
+        <echo file="${src.native}/cc${build.tstamp}.c" append="false">/* Created by
Apache Ant */
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+int main() {printf("1");return 0;}
+    </echo>
+        <cexec dir="${src.native}" executable="cl" output="cc${build.tstamp}.log"
+              resultproperty="have.err">
+            <and>
+                <systemid equals="windows"/>
+                <equals arg1="${cc}" arg2="cl"/>
+            </and>
+            <arg line="-nologo"/>
+            <arg line="cc${build.tstamp}.c /link /out:cc${build.tstamp}.exe @{check}.lib"/>
+        </cexec>
+        <conditional variable="@{result}" value="ok" else="not found">
+            <equals arg1="${have.err}" arg2="0"/>
+        </conditional>
+        <delete>
+            <fileset dir="${src.native}">
+                <filename name="cc${build.tstamp}*" />
+            </fileset>
+        </delete>
+        <property name="@{result}" value="0"/>
+        <print format="%1$-45s %2$s" message="Checking for @{check} library : ${@{result}}"/>
         </sequential>
     </macrodef>
+
     <target name="test1">
         <property name="foo" value="bar" />
         <variable name="foo" value="-D__${systemid.CPU}__" />
@@ -188,9 +256,16 @@
             </and>
         </conditional>
         <echo message="check1 = ${check1}"/>
-        <sizeof check="int" result="sizeof.int">
-        </sizeof>
-        <sizeof check="__int64" result="sizeof.void">
-        </sizeof>
+        <sizeof check="int"/>
+        <sizeof check="long long" result="config.sizeof.longlong"/>
+        <sequence if="systemid.os" not="windows">
+            <have-include check="unistd"/>
+        </sequence>
+        <sequence if="systemid.os" equals="windows">
+            <have-include check="windows"/>
+            <have-library check="bufferoverflow"/>
+            <have-library check="ktmw32"/>            
+        </sequence>
+        <print format="#define HAVE_UNISTD      %1s" message="${config.have.unistd}"/>
     </target>
 </project>



Mime
View raw message