TortoiseGitMerge: Refactor code that gets and sets current line
[TortoiseGit.git] / Languages / LanguagePack.build
blob4458bbee90bbc40846b1e430a483c0e057992510
1 <?xml version="1.0"?>
2 <!--
3 ============================================================
4 $Date: 2008-11-08 01:10:56 +0800 (Sat, 08 Nov 2008) $
5 $Author: steveking $
6 $Rev: 14529 $
7 ============================================================
9 NAnt build script for the TortoiseSVN language pack installers
11 -->
13 <project name="LanguagePack" default="all" basepath=".">
14 <description>
15 Builds the Language pack installers
16 </description>
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')}"
25 <target name="clean">
26 <description>
27 Removes all previously built language pack installers.
28 </description>
29 <if test="${cleanup == 'yes'}">
30 <delete>
31 <fileset>
32 <include name="..\bin\Tortoise*.dll" />
33 <include name="..\bin\LanguagePack_*-${platform}-*.msi" />
34 </fileset>
35 </delete>
36 </if>
37 </target>
39 <target name="createecho2">
40 <script language="C#" prefix="tsvn">
41 <imports>
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" />
47 </imports>
48 <code>
49 <![CDATA[
50 /* Based on EchoTask.cs NAnt 0.85-rc4 */
51 /* Includes support for different Encoding, if none is set, it uses ANSI (Default) */
53 [TaskName("echo2")]
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")]
70 public string Message
72 get { return _message; }
73 set
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);
81 else
83 _message = value;
86 else
88 _message = null;
93 public string Contents
95 get { return _contents; }
96 set
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);
104 else
106 _contents = value;
109 else
111 _contents = null;
116 [TaskAttribute("file")]
117 public FileInfo File
119 get { return _file; }
120 set { _file = value; }
123 [TaskAttribute("append")]
124 public bool Append
126 get { return _append; }
127 set { _append = value; }
130 [TaskAttribute("level")]
131 public Level MessageLevel
133 get { return _messageLevel; }
134 set
136 if (!Enum.IsDefined(typeof(Level), value))
138 throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "An invalid level {0} was specified.", value));
140 else
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()
160 if (File != null)
161 { // output to file
162 try
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);
184 else
186 writer.WriteLine();
190 catch (Exception ex)
192 throw new BuildException(string.Format(CultureInfo.InvariantCulture,
193 "Failed to write message to file '{0}'.", File.FullName),
194 Location, ex);
197 else
198 { // output to build log
199 if (!StringUtils.IsNullOrEmpty(Message))
201 Log(MessageLevel, Message);
203 else if (!StringUtils.IsNullOrEmpty(Contents))
205 Log(MessageLevel, Contents);
207 else
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
222 </code>
223 </script>
224 </target>
226 <target name="all" depends="clean">
227 <description>
228 Builds the installers.
229 </description>
230 <call target="createecho2" />
232 <if test="${platform == 'x64'}">
233 <setenv>
234 <variable name="Platform" value="x64" />
235 </setenv>
236 </if>
237 <if test="${platform != 'x64'}">
238 <setenv>
239 <variable name="Platform" value="win32" />
240 </setenv>
241 </if>
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"/>
248 </foreach>
249 </target>
251 <target name="doit">
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'}" />
257 <regex
258 pattern="^(?'langISO'[A-z_]+);[ \t]+(?'langCC'\d+);[ \t]+(?'langhelpfile'\d+);[ \t]+(?'langUI'.+);[ \t]+(?'langweb'.+);[ \t]+(?'langnative'.+)"
259 input="${langline}"
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" />
269 </exec>
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" />
275 </exec>
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" />
281 </exec>
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" />
287 </exec>
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" />
293 <arg value="-o" />
294 <arg value="subversion.mo" />
295 </exec>
297 <!--
298 Build the <Files></Files> parts for the spell checker files and thesauri.
300 <property name="SpellCheckFiles" value="" />
301 <foreach item="File" property="filename">
302 <in>
303 <items>
304 <include name="${SpellCheckDir}${langISO}*.*" />
305 </items>
306 </in>
307 <do>
308 <property name="SpellCheckFiles" value="&lt;File Id='${path::get-file-name(filename)}' Name='${path::get-file-name(filename)}' DiskId='1' Source='${filename}' Vital='no'&gt;&lt;/File&gt;${SpellCheckFiles}" />
309 <echo message="${filename}" />
310 </do>
311 </foreach>
313 <!-- create the files for the installer -->
314 <if test="${environment::variable-exists('MajorVersion')}">
315 <loadfile file="LanguagePack.wxs" property="versionwxsfile" encoding="utf-8" >
316 <filterchain>
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}" />
329 </replacetokens>
330 </filterchain>
331 </loadfile>
332 <echo2 file="LanguagePack_${langISO}.wxs" message="${versionwxsfile}" encoding="utf-8" />
333 </if>
335 <setenv>
336 <variable name="TSVNHelpFile" value=" " />
337 <variable name="TMergeHelpFile" value=" " />
338 <variable name="TSVNMoFile" value=" " />
339 </setenv>
341 <if test="${file::exists('subversion.mo')}">
342 <setenv>
343 <variable name="TSVNMoFile" value="${langISO}" />
344 </setenv>
345 </if>
347 <property name="chmFileName" value="..\doc\output\TortoiseSVN_${langISO}.chm" />
348 <setenv if="${file::exists(chmFileName)}">
349 <variable name="TSVNHelpFile" value="${langISO}" />
350 </setenv>
352 <property name="chmFileName" value="..\doc\output\TortoiseMerge_${langISO}.chm" />
353 <setenv if="${file::exists(chmFileName)}">
354 <variable name="TMergeHelpFile" value="${langISO}" />
355 </setenv>
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" />
361 <arg value="-out" />
362 <arg value="..\bin\" />
363 <arg value="LanguagePack_${langISO}.wxs" />
364 <arg value="WixUI_LanguagePacks.wxs" />
365 </exec>
366 <exec program="light">
367 <arg value="-nologo" />
368 <arg value="-sw1008" />
369 <arg value="-sice:ICE82" />
370 <arg value="-sval" if="${platform == 'x64'}" />
371 <arg value="-out" />
372 <arg value="..\bin\LanguagePack_${verstring}${devrelease}-${platform}-${langISO}.msi" />
373 <arg value="..\bin\LanguagePack_${langISO}.wixobj" />
374 <arg value="..\bin\WixUI_LanguagePacks.wixobj" />
375 <arg value="-ext" />
376 <arg value="WixUIExtension" />
377 <arg value="-cultures:en-us" />
378 </exec>
379 <delete>
380 <fileset>
381 <include name="..\bin\*.wixobj" />
382 <include name="..\bin\*.wixpdb" />
383 </fileset>
384 </delete>
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" />
392 </target>
393 </project>