summary refs log tree commit diff
path: root/crypto/NBuild.build
blob: e14102139d989a01b09d5e15327bcb3e690ce8d8 (plain) (blame)
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
<?xml version="1.0"?>
<project name="bccrypto-csharp" default="compile-release" basedir=".">

  <!-- Source control properties -->
  <property name="GITURL" value="bcgit@git.bouncycastle.org:bc-csharp" />
  <property name="GITCMD" value="C:/Program Files/Git/bin/git.exe" />

  <property name="api-debugpath" value="./api/bin/debug" />
  <property name="api-releasepath" value="./api/bin/release" />
  <property name="api-srcpath" value="./src" />
  <property name="bzip2-srcpath" value="./bzip2/src" />
  <property name="test-srcpath" value="./test/src" />
  <property name="test-datapath" value="./test/data" />
  <property name="test-libpath" value="./test/lib" />
  <property name="test-binpath" value="./test/bin"/>
  <property name="dist-path" value="./dist"/>

  <!-- Version -->
  <property name="version" value="1.8.9"/>
  <property name="name" value="BouncyCastle.Crypto"/>

  <property name="OPTIONAL_STRONG_NAME" value="" />
  <if test="${property::exists('use-strong-name') and use-strong-name}">
    <echo>Compile targets will be signed using keyfile ../BouncyCastle.snk</echo>
    <property name="OPTIONAL_STRONG_NAME" value=";STRONG_NAME" />
  </if>

  <target name="init">
    <call target="set-framework-props" />
  </target>

  <target name="set-framework-props">
    <if test="${not(target::exists('set-'+framework::get-target-framework()+'-framework-props'))}">
      <fail message="Unsupported framework: '${framework::get-target-framework()}'." />
    </if>
    <call target="set-${framework::get-target-framework()}-framework-props" />
  </target>
  <target name="set-mono-1.0-framework-props">
    <property name="compile-defines" value="NET_1_1" />
    <property name="debug-extension" value="dll.mdb" />
    <property name="enable-nostdlib" value="false" />
    <property name="nunit-console" value="nunit-console" />
    <property name="switch" value="-" />
  </target>
  <target name="set-mono-2.0-framework-props">
    <property name="compile-defines" value="NET_2_0" />
    <property name="debug-extension" value="dll.mdb" />
    <property name="enable-nostdlib" value="false" />
    <property name="nunit-console" value="nunit-console" />
    <property name="switch" value="-" />
  </target>
  <target name="set-mono-3.5-framework-props">
    <property name="compile-defines" value="NET_2_0" />
    <property name="debug-extension" value="dll.mdb" />
    <property name="enable-nostdlib" value="false" />
    <property name="nunit-console" value="nunit-console" />
    <property name="switch" value="-" />
  </target>
  <target name="set-mono-4.0-framework-props">
    <property name="compile-defines" value="NET_2_0" />
    <property name="debug-extension" value="dll.mdb" />
    <property name="enable-nostdlib" value="false" />
    <property name="nunit-console" value="nunit-console" />
    <property name="switch" value="-" />
  </target>
  <target name="set-net-1.1-framework-props">
    <property name="compile-defines" value="NET_1_1" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-net-2.0-framework-props">
    <property name="compile-defines" value="NET_2_0" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-net-3.5-framework-props">
    <property name="compile-defines" value="NET_2_0" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-net-4.0-framework-props">
    <property name="compile-defines" value="NET_2_0" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-netcf-1.0-framework-props">
    <property name="compile-defines" value="NETCF_1_0" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-netcf-2.0-framework-props">
    <property name="compile-defines" value="NETCF_2_0" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-silverlight-2.0-framework-props">
    <property name="compile-defines" value="SILVERLIGHT" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-silverlight-3.0-framework-props">
    <property name="compile-defines" value="SILVERLIGHT" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>
  <target name="set-silverlight-4.0-framework-props">
    <property name="compile-defines" value="SILVERLIGHT" />
    <property name="debug-extension" value="pdb" />
    <property name="enable-nostdlib" value="true" />
    <property name="nunit-console" value="nunit-console.exe" />
    <property name="switch" value="/" />
  </target>

  <target name="clean">
    <delete failonerror="false" dir="./api" />
    <delete failonerror="false" dir="${dist-path}" />
    <delete failonerror="false" dir="${test-binpath}" />
    <delete failonerror="false" file="./TestResult.xml" />
  </target>

  <!-- Compile api in debug mode and compile tests -->
  <target name="compile-debug" depends="init">
    <echo message="Compiling Debug"/>
    <echo message="Compiling API in debug mode."/>
    <mkdir dir="${api-debugpath}"/>
    <csc target="library" noconfig="true" nostdlib="${enable-nostdlib}" output="${api-debugpath}/${name}.dll"
      verbose="false" debug="true" define="${compile-defines}${OPTIONAL_STRONG_NAME}">
      <sources>
        <include name="${api-srcpath}/**/*.cs"/>
        <include name="${bzip2-srcpath}/**/*.cs"/>
      </sources>
      <references>
        <include name="mscorlib.dll"/>
        <include name="System.dll"/>
      </references>
    </csc>

    <copy todir="${test-binpath}">
      <fileset basedir="${test-libpath}">
        <include name="*.dll" />
      </fileset>
    </copy>
    <copy file="${api-debugpath}/${name}.dll" tofile="${test-binpath}/${name}.dll" />
    <copy file="${api-debugpath}/${name}.${debug-extension}"
        tofile="${test-binpath}/${name}.${debug-extension}" />

    <echo message="Compiling Tests."/>
    <mkdir dir="${api-debugpath}"/>
    <csc target="library" noconfig="true" nostdlib="${enable-nostdlib}" output="${test-binpath}/BCTest.dll"
      verbose="false" debug="true" define="${compile-defines}${OPTIONAL_STRONG_NAME}">
      <sources>
        <include name="${test-srcpath}/**/*.cs"/>
      </sources>
      <resources prefix="crypto" dynamicprefix="true">
        <include name="${test-datapath}/**/*.*"/>
        <exclude name="${test-datapath}/**/README.txt"/>
        <exclude name="${test-datapath}/tls/*.tmpl"/>
      </resources>
      <references>
        <include name="mscorlib.dll"/>
        <include name="System.dll"/>
        <include name="${test-libpath}/*.dll"/>
        <include name="${test-binpath}/${name}.dll"/>
      </references>
    </csc>
  </target>

  <!-- Compile Release.-->
  <target name="compile-release" depends="init">
    <echo message="Compiling Release"/>
    <echo message="Compiling API in release mode."/>
    <mkdir dir="${api-releasepath}"/>
    <csc target="library" noconfig="true" nostdlib="${enable-nostdlib}" output="${api-releasepath}/${name}.dll"
      verbose="false" debug="false" optimize="true" define="${compile-defines}${OPTIONAL_STRONG_NAME}">
      <sources>
        <include name="${api-srcpath}/**/*.cs"/>
        <include name="${bzip2-srcpath}/**/*.cs"/>
      </sources>
      <references>
        <include name="mscorlib.dll"/>
        <include name="System.dll"/>
      </references>
    </csc>
  </target>

  <!-- Make distribution.-->
  <target name="dist" depends="init">
    <echo message="Building signed assemblies for release ${version}"/>
    <mkdir dir="${dist-path}"/>

    <exec program="${GITCMD}" verbose="true" workingdir="..">
      <arg value="archive" />
      <arg line="--format zip" />
      <arg value="--output" />
      <arg path="${dist-path}/bccrypto-csharp-${version}-src.zip" />
      <arg value="--prefix" />
      <arg value="bccrypto-csharp-${version}/" />
      <arg value="--remote" />
      <arg value="${GITURL}" />
      <arg value="release-${version}" />
      <arg value="-9" />
    </exec>

    <unzip zipfile="${dist-path}/bccrypto-csharp-${version}-src.zip" todir="${dist-path}/src" />

    <csc target="library" noconfig="true" nostdlib="${enable-nostdlib}" output="${dist-path}/${name}.dll"
      verbose="false" debug="false" optimize="true" define="${compile-defines};STRONG_NAME">
      <sources>
        <include name="${dist-path}/src/bccrypto-csharp-${version}/crypto/${api-srcpath}/**/*.cs"/>
        <include name="${dist-path}/src/bccrypto-csharp-${version}/crypto/${bzip2-srcpath}/**/*.cs"/>
      </sources>
      <references>
        <include name="mscorlib.dll"/>
        <include name="System.dll"/>
      </references>
    </csc>
    <zip zipfile="${dist-path}/bccrypto-csharp-${version}-bin.zip" ziplevel="9">
      <fileset basedir="${dist-path}">
        <include name="${name}.dll" />
      </fileset>
    </zip>

  </target>

  <target name="all" depends="compile-debug, compile-release"/>

  <target name="test" depends="compile-debug">
    <exec program="${nunit-console}" commandline="${switch}labels testcfg.nunit" workingdir="${nant.project.basedir}"></exec>
  </target>

</project>