forked from mathnet/mathnet-filtering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
380 lines (308 loc) · 14.8 KB
/
build.fsx
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
// __ __ _ _ _ _ ______ _______
// | \/ | | | | | | \ | | ____|__ __|
// | \ / | __ _| |_| |__ | \| | |__ | |
// | |\/| |/ _` | __| '_ \ | . ` | __| | |
// | | | | (_| | |_| | | |_| |\ | |____ | |
// |_| |_|\__,_|\__|_| |_(_)_| \_|______| |_|
//
// Math.NET Filtering - http://filtering.mathdotnet.com
// Copyright (c) Math.NET - Open Source MIT/X11 License
//
// FAKE build script, see http://fsharp.github.io/FAKE
//
// --------------------------------------------------------------------------------------
// PRELUDE
// --------------------------------------------------------------------------------------
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.DocuHelper
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Fake.StringHelper
open System
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let header = ReadFile(__SOURCE_DIRECTORY__ @@ "build.fsx") |> Seq.take 10 |> Seq.map (fun s -> s.Substring(2)) |> toLines
trace header
// --------------------------------------------------------------------------------------
// PROJECT INFO
// --------------------------------------------------------------------------------------
// VERSION OVERVIEW
let release = LoadReleaseNotes "RELEASENOTES.md"
let buildPart = "0"
let assemblyVersion = release.AssemblyVersion + "." + buildPart
let packageVersion = release.NugetVersion
let releaseNotes = release.Notes |> List.map (fun l -> l.Replace("*","").Replace("`","")) |> toLines
trace (sprintf " Math.NET Filtering v%s" packageVersion)
trace ""
// CORE PACKAGES
type Package =
{ Id: string
Version: string
Title: string
Summary: string
Description: string
ReleaseNotes: string
Tags: string
Authors: string list
Dependencies: (string*string) list
Files: (string * string option * string option) list }
type Bundle =
{ Id: string
Version: string
Title: string
ReleaseNotesFile: string
Packages: Package list }
let summary = "Math.NET Filtering, providing methods and algorithms for signal processing and filtering in science, engineering and every day use."
let description = "Math.NET Filtering with finite and infinite impulse response filter design and application, median filtering and other signal processing methods and algorithms. MIT license. "
let descriptionKalman = "Math.NET Filtering: separate package with Kalman filter only. Cannot currently be included into the main package because of licensing restrictions. LGPL license. "
let support = "Supports .Net 4.0 and Mono on Windows, Linux and Mac."
let tags = "math filter signal FIR IIR median kalman design"
let libnet35 = "lib/net35"
let libnet40 = "lib/net40"
let libnet45 = "lib/net45"
let libpcl47 = "lib/portable-net45+sl5+netcore45+MonoAndroid1+MonoTouch1"
let libpcl344 = "lib/portable-net45+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1"
let filteringPack =
{ Id = "MathNet.Filtering"
Version = packageVersion
Title = "Math.NET Filtering"
Summary = summary
Description = description + support
ReleaseNotes = releaseNotes
Tags = tags
Authors = [ "Christoph Ruegg" ]
Dependencies =
[ "MathNet.Numerics", GetPackageVersion "packages" "MathNet.Numerics" ]
Files =
[ @"..\..\out\lib\Net35\MathNet.Filtering.*", Some libnet35, Some @"**\MathNet.Filtering.Kalman.*";
@"..\..\out\lib\Net40\MathNet.Filtering.*", Some libnet40, Some @"**\MathNet.Filtering.Kalman.*";
@"..\..\out\lib\Net45\MathNet.Filtering.*", Some libnet45, Some @"**\MathNet.Filtering.Kalman.*";
@"..\..\out\lib\Profile47\MathNet.Filtering.*", Some libpcl47, Some @"**\MathNet.Filtering.Kalman.*";
@"..\..\out\lib\Profile344\MathNet.Filtering.*", Some libpcl344, Some @"**\MathNet.Filtering.Kalman.*";
@"..\..\src\Filtering\**\*.cs", Some "src/Common", None ] }
let kalmanPack =
{ Id = "MathNet.Filtering.Kalman"
Version = packageVersion
Title = "Math.NET Filtering - Kalman Filter"
Summary = summary
Description = descriptionKalman + support
ReleaseNotes = releaseNotes
Tags = tags
Authors = [ "Christoph Ruegg" ]
Dependencies =
[ "MathNet.Numerics", GetPackageVersion "packages" "MathNet.Numerics" ]
Files =
[ @"..\..\out\lib\Net35\MathNet.Filtering.Kalman.*", Some libnet35, None;
@"..\..\out\lib\Net40\MathNet.Filtering.Kalman.*", Some libnet40, None;
@"..\..\out\lib\Net45\MathNet.Filtering.Kalman.*", Some libnet45, None;
@"..\..\out\lib\Profile47\MathNet.Filtering.Kalman.*", Some libpcl47, None;
@"..\..\out\lib\Profile344\MathNet.Filtering.Kalman.*", Some libpcl344, None;
@"..\..\src\Kalman\**\*.cs", Some "src/Common", None ] }
let coreBundle =
{ Id = filteringPack.Id
Version = packageVersion
Title = filteringPack.Title
ReleaseNotesFile = "RELEASENOTES.md"
Packages = [ filteringPack; kalmanPack ] }
// --------------------------------------------------------------------------------------
// PREPARE
// --------------------------------------------------------------------------------------
Target "Start" DoNothing
Target "Clean" (fun _ ->
CleanDirs [ "obj" ]
CleanDirs [ "out/api"; "out/docs"; "out/packages" ]
CleanDirs [ "out/lib/Net35"; "out/lib/Net40"; "out/lib/Net45"; "out/lib/Profile47"; "out/lib/Profile344" ]
CleanDirs [ "out/test/Net35"; "out/test/Net40"; "out/test/Net45"; "out/test/Profile47"; "out/test/Profile344" ])
Target "ApplyVersion" (fun _ ->
BulkReplaceAssemblyInfoVersions "src" (fun f ->
{ f with
AssemblyVersion = assemblyVersion
AssemblyFileVersion = assemblyVersion
AssemblyInformationalVersion = packageVersion }))
Target "Prepare" DoNothing
"Start"
=?> ("Clean", not (hasBuildParam "incremental"))
==> "ApplyVersion"
==> "Prepare"
// --------------------------------------------------------------------------------------
// BUILD
// --------------------------------------------------------------------------------------
let buildConfig config subject = MSBuild "" (if hasBuildParam "incremental" then "Build" else "Rebuild") [ "Configuration", config ] subject |> ignore
let build subject = buildConfig "Release" subject
Target "BuildMain" (fun _ -> build !! "MathNet.Filtering.sln")
Target "BuildNet35" (fun _ -> build !! "MathNet.Filtering.Net35Only.sln")
Target "BuildAll" (fun _ -> build !! "MathNet.Filtering.All.sln")
Target "Build" DoNothing
"Prepare"
=?> ("BuildNet35", hasBuildParam "net35")
=?> ("BuildAll", hasBuildParam "all" || hasBuildParam "release")
=?> ("BuildMain", not (hasBuildParam "all" || hasBuildParam "release" || hasBuildParam "net35"))
==> "Build"
// --------------------------------------------------------------------------------------
// TEST
// --------------------------------------------------------------------------------------
let test target =
let quick p = if hasBuildParam "quick" then { p with ExcludeCategory="LongRunning" } else p
NUnit (fun p ->
{ p with
DisableShadowCopy = true
TimeOut = TimeSpan.FromMinutes 30.
OutputFile = "TestResults.xml" } |> quick) target
Target "Test" (fun _ -> test !! "out/test/**/*UnitTests*.dll")
"Build" ==> "Test"
// --------------------------------------------------------------------------------------
// PACKAGES
// --------------------------------------------------------------------------------------
let provideLicense path =
ReadFileAsString "LICENSE.md"
|> ConvertTextToWindowsLineBreaks
|> ReplaceFile (path @@ "license.txt")
let provideReadme title releasenotes path =
String.concat Environment.NewLine [header; " " + title; ""; ReadFileAsString releasenotes]
|> ConvertTextToWindowsLineBreaks
|> ReplaceFile (path @@ "readme.txt")
let provideZipExtraFiles path (bundle:Bundle) =
provideLicense path
provideReadme (sprintf "%s v%s" bundle.Title bundle.Version) bundle.ReleaseNotesFile path
let provideNuGetExtraFiles path (bundle:Bundle) (pack:Package) =
provideLicense path
provideReadme (sprintf "%s v%s" pack.Title pack.Version) bundle.ReleaseNotesFile path
// ZIP
let zip zipDir filesDir filesFilter bundle =
CleanDir "obj/Zip"
let workPath = "obj/Zip/" + bundle.Id
CopyDir workPath filesDir filesFilter
provideZipExtraFiles workPath bundle
Zip "obj/Zip/" (zipDir @@ sprintf "%s-%s.zip" bundle.Id bundle.Version) !! (workPath + "/**/*.*")
CleanDir "obj/Zip"
Target "Zip" (fun _ ->
CleanDir "out/packages/Zip"
coreBundle |> zip "out/packages/Zip" "out/lib" (fun f -> f.Contains("MathNet.Filtering.") || f.Contains("MathNet.Numerics.")))
"Build" ==> "Zip"
// NUGET
let updateNuspec (pack:Package) outPath symbols updateFiles spec =
{ spec with ToolPath = "packages/NuGet.CommandLine/tools/NuGet.exe"
OutputPath = outPath
WorkingDir = "obj/NuGet"
Version = pack.Version
ReleaseNotes = pack.ReleaseNotes
Project = pack.Id
Title = pack.Title
Summary = pack.Summary
Description = pack.Description
Tags = pack.Tags
Authors = pack.Authors
Dependencies = pack.Dependencies
SymbolPackage = symbols
Files = updateFiles pack.Files
Publish = false }
let nugetPack bundle outPath =
CleanDir "obj/NuGet"
for pack in bundle.Packages do
provideNuGetExtraFiles "obj/NuGet" bundle pack
let withLicenseReadme f = [ "license.txt", None, None; "readme.txt", None, None; ] @ f
let withoutSymbolsSources f =
List.choose (function | (_, Some (target:string), _) when target.StartsWith("src") -> None
| (s, t, None) -> Some (s, t, Some ("**/*.pdb"))
| (s, t, Some e) -> Some (s, t, Some (e + ";**/*.pdb"))) f
// first pass - generates symbol + normal package. NuGet does drop the symbols from the normal package, but unfortunately not the sources.
NuGet (updateNuspec pack outPath NugetSymbolPackage.Nuspec withLicenseReadme) "build/MathNet.Filtering.nuspec"
// second pass - generate only normal package, again, but this time explicitly drop the sources (and the debug symbols)
NuGet (updateNuspec pack outPath NugetSymbolPackage.None (withLicenseReadme >> withoutSymbolsSources)) "build/MathNet.Filtering.nuspec"
CleanDir "obj/NuGet"
Target "NuGet" (fun _ ->
CleanDir "out/packages/NuGet"
if hasBuildParam "all" || hasBuildParam "release" then
nugetPack coreBundle "out/packages/NuGet")
"Build" ==> "NuGet"
// --------------------------------------------------------------------------------------
// Documentation
// --------------------------------------------------------------------------------------
// DOCS
Target "CleanDocs" (fun _ -> CleanDirs ["out/docs"])
Target "Docs" (fun _ ->
executeFSIWithArgs "docs/tools" "build-docs.fsx" ["--define:RELEASE"] [] |> ignore
)
Target "DocsDev" (fun _ ->
executeFSIWithArgs "docs/tools" "build-docs.fsx" [] [] |> ignore
)
"Build" ==> "CleanDocs" ==> "Docs"
"Start"
=?> ("CleanDocs", not (hasBuildParam "incremental"))
==> "DocsDev"
// API REFERENCE
Target "CleanApi" (fun _ -> CleanDirs ["out/api"])
Target "Api" (fun _ ->
!! "out/lib/Net40/MathNet.Filtering.dll" ++ "out/lib/Net40/MathNet.Filtering.Kalman.dll"
|> Docu (fun p ->
{ p with
ToolPath = "tools/docu/docu.exe"
TemplatesPath = "tools/docu/templates/"
TimeOut = TimeSpan.FromMinutes 10.
OutputPath = "out/api/" }))
"Build" ==> "CleanApi" ==> "Api"
// --------------------------------------------------------------------------------------
// Publishing
// Requires permissions; intended only for maintainers
// --------------------------------------------------------------------------------------
let publishReleaseTag title prefix version notes =
// inspired by Deedle/tpetricek
let tagName = prefix + "v" + version
let tagMessage = String.concat Environment.NewLine [title + " v" + version; ""; notes ]
let cmd = sprintf """tag -a %s -m "%s" """ tagName tagMessage
Git.CommandHelper.runSimpleGitCommand "." cmd |> printfn "%s"
let _, remotes, _ = Git.CommandHelper.runGitCommand "." "remote -v"
let main = remotes |> Seq.find (fun s -> s.Contains("(push)") && s.Contains("mathnet/mathnet-filtering"))
let remoteName = main.Split('\t').[0]
Git.Branches.pushTag "." remoteName tagName
Target "PublishTag" (fun _ -> publishReleaseTag "Math.NET Filtering" "" packageVersion releaseNotes)
Target "PublishDocs" (fun _ ->
let repo = "../mathnet-websites"
Git.Branches.pull repo "origin" "master"
CleanDir "../mathnet-websites/filtering/docs"
CopyRecursive "out/docs" "../mathnet-websites/filtering/docs" true |> printfn "%A"
Git.Staging.StageAll repo
Git.Commit.Commit repo (sprintf "Filtering: %s docs update" packageVersion)
Git.Branches.pushBranch repo "origin" "master")
Target "PublishApi" (fun _ ->
let repo = "../mathnet-websites"
Git.Branches.pull repo "origin" "master"
CleanDir "../mathnet-websites/filtering/api"
CopyRecursive "out/api" "../mathnet-websites/filtering/api" true |> printfn "%A"
Git.Staging.StageAll repo
Git.Commit.Commit repo (sprintf "Filtering: %s api update" packageVersion)
Git.Branches.pushBranch repo "origin" "master")
let publishNuGet packageFiles =
// TODO: Migrate to NuGet helper once it supports direct (non-integrated) operations
let rec impl trials file =
trace ("NuGet Push: " + System.IO.Path.GetFileName(file) + ".")
try
let args = sprintf "push \"%s\"" (FullName file)
let result =
ExecProcess (fun info ->
info.FileName <- "packages/NuGet.CommandLine/tools/NuGet.exe"
info.WorkingDirectory <- FullName "obj/NuGet"
info.Arguments <- args) (TimeSpan.FromMinutes 10.)
if result <> 0 then failwith "Error during NuGet push."
with exn ->
if trials > 0 then impl (trials-1) file
else ()
Seq.iter (impl 3) packageFiles
Target "PublishNuGet" (fun _ -> !! "out/packages/NuGet/*.nupkg" -- "out/packages/NuGet/*.symbols.nupkg" |> publishNuGet)
Target "Publish" DoNothing
"PublishTag" ==> "Publish"
"PublishNuGet" ==> "Publish"
"PublishDocs" ==> "Publish"
"PublishApi" ==> "Publish"
// --------------------------------------------------------------------------------------
// Default Targets
// --------------------------------------------------------------------------------------
Target "All" DoNothing
"Build" ==> "All"
"Zip" ==> "All"
"NuGet" ==> "All"
"Docs" ==> "All"
"Api" ==> "All"
"Test" ==> "All"
RunTargetOrDefault "Test"