blob: cf5a6988f35602c49a7efd9894738000f594380f [file] [log] [blame]
<?xml version="1.0" encoding="utf-8" ?>
<!--
* 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. *
-->
<project name="etch.common" basedir="." >
<!-- Static properties -->
<property name="Etch.copyrightNotice" value="Copyright © Apache Software Foundation 2013" />
<!-- Compute top of tree -->
<condition property="Etch.basedir" value="${basedir}" >
<not><isset property="Etch.basedir" /></not>
</condition>
<property name="Etch.runtime.workspace" value="${Etch.basedir}" />
<!-- Load Environment -->
<property environment="env" />
<property file="${Etch.basedir}/build.dependencies" prefix="file" />
<property file="${Etch.basedir}/build.properties" prefix="build" />
<!-- Pull properties from commandline -->
<condition property="build.skip.tests" value="${skip.tests}">
<isset property="skip.tests" />
</condition>
<condition property="build.skip.examples" value="${skip.examples}">
<isset property="skip.examples" />
</condition>
<condition property="build.javacc.home" value="${javacc.home}" >
<isset property="javacc.home" />
</condition>
<condition property="build.junit.lib" value="${junit.lib}" >
<isset property="junit.lib" />
</condition>
<condition property="build.velocity.lib" value="${velocity.lib}" >
<isset property="velocity.lib" />
</condition>
<condition property="build.nsis.home" value="${nsis.home}" >
<isset property="nsis.home" />
</condition>
<condition property="build.ant-dotnet.lib" value="${ant-dotnet.lib}" >
<isset property="ant-dotnet.lib" />
</condition>
<condition property="build.ant-cmake.lib" value="${ant-cmake.lib}" >
<isset property="ant-cmake.lib" />
</condition>
<property file="${Etch.basedir}/build.dependencies" prefix="build" />
<!-- load runtime properties -->
<property prefix="Etch.property." file="${Etch.basedir}/etch.properties" />
<!-- Compute version numbers -->
<condition property="Etch.property.majorVersion" value="0">
<not><isset property="Etch.property.majorVersion" /></not>
</condition>
<condition property="Etch.property.minorVersion" value="0" >
<not><isset property="Etch.property.minorVersion" /></not>
</condition>
<condition property="Etch.property.patchVersion" value="0" >
<not><isset property="Etch.property.patchVersion" /></not>
</condition>
<condition property="Etch.property.osVersion" value="unknown" >
<not><isset property="Etch.property.osVersion" /></not>
</condition>
<condition property="Etch.property.platformVersion" value="unknown" >
<not><isset property="Etch.property.platformVersion" /></not>
</condition>
<condition property="Etch.runtime.buildKey" value="LOCAL" >
<not><isset property="Etch.runtime.buildKey" /></not>
</condition>
<condition property="Etch.runtime.buildNumber" value="0" >
<not><isset property="Etch.runtime.buildNumber" /></not>
</condition>
<condition property="Etch.runtime.revisionNumber" value="0" >
<not><isset property="Etch.runtime.revisionNumber" /></not>
</condition>
<condition property="Etch.property.suffix" value="" >
<not><isset property="Etch.property.suffix" /></not>
</condition>
<property name="Etch.target" location="${Etch.basedir}/target" />
<property name="Etch.dist" location="${Etch.target}/Installers/dist" />
<property name="Etch.clover-dist" location="${Etch.target}/Installers/dist-clover" />
<property name="Etch.support" location="${Etch.target}/Support/dist" />
<property name="Etch.clover-support" location="${Etch.target}/Support/dist-clover" />
<property name="Etch.version" value="${Etch.property.majorVersion}.${Etch.property.minorVersion}.${Etch.property.patchVersion}" />
<property name="Etch.longversion" value="${Etch.version}${Etch.property.suffix}" />
<property name="Etch.longname" value="apache-etch-${Etch.longversion}" />
<property name="Etch.shortversion" value="${Etch.property.majorVersion}.${Etch.property.minorVersion}" />
<property name="Etch.buildTag" value="${Etch.runtime.buildKey}-${Etch.runtime.buildNumber}" />
<property name="Etch.buildSupportDirectory" location="${Etch.basedir}/build-support" />
<property name="Etch.logDirectory" location="${Etch.target}/BuildLogs" />
<property name="Etch.installerDirectory" location="${Etch.target}/Installers" />
<condition property="Etch.runtime.tests.fail" value="${Etch.target}\fail">
<isset property="build.publish" />
</condition>
<!-- define artifacts -->
<property name="etch-compiler.jar" value="apache-etch-compiler-${Etch.longversion}.jar" />
<property name="etch-compiler-src.zip" value="apache-etch-compiler-${Etch.longversion}-src.zip" />
<property name="etch-java-compiler.jar" value="apache-etch-java-compiler-${Etch.longversion}.jar" />
<property name="etch-java-compiler-src.zip" value="apache-etch-java-compiler-${Etch.longversion}-src.zip" />
<property name="etch-c-compiler.jar" value="apache-etch-c-compiler-${Etch.longversion}.jar" />
<property name="etch-c-compiler-src.zip" value="apache-etch-c-compiler-${Etch.longversion}-src.zip" />
<property name="etch-cpp-compiler.jar" value="apache-etch-cpp-compiler-${Etch.longversion}.jar" />
<property name="etch-cpp-compiler-src.zip" value="apache-etch-cpp-compiler-${Etch.longversion}-src.zip" />
<property name="etch-go-compiler.jar" value="apache-etch-go-compiler-${Etch.longversion}.jar" />
<property name="etch-go-compiler-src.zip" value="apache-etch-go-compiler-${Etch.longversion}-src.zip" />
<property name="etch-csharp-compiler.jar" value="apache-etch-csharp-compiler-${Etch.longversion}.jar" />
<property name="etch-csharp-compiler-src.zip" value="apache-etch-csharp-compiler-${Etch.longversion}-src.zip" />
<property name="etch-xml-compiler.jar" value="apache-etch-xml-compiler-${Etch.longversion}.jar" />
<property name="etch-xml-compiler-src.zip" value="apache-etch-xml-compiler-${Etch.longversion}-src.zip" />
<property name="etch-util.jar" value="apache-etch-util-${Etch.longversion}.jar" />
<property name="etch-util-src.zip" value="apache-etch-util-${Etch.longversion}-src.zip" />
<property name="etch-ant-task.jar" value="apache-etch-ant-plugin-${Etch.longversion}.jar" />
<property name="etch-ant-task-src.zip" value="apache-etch-ant-plugin-${Etch.longversion}-src.zip" />
<!-- check if binding is available -->
<condition property="is-binding-java-available" >
<and>
<available file="${Etch.dist}${file.separator}binding-java" />
<available file="${Etch.dist}${file.separator}lib${file.separator}${etch-java-compiler.jar}" />
</and>
</condition>
<condition property="is-binding-c-available" >
<and>
<available file="${Etch.dist}${file.separator}binding-c" />
<available file="${Etch.dist}${file.separator}lib${file.separator}${etch-c-compiler.jar}" />
</and>
</condition>
<condition property="is-binding-cpp-available" >
<and>
<available file="${Etch.dist}${file.separator}binding-cpp" />
<available file="${Etch.dist}${file.separator}lib${file.separator}${etch-cpp-compiler.jar}" />
</and>
</condition>
<condition property="is-binding-go-available" >
<and>
<available file="${Etch.dist}${file.separator}binding-go" />
<available file="${Etch.dist}${file.separator}lib${file.separator}${etch-go-compiler.jar}" />
</and>
</condition>
<condition property="is-binding-csharp-available" >
<and>
<available file="${Etch.dist}${file.separator}binding-csharp" />
<available file="${Etch.dist}${file.separator}lib${file.separator}${etch-csharp-compiler.jar}" />
</and>
</condition>
<condition property="is-binding-xml-available" >
<and>
<!--<available file="${Etch.dist}${file.separator}binding-csharp" />-->
<available file="${Etch.dist}${file.separator}lib${file.separator}${etch-xml-compiler.jar}" />
</and>
</condition>
<condition property="is-binding-python-available" >
<and>
<!--<available file="${Etch.dist}${file.separator}binding-python" />-->
<available file="${Etch.dist}${file.separator}lib${file.separator}${etch-python-compiler.jar}" />
</and>
</condition>
<!-- java-runtime -->
<property name="etch-java-runtime.jar" value="apache-etch-java-runtime-${Etch.longversion}.jar" />
<property name="etch-java-runtime.zip" value="apache-etch-java-runtime-${Etch.longversion}.zip" />
<property name="etch-java-runtime-src.zip" value="apache-etch-java-runtime-${Etch.longversion}-src.zip" />
<!-- csharp-runtime -->
<property name="etch-csharp-runtime.dll" value="ApacheEtchCsharp.dll" />
<property name="etch-csharp-runtime.pdb" value="ApacheEtchCsharp.pdb" />
<property name="etch-csharp-runtime.zip" value="apache-etch-csharp-runtime-${Etch.longversion}.zip" />
<property name="etch-csharp-runtime-src.zip" value="apache-etch-csharp-runtime-${Etch.longversion}-src.zip" />
<!-- c-runtime -->
<property name="etch-c-runtime.dll" value="etch.dll" />
<property name="etch-c-runtime.pdb" value="etch.pdb" />
<property name="etch-c-runtime.zip" value="apache-etch-c-runtime-${Etch.longversion}.zip" />
<property name="etch-c-runtime-src.zip" value="apache-etch-c-runtime-${Etch.longversion}-src.zip" />
<!-- cpp-runtime -->
<property name="etch-cpp-runtime.dll" value="etch.dll" />
<property name="etch-cpp-runtime.lib" value="etch.lib" />
<property name="etch-cpp-runtime.pdb" value="etch.pdb" />
<property name="etch-cpp-runtime.zip" value="apache-etch-cpp-runtime-${Etch.longversion}.zip" />
<property name="etch-cpp-runtime-src.zip" value="apache-etch-cpp-runtime-${Etch.longversion}-src.zip" />
<!-- Define filterset for build-time substitutions -->
<filterset id="Etch.buildTokens" >
<filter token="EtchVersion" value="${Etch.version}" />
<filter token="EtchLongVersion" value="${Etch.longversion}" />
<filter token="EtchLongName" value="${Etch.longname}" />
<filter token="EtchBuildTag" value="${Etch.buildTag}" />
<filter token="EtchRuntimeRevisionNumber" value="${Etch.runtime.revisionNumber}" />
<filter token="EtchRuntimeBuildKey" value="${Etch.runtime.buildKey}" />
<filter token="EtchRuntimeBuildNumber" value="${Etch.runtime.buildNumber}" />
<filter token="EtchMajorVersion" value="${Etch.property.majorVersion}" />
<filter token="EtchMinorVersion" value="${Etch.property.minorVersion}" />
<filter token="EtchPatchVersion" value="${Etch.property.patchVersion}" />
</filterset>
<!-- TODO: Migrate to .NET tasks for ANT -->
<property name="tool.vs-2k5-task" value="${Etch.runtime.workspace}/scripts/vs-2k5-task.bat" />
<!-- NSIS installer support -->
<property name="tool.makensis" value="${build.nsis.home}\makensis.exe" />
<condition property="NSIS.enabled">
<and>
<os family="windows" />
<available file="${tool.makensis}" />
</and>
</condition>
<tempfile property="Etch.build.tmpdir" destdir="/tmp" />
<property name="Etch.dependency.javacc.home" value="${build.javacc.home}" />
<property name="Etch.dependency.junit.jar" location="${build.junit.lib}/junit-4.3.1.jar" />
<property name="Etch.dependency.velocity.jar" value="${build.velocity.lib}/velocity-1.7.jar" />
<property name="Etch.dependency.velocity-dep.jar" value="${build.velocity.lib}/velocity-1.7-dep.jar" />
<property name="Etch.dependency.ant-dotnet-1.1.jar" value="${build.ant-dotnet.lib}/ant-dotnet-1.1.jar" />
<property name="Etch.dependency.ant-cmake.jar" value="${build.ant-cmake.lib}/cmakeant.jar" />
<property name="Etch.dependency.ant-contrib.jar" value="${build.ant-contrib.lib}/ant-contrib-1.0b3.jar" />
<!-- Csharp Support -->
<condition property="USE.dotnet">
<and>
<os family="windows" />
<available file="${env.DOTNET_HOME}/msbuild.exe" />
<available file="${build.ant-dotnet.lib}/ant-dotnet-1.1.jar" />
<available file="${env.NUNIT_HOME}/bin/net-2.0/nunit.exe" />
</and>
</condition>
<condition property="USE.mono">
<and>
<not><os family="windows" /></not>
<!-- TODO mono support is not fully baked, use -DUSE.mono to test -->
<!-- <available file="${build.mono.home}/bin/mdtool" /> -->
<isset property="USE.mono" />
</and>
</condition>
<condition property="BUILD.csharp">
<or>
<isset property="USE.dotnet" />
<isset property="USE.mono" />
</or>
</condition>
<property name="tool.mdtool" value="${build.mono.home}/bin/mdtool" />
<!-- CMake ANT Support -->
<condition property="USE.cmake" value="true" >
<available file="${Etch.dependency.ant-cmake.jar}" />
</condition>
<!-- clover support -->
<!-- TODO: make this toggle-able -->
<property name="With.clover" value="true" />
<condition property="Clover.enabled" >
<and>
<available file="${build.clover.home}/lib/clover.jar" />
<isset property="With.clover" />
</and>
</condition>
<property name="Etch.dependency.clover.jar" value="${build.clover.home}/lib/clover.jar" />
<taskdef resource="cloverlib.xml" classpath="${Etch.dependency.clover.jar}" />
<!-- If Clover is enabled, use the clover version of the Etch build, this
allows code-coverage metrics to be collected throughout the build process -->
<condition property="Etch.HOME" value="${Etch.clover-dist}" >
<istrue value="${Clover.enabled}" />
</condition>
<condition property="Etch.HOME" value="${Etch.dist}" >
<not><isset property="Etch.HOME" /></not>
</condition>
<condition property="Etch.SUPPORT" value="${Etch.clover-support}" >
<istrue value="${Clover.enabled}" />
</condition>
<condition property="Etch.SUPPORT" value="${Etch.support}" >
<not><isset property="Etch.SUPPORT" /></not>
</condition>
<property name="Clover.path" location="${Etch.clover-dist}/clover" />
<property name="Clover.db.path" location="${Clover.path}/db" />
<property name="Clover.db" location="${Clover.db.path}/clover.master.db" />
<property name="Clover.coverage" location="${Clover.path}/code-coverage-results" />
<!-- properties for examples -->
<property name="EXAMPLE.etch.home" value="${Etch.dist}" />
<property name="EXAMPLE.etch.version" value="${Etch.version}" />
<property name="EXAMPLE.etch.longversion" value="${Etch.longversion}" />
<property name="EXAMPLE.ant.dotnet.jar" value="${Etch.dependency.ant-dotnet-1.1.jar}" />
<!-- csharp ANT support -->
<taskdef onerror="report" resource="org/apache/ant/dotnet/antlib.xml" classpath="${Etch.dependency.ant-dotnet-1.1.jar}" />
<!-- CMake ANT support -->
<taskdef onerror="report" name="cmake" classname="org.iainhull.ant.CmakeBuilder" classpath="${Etch.dependency.ant-cmake.jar}"/>
<!-- Ant contrib support -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${Etch.dependency.ant-contrib.jar}"/>
<!-- dependencies -->
<!-- TODO: remove clover reference if clover-disabled -->
<path id="Etch.dependencies.jar.paths">
<pathelement location="${Etch.dependency.velocity-dep.jar}" />
<pathelement location="${Etch.dependency.junit.jar}" />
<pathelement location="${Etch.dependency.clover.jar}" />
</path>
<!-- macros -->
<macrodef name="build_component" >
<attribute name="root" default="." />
<attribute name="dir" />
<attribute name="target" default="${Etch.build.target}" />
<attribute name="script" default="build" />
<attribute name="antfile" default="@{script}.xml" />
<attribute name="loglabel" default="@{dir}" />
<attribute name="output" default="${Etch.logDirectory}/@{loglabel}.@{target}.txt" />
<element name="componentAntElements" optional="true" implicit="true" />
<sequential>
<echo message="@{loglabel}.@{target}" />
<ant dir="@{root}/@{dir}" antfile="@{antfile}" inheritAll="false" inheritRefs="false" output="@{output}" target="@{target}">
<propertyset id="build-parameters">
<propertyref name="DO.maven.install" />
<propertyref name="build.tests.fail" />
</propertyset>
<componentAntElements />
</ant>
</sequential>
</macrodef>
<macrodef name="build_example" >
<attribute name="root" default="." />
<attribute name="dir" />
<attribute name="script" default="build" />
<attribute name="antfile" default="@{script}.xml" />
<attribute name="loglabel" default="@{dir}" />
<attribute name="logdir" default="logs" />
<attribute name="target" default="${Etch.build.target}" />
<attribute name="output" default="@{logdir}/@{loglabel}.txt" />
<element name="componentAntElements" optional="true" implicit="true" />
<sequential>
<mkdir dir="@{logdir}" />
<echo message="@{loglabel}" />
<ant dir="@{root}/@{dir}" antfile="@{antfile}" inheritAll="false" inheritRefs="false" output="@{output}" target="@{target}">
<propertyset id="examples-parameters">
<propertyref prefix="EXAMPLE" />
<mapper type="glob" from="EXAMPLE.*" to="*" />
</propertyset>
<componentAntElements />
</ant>
</sequential>
</macrodef>
<!-- token filter macro -->
<macrodef name="update-tokens" >
<attribute name="filename" />
<attribute name="template" default="@{filename}.tmpl" />
<sequential>
<!-- Generate version info -->
<copy tofile="@{filename}" file="@{template}" overwrite="true">
<filterset refid="Etch.buildTokens" />
</copy>
</sequential>
</macrodef>
<!-- NSIS macro -->
<macrodef name="makensis">
<attribute name="root" default="." />
<attribute name="dir" default="." />
<attribute name="target" default="${Etch.build.target}" />
<attribute name="script" default="myscript" />
<attribute name="loglabel" default="@{script}" />
<attribute name="destfile" default="@{script}-setup.exe" />
<attribute name="version" default="${Etch.version}" />
<attribute name="output" default="${Etch.logsDirectory}/@{loglabel}.@{target}.txt" />
<attribute name="failonerror" default="false" />
<sequential>
<exec executable="${tool.makensis}" dir="@{root}/@{dir}" failonerror="@{failonerror}" >
<arg value="/V4" />
<arg value="/DPRODUCT_VERSION=@{version}" />
<arg value="/DOUT_FILE=@{destfile}" />
<arg value="@{script}.nsi" />
</exec>
</sequential>
</macrodef>
<!-- Clover macro -->
<macrodef name="initialize-clover" >
<attribute name="enabled" default="${Clover.enabled}" />
<attribute name="suffix" default="none" />
<element name="options" implicit="true" />
<sequential>
<!-- TODO: do not make directories if clover is disabled -->
<mkdir dir="${Clover.db.path}/@{suffix}" />
<clover-setup
initstring="${Clover.db.path}/@{suffix}/clover.db"
enabled="@{enabled}"
source="1.5"
flushpolicy="threaded"
flushinterval="90000" >
<options />
</clover-setup>
</sequential>
</macrodef>
<!-- MONO mdtool macro -->
<macrodef name="mdtool">
<attribute name="dir" default="." />
<attribute name="failonerror" default="false" />
<attribute name="project" default="project.csproj" />
<attribute name="target" default="${Etch.build.target}" />
<sequential>
<exec executable="${tool.mdtool}" dir="@{dir}" failonerror="@{failonerror}" >
<arg value="build" />
<arg value="--buildfile:@{project}" />
</exec>
</sequential>
</macrodef>
</project>