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