david_williams | 42f9b24 | 2006-11-27 18:45:14 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 2 | <!-- |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 3 | |
| 4 | |
| 5 | dependency |
| 6 | This script get a library from a remote repository and stores it in a local cache. |
| 7 | |
| 8 | The following properties are used by this script: |
| 9 | |
| 10 | local.cache.dir - the absolute path to the local repository for the libraries |
| 11 | dependency.url : Url to a remote repository that will be used to download the library |
| 12 | dependency.file: Name of the library that is used. If the library is platform dependent |
| 13 | it must have suffixes such as: file.linux.gtk.x86 |
david_williams | 42f9b24 | 2006-11-27 18:45:14 +0000 | [diff] [blame] | 14 | These suffixes are the same as those used by releng baseos,basews,base arch |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 15 | baseos= linux or win32 |
| 16 | basews= gtk or win32 |
david_williams | 42f9b24 | 2006-11-27 18:45:14 +0000 | [diff] [blame] | 17 | base arch=x86 or ppc |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 18 | dependency.name: A short user readable name for the library. |
| 19 | dependency.description: One line description for the library. |
| 20 | dependency.autodownload: [optional] default true. Set this to false if the file cannot be |
| 21 | downloaded automatically (i.e. requies license accept click through). |
| 22 | If autodownload is false, and the library is not avaialbe in the local |
| 23 | repository (cache). User must download the library and copy it into |
| 24 | the local repository. |
| 25 | dependency.releng.url: [optional] A mirror of the original repository. Useful for libraries |
| 26 | that can get deleted from their original URLs. Releng will use |
| 27 | the local cache, original url, releng.url in that order to get the |
| 28 | the dependency. If a releng.url is not provided, the library will |
| 29 | always be requested from itrs original site. |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 30 | --> |
| 31 | <project name="dependency" default="default"> |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 32 | <description> |
| 33 | This script get a library from a remote repository and stores it in a |
| 34 | local cache. |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 35 | </description> |
| 36 | |
| 37 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 38 | <!-- ================================= |
| 39 | target: default |
| 40 | ================================= --> |
| 41 | <target name="default" |
| 42 | description="This script get a library from a remote repository and stores it in a local cache."> |
| 43 | <condition property="dependency.download.file"> |
| 44 | <or> |
| 45 | <not> |
| 46 | <isset property="dependency.autodownload" /> |
| 47 | </not> |
| 48 | <and> |
| 49 | <isset property="dependency.autodownload" /> |
| 50 | <equals arg1="${dependency.autodownload}" |
| 51 | arg2="true" /> |
| 52 | </and> |
| 53 | </or> |
| 54 | </condition> |
| 55 | <antcall target="get" /> |
| 56 | <antcall target="checkAutoDownload" /> |
| 57 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 58 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 59 | <!-- - - - - - - - - - - - - - - - - - |
| 60 | target: sub tasks |
| 61 | - - - - - - - - - - - - - - - - - --> |
| 62 | <target name="get" if="dependency.download.file"> |
| 63 | <mkdir dir="${local.cache.dir}" /> |
| 64 | <available file="${local.cache.dir}/${dependency.file}" |
| 65 | property="local.cache.file.exists" /> |
| 66 | <antcall target="download" /> |
| 67 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 68 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 69 | <target name="checkAutoDownload" |
| 70 | unless="dependency.download.file"> |
| 71 | <fail unless="local.cache.file.exists" |
| 72 | message="The dependent file ${dependency.name}, must be manually downloaded and placed in ${local.cache.dir}." /> |
| 73 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 74 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 75 | <target name="download" |
| 76 | unless="local.cache.file.exists"> |
| 77 | <get verbose="true" |
| 78 | src="${dependency.url}/${dependency.file}" |
| 79 | dest="${local.cache.dir}/${dependency.file}" |
| 80 | ignoreerrors="true" /> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 81 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 82 | <condition property="download.from.mirror"> |
| 83 | <and> |
| 84 | <isset property="dependency.releng.url" /> |
| 85 | <not> |
| 86 | <available file="${local.cache.dir}/${dependency.file}" /> |
| 87 | </not> |
| 88 | </and> |
| 89 | </condition> |
| 90 | <antcall target="downloadMirror" /> |
| 91 | </target> |
| 92 | <target name="downloadMirror" if="download.from.mirror"> |
| 93 | <echo message="Using mirror repository: ${main.url.file.exists}" /> |
| 94 | <echo message="Using mirror repository: ${dependency.releng.url}" /> |
| 95 | <get verbose="true" |
| 96 | src="${dependency.releng.url}/${dependency.file}" |
| 97 | dest="${local.cache.dir}/${dependency.file}" /> |
| 98 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 99 | |
| 100 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 101 | <!-- ================================= |
| 102 | target: install |
| 103 | ================================= --> |
| 104 | <target name="install"> |
| 105 | <condition property="file.type" value="zip"> |
| 106 | <isfileselected file="${dependency.file}"> |
| 107 | <selector> |
| 108 | <filename name="**/*.zip" /> |
| 109 | </selector> |
| 110 | </isfileselected> |
| 111 | </condition> |
| 112 | <condition property="file.type" value="tgz"> |
| 113 | <isfileselected file="${dependency.file}"> |
| 114 | <selector> |
| 115 | <filename name="**/*.tar.gz" /> |
| 116 | </selector> |
| 117 | </isfileselected> |
| 118 | </condition> |
| 119 | <condition property="file.type" value="tgz"> |
| 120 | <isfileselected file="${dependency.file}"> |
| 121 | <selector> |
| 122 | <filename name="**/*.tgz" /> |
| 123 | </selector> |
| 124 | </isfileselected> |
| 125 | </condition> |
| 126 | <condition property="file.type" value="tar"> |
| 127 | <isfileselected file="${dependency.file}"> |
| 128 | <selector> |
| 129 | <filename name="**/*.tar" /> |
| 130 | </selector> |
| 131 | </isfileselected> |
| 132 | </condition> |
david_williams | df8c92e | 2007-02-17 04:55:27 +0000 | [diff] [blame] | 133 | <condition property="file.type" value="map"> |
| 134 | <isfileselected file="${dependency.file}"> |
| 135 | <selector> |
| 136 | <filename name="**/*.map" /> |
| 137 | </selector> |
| 138 | </isfileselected> |
| 139 | </condition> |
david_williams | 948bf55 | 2007-02-26 05:17:22 +0000 | [diff] [blame] | 140 | <condition property="file.type" value="jar"> |
| 141 | <isfileselected file="${dependency.file}"> |
| 142 | <selector> |
| 143 | <filename name="**/*.jar" /> |
| 144 | </selector> |
| 145 | </isfileselected> |
| 146 | </condition> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 147 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 148 | <antcall target="install-${file.type}" /> |
| 149 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 150 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 151 | <target name="install-tar"> |
| 152 | <untar dest="${install.destination}" |
| 153 | src="${local.cache.dir}/${dependency.file}" |
| 154 | overwrite="true" /> |
| 155 | </target> |
| 156 | <target name="install-tgz"> |
| 157 | <untar dest="${install.destination}" |
| 158 | src="${local.cache.dir}/${dependency.file}" |
| 159 | compression="gzip" |
| 160 | overwrite="true" /> |
| 161 | </target> |
| 162 | <target name="install-zip"> |
| 163 | <unzip dest="${install.destination}" |
| 164 | src="${local.cache.dir}/${dependency.file}" |
| 165 | overwrite="true" /> |
| 166 | </target> |
david_williams | df8c92e | 2007-02-17 04:55:27 +0000 | [diff] [blame] | 167 | <target name="install-map"> |
| 168 | <copy todir="${install.destination}" |
| 169 | file="${local.cache.dir}/${dependency.file}" |
| 170 | overwrite="true" /> |
| 171 | </target> |
david_williams | 948bf55 | 2007-02-26 05:17:22 +0000 | [diff] [blame] | 172 | <target name="install-jar"> |
| 173 | <copy todir="${install.destination}" |
| 174 | file="${local.cache.dir}/${dependency.file}" |
| 175 | overwrite="true" /> |
| 176 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 177 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 178 | <target name="checkDependency"> |
| 179 | <dirname file="${ant.file}" |
| 180 | property="dependency.dir" /> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 181 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 182 | <copy tofile="${buildDirectory}/dependency.${groupId}.xml" |
| 183 | overwrite="true"> |
| 184 | <fileset dir="${dependency.dir}"> |
| 185 | <include name="template.xml" /> |
| 186 | </fileset> |
| 187 | </copy> |
| 188 | <echo message="Creating dependency script: ${buildDirectory}/dependency.${groupId}.xml " /> |
| 189 | <replace file="${buildDirectory}/dependency.${groupId}.xml" |
| 190 | value="${groupId}."> |
| 191 | <replacetoken>@dependencyGroupId@</replacetoken> |
| 192 | </replace> |
| 193 | <replace file="${buildDirectory}/dependency.${groupId}.xml" |
| 194 | value="${dependency.dir}"> |
| 195 | <replacetoken>@dependencyDir@</replacetoken> |
| 196 | </replace> |
| 197 | <replace file="${buildDirectory}/dependency.${groupId}.xml" |
| 198 | value="${dependency.properties}"> |
| 199 | <replacetoken>@dependencyProperties@</replacetoken> |
| 200 | </replace> |
| 201 | <ant antfile="${buildDirectory}/dependency.${groupId}.xml" |
| 202 | target="get" /> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 203 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 204 | <!-- |
| 205 | <delete failonerror="false"> |
| 206 | <fileset dir="."> |
| 207 | <include name="${buildDirectory}/dependency.${groupId}.xml" /> |
| 208 | </fileset> |
| 209 | </delete> |
| 210 | --> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 211 | |
| 212 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 213 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 214 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 215 | <target name="installDependency"> |
| 216 | <dirname file="${ant.file}" |
| 217 | property="dependency.dir" /> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 218 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 219 | <copy tofile="${buildDirectory}/dependency.${groupId}.xml"> |
| 220 | <fileset dir="${dependency.dir}"> |
| 221 | <include name="template.xml" /> |
| 222 | </fileset> |
| 223 | </copy> |
| 224 | <replace file="${buildDirectory}/dependency.${groupId}.xml" |
| 225 | value="${groupId}."> |
| 226 | <replacetoken>@dependencyGroupId@</replacetoken> |
| 227 | </replace> |
| 228 | <replace file="${buildDirectory}/dependency.${groupId}.xml" |
| 229 | value="${dependency.dir}"> |
| 230 | <replacetoken>@dependencyDir@</replacetoken> |
| 231 | </replace> |
| 232 | <replace file="${buildDirectory}/dependency.${groupId}.xml" |
| 233 | value="${dependency.properties}"> |
| 234 | <replacetoken>@dependencyProperties@</replacetoken> |
| 235 | </replace> |
| 236 | <ant antfile="${buildDirectory}/dependency.${groupId}.xml" |
| 237 | target="install"> |
| 238 | <property name="install.destination" |
| 239 | value="${install.destination}" /> |
| 240 | </ant> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 241 | |
david_williams | 1cff0e9 | 2006-11-23 00:40:29 +0000 | [diff] [blame] | 242 | <!-- |
| 243 | <delete failonerror="false"> |
| 244 | <fileset dir="."> |
| 245 | <include name="${buildDirectory}/dependency.${groupId}.xml" /> |
| 246 | </fileset> |
| 247 | </delete> |
| 248 | --> |
| 249 | </target> |
ndai | b8cedc8 | 2005-09-13 18:00:32 +0000 | [diff] [blame] | 250 | |
| 251 | |
| 252 | </project> |
| 253 | |