mirror of https://github.com/eclipse/paho.mqtt.c
256 lines
9.1 KiB
XML
256 lines
9.1 KiB
XML
<project name="MQTT C Client" default="full">
|
|
|
|
<taskdef resource="net/sf/antcontrib/antlib.xml">
|
|
<classpath>
|
|
<pathelement location="/opt/public/cbi/build/3rdPartyJars/ant-contrib.jar" />
|
|
<pathelement location="/usr/share/java/ant-contrib.jar" />
|
|
</classpath>
|
|
</taskdef>
|
|
|
|
<property name="output.folder" value="build/output" />
|
|
<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" />
|
|
<property name="ssl" value="yes" />
|
|
<property name="test.hostname" value="m2m.eclipse.org"/>
|
|
|
|
<target name="init">
|
|
<tstamp>
|
|
<format property="buildTimestamp" pattern="yyyyMMddHHmm" />
|
|
</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">
|
|
<property name="build.level" value="${DSTAMP}${TSTAMP}" />
|
|
<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" />
|
|
<mkdir dir="${output.folder}"/>
|
|
|
|
<!-- display gcc version -->
|
|
<exec executable="gcc" failonerror="true">
|
|
<arg line="-v"/>
|
|
</exec>
|
|
|
|
<!-- 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} -Wl,-init,MQTTClient_init -Wl,-soname,lib${libname}.so -o ${output.filename} ${sync.source.files}"/>
|
|
</exec>
|
|
<exec executable="strip" failonerror="true">
|
|
<arg value="${output.filename}" />
|
|
</exec>
|
|
|
|
<if>
|
|
<equals arg1="${ssl}" arg2="yes" />
|
|
<then>
|
|
<!-- 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} -Wl,-init,MQTTClient_init -Wl,-soname,lib${libname.ssl}.so -o ${output.ssl.filename} ${sync.source.files}"/>
|
|
</exec>
|
|
<exec executable="strip" failonerror="true">
|
|
<arg value="${output.ssl.filename}" />
|
|
</exec>
|
|
</then>
|
|
</if>
|
|
|
|
<!-- 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} -Wl,-init,MQTTAsync_init -Wl,-soname,lib${libname.async}.so -o ${output.async.filename} ${async.source.files}"/>
|
|
</exec>
|
|
<exec executable="strip" failonerror="true">
|
|
<arg value="${output.async.filename}" />
|
|
</exec>
|
|
|
|
<if>
|
|
<equals arg1="${ssl}" arg2="yes" />
|
|
<then>
|
|
<!-- 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} -Wl,-init,MQTTAsync_init -Wl,-soname,lib${libname.async.ssl}.so -o ${output.async.ssl.filename} ${async.source.files}"/>
|
|
</exec>
|
|
<exec executable="strip" failonerror="true">
|
|
<arg value="${output.async.ssl.filename}" />
|
|
</exec>
|
|
</then>
|
|
</if>
|
|
|
|
<!-- MQTTVersion -->
|
|
<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 -->
|
|
<mkdir dir="${output.folder}/samples"/>
|
|
<copy overwrite="true" todir="${output.folder}/samples">
|
|
<fileset dir="src/samples">
|
|
<include name="*"/>
|
|
</fileset>
|
|
</copy>
|
|
<foreach target="sample.compile" param="aFile" list="stdinpub,stdoutsub,pubsync,pubasync,subasync"/>
|
|
<foreach target="sample.async.compile" param="aFile" list="stdoutsuba,MQTTAsync_publish,MQTTAsync_subscribe"/>
|
|
|
|
<!-- Build tests -->
|
|
<foreach target="onecompile" param="aFile" list="test1"/>
|
|
<foreach target="onecompiles" param="aFile" list="test3"/>
|
|
<foreach target="asynccompile" param="aFile" list="test4"/>
|
|
<foreach target="asynccompiles" param="aFile" list="test5"/>
|
|
|
|
<mkdir dir="${output.folder}/include"/>
|
|
<echo message="Copying the headers for the C clients from the output tree" />
|
|
<copy overwrite="true" todir="${output.folder}/include">
|
|
<fileset dir="src">
|
|
<include name="MQTTClient.h"/>
|
|
<include name="MQTTClientPersistence.h"/>
|
|
<include name="MQTTAsync.h"/>
|
|
</fileset>
|
|
</copy>
|
|
|
|
<zip destfile="${output.folder}/paho-client-mqtt-c.zip">
|
|
<zipfileset dir="${output.folder}" includes="*.so,include/*,MQTTVersion,samples/*"/>
|
|
</zip>
|
|
|
|
</then>
|
|
<elseif>
|
|
<os family="windows" />
|
|
<then>
|
|
|
|
</then>
|
|
</elseif>
|
|
</if>
|
|
</target>
|
|
|
|
<target name="sample.compile" >
|
|
<exec executable="gcc" failonerror="true">
|
|
<arg line="-I src -lpthread -lmqttv3c -L${output.folder} -o ${output.folder}/samples/${aFile} src/samples/${aFile}.c"/>
|
|
</exec>
|
|
</target>
|
|
|
|
<target name="sample.async.compile" >
|
|
<exec executable="gcc" failonerror="true">
|
|
<arg line="-I src -lpthread -lmqttv3a -L${output.folder} -o ${output.folder}/samples/${aFile} src/samples/${aFile}.c"/>
|
|
</exec>
|
|
</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="onecompiles" >
|
|
<exec executable="gcc" failonerror="true">
|
|
<arg line="-I src -lpthread -lmqttv3cs -lssl -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="asynccompiles" >
|
|
<exec executable="gcc" failonerror="true">
|
|
<arg line="-I src -lpthread -lmqttv3as -lssl -L${output.folder} -o ${output.folder}/${aFile} test/${aFile}.c"/>
|
|
</exec>
|
|
</target>
|
|
|
|
<target name="test" >
|
|
<foreach target="runAtest" param="aTest" list="test1,test4"/>
|
|
<foreach target="runSSLtest" param="aTest" list="test3,test5"/>
|
|
</target>
|
|
|
|
<target name="runAtest">
|
|
<exec executable="./${aTest}" failonerror="true" dir="${output.folder}" >
|
|
<arg value="--connection" />
|
|
<arg value="tcp://${test.hostname}:18883" />
|
|
<env key="LD_LIBRARY_PATH" value="." />
|
|
</exec>
|
|
</target>
|
|
|
|
<target name="runSSLtest">
|
|
<exec executable="./${aTest}" failonerror="true" dir="${output.folder}" >
|
|
<arg value="--hostname" />
|
|
<arg value="${test.hostname}" />
|
|
<env key="LD_LIBRARY_PATH" value="." />
|
|
</exec>
|
|
</target>
|
|
|
|
<target name="doc" >
|
|
<if>
|
|
<available file="/usr/bin/doxygen"/>
|
|
<then>
|
|
<mkdir dir="${output.folder}/doc"/>
|
|
<exec executable="doxygen" dir="src">
|
|
<arg value="../doc/DoxyfileV3ClientAPI"/>
|
|
</exec>
|
|
<exec executable="doxygen" dir="src">
|
|
<arg value="../doc/DoxyfileV3AsyncAPI"/>
|
|
</exec>
|
|
<zip destfile="${output.folder}/MQTTClient_doc.zip">
|
|
<zipfileset dir="${output.folder}/doc/MQTTClient" />
|
|
</zip>
|
|
<zip destfile="${output.folder}/MQTTAsync_doc.zip">
|
|
<zipfileset dir="${output.folder}/doc/MQTTAsync" prefix="MQTTAsync/"/>
|
|
</zip>
|
|
<delete dir="${output.folder}/doc" />
|
|
</then>
|
|
<else>
|
|
<echo message="doxygen is not available" />
|
|
</else>
|
|
</if>
|
|
</target>
|
|
|
|
<target name="copy">
|
|
<if>
|
|
<available file="/shared/technology"/>
|
|
<then>
|
|
<mkdir dir="/shared/technology/paho/C"/>
|
|
<echo message="Copying the build output to /shared" />
|
|
<copy overwrite="true" todir="/shared/technology/paho/C">
|
|
<fileset dir="${output.folder}">
|
|
<include name="*.zip"/>
|
|
</fileset>
|
|
</copy>
|
|
</then>
|
|
</if>
|
|
</target>
|
|
|
|
<target name="full" depends="init, version, compile, test, doc, copy" />
|
|
|
|
</project>
|