build.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!--****************************************************************************
  2. Copyright (c) 2012, 2020 IBM Corp.
  3. All rights reserved. This program and the accompanying materials
  4. are made available under the terms of the Eclipse Public License v2.0
  5. and Eclipse Distribution License v1.0 which accompany this distribution.
  6. The Eclipse Public License is available at
  7. https://www.eclipse.org/legal/epl-2.0/
  8. and the Eclipse Distribution License is available at
  9. http://www.eclipse.org/org/documents/edl-v10.php.
  10. Contributors:
  11. Ian Craggs - initial API and implementation and/or initial documentation
  12. *******************************************************************************-->
  13. <project name="MQTT C Client" default="full">
  14. <taskdef resource="net/sf/antcontrib/antlib.xml">
  15. <classpath>
  16. <pathelement location="/opt/public/cbi/build/3rdPartyJars/ant-contrib.jar" />
  17. <pathelement location="/usr/share/java/ant-contrib.jar" />
  18. </classpath>
  19. </taskdef>
  20. <property name="output.folder" value="build/output" />
  21. <loadfile property="version.major" srcFile="version.major"/>
  22. <loadfile property="version.minor" srcFile="version.minor"/>
  23. <loadfile property="version.patch" srcFile="version.patch"/>
  24. <property name="release.version" value="${version.major}.${version.minor}.${version.patch}" />
  25. <property name="libname" value="mqttv3c" />
  26. <property name="libname.ssl" value="mqttv3cs" />
  27. <property name="libname.async" value="mqttv3a" />
  28. <property name="libname.async.ssl" value="mqttv3as" />
  29. <property name="ssl" value="yes" />
  30. <property name="windows.openssl.folder" value="c:\openssl\bin" />
  31. <property name="test.hostname" value="iot.eclipse.org"/>
  32. <property name="test.port" value="1883"/>
  33. <property name="proxy.port" value="18883"/>
  34. <if>
  35. <os family="windows"/>
  36. <then>
  37. <property name="os.family" value="windows" />
  38. </then>
  39. <else>
  40. <if>
  41. <os family="mac"/>
  42. <then>
  43. <property name="os.family" value="mac" />
  44. </then>
  45. <else>
  46. <property name="os.family" value="unix" />
  47. </else>
  48. </if>
  49. </else>
  50. </if>
  51. <echo message="os.family is '${os.family}'" />
  52. <target name="init">
  53. <tstamp>
  54. <format property="buildTimestamp" pattern="yyyyMMddHHmm" />
  55. </tstamp>
  56. <fileset id="sync.source.fileset" dir="src">
  57. <include name="*.c"/>
  58. <exclude name="MQTTAsync.c"/>
  59. <exclude name="MQTTVersion.c"/>
  60. </fileset>
  61. <pathconvert refid="sync.source.fileset" property="sync.source.files" pathsep=" "/>
  62. <fileset id="async.source.fileset" dir="src">
  63. <include name="*.c"/>
  64. <exclude name="MQTTClient.c"/>
  65. <exclude name="MQTTVersion.c"/>
  66. </fileset>
  67. <pathconvert refid="async.source.fileset" property="async.source.files" pathsep=" "/>
  68. </target>
  69. <target name="version" depends="init" description="replace tags with the right levels">
  70. <property name="build.level" value="${DSTAMP}${TSTAMP}" />
  71. <copy file="src/VersionInfo.h.in" tofile="src/VersionInfo.h" overwrite="true"/>
  72. <replace file="src/VersionInfo.h" token="@BUILD_TIMESTAMP@" value="${build.level}" />
  73. <replace file="src/VersionInfo.h" token="@CLIENT_VERSION@" value="${release.version}" />
  74. </target>
  75. <target name="test" >
  76. <!-- display Python version -->
  77. <exec executable="python" failonerror="true">
  78. <arg line="-V"/>
  79. </exec>
  80. <exec executable="python" dir="test" spawn="true">
  81. <arg value="mqttsas2.py" />
  82. <arg value="${test.hostname}" />
  83. <arg value="${test.port}" />
  84. <arg value="${proxy.port}" />
  85. </exec>
  86. <if>
  87. <os family="windows"/>
  88. <then>
  89. <foreach target="runAtest" param="aTest" list="test1,test2,test4,test9"/>
  90. </then>
  91. <else>
  92. <foreach target="runAtest" param="aTest" list="test1,test2,test4,test9"/>
  93. </else>
  94. </if>
  95. <foreach target="runSSLtest" param="aTest" list="test3,test5"/>
  96. </target>
  97. <target name="runAtest">
  98. <if>
  99. <os family="windows"/>
  100. <then>
  101. <exec executable="cmd.exe" failonerror="true" dir="${output.folder}/test" >
  102. <arg value="/c" />
  103. <arg value="${aTest}.exe" />
  104. <arg value="--connection" />
  105. <arg value="tcp://${test.hostname}:${test.port}" />
  106. <arg value="--proxy_connection" />
  107. <arg value="tcp://localhost:${proxy.port}" />
  108. <env key="PATH" path="${output.folder}" />
  109. </exec>
  110. </then>
  111. <else>
  112. <exec executable="./${aTest}" failonerror="true" dir="${output.folder}/test" >
  113. <arg value="--connection" />
  114. <arg value="tcp://${test.hostname}:${test.port}" />
  115. <arg value="--proxy_connection" />
  116. <arg value="tcp://localhost:${proxy.port}" />
  117. <env key="LD_LIBRARY_PATH" path="${output.folder}" />
  118. <env key="DYLD_LIBRARY_PATH" path="${output.folder}" />
  119. </exec>
  120. </else>
  121. </if>
  122. </target>
  123. <target name="runSSLtest">
  124. <if>
  125. <os family="windows"/>
  126. <then>
  127. <exec executable="cmd.exe" failonerror="true" dir="${output.folder}/test" >
  128. <arg value="/c" />
  129. <arg value="${aTest}.exe" />
  130. <arg value="--hostname" />
  131. <arg value="${test.hostname}" />
  132. <env key="PATH" path="${output.folder};${windows.openssl.folder}" />
  133. </exec>
  134. </then>
  135. <else>
  136. <exec executable="./${aTest}" failonerror="true" dir="${output.folder}/test" >
  137. <arg value="--hostname" />
  138. <arg value="${test.hostname}" />
  139. <env key="LD_LIBRARY_PATH" path="${output.folder}" />
  140. <env key="DYLD_LIBRARY_PATH" path="${output.folder}" />
  141. </exec>
  142. </else>
  143. </if>
  144. </target>
  145. <target name="doc" >
  146. <if>
  147. <available file="/usr/bin/doxygen"/>
  148. <then>
  149. <mkdir dir="${output.folder}/doc"/>
  150. <exec executable="doxygen" dir="src">
  151. <arg value="../doc/DoxyfileV3ClientAPI"/>
  152. </exec>
  153. <exec executable="doxygen" dir="src">
  154. <arg value="../doc/DoxyfileV3AsyncAPI"/>
  155. </exec>
  156. <zip destfile="${output.folder}/MQTTClient_doc.zip">
  157. <zipfileset dir="${output.folder}/doc/MQTTClient" />
  158. </zip>
  159. <zip destfile="${output.folder}/MQTTAsync_doc.zip">
  160. <zipfileset dir="${output.folder}/doc/MQTTAsync" prefix="MQTTAsync/"/>
  161. </zip>
  162. <delete dir="${output.folder}/doc" />
  163. </then>
  164. <else>
  165. <echo message="doxygen is not available" />
  166. </else>
  167. </if>
  168. </target>
  169. <target name="build" >
  170. <if>
  171. <os family="unix"/>
  172. <then>
  173. <delete dir="${output.folder}" />
  174. <!-- display gcc version -->
  175. <exec executable="gcc" failonerror="true">
  176. <arg line="-v"/>
  177. </exec>
  178. <if>
  179. <available file="/usr/bin/make"/>
  180. <then>
  181. <exec executable="make" dir="."/>
  182. </then>
  183. </if>
  184. </then>
  185. </if>
  186. <if>
  187. <os family="windows"/>
  188. <then>
  189. <delete dir="${output.folder}" />
  190. <!-- display gcc version -->
  191. <exec executable="cl" failonerror="true">
  192. </exec>
  193. <exec executable="msbuild" dir=".">
  194. <arg line='"Windows Build\Paho C MQTT APIs.sln"'/>
  195. <arg line="/p:Configuration=Release"/>
  196. </exec>
  197. </then>
  198. </if>
  199. </target>
  200. <target name="package">
  201. <mkdir dir="${output.folder}/include"/>
  202. <copy overwrite="true" todir="${output.folder}/include">
  203. <fileset dir="src" includes="MQTTClient.h,MQTTAsync.h,MQTTClientPersistence.h"/>
  204. </copy>
  205. <copy overwrite="true" todir="${output.folder}">
  206. <fileset dir="." includes="README.md,CONTRIBUTING.md,about.html,notice.html,edl-v10,epl-v20"/>
  207. </copy>
  208. <mkdir dir="${output.folder}/lib"/>
  209. <move overwrite="true" todir="${output.folder}/lib">
  210. <fileset dir="${output.folder}" includes="*paho*"/>
  211. </move>
  212. <mkdir dir="${output.folder}/bin"/>
  213. <move overwrite="true" todir="${output.folder}/bin">
  214. <fileset dir="${output.folder}/samples" includes="*"/>
  215. <fileset dir="${output.folder}" includes="MQTTVersion"/>
  216. </move>
  217. <copy overwrite="true" todir="${output.folder}/samples">
  218. <fileset dir="src/samples" includes="*"/>
  219. </copy>
  220. <delete>
  221. <fileset dir="." includes="eclipse-paho-mqtt-c-windows-${release.version}.zip"/>
  222. <fileset dir="." includes="eclipse-paho-mqtt-c-${os.family}-${release.version}.tar.gz"/>
  223. </delete>
  224. <if>
  225. <os family="windows"/>
  226. <then>
  227. <exec executable="c:\cygwin\bin\zip.exe" failonerror="true" dir="${output.folder}">
  228. <arg value="-r"/>
  229. <arg value="eclipse-paho-mqtt-c-windows-${release.version}.zip"/>
  230. <arg value="about.html"/>
  231. <arg value="notice.html"/>
  232. <arg value="README.md"/>
  233. <arg value="CONTRIBUTING.md"/>
  234. <arg value="epl-v20"/>
  235. <arg value="edl-v10"/>
  236. <arg value="include"/>
  237. <arg value="samples"/>
  238. <arg value="lib"/>
  239. <arg value="bin"/>
  240. </exec>
  241. </then>
  242. <else>
  243. <exec executable="tar" failonerror="true" dir="${output.folder}">
  244. <arg value="czf"/>
  245. <arg value="eclipse-paho-mqtt-c-${os.family}-${release.version}.tar.gz"/>
  246. <arg value="about.html"/>
  247. <arg value="notice.html"/>
  248. <arg value="README.md"/>
  249. <arg value="CONTRIBUTING.md"/>
  250. <arg value="epl-v20"/>
  251. <arg value="edl-v10"/>
  252. <arg value="include"/>
  253. <arg value="samples"/>
  254. <arg value="lib"/>
  255. <arg value="bin"/>
  256. </exec>
  257. </else>
  258. </if>
  259. <if>
  260. <os family="unix"/>
  261. <then>
  262. <exec executable="tar" failonerror="true" dir=".">
  263. <arg value="czf"/>
  264. <arg value="${output.folder}/eclipse-paho-mqtt-c-src-${release.version}.tar.gz"/>
  265. <arg value="about.html"/>
  266. <arg value="notice.html"/>
  267. <arg value="README.md"/>
  268. <arg value="CONTRIBUTING.md"/>
  269. <arg value="epl-v20"/>
  270. <arg value="edl-v10"/>
  271. <arg value="Makefile"/>
  272. <arg value="build.xml"/>
  273. <arg value="src"/>
  274. <arg value="test"/>
  275. <arg value="Windows Build"/>
  276. </exec>
  277. </then>
  278. </if>
  279. </target>
  280. <target name="copy">
  281. <if>
  282. <available file="/shared/technology"/>
  283. <then>
  284. <mkdir dir="/shared/technology/paho/C/${release.version}/${build.level}"/>
  285. <echo message="Copying the build output to /shared" />
  286. <copy overwrite="true" todir="/shared/technology/paho/C/${release.version}/${build.level}">
  287. <fileset dir="${output.folder}">
  288. <include name="*.gz"/>
  289. <include name="*.zip"/>
  290. </fileset>
  291. </copy>
  292. </then>
  293. </if>
  294. </target>
  295. <target name="full" depends="init, version, build, test, doc, package, copy" />
  296. </project>