forked from icsharpcode/SharpZipLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SharpZlib.build
346 lines (297 loc) · 9.71 KB
/
SharpZlib.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<?xml version="1.0" encoding="utf-8" ?>
<!-- Nant style build file for #ZipLib -->
<!--
By default, #ziplib will be built targeting the CLR on which NAnt is
running.
To build #ziplib targeting a specific CLR, pass the identifier of that
CLR as the -t(argetframework) option.
For example:
NAnt.exe -t:netcf-1.0, would build #ziplib targeting .NET Compact
Framework 1.0.
A non-exhaustive list of framework identifiers:
* net-1.0 .NET Framework 1.0
* net-1.1 .NET Framework 1.1
* net-2.0 .NET Framework 2.0
* netcf-1.0 .NET Compact Framework 1.0
* netcf-2.0 .NET Compact Framework 2.0
* mono-1.0 Mono 1.0 profile
* mono-2.0 Mono 2.0 profile
-->
<project name="#ZipLib" default="build" basedir="." >
<!-- Setup Properties -->
<property name="debug" value="False"/>
<property name="optimize" value="True"/>
<property name="checked" value="False" />
<property name="version" value="0.85.5"/>
<property name="build.output.dir" value="bin" overwrite="False" />
<property name="sharpziplib.name" value="ICSharpCode.SharpZipLib" />
<property name="build.sharpziplib.path" value="${build.output.dir}/${sharpziplib.name}.dll" />
<property name="build.defines" value="AUTOBUILD" />
<target name="rebuild"
description="Clean and rebuild"
depends="clean, build"
/>
<target
name="clean"
description="Remove build artefacts"
>
<delete verbose="true" >
<fileset basedir=".">
<include name="${build.output.dir}/ICSharpCode.SharpZipLib.dll" />
<include name="${build.output.dir}/ICSharpCode.SharpZipLib.pdb" />
</fileset>
</delete>
<nant buildfile = "samples/cs/samples.build" target="clean" />
<nant buildfile = "samples/vb/samples.build" target="clean" />
<nant buildfile = "tests/tests.build" target="clean" />
</target>
<target name="test" depends="build" description="Run unit tests" >
<nant buildfile="tests/tests.build" target="test"/>
</target>
<target name="build" description="Build the current source." depends="setup">
<call target="build-${framework::get-target-framework()}" />
<copy todir="bin" overwrite="True" >
<fileset basedir="${build.output.dir}">
<include name="${sharpziplib.name}.dll"/>
</fileset>
</copy>
</target>
<target name="build-netcf-1.0" >
<call target="build-net-1.1" />
</target>
<target name="build-netcf-2.0" >
<!-- The compiler for Microsoft .NET Compact Framework 2.0 does not support the /keyfile option. -->
<call target="build-net-1.1" />
</target>
<target name="build-net-1.1" >
<csc
target="library"
output="${build.sharpziplib.path}"
optimize="${optimize}"
debug="${debug}"
checked="${checked}"
define="${build.defines}"
doc="${build.output.dir}/ICSharpCode.SharpZipLib.xml"
>
<sources basedir="src">
<include name="**/*.cs"/>
</sources>
<references>
<include name="mscorlib.dll" />
<include name="System.dll" />
</references>
</csc>
</target>
<target name="build-net-2.0" >
<csc
target="library"
output="${build.sharpziplib.path}"
optimize="${optimize}"
debug="${debug}"
checked="${checked}"
define="${build.defines}"
keyfile="ICSharpCode.SharpZipLib.key"
doc="${build.output.dir}/ICSharpCode.SharpZipLib.xml"
>
<sources basedir="src">
<include name="**/*.cs"/>
</sources>
<references>
<include name="mscorlib.dll" />
<include name="System.dll" />
</references>
</csc>
</target>
<target name="build-mono-1.0" >
<fail message="Dont know how to build for Mono 1.0." />
</target>
<target name="build-mono-2.0" >
<fail message="Dont know how to build for Mono 2.0." />
</target>
<target name="build-samples" >
<nant buildfile = "samples/cs/samples.build" />
<nant buildfile = "samples/vb/samples.build" />
</target>
<!-- internal targets -->
<target name="show-setup" depends="setup">
<echo message="Current setup"/>
<echo message="Target framework = '${framework::get-target-framework()}'"/>
<echo message="build.defines = '${build.defines}'"/>
<echo message="build.output.dir = '${build.output.dir}'"/>
</target>
<target name="setup">
<if test="${target::exists('setup-for-' + framework::get-target-framework())}">
<call target="setup-for-${framework::get-target-framework()}" />
</if>
<mkdir dir="bin" />
</target>
<target name="setup-for-net-1.0">
<property name="build.defines" value="AUTOBUILD,NET,NET_1_0" />
</target>
<target name="setup-for-net-1.1">
<property name="build.defines" value="AUTOBUILD,NET,NET_1_1" />
</target>
<target name="setup-for-net-2.0">
<property name="build.defines" value="AUTOBUILD,NET,NET_2_0" />
</target>
<target name="setup-for-netcf-1.0">
<property name="build.defines" value="AUTOBUILD,NETCF,NETCF_1_0" />
</target>
<target name="setup-for-netcf-2.0">
<property name="build.defines" value="AUTOBUILD,NETCF,NETCF_2_0" />
</target>
<!-- Mono has not actually been used or tested please let us know if you use Mono! -->
<target name="setup-for-mono-1.0">
<property name="build.defines" value="AUTOBUILD,MONO,MONO_1_0" />
</target>
<target name="setup-for-mono-2.0">
<property name="build.defines" value="AUTOBUILD,MONO,MONO_2_0" />
</target>
<!--
<target
name="release.run" >
Speculative notes more than real working build. A lot to sort out.
Cant do both frameworks AFAIK which is a pain
<call target="preparerelease" />
<delete dir="${release.output.dir}" if="${directory::exists('${release.output.dir}')}" />
<mkdir dir="${release.output.dir}" />
<call target="clean" />
<call target="build.run.desktop" />
<zip zipfile="${release.output.dir}/ICSharpCode.SharpZipLib_11.zip" >
<fileset basedir="${build.output.dir}">
<include name="${build.target.name}" />
</fileset>
</zip>
<call target="clean" />
<echo message="release building is not working" />
</target>
-->
<target name="preparerelease" >
<script language="C#">
<code>
<![CDATA[
static StringCollection SearchDirectory(string directory, string filemask)
{
StringCollection collection = new StringCollection();
SearchDirectory(directory, filemask, collection);
return collection;
}
static void SearchDirectory(string directory, string filemask, StringCollection collection)
{
try {
string[] file = Directory.GetFiles(directory, filemask);
foreach (string f in file) {
collection.Add(f);
}
string[] dir = Directory.GetDirectories(directory);
foreach (string d in dir) {
SearchDirectory(d, filemask, collection);
}
} catch (Exception) {
}
}
static Regex AssemblyVersion = new Regex("AssemblyVersion\\(.*\\)]");
static void SetVersionInfo(string fileName, string version)
{
StreamReader inFile = null;
string content;
try {
inFile = new StreamReader(fileName);
content = inFile.ReadToEnd();
} catch (Exception e) {
Console.WriteLine(e);
return;
} finally {
if (inFile != null) {
inFile.Close();
}
}
if (content != null) {
string newContent = AssemblyVersion.Replace(content, "AssemblyVersion(\"" + version + "\")]");
StreamWriter outFile = null;
try {
outFile = new StreamWriter(fileName);
outFile.Write(newContent);
} catch (Exception e) {
Console.WriteLine(e);
return;
} finally {
if (outFile != null) {
outFile.Close();
}
}
}
}
static string revisionNumber = "0";
static string ReadRevisionFromFile()
{
try {
StreamReader reader = new StreamReader(@"REVISION");
using (reader) {
return reader.ReadLine();
}
}
catch (Exception e) {
Console.WriteLine(e.Message);
throw new Exception("Cannot read revision number from file: " + e.Message);
}
}
static void RetrieveRevisionNumber()
{
try {
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("svn", "info");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
try {
System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
Regex r = new Regex(@"Revision:\s+(\d+)");
Match m = r.Match(output);
if (m != null && m.Success && m.Groups[1] != null) {
revisionNumber = m.Groups[1].Value;
Console.WriteLine("SVN Version '{0}'", revisionNumber);
}
if ((revisionNumber == null) || revisionNumber.Equals("") || revisionNumber.Equals("0")) {
throw new Exception("Could not find revision number in svn output");
}
} catch (Exception e) {
revisionNumber = ReadRevisionFromFile();
Console.WriteLine("Exception retrieving SVN revision - {0} using revision {1}", e.Message, revisionNumber);
}
} catch {
}
}
static void SetVersion(string directory, string version)
{
StringCollection col = SearchDirectory(directory, "AssemblyInfo.cs");
string[] dontTouchList = new string[] {
"samples/HttpCompressionModule/src/AssemblyInfo.cs",
"samples/DIME/DimeDataSetService/AssemblyInfo.cs",
"samples/DIME/DimeDataSetServiceConsumer/AssemblyInfo.cs",
};
string versionNumber = version + "." + revisionNumber;
foreach (string fileName in col) {
bool doSetVersion = true;
foreach (string dontTouch in dontTouchList) {
if (fileName.EndsWith(dontTouch.Replace("/", Path.DirectorySeparatorChar.ToString()))) {
doSetVersion = false;
break;
}
}
if (doSetVersion) {
Console.WriteLine("set revision to file : " + fileName + " to " + versionNumber);
SetVersionInfo(fileName, versionNumber);
}
}
}
public static void ScriptMain(Project project)
{
RetrieveRevisionNumber();
SetVersion(".", project.Properties["version"].ToString());
}
]]>
</code>
</script>
</target>
</project>