-
Notifications
You must be signed in to change notification settings - Fork 133
/
build.fsx
277 lines (210 loc) · 10.4 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
// __ __ _ _ _ _ ______ _______
// | \/ | | | | | | \ | | ____|__ __|
// | \ / | __ _| |_| |__ | \| | |__ | |
// | |\/| |/ _` | __| '_ \ | . ` | __| | |
// | | | | (_| | |_| | | |_| |\ | |____ | |
// |_| |_|\__,_|\__|_| |_(_)_| \_|______| |_|
//
// Math.NET Spatial - https://spatial.mathdotnet.com
// Copyright (c) Math.NET - Open Source MIT/X11 License
//
// FAKE build script, see http://fsharp.github.io/FAKE
//
// --------------------------------------------------------------------------------------
// PRELUDE
// --------------------------------------------------------------------------------------
#I "packages/build/FAKE/tools"
#r "packages/build/FAKE/tools/FakeLib.dll"
open Fake
open Fake.DocuHelper
open System
open System.IO
#load "build/build-framework.fsx"
open BuildFramework
// --------------------------------------------------------------------------------------
// PROJECT INFO
// --------------------------------------------------------------------------------------
// VERSION OVERVIEW
let spatialRelease = release "spatial" "Math.NET Spatial" "RELEASENOTES.md"
let releases = [ spatialRelease ]
traceHeader releases
// SPATIAL PACKAGES
let spatialZipPackage = zipPackage "MathNet.Spatial" "Math.NET Spatial" spatialRelease
let spatialStrongNameZipPackage = zipPackage "MathNet.Spatial.Signed" "Math.NET Spatial" spatialRelease
let spatialNuGetPackage = nugetPackage "MathNet.Spatial" spatialRelease
let spatialStrongNameNuGetPackage = nugetPackage "MathNet.Spatial.Signed" spatialRelease
let spatialProject = project "MathNet.Spatial" "src/Spatial/Spatial.csproj" [spatialNuGetPackage]
let spatialStrongNameProject = project "MathNet.Spatial" "src/Spatial/Spatial.Signed.csproj" [spatialStrongNameNuGetPackage]
let spatialSolution = solution "Spatial" "MathNet.Spatial.sln" [spatialProject] [spatialZipPackage]
let spatialStrongNameSolution = solution "Spatial" "MathNet.Spatial.Signed.sln" [spatialStrongNameProject] [spatialStrongNameZipPackage]
// ALL
let allSolutions = [spatialSolution; spatialStrongNameSolution]
let allProjects = allSolutions |> List.collect (fun s -> s.Projects) |> List.distinct
// --------------------------------------------------------------------------------------
// PREPARE
// --------------------------------------------------------------------------------------
Target "Start" DoNothing
Target "Clean" (fun _ ->
DeleteDirs (!! "src/**/obj/" ++ "src/**/bin/" )
CleanDirs [ "out/api"; "out/docs" ]
allSolutions |> List.iter (fun solution -> CleanDirs [ solution.OutputZipDir; solution.OutputNuGetDir; solution.OutputLibDir; solution.OutputLibStrongNameDir ]))
Target "ApplyVersion" (fun _ ->
allProjects |> List.iter patchVersionInProjectFile
patchVersionInAssemblyInfo "src/Spatial.Tests" spatialRelease)
Target "Restore" (fun _ -> allSolutions |> List.iter restoreWeak)
"Start"
=?> ("Clean", not (hasBuildParam "incremental"))
==> "Restore"
Target "Prepare" DoNothing
"Start"
=?> ("Clean", not (hasBuildParam "incremental"))
==> "ApplyVersion"
==> "Prepare"
// --------------------------------------------------------------------------------------
// BUILD, SIGN, COLLECT
// --------------------------------------------------------------------------------------
let fingerprint = "490408de3618bed0a28e68dc5face46e5a3a97dd"
let timeserver = "http://time.certum.pl/"
Target "Build" (fun _ ->
// Strong Name Build (with strong name, without certificate signature)
if hasBuildParam "strongname" then
CleanDirs (!! "src/**/obj/" ++ "src/**/bin/" )
restoreStrong spatialStrongNameSolution
buildStrong spatialStrongNameSolution
if isWindows && hasBuildParam "sign" then sign fingerprint timeserver spatialStrongNameSolution
collectBinariesSN spatialStrongNameSolution
zip spatialStrongNameZipPackage spatialStrongNameSolution.OutputZipDir spatialStrongNameSolution.OutputLibStrongNameDir (fun f -> f.Contains("MathNet.Spatial.") || f.Contains("MathNet.Numerics."))
if isWindows then
packStrong spatialStrongNameSolution
collectNuGetPackages spatialStrongNameSolution
// Normal Build (without strong name, with certificate signature)
CleanDirs (!! "src/**/obj/" ++ "src/**/bin/" )
restoreWeak spatialSolution
buildWeak spatialSolution
if isWindows && hasBuildParam "sign" then sign fingerprint timeserver spatialSolution
collectBinaries spatialSolution
zip spatialZipPackage spatialSolution.OutputZipDir spatialSolution.OutputLibDir (fun f -> f.Contains("MathNet.Spatial.") || f.Contains("MathNet.Numerics."))
if isWindows then
packWeak spatialSolution
collectNuGetPackages spatialSolution
// NuGet Sign (all or nothing)
if isWindows && hasBuildParam "sign" then signNuGet fingerprint timeserver [spatialSolution; spatialStrongNameSolution]
)
"Prepare" ==> "Build"
// --------------------------------------------------------------------------------------
// TEST
// --------------------------------------------------------------------------------------
let testSpatial framework = test "src/Spatial.Tests" "Spatial.Tests.csproj" framework
Target "TestSpatial" DoNothing
Target "TestSpatialCore3.1" (fun _ -> testSpatial "netcoreapp3.1")
Target "TestSpatialNET461" (fun _ -> testSpatial "net461")
Target "TestSpatialNET47" (fun _ -> testSpatial "net47")
"Build" ==> "TestSpatialCore3.1" ==> "TestSpatial"
"Build" =?> ("TestSpatialNET461", isWindows) ==> "TestSpatial"
"Build" =?> ("TestSpatialNET47", isWindows)
Target "Test" DoNothing
"TestSpatial" ==> "Test"
// --------------------------------------------------------------------------------------
// BENCHMARKS
// --------------------------------------------------------------------------------------
//let dotnetBuild configuration solution = DotNetCli.Build (fun p ->
// let defaultArgs = ["--no-restore"]
// { p with
// Project = solution
// Configuration = configuration
// AdditionalArgs = defaultArgs})
//let CopyBenchmarks target source framework =
// Directory.GetFiles(source, "*.md", SearchOption.TopDirectoryOnly)
// |> Seq.iter (fun file ->
// let fi =
// file
// |> replaceFirst source ""
// |> replaceFirst "\Spatial.Benchmarks." ""
// |> replaceFirst "Benchmarks-report-github" (sprintf ".%s" framework)
// |> trimSeparator
// trace fi
// let newFile = target @@ fi
// logVerbosefn "%s => %s" file newFile
// DirectoryName newFile |> ensureDirectory
// File.Copy(file, newFile, true))
// |> ignore
//let benchmarkLibrary framework = testLibrary "src/Spatial.Benchmarks/" "Spatial.Benchmarks.csproj" framework
//let benchmarkRootDir = currentDirectory </> "src" </> "Spatial.Benchmarks"
//let benchmarkSourceFiles = benchmarkRootDir </> "BenchmarkDotNet.Artifacts" </> "results"
//let benchmarkDestination = benchmarkRootDir
//Target "Benchmarks" DoNothing
//Target "RunBenchmarks" DoNothing
//Target "CleanBenchmarks" (fun _ -> CleanDirs [ benchmarkRootDir </> "BenchmarkDotNet.Artifacts" ])
//Target "Benchmark#Core" (fun _ ->
// benchmarkLibrary "netcoreapp2.0"
// CopyBenchmarks benchmarkDestination benchmarkSourceFiles "netstandard20")
//Target "Benchmark#Net471" (fun _ ->
// benchmarkLibrary "net471"
// CopyBenchmarks benchmarkDestination benchmarkSourceFiles "net471")
//"BuildBenchmarks" ==> "Benchmark#Core" ==> "RunBenchmarks"
//"BuildBenchmarks" =?> ("Benchmark#Net471", isWindows) ==> "RunBenchmarks"
//"RestoreBenchmark"
//==> "CleanBenchmarks"
//==> "BuildBenchmarks"
//==> "RunBenchmarks"
//==> "Benchmarks"
// --------------------------------------------------------------------------------------
// Documentation
// --------------------------------------------------------------------------------------
// DOCS
Target "CleanDocs" (fun _ -> CleanDirs ["out/docs"])
let extraDocs =
[ "LICENSE.md", "License.md"
"CONTRIBUTING.md", "Contributing.md"
"CONTRIBUTORS.md", "Contributors.md" ]
Target "Docs" (fun _ ->
provideDocExtraFiles extraDocs releases
generateDocs true false)
Target "DocsDev" (fun _ ->
provideDocExtraFiles extraDocs releases
generateDocs true true)
Target "DocsWatch" (fun _ ->
provideDocExtraFiles extraDocs releases
use watcher = new FileSystemWatcher(DirectoryInfo("docs/content").FullName, "*.*")
watcher.EnableRaisingEvents <- true
watcher.Changed.Add(fun e -> generateDocs false true)
watcher.Created.Add(fun e -> generateDocs false true)
watcher.Renamed.Add(fun e -> generateDocs false true)
watcher.Deleted.Add(fun e -> generateDocs false true)
traceImportant "Waiting for docs edits. Press any key to stop."
System.Console.ReadKey() |> ignore
watcher.EnableRaisingEvents <- false
watcher.Dispose())
"Build" ==> "CleanDocs" ==> "Docs"
"Start"
=?> ("CleanDocs", not (hasBuildParam "incremental"))
==> "DocsDev"
==> "DocsWatch"
// API REFERENCE
Target "CleanApi" (fun _ -> CleanDirs ["out/api"])
Target "Api" (fun _ ->
!! "src/Spatial/bin/Release/net461/MathNet.Spatial.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
// --------------------------------------------------------------------------------------
Target "PublishTag" (fun _ -> publishReleaseTag "Math.NET Spatial" "" spatialRelease)
Target "PublishDocs" (fun _ -> publishDocs spatialRelease)
Target "PublishApi" (fun _ -> publishApi spatialRelease)
Target "PublishArchive" (fun _ -> publishArchives [spatialSolution; spatialStrongNameSolution])
Target "PublishNuGet" (fun _ -> publishNuGet [spatialSolution; spatialStrongNameSolution])
Target "Publish" DoNothing
Dependencies "Publish" [ "PublishTag"; "PublishDocs"; "PublishApi"; "PublishArchive"; "PublishNuGet" ]
// --------------------------------------------------------------------------------------
// Default Targets
// --------------------------------------------------------------------------------------
Target "All" DoNothing
Dependencies "All" [ "Build"; "Docs"; "Api"; "Test" ]
RunTargetOrDefault "Test"