| <?xml version="1.0"?> |
| <!-- |
| 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 |
| |
| https://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:au="antlib:org.apache.ant.antunit" |
| xmlns:dn="antlib:org.apache.ant.dotnet"> |
| |
| <import file="augment-path.xml"/> |
| |
| <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"/> |
| <property name="testCSC.exe" location="${build.dir}/ExampleCsc.exe" /> |
| |
| <target name="probe_for_apps" > |
| |
| <condition property="csc.found"> |
| <or> |
| <available file="csc" filepath="${augmented.PATH}"/> |
| <available file="csc.exe" filepath="${augmented.PATH}"/> |
| </or> |
| </condition> |
| <echo> csc.found=${csc.found}</echo> |
| |
| <!-- Mono C# compiler --> |
| <condition property="mcs.found"> |
| <available file="mcs" filepath="${augmented.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="setUp" depends="probe_for_apps"> |
| <mkdir dir="${build.dir}"/> |
| </target> |
| |
| <target name="tearDown"> |
| <delete dir="${build.dir}"/> |
| </target> |
| |
| <target name="validate_csc"> |
| <fail unless="c#.found">Needed C# compiler is missing</fail> |
| </target> |
| |
| <target name="testCSC" depends="validate_csc"> |
| <au:assertFileDoesntExist file="${testCSC.exe}"/> |
| <dn:csc |
| destFile="${testCSC.exe}" |
| targetType="exe"> |
| <src dir="${src.dir}" includes="ex*.cs"/> |
| </dn:csc> |
| <au:assertFileExists file="${testCSC.exe}"/> |
| <dn:dotnetexec executable="${testCSC.exe}" failonerror="true" /> |
| </target> |
| |
| <target name="testCSCNoConfig" depends="validate_csc"> |
| <dn:csc noconfig="true" useresponsefile="true" |
| destFile="${testCSC.exe}" |
| targetType="exe"> |
| <src dir="${src.dir}" includes="ex*.cs"/> |
| </dn:csc> |
| <au:assertLogContains text="/noconfig" level="verbose"/> |
| </target> |
| </project> |
| |