File: samples.common

package info (click to toggle)
nunit 2.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 13,092 kB
  • ctags: 14,310
  • sloc: cs: 87,766; xml: 5,858; cpp: 512; sh: 198; makefile: 48; ansic: 8
file content (263 lines) | stat: -rw-r--r-- 7,943 bytes parent folder | download | duplicates (3)
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
<?xml version="1.0"?>
<project>

  <property name="project.base" value="${project::get-base-directory()}" />

  <property name="samples.base" value="${path::get-full-path('../..')}" />
  <!-- Duplicate the following if more levels are added -->te
  <property name="samples.base" value="${path::get-full-path('../../..')}"
            unless="${path::get-file-name(samples.base)=='samples'}" />

  <property name="output.dir" value="${samples.base}/bin" />

  <property name="nunit.bin.dir"
            value="${path::combine(path::get-directory-name(samples.base), 'bin')}" />
  <property name="nunit.framework.dll"
            value="${path::combine(nunit.bin.dir,'net-1.1/framework/nunit.framework.dll')}" />
  <property name="nunit.core.dll"
            value="${path::combine(nunit.bin.dir,'net-1.1/nunit.core.dll')}" />
  <property name="nunit.core.interfaces.dll"
            value="${path::combine(nunit.bin.dir,'net-1.1/nunit.core.interfaces.dll')}" />

  <property name="sample" value="${project::get-name()}"
            unless="${property::exists('sample')}"/>
  <property name="sample.dll" value="${sample}.dll" />

  <property name="sample.type"
          value="${path::get-file-name(path::get-directory-name(project.base))}" />
  <property name="sample.type" value="addin" if="${sample.type=='Core'}" />

  <if test="${directory::exists(path::combine(project.base, 'Tests'))}" >
    <property name="tests" value="${sample}Tests"
          unless="${property::exists('tests')}" />
    <property name="test.dll" value="${tests}.dll" />
  </if>
  
  <property name="nunit.build" value="false"
    unless="${property::exists('project.package.dir')}"/>
  <property name="nunit.build" value="true" 
    if="${property::exists('project.package.dir')}"/>

  <property name="build.debug" value="true"
            unless="${property::exists('build.debug')}" />

  <if test="${not property::exists('build.config')}">
    <property name="build.config" value="Debug"
              if="${build.debug}" />
    <property name="build.config" value="Release"
              unless="${build.debug}" />
  </if>


  <target name="clean" description="Remove files created by build">

    <delete file="${output.dir}/${sample.dll}" />
    <delete file="${output.dir}/${sample}.pdb" />

    <if test="${property::exists('test.dll')}">
      <delete file="${output.dir}/${test.dll}" />
      <delete file="${output.dir}/${path::change-extension(test.dll, '.pdb')}" />
    </if>

  </target>

  <target name="init">

    <mkdir dir="${output.dir}" unless="${directory::exists(output.dir)}" />

    <copy file="${nunit.framework.dll}" todir="${output.dir}"
          if="${not nunit.build and file::exists(nunit.framework.dll)}" />

  </target>

  <target name="init-addin">

    <mkdir dir="${output.dir}" unless="${directory::exists(output.dir)}" />

    <copy file="${nunit.core.dll}" todir="${output.dir}"
          if="${not nunit.build and file::exists(nunit.core.dll)}" />
    <copy file="${nunit.core.interfaces.dll}" todir="${output.dir}"
          if="${not nunit.build and file::exists(nunit.core.interfaces.dll)}" />

  </target>

  <target name="build" Description="Build the sample">
    <call target="build-${sample.type}"/>
  </target>
  
  <target name="build-csharp" depends="init">

    <csc target="library" output="${output.dir}/${sample.dll}" debug="${build.debug}">
      <sources>
        <patternset refid="source-files"/>
      </sources>
      <references basedir="${output.dir}">
        <include name="nunit.framework.dll" />
      </references>
    </csc>

  </target>

  <target name="build-fsharp" depends="init">

    <property name="fsc.path" value="C:/Program Files/Microsoft SDKs/F#/3.0/Framework/v4.0/fsc.exe"/>

    <echo message="F# Build not yet supported"/>

  </target>

  <target name="build-addin" depends="init-addin">

    <csc target="library" output="${output.dir}/${sample}.dll" debug="${build.debug}">
      <sources>
        <patternset refid="source-files"/>
      </sources>
      <references basedir="${output.dir}">
        <include name="nunit.core.interfaces.dll" />
        <include name="nunit.core.dll" />
      </references>
    </csc>

    <call target="build-addin-test" if="${property::exists('test.dll')}" />

  </target>

  <target name="build-addin-test">

    <csc target="library" output="${output.dir}/${test.dll}" debug="${build.debug}">
      <sources basedir="Tests">
        <patternset refid="test-files"/>
      </sources>
      <references basedir="${output.dir}">
        <include name="nunit.framework.dll" />
        <include name="${sample}.dll" />
      </references>
    </csc>

  </target>

  <target name="build-vb" depends="init">

    <vbc target="library"
        output="${output.dir}/${sample.dll}" debug="${build.debug}">
      <imports>
        <import namespace="System"/>
        <import namespace="System.Collections"/>
      </imports>
      <sources>
        <patternset refid="source-files"/>
      </sources>
      <references basedir="${output.dir}">
        <include name="System.dll" />
        <include name="nunit.framework.dll" />
      </references>
    </vbc>

  </target>

  <target name="build-cpp" depends="init,set-vs-path">

    <fail message="Visual Studio 2010 must be installed to build this sample"
      unless="${property::exists( 'vs.2010.path' )}"/>

    <exec program="devenv.exe"
      basedir="${vs.2010.path}" 
      workingdir="."
      commandline="${sample}.vcxproj /build ${build.config} /out ${output.dir}/${sample.dll}"/>

  </target>

  <target name="set-vs-path">

    <readregistry property="vs.2010.path"
      key="Software\Microsoft\VisualStudio\10.0\InstallDir"
      hive="LocalMachine" failonerror="false"
      unless="${property::exists( 'vs.2010.path' )}"/>

  </target>

  <!-- ************************************************************* -->
  <!-- Package targets are only used by the NUnit build script in    -->
  <!-- order to package the samples for distribution.                -->
  <!-- ************************************************************* -->
  
  <target name="package">

    <fail message="Can't use package target directly - it must be called from the NUnit build script."
          unless="${nunit.build}"/>

    <property name="sample.path"
              value="${string::replace(project.base, samples.base, package.samples.dir)}" />

    <call target="package-${sample.type}" />

  </target>

  <target name="package-csharp">

    <property name="sample.proj" value="${sample}.csproj" />

    <call target="copy-source-files" />

  </target>

  <target name="package-fsharp">

    <property name="sample.proj" value="${sample}.fsproj" />

    <call target="copy-source-files" />

  </target>

  <target name="package-vb">
    
    <property name="sample.proj" value="${sample}.vbproj" />

    <call target="copy-source-files" />

  </target>

  <target name="package-cpp">
    
    <property name="sample.proj" value="${sample}.vcxproj" />

    <call target="copy-source-files" />

  </target>

  <target name="package-addin">
    
    <property name="sample.proj" value="${sample}.csproj" />

    <call target="copy-source-files" />
    <call target="copy-test-files" 
      if="${property::exists('test.dll')}"/>

  </target>

  <target name="copy-source-files">

    <copy todir="${sample.path}" includeemptydirs="false">
      <fileset basedir=".">
        <include name="${sample.proj}" />
        <include name="${sample}.build" />
        <include name="Readme.txt" />
        <patternset refid="source-files" />
      </fileset>
    </copy>

  </target>

  <target name="copy-test-files">

    <copy todir="${sample.path}/Tests" includeemptydirs="false">
      <fileset basedir="Tests">
        <include name="${sample}Tests.csproj" />
        <include name="${sample}Tests.build" />
        <patternset refid="test-files" />
      </fileset>
    </copy>

  </target>

</project>