forked from sharpdx/SharpDX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SharpDXNant.build
529 lines (456 loc) · 20.4 KB
/
SharpDXNant.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<!--
// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-->
<!-- Nant Build file for SharpDX -->
<project name="SharpDX Build" default="help">
<include buildfile="NantExtensions.include"/>
<property name="project.name" value="SharpDX"/>
<property name="project.sname" value="sharpdx"/>
<property name="solution.platform" value="Any CPU"/>
<property name="build_type" value="net20"/>
<property name="build_signed" value="false"/>
<property name="keeppdb" value="false"/>
<property name="keepexe" value="false"/>
<property name="cleandir" value="./"/>
<property name="build-date" value=""/>
<property name="nightly-builds" value="false"/>
<property name="publish-labels" value="Type-Archive,Featured"/>
<property name="publish-project-name" value="sharpdx"/>
<property name="publish-summary" value=""/>
<property name="publish" value="false"/>
<!-- Load NantGoogleTask -->
<loadtasks assembly="External\NantGoogleCode\NantGoogleCode.dll" />
<!-- Prints the version -->
<target name="setup" descriptio="Loads the version for the project">
<!-- Load version from source code SharedAssemblyInfo.cs -->
<loadfile file="Source/SharedAssemblyInfo.cs" property="assembly_version_file" />
<property name="version-dir" value="Standard-net20" if="${build_type == 'net20'}"/>
<property name="version-dir" value="Standard-net40" if="${build_type == 'net40'}"/>
<property name="version-dir" value="Signed-net20" if="${build_type == 'net20' and build_signed}"/>
<property name="version-dir" value="Signed-net40" if="${build_type == 'net40' and build_signed}"/>
<property name="version-dir" value="Standard-winrt" if="${build_type == 'win8'}"/>
<property name="version-dir" value="Signed-winrt" if="${build_type == 'win8' and build_signed}"/>
<property name="version-dir" value="Standard-wp8-${solution.platform}" if="${build_type == 'wp8'}"/>
<property name="version-dir" value="Signed-wp8-${solution.platform}" if="${build_type == 'wp8' and build_signed}"/>
<property name="version-dir" value="Win8Desktop-net40" if="${build_type == 'dx11_1'}"/>
<!-- override default solution.name for WP8 -->
<property name="solution.name" value="SharpDX"/>
<property name="solution.name" value="SharpDXWP8" if="${build_type == 'wp8'}"/>
<regex pattern="AssemblyVersion\(.(?'assembly_version'\d+\.\d+.\d+)" input="${assembly_version_file}" />
<property name="output_bin_zip" value="${project.name}-Bin-${assembly_version}${build-date}.exe"/>
<property name="output_bin_and_samples_zip" value="${project.name}-Full-${assembly_version}${build-date}.exe"/>
<!-- Setup configuration -->
<property name="configuration" value="Net20Release" if="${build_type == 'net20'}"/>
<property name="configuration" value="Net40Release" if="${build_type == 'net40'}"/>
<property name="configuration" value="Win8Release" if="${build_type == 'win8'}"/>
<property name="configuration" value="WP8Release" if="${build_type == 'wp8'}"/>
<property name="configuration" value="DIRECTX11_1Release" if="${build_type == 'dx11_1'}"/>
<property name="bin-dir" value="${configuration}"/>
<property name="bin-dir" value="${configuration}-${solution.platform}" if="${build_type == 'wp8'}"/>
<echo message="${project.name} version from file is ${assembly_version}"/>
</target>
<!-- Clean all directories -->
<target name="clean" description="Delete all previously compiled binaries.">
<echo message="Remove binaries from directory ${cleandir} (keepexe ${keepexe}, keeppdb ${keeppdb})"/>
<delete verbose='true'>
<fileset basedir="${cleandir}">
<include name="**/Bin/*.exe" unless="${keepexe}"/>
<include name="**/Bin/*.dll" unless="${keepexe}"/>
<include name="**/Bin/*.pdb" unless="${keeppdb}"/>
<include name="**/Bin/x86/*.*" />
<include name="**/Bin/x64/*.*" />
<include name="**/Bin/*.lib" />
<include name="**/Bin/*.exp" />
<include name="**/Bin/*.check" />
<include name="**/AppPackages/**" />
<include name="**/Debug/**" />
<include name="**/Release/**" />
<include name="**/Net20Debug/**" />
<include name="**/Net40Debug/**" />
<include name="**/Net20Release/**" />
<include name="**/Net40Release/**" />
<include name="**/Win8Debug/**" />
<include name="**/Win8Release/**" />
<include name="**/obj/**" />
<include name="**/Generated/**" />
<include name="**/*.suo" />
<include name="**/*.bak" />
<include name="**/*.user" />
<exclude name="**/_ReSharper.*/**" />
<exclude name="**/Build/**" />
<exclude name="**/External/**" />
<exclude name="**/.git/**" />
</fileset>
</delete>
<!--Reset property cleandir -->
<property name="cleandir" value="./"/>
</target>
<!-- Pusblish task. Upload zip files to googlecode -->
<target name="publish" description="Set publish code">
<property name="publish" value="true"/>
<call target="git-sync"/>
</target>
<target name="publish-code" description="Publish to google code">
<loadfile file="googlecode_password.txt" property="googlecode_password" />
<if test="${file::exists(output_bin_zip)}">
<gcupload labels="Type-Archive" username="[email protected]" password="${googlecode_password}" projectname="${publish-project-name}" filename="${output_bin_zip}" targetfilename="${output_bin_zip}" summary="${publish-summary}"/>
</if>
<if test="${file::exists(output_bin_and_samples_zip)}">
<gcupload labels="Type-Archive" username="[email protected]" password="${googlecode_password}" projectname="${publish-project-name}" filename="${output_bin_and_samples_zip}" targetfilename="${output_bin_and_samples_zip}" summary="${publish-summary}"/>
</if>
</target>
<!-- Git-Sync task. -->
<target name="git-sync" description="Synchronize with git">
<call target="setup"/>
<!-- Rebase from Git -->
<exec program="git.exe">
<arg value="pull" />
<arg value="--rebase" />
<arg value="origin" />
</exec>
<if test="${publish}">
<!-- Setup last tags-->
<property name="publish-last-tag" value="last_stable"/>
<!-- Use Special tag for nightly-builds -->
<if test="${nightly-builds}">
<property name="publish-last-tag" value="last_nightly_build"/>
</if>
<!-- Rebase from Git -->
<exec program="git.exe" output="git-last-commit.txt">
<arg value="log" />
<arg value="-1" />
<arg value="--format="%H %s"" />
</exec>
<loadfile file="git-last-commit.txt" property="git-last-commit" />
<delete file="git-last-commit.txt"/>
<exec program="git.exe">
<arg value="tag" />
<arg value="${assembly_version}" />
</exec>
<!-- This is asking for user/password WTF?!
<exec program="git.exe">
<arg value="push" />
<arg value="origin" />
<arg value="tag" />
<arg value="${assembly_version}" />
</exec>
-->
<property name="publish-summary" value="Last commit -> ${git-last-commit}"/>
</if>
</target>
<!-- Full clean and build -->
<target name="help" description="Prints help about this build." >
<echo message="Usage MakeSharpDX.cmd target"/>
<echo message=""/>
<echo message="Target to prepare publish before full, nightly-builds:"/>
<echo message=" publish = Prepare build for publish"/>
<echo message=""/>
<echo message="Target to call before build/zip:"/>
<echo message=" net20 = Prepare for net20 build (Framework .NET 2.0+)"/>
<echo message=" net40 = Prepare for net40 build (Framework .NET 4.0+)"/>
<echo message="signed-net20 = Prepare for signed build (Framework .NET 2.0+)"/>
<echo message="signed-net40 = Prepare for signed build (Framework .NET 4.0+)"/>
<echo message=" win8 = Prepare for DirectX11.1 Win8 Metro build (Framework .NET 4.5Core)"/>
<echo message=" signed-win8 = Prepare for Signed DirectX11.1 Win8 Metro build (Framework .NET 4.5Core)"/>
<echo message=" wp8 = Prepare for DirectX11.1 WP8 build (Framework .NET 4.5Core)"/>
<echo message=" signed-wp8 = Prepare for Signed DirectX11.1 WP8 build (Framework .NET 4.5Core)"/>
<echo message=" dx11_1 = Prepare for DirectX11.1 desktop build (Framework .NET 2.0+)"/>
<echo message=""/>
<echo message=" clean = Full cleanup"/>
<echo message=" build = Build Standard Assemblies"/>
<echo message=" doc = Generates documentation (Run 'build' target before this)"/>
<echo message=" zip = Zip assemblies and samplles (Run 'build' target before this)"/>
<echo message=" nuget = Build Nuget Packages (Run 'build' target before this)"/>
<echo message=" nuget-push = Publish Nuget packages (Run 'nuget' target before this)"/>
<echo message=""/>
<echo message=" full = Run build+doc+zip for all targets (normal, signed, win8, dx11_1)"/>
<echo message=""/>
<echo message="Example:"/>
<echo message="- Build Win8 build only = MakeSharpDX.cmd win8 build"/>
<echo message="- Build Full build only = MakeSharpDX.cmd full"/>
<echo message="- Build Nightly-builds Full build and publish = MakeSharpDX.cmd publish nightly-builds full"/>
</target>
<!-- Full clean and build -->
<target name="full" description="Full build targets.">
<!-- Build Signed target first -->
<call target="signed-net20"/>
<call target="build"/>
<call target="signed-net40"/>
<call target="build"/>
<call target="signed-win8"/>
<call target="build"/>
<!-- Build WP8 targets x86/ARM -->
<call target="wp8"/>
<call target="x86"/>
<call target="build"/>
<call target="wp8"/>
<call target="arm"/>
<call target="build"/>
<!-- Build all Any CPU targets -->
<call target="anycpu"/>
<call target="win8"/>
<call target="build"/>
<call target="dx11_1"/>
<call target="build"/>
<call target="net20"/>
<call target="build"/>
<call target="net40"/>
<call target="build"/>
<call target="nuget"/>
<call target="doc"/>
<call target="zip"/>
<call target="publish-code" if="${publish}"/>
</target>
<target name="x86" description="Build x86 targets">
<property name="solution.platform" value="x86"/>
</target>
<target name="arm" description="Build arm targets">
<property name="solution.platform" value="ARM"/>
</target>
<target name="anycpu" description="Build Any CPU targets">
<property name="solution.platform" value="Any CPU"/>
</target>
<target name="net20" description="Build net20 targets">
<property name="build_type" value="net20"/>
<property name="build_signed" value="false"/>
</target>
<target name="net40" description="Build net40 targets">
<property name="build_type" value="net40"/>
<property name="build_signed" value="false"/>
</target>
<target name="signed-net20" description="Build signed-net20 targets">
<property name="build_type" value="net20"/>
<property name="build_signed" value="true"/>
</target>
<target name="signed-net40" description="Build signed-net40 targets">
<property name="build_type" value="net40"/>
<property name="build_signed" value="true"/>
</target>
<target name="signed-win8" description="Build signed-win8 targets">
<property name="build_type" value="win8"/>
<property name="build_signed" value="true"/>
</target>
<target name="win8" description="Build win8 targets">
<property name="build_type" value="win8"/>
<property name="build_signed" value="false"/>
</target>
<target name="signed-wp8" description="Build signed-wp8 targets">
<property name="build_type" value="wp8"/>
<property name="build_signed" value="true"/>
</target>
<target name="wp8" description="Build wp8 targets">
<property name="build_type" value="wp8"/>
<property name="build_signed" value="false"/>
</target>
<target name="dx11_1" description="Build dx11_1 targets">
<property name="build_type" value="dx11_1"/>
<property name="build_signed" value="false"/>
</target>
<!-- Internal task to patch all samples and convert csproj -->
<target name="patch-samples" description="Patch Samples Files">
<foreach item="File" property="csproj-path">
<in>
<items>
<include name="Samples/**/*.sample.csproj" />
</items>
</in>
<do>
<property name="csproj-path-dest" value="${path::combine(path::get-directory-name(csproj-path),path::get-file-name-without-extension(path::get-file-name-without-extension(csproj-path)))}.csproj"/>
<property name="csproj-str" value="${file::read(csproj-path)}"/>
<property name="csproj-win8" value="${string::contains(csproj-path-dest,'Win8')}"/>
<if test="${csproj-win8}">
<echo message="Create file on ${csproj-path-dest} ${file::write(csproj-path-dest, regex::replace(csproj-str, '\\Source\\.*?Configuration\)', '\Bin\Win8Metro')) }"/>
</if>
</do>
</foreach>
</target>
<!-- Full clean and build -->
<target name="nightly-builds" description="Full nighly-builds targets.">
<property name="nightly-builds" value="true"/>
<property name="publish-project-name" value="sharpdx-nightly-builds"/>
<property name="publish-labels" value="Type-Archive"/>
<property name="build-date" value="_${string::pad-left(datetime::get-year(datetime::now()),4,0)}${string::pad-left(datetime::get-month(datetime::now()),2,0)}${string::pad-left(datetime::get-day(datetime::now()),2,0)}"/>
</target>
<!-- Nuget Package build -->
<target name="nuget" description="Build NuGet Packages">
<!-- Setup based on config -->
<call target="setup"/>
<delete dir="Packages"/>
<mkdir dir="Packages"/>
<foreach item="File" property="filename">
<in>
<items>
<include name="Source/**/*.nuspec" />
<exclude name="**/SharpDX.Animation.nuspec" />
</items>
</in>
<do>
<echo message="Nuget on ${path::get-directory-name(filename)}"/>
<exec program="nuget.exe" workingdir="${path::get-directory-name(filename)}">
<arg value="pack" />
<arg value="-Symbols" />
<!-- <arg value="-Verbose" /> -->
<arg value="-OutputDirectory" />
<arg value="${project::get-base-directory()}\Packages" />
<arg value="-Properties" />
<arg value="version=${assembly_version}" />
<arg value="${filename}" />
</exec>
</do>
</foreach>
</target>
<!-- Nuget-Publish -->
<target name="nuget-push" description="Publish NuGet Packages">
<!-- Setup based on config -->
<call target="setup"/>
<foreach item="File" property="filename">
<in>
<items>
<include name="Packages/*.nupkg" />
</items>
</in>
<do>
<echo message="Nuget push ${filename}"/>
<exec program="nuget.exe" failonerror="false">
<arg value="push" />
<arg value="${filename}" />
</exec>
</do>
</foreach>
</target>
<!-- Main build task -->
<target name="build" description="Build all targets.">
<!-- Setup based on config -->
<call target="setup"/>
<echo message="****************************************************************************"/>
<echo message="----------------------------------------------------------------------------"/>
<echo message=""/>
<echo message="Building target [${version-dir}]"/>
<echo message=""/>
<echo message="----------------------------------------------------------------------------"/>
<echo message="****************************************************************************"/>
<!-- Clean all directories -->
<property name="keeppdb" value="false"/>
<property name="keepexe" value="false"/>
<call target="clean"/>
<!-- Copy doc to SharpGen directory -->
<mkdir dir="Source/Tools/SharpGen/Bin/Release"/>
<copy todir="Source/Tools/SharpGen/Bin/Release">
<fileset basedir="Source/Tools/SharpGen/Doc/">
<include name="*.*" />
</fileset>
</copy>
<!-- Create Bin Output Directory -->
<delete dir="Bin/${version-dir}"/>
<mkdir dir="Bin/${version-dir}"/>
<!-- Setup MSBuild -->
<exec program="msbuild.exe" >
<arg value="/t:Build"/>
<arg value="/p:Configuration=${configuration}"/>
<arg value='/p:Platform="${solution.platform}"'/>
<arg value='/p:SharpDXSign=${build_signed}'/>
<arg value="/v:normal"/>
<arg value="${solution.name}.sln" />
</exec>
<mkdir dir="Bin/Redist"/>
<copy todir="Bin/Redist">
<fileset basedir="External/">
<include name="D3D/**/*.dll" />
<include name="D3D/**/*.txt" />
</fileset>
</copy>
<foreach item="File" property="filename" if="${build_signed}">
<in>
<items>
<include name="Bin/${version-dir}/*.exe" />
<include name="Bin/${version-dir}/*.dll" />
<exclude name="Bin/${version-dir}/sharpdx_*.dll" />
</items>
</in>
<do>
<!-- Setup MSBuild -->
<exec program="C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64\sn.exe" workingdir="${path::get-directory-name(filename)}">
<arg value="-Ra"/>
<arg value="${filename}"/>
<arg value="..\..\SharpDX.snk" />
</exec>
</do>
</foreach>
</target>
<!-- Documentation -->
<target name="doc" description="Generates documentation">
<!-- Setup based on config -->
<call target="setup"/>
<!-- Create Bin Output Directory -->
<delete dir="Build/Documentation"/>
<exec program="Source/Tools/SharpDoc/Bin/Release/sharpdoc.exe" workingdir="Documentation">
<arg value="--config=config.xml"/>
<arg value="--output=..\Build\Documentation"/>
</exec>
</target>
<!-- Main zip task -->
<target name="zip" description="Build all targets.">
<!-- Setup based on config -->
<call target="setup"/>
<property name="cleandir" value="Samples/"/>
<property name="keeppdb" value="false"/>
<property name="keepexe" value="false"/>
<call target="clean"/>
<!-- Create Samples Output Directory -->
<delete dir="Build/Samples"/>
<copy todir="Build/">
<fileset>
<include name="Bin/**/*.exe"/>
<include name="Bin/**/*.dll"/>
<include name="Bin/**/*.winmd"/>
<include name="Bin/**/*.xml"/>
<include name="Samples/**"/>
<include name="*.html"/>
<include name="SharpDX.targets"/>
<include name="*.txt"/>
<exclude name="Samples/Win8/Win8Demos.sln"/>
<exclude name="**/*.sample.csproj"/>
<exclude name="**/_ReSharper.*/"/>
<exclude name="googlecode_password.txt"/>
<exclude name="Samples/Win8/**/AppPackages/**"/>
</fileset>
</copy>
<delete file="${output_bin_zip}"/>
<exec program="External/7-Zip/7z.exe" workingdir="Build">
<arg value="a"/>
<arg value="-r"/>
<arg value="-sfx7z.sfx"/>
<arg value="..\${output_bin_zip}"/>
<arg value="Bin\*.*"/>
<arg value="ChangeLog.txt"/>
<arg value="License.txt"/>
<arg value="ReleaseNotes.html"/>
</exec>
<delete file="${output_bin_and_samples_zip}"/>
<exec program="External/7-Zip/7z.exe" workingdir="Build">
<arg value="a"/>
<arg value="-r"/>
<arg value="-sfx7z.sfx"/>
<arg value="..\${output_bin_and_samples_zip}"/>
<arg value="*.*"/>
</exec>
</target>
</project>