Commit d5608340 authored by Ian Craggs's avatar Ian Craggs

Ant build plus tests

parent c1efe23d
<project name="MQTT C Client" default="full">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="output.folder" value="build/output" />
<property name="build.level" value="${today}" />
<property name="release.version" value="1.0.0.2" />
<property name="libname" value="mqttv3c" />
<property name="libname.ssl" value="mqttv3cs" />
<property name="libname.async" value="mqttv3a" />
<property name="libname.async.ssl" value="mqttv3as" />
<target name="init">
<tstamp/>
<fileset id="sync.source.fileset" dir="src">
<include name="*.c"/>
<exclude name="MQTTAsync.c"/>
<exclude name="MQTTVersion.c"/>
</fileset>
<pathconvert refid="sync.source.fileset" property="sync.source.files" pathsep=" "/>
<fileset id="async.source.fileset" dir="src">
<include name="*.c"/>
<exclude name="MQTTClient.c"/>
<exclude name="MQTTVersion.c"/>
</fileset>
<pathconvert refid="async.source.fileset" property="async.source.files" pathsep=" "/>
</target>
<target name="version" depends="init" description="replace tags in the source with the right levels">
<replace file="src/MQTTClient.c" token="##MQTTCLIENT_BUILD_TAG##" value="${build.level}" />
<replace file="src/MQTTClient.c" token="##MQTTCLIENT_VERSION_TAG##" value="${release.version}" />
<replace file="src/MQTTAsync.c" token="##MQTTCLIENT_BUILD_TAG##" value="${build.level}" />
<replace file="src/MQTTAsync.c" token="##MQTTCLIENT_VERSION_TAG##" value="${release.version}" />
</target>
<target name="compile" depends="version">
<if>
<os family="unix" />
<then>
<property name="ccflags.so" value="-fPIC -Os -Wall" />
<property name="ldflags.so" value="-fvisibility=hidden -shared -Wl,-soname,lib${libname}.so" />
<mkdir dir="${output.folder}"/>
<!-- non-SSL, synchronous library -->
<property name="output.filename" value="${output.folder}/lib${libname}.so" />
<exec executable="gcc" failonerror="true">
<arg line="${ccflags.so} ${ldflags.so} -o ${output.filename} ${sync.source.files}"/>
</exec>
<exec executable="strip" failonerror="true">
<arg value="${output.filename}" />
</exec>
<!-- SSL, synchronous library -->
<property name="output.ssl.filename" value="${output.folder}/lib${libname.ssl}.so" />
<exec executable="gcc" failonerror="true">
<arg line="-DOPENSSL ${ccflags.so} ${ldflags.so} -o ${output.ssl.filename} ${sync.source.files}"/>
</exec>
<exec executable="strip" failonerror="true">
<arg value="${output.ssl.filename}" />
</exec>
<!-- non-SSL, asynchronous library -->
<property name="output.async.filename" value="${output.folder}/lib${libname.async}.so" />
<exec executable="gcc" failonerror="true">
<arg line="${ccflags.so} ${ldflags.so} -o ${output.async.filename} ${async.source.files}"/>
</exec>
<exec executable="strip" failonerror="true">
<arg value="${output.async.filename}" />
</exec>
<!-- SSL, asynchronous library -->
<property name="output.async.ssl.filename" value="${output.folder}/lib${libname.async.ssl}.so" />
<exec executable="gcc" failonerror="true">
<arg line="-DOPENSSL ${ccflags.so} ${ldflags.so} -o ${output.async.ssl.filename} ${sync.source.files}"/>
</exec>
<exec executable="strip" failonerror="true">
<arg value="${output.async.ssl.filename}" />
</exec>
<!-- MQTTVersion -->
<property name="output.async.ssl.filename" value="${output.folder}/lib${libname.async.ssl}.so" />
<exec executable="gcc" failonerror="true">
<arg line="-lpthread -ldl -o ${output.folder}/MQTTVersion src/MQTTVersion.c"/>
</exec>
<exec executable="strip" failonerror="true">
<arg value="${output.folder}/MQTTVersion" />
</exec>
<!-- Samples
<property name="output.async.ssl.filename" value="${output.folder}/lib${libname.async.ssl}.so" />
<foreach list="$">
<exec executable="gcc" failonerror="true">
<arg line="-lpthread -ldl -o ${output.folder}/MQTTVersion src/MQTTVersion.c"/>
</exec>
<exec executable="strip" failonerror="true">
<arg value="${output.folder}/MQTTVersion" />
</exec> -->
<!-- Build tests -->
<foreach target="onecompile" param="aFile" list="test1,test3"/>
<foreach target="asynccompile" param="aFile" list="test4,test5"/>
</then>
<elseif>
<os family="windows" />
<then>
</then>
</elseif>
</if>
</target>
<target name="onecompile" >
<exec executable="gcc" failonerror="true">
<arg line="-I src -lpthread -lmqttv3c -L${output.folder} -o ${output.folder}/${aFile} test/${aFile}.c"/>
</exec>
</target>
<target name="asynccompile" >
<exec executable="gcc" failonerror="true">
<arg line="-I src -lpthread -lmqttv3a -L${output.folder} -o ${output.folder}/${aFile} test/${aFile}.c"/>
</exec>
</target>
<target name="doc" >
<if>
<available file="${doxygen}"/>
<then>
<exec executable="${doxygen}" dir="${mqttclient_src}">
<arg value="${source.folder}/mqttv3c/doc/DoxyfileV3ClientAPI"/>
</exec>
<mkdir dir="${ship.folder}/doc/html"/>
<copy todir="${ship.folder}/doc/html">
<fileset dir="${mqttclient_src}/MQTTClient/html"/>
</copy>
<!-- <zip destfile="${output.folder}/doc/MQTTClient.zip">
<zipfileset dir="${mqttclient_src}/MQTTClient" />
</zip> -->
<exec executable="${doxygen}" dir="${mqttclient_src}">
<arg value="${source.folder}/mqttv3c/doc/DoxyfileV3AsyncAPI"/>
</exec>
<mkdir dir="${ship.folder}/doc/html/MQTTAsync"/>
<copy todir="${ship.folder}/doc/html/MQTTAsync">
<fileset dir="${mqttclient_src}/MQTTAsync"/>
</copy>
<!-- <zip destfile="${output.folder}/doc/MQTTAsync.zip">
<zipfileset dir="${mqttclient_src}/MQTTAsync" prefix="MQTTAsync/"/>
</zip> -->
<delete dir="${mqttclient_src}/MQTTClient" />
<delete dir="${mqttclient_src}/MQTTAsync" />
</then>
<else>
<echo message="doxygen is not available" />
</else>
</if>
</target>
<target name="copy">
<mkdir dir="${ship.folder}/include"/>
<echo message="Copying the headers for the c_client from the output tree" />
<copy overwrite="true" todir="${ship.folder}/include">
<fileset dir="${mqttclient_src}">
<include name="MQTTClient.h"/>
<include name="MQTTClientPersistence.h"/>
<include name="MQTTAsync.h"/>
</fileset>
</copy>
<echo message="Copying the source.zip file from the output tree" />
<copy overwrite="true" todir="${ship.folder}">
<fileset dir="${output.folder}">
<include name="source.zip"/>
</fileset>
</copy>
</target>
<!-- target name="full" depends="init, version, compile, doc, copy" -->
<target name="full" depends="init, version, compile" />
</project>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment