|
- <?xml version="1.0"?>
- <!--
- Copyright 2003-2004 The Apache Software Foundation
-
- Licensed 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.
- -->
-
- <project name="dotnet" basedir="." default="testCSC"
- xmlns:dn="antlib:org.apache.tools.ant.taskdefs.optional.dotnet">
-
- <property environment="env"/>
- <property name="build.dir" location="build"/>
- <property name="src.dir" location="src"/>
-
- <property name="out.csc" location="${src.dir}/out.cs"/>
- <property name="out.app" location="${build.dir}/out.exe"/>
- <property name="out.type" value="exe"/>
-
- <taskdef
- uri="antlib:org.apache.tools.ant.taskdefs.optional.dotnet"
- resource="org/apache/tools/ant/taskdefs/optional/dotnet/antlib.xml">
- <classpath>
- <pathelement location="../../../build/lib/dotnet.jar"/>
- </classpath>
- </taskdef>
-
- <target name="probe_for_apps" >
- <condition property="csc.found">
- <or>
- <available file="csc" filepath="${env.PATH}" />
- <available file="csc.exe" filepath="${env.PATH}" />
- <available file="csc.exe" filepath="${env.Path}" />
- </or>
- </condition>
- <echo> csc.found=${csc.found}</echo>
-
- <!-- Mono C# compiler -->
- <condition property="mcs.found">
- <available file="mcs" filepath="${env.PATH}" />
- </condition>
- <echo> mcs.found=${mcs.found}</echo>
-
- <!-- any C# compiler -->
- <condition property="c#.found">
- <or>
- <isset property="csc.found"/>
- <isset property="mcs.found"/>
- </or>
- </condition>
- </target>
-
- <target name="init" depends="probe_for_apps">
- <mkdir dir="${build.dir}"/>
- <property name="testCSC.exe"
- location="${build.dir}/ExampleCsc.exe" />
- </target>
-
- <target name="teardown">
- <delete dir="${build.dir}"/>
- </target>
-
- <target name="validate_csc" depends="init">
- <fail unless="c#.found">Needed C# compiler is missing</fail>
- </target>
-
- <target name="testCSC" depends="validate_csc">
- <csc
- destFile="${testCSC.exe}"
- targetType="exe">
- <src dir="${src.dir}" includes="ex*.cs"/>
- </csc>
- <available property="app.created" file="${testCSC.exe}"/>
- <fail unless="app.created">No app ${testCSC.exe} created</fail>
- <dn:dotnetexec executable="${testCSC.exe}" failonerror="true" />
- <delete file="${testCSC.exe}"/>
- </target>
-
- </project>
|