forked from sharpdx/SharpDX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSharpDXNant.build
398 lines (355 loc) · 14.9 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
<!--
// 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="keeppdb" value="false"/>
<property name="keepexe" value="false"/>
<property name="cleandir" value="./"/>
<property name="build-date" value=""/>
<!-- 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" />
<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"/>
<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="**/*.sln.ide/**" />
<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>
<!-- 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="build"/>
<!-- <call target="nuget"/> -->
<!-- <call target="doc"/> -->
<call target="prepare-package"/>
<call target="zip"/>
<call target="fix-sharpdx-path-samples"/>
<!-- TODO: Add call to AdvancedInstaller here -->
</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 All Targets"/>
<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"/>
<!-- Setup MSBuild -->
<exec program="msbuild.exe" >
<arg value="/tv:4.0"/>
<arg value="/t:Build;BuildSamples"/>
<arg value="/verbosity:quiet"/>
<arg value="/clp:ErrorsOnly"/>
<arg value="SharpDX.build" />
</exec>
</target>
<target name="fix-sharpdx-path-samples">
<script language="C#">
<references>
<include name="System.dll" />
</references>
<imports>
<import namespace="System.Text.RegularExpressions" />
</imports>
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
var regex = new Regex(@"HintPath>\.\..*Bin\\", RegexOptions.IgnoreCase);
var regexTargets = new Regex(@"Project="".*SharpDX.targets", RegexOptions.IgnoreCase);
var regexIncludes =new Regex(@"Include=""\.\..*Bin\\", RegexOptions.IgnoreCase);
foreach (var csproj in Directory.EnumerateFiles(Path.Combine(project.BaseDirectory, @"Build\Samples"), "*.csproj", SearchOption.AllDirectories))
{
var text = File.ReadAllText(csproj);
text = regex.Replace(text, @"HintPath>$(SharpDXSdkDir)\Bin\");
text = regexTargets.Replace(text, @"Project=""$(SharpDXSdkDir)\SharpDX.targets");
text = regexIncludes.Replace(text, @"Include=""$(SharpDXSdkDir)\Bin\");
File.WriteAllText(csproj, text);
Console.WriteLine("Fix project sample [{0}]", csproj);
}
}
]]>
</code>
</script>
</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="prepare-package" description="Package all files into a single Build directory">
<!-- 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"/>
<delete dir="Build"/>
<mkdir dir="Build"/>
<copy todir="Build/" includeemptydirs="false">
<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>
</target>
<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"/>
<delete dir="Build"/>
<mkdir dir="Build"/>
<copy todir="Build/" includeemptydirs="false">
<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>