1 <?xml version="1.0"?>
\r
3 ============================================================
\r
4 $Date: 2008-11-08 01:10:56 +0800 (Sat, 08 Nov 2008) $
\r
7 ============================================================
\r
9 NAnt build script for the TortoiseSVN language pack installers
\r
13 <project name="LanguagePack" default="all" basepath=".">
\r
15 Builds the Language pack installers
\r
18 <include buildfile="../default.build.user" if="${file::exists('../default.build.user')}"/>
\r
20 <property name="SpellCheckDir"
\r
21 value="..\..\Common\Spell\"
\r
22 unless="${property::exists('SpellCheckDir')}"
\r
25 <target name="clean">
\r
27 Removes all previously built language pack installers.
\r
29 <if test="${cleanup == 'yes'}">
\r
32 <include name="..\bin\Tortoise*.dll" />
\r
33 <include name="..\bin\LanguagePack_*-${platform}-*.msi" />
\r
39 <target name="createecho2">
\r
40 <script language="C#" prefix="tsvn">
\r
42 <import namespace="System.Globalization" />
\r
43 <import namespace="System.Xml" />
\r
44 <import namespace="NAnt.Core.Attributes" />
\r
45 <import namespace="NAnt.Core.Util" />
\r
46 <import namespace="NAnt.Core.Tasks" />
\r
50 /* Based on EchoTask.cs NAnt 0.85-rc4 */
\r
51 /* Includes support for different Encoding, if none is set, it uses ANSI (Default) */
\r
54 public class Echo2Task : Task
\r
56 #region Private Instance Fields
\r
58 private string _message;
\r
59 private string _contents;
\r
60 private FileInfo _file;
\r
61 private bool _append = false;
\r
62 private Level _messageLevel = Level.Info;
\r
63 private Encoding _encoding;
\r
65 #endregion Private Instance Fields
\r
67 #region Public Instance Properties
\r
69 [TaskAttribute("message")]
\r
70 public string Message
\r
72 get { return _message; }
\r
75 if (!StringUtils.IsNullOrEmpty(value))
\r
77 if (!StringUtils.IsNullOrEmpty(Contents))
\r
79 throw new ValidationException("Inline content and the message attribute are mutually exclusive in the <echo> task.", Location);
\r
93 public string Contents
\r
95 get { return _contents; }
\r
98 if (!StringUtils.IsNullOrEmpty(value))
\r
100 if (!StringUtils.IsNullOrEmpty(Message))
\r
102 throw new ValidationException("Inline content and the message attribute are mutually exclusive in the <echo> task.", Location);
\r
116 [TaskAttribute("file")]
\r
117 public FileInfo File
\r
119 get { return _file; }
\r
120 set { _file = value; }
\r
123 [TaskAttribute("append")]
\r
124 public bool Append
\r
126 get { return _append; }
\r
127 set { _append = value; }
\r
130 [TaskAttribute("level")]
\r
131 public Level MessageLevel
\r
133 get { return _messageLevel; }
\r
136 if (!Enum.IsDefined(typeof(Level), value))
\r
138 throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "An invalid level {0} was specified.", value));
\r
142 this._messageLevel = value;
\r
147 [TaskAttribute("encoding")]
\r
148 public Encoding Encoding
\r
150 get { return _encoding; }
\r
151 set { _encoding = value; }
\r
154 #endregion Public Instance Properties
\r
156 #region Override implementation of Task
\r
158 protected override void ExecuteTask()
\r
161 { // output to file
\r
164 // ensure the output directory exists
\r
165 if (!File.Directory.Exists)
\r
167 File.Directory.Create();
\r
168 File.Directory.Refresh();
\r
171 // determine character encoding to use
\r
172 Encoding encoding = (Encoding != null) ? Encoding : Encoding.Default;
\r
173 // write the message to the file
\r
174 using (StreamWriter writer = new StreamWriter(File.FullName, Append, encoding))
\r
176 if (!StringUtils.IsNullOrEmpty(Message))
\r
178 writer.WriteLine(Message);
\r
180 else if (!StringUtils.IsNullOrEmpty(Contents))
\r
182 writer.WriteLine(Contents);
\r
186 writer.WriteLine();
\r
190 catch (Exception ex)
\r
192 throw new BuildException(string.Format(CultureInfo.InvariantCulture,
\r
193 "Failed to write message to file '{0}'.", File.FullName),
\r
198 { // output to build log
\r
199 if (!StringUtils.IsNullOrEmpty(Message))
\r
201 Log(MessageLevel, Message);
\r
203 else if (!StringUtils.IsNullOrEmpty(Contents))
\r
205 Log(MessageLevel, Contents);
\r
209 Log(MessageLevel, string.Empty);
\r
214 protected override void InitializeTask(XmlNode taskNode)
\r
216 Contents = Project.ExpandProperties(taskNode.InnerText, Location);
\r
219 #endregion Override implementation of Task
\r
226 <target name="all" depends="clean">
\r
228 Builds the installers.
\r
230 <call target="createecho2" />
\r
232 <if test="${platform == 'x64'}">
\r
234 <variable name="Platform" value="x64" />
\r
237 <if test="${platform != 'x64'}">
\r
239 <variable name="Platform" value="win32" />
\r
243 <loadfile file="Languages.txt" property="languagelines" encoding="utf-8"/>
\r
244 <!-- the next line is split in two because we need the newline in the string -->
\r
245 <foreach item="String" in="${languagelines}" delim="
\r
246 " property="langline">
\r
247 <call target="doit" unless="${string::starts-with(langline, '#') or string::get-length(langline)==0}" failonerror="false"/>
\r
251 <target name="doit">
\r
252 <property name="platformfolder" value="${configuration}${bindirextension}" />
\r
254 <property name="ResTextFileName" value="..\bin\release${bindirextension}\bin\restext.exe" />
\r
255 <property name="ResTextFileName" value="..\bin\release\bin\restext.exe" if="${crosscompile == 'yes'}" />
\r
258 pattern="^(?'langISO'[A-z_]+);[ \t]+(?'langCC'\d+);[ \t]+(?'langhelpfile'\d+);[ \t]+(?'langUI'.+);[ \t]+(?'langweb'.+);[ \t]+(?'langnative'.+)"
\r
259 input="${langline}"
\r
261 <echo message="Building ${langweb} dlls and installer" />
\r
263 <!-- create the dlls -->
\r
264 <exec program="${ResTextFileName}" failonerror="false">
\r
265 <arg value="apply" />
\r
266 <arg value="..\bin\${platformfolder}\bin\TortoiseProcLang.dll" />
\r
267 <arg value="..\bin\TortoiseProc${langCC}.dll" />
\r
268 <arg value="Tortoise_${langISO}.po" />
\r
270 <exec program="${ResTextFileName}" failonerror="false">
\r
271 <arg value="apply" />
\r
272 <arg value="..\bin\${platformfolder}\bin\TortoiseMergeLang.dll" />
\r
273 <arg value="..\bin\TortoiseMerge${langCC}.dll" />
\r
274 <arg value="Tortoise_${langISO}.po" />
\r
276 <exec program="${ResTextFileName}" failonerror="false">
\r
277 <arg value="apply" />
\r
278 <arg value="..\bin\${platformfolder}\bin\TortoiseBlameLang.dll" />
\r
279 <arg value="..\bin\TortoiseBlame${langCC}.dll" />
\r
280 <arg value="Tortoise_${langISO}.po" />
\r
282 <exec program="${ResTextFileName}" failonerror="false">
\r
283 <arg value="apply" />
\r
284 <arg value="..\bin\${platformfolder}\bin\TortoiseIDiffLang.dll" />
\r
285 <arg value="..\bin\TortoiseIDiff${langCC}.dll" />
\r
286 <arg value="Tortoise_${langISO}.po" />
\r
289 <!-- create the mo files -->
\r
290 <property name="PoFileName" value="..\ext\Subversion\Subversion\po\${langISO}.po" />
\r
291 <exec program="msgfmt" if="${file::exists(PoFileName)}" failonerror="false" >
\r
292 <arg value="..\ext\Subversion\Subversion\po\${langISO}.po" />
\r
294 <arg value="subversion.mo" />
\r
298 Build the <Files></Files> parts for the spell checker files and thesauri.
\r
300 <property name="SpellCheckFiles" value="" />
\r
301 <foreach item="File" property="filename">
\r
304 <include name="${SpellCheckDir}${langISO}*.*" />
\r
308 <property name="SpellCheckFiles" value="<File Id='${path::get-file-name(filename)}' Name='${path::get-file-name(filename)}' DiskId='1' Source='${filename}' Vital='no'></File>${SpellCheckFiles}" />
\r
309 <echo message="${filename}" />
\r
313 <!-- create the files for the installer -->
\r
314 <if test="${environment::variable-exists('MajorVersion')}">
\r
315 <loadfile file="LanguagePack.wxs" property="versionwxsfile" encoding="utf-8" >
\r
317 <replacetokens begintoken="$" endtoken="$">
\r
318 <token key="MajorVersion" value="${environment::get-variable('MajorVersion')}" />
\r
319 <token key="MinorVersion" value="${environment::get-variable('MinorVersion')}" />
\r
320 <token key="MicroVersion" value="${environment::get-variable('Microversion')}" />
\r
321 <token key="WCREV" value="${environment::get-variable('WCREV')}" />
\r
322 <token key="DEVRELEASE" value="${devrelease}" />
\r
323 <token key="PLATFORM" value="${platform}" />
\r
324 <token key="LANGUI" value="${langUI}" />
\r
325 <token key="COUNTRYCODE" value="${langISO}" />
\r
326 <token key="COUNTRYID" value="${langCC}" />
\r
327 <token key="LANGNATIVE" value="${langnative}" />
\r
328 <token key="SPELLCHECKFILES" value="${SpellCheckFiles}" />
\r
332 <echo2 file="LanguagePack_${langISO}.wxs" message="${versionwxsfile}" encoding="utf-8" />
\r
336 <variable name="TSVNHelpFile" value=" " />
\r
337 <variable name="TMergeHelpFile" value=" " />
\r
338 <variable name="TSVNMoFile" value=" " />
\r
341 <if test="${file::exists('subversion.mo')}">
\r
343 <variable name="TSVNMoFile" value="${langISO}" />
\r
347 <property name="chmFileName" value="..\doc\output\TortoiseSVN_${langISO}.chm" />
\r
348 <setenv if="${file::exists(chmFileName)}">
\r
349 <variable name="TSVNHelpFile" value="${langISO}" />
\r
352 <property name="chmFileName" value="..\doc\output\TortoiseMerge_${langISO}.chm" />
\r
353 <setenv if="${file::exists(chmFileName)}">
\r
354 <variable name="TMergeHelpFile" value="${langISO}" />
\r
357 <property name="verstring" value="${environment::get-variable('MajorVersion')}.${environment::get-variable('MinorVersion')}.${environment::get-variable('MicroVersion')}.${environment::get-variable('WCREV')}" />
\r
359 <exec program="candle">
\r
360 <arg value="-nologo" />
\r
361 <arg value="-out" />
\r
362 <arg value="..\bin\" />
\r
363 <arg value="LanguagePack_${langISO}.wxs" />
\r
364 <arg value="WixUI_LanguagePacks.wxs" />
\r
366 <exec program="light">
\r
367 <arg value="-nologo" />
\r
368 <arg value="-sw1008" />
\r
369 <arg value="-sice:ICE82" />
\r
370 <arg value="-sval" if="${platform == 'x64'}" />
\r
371 <arg value="-out" />
\r
372 <arg value="..\bin\LanguagePack_${verstring}${devrelease}-${platform}-${langISO}.msi" />
\r
373 <arg value="..\bin\LanguagePack_${langISO}.wixobj" />
\r
374 <arg value="..\bin\WixUI_LanguagePacks.wixobj" />
\r
375 <arg value="-ext" />
\r
376 <arg value="WixUIExtension" />
\r
377 <arg value="-cultures:en-us" />
\r
381 <include name="..\bin\*.wixobj" />
\r
382 <include name="..\bin\*.wixpdb" />
\r
386 <delete file="LanguagePack_${langISO}.wxs" failonerror="false" />
\r
387 <delete file="..\bin\TortoiseProc${langCC}.dll" failonerror="false" />
\r
388 <delete file="..\bin\TortoiseMerge${langCC}.dll" failonerror="false" />
\r
389 <delete file="..\bin\TortoiseBlame${langCC}.dll" failonerror="false" />
\r
390 <delete file="..\bin\TortoiseIDiff${langCC}.dll" failonerror="false" />
\r
391 <delete file="subversion.mo" failonerror="false" />
\r