forked from fslaborg/FSharp.Charting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
194 lines (156 loc) · 6.73 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
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll"
open System
open System.IO
open System.Text.RegularExpressions
open Fake
open Fake.AssemblyInfoFile
open Fake.Git
open Fake.Testing
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let files includes =
{ BaseDirectory = __SOURCE_DIRECTORY__
Includes = includes
Excludes = [] }
// Information about the project to be used at NuGet and in AssemblyInfo files
let project = "FSharp.Charting"
let authors = ["Carl Nolan, Tomas Petricek"]
let summary = "A Charting Library for F#"
let description = """
The FSharp.Charting library (FSharp.Charting.dll) is a compositional library for creating charts
from F#. It is designed to be a great fit for data scripting in F# Interactive, but
charts can also be embedded in Windows applications. The library is a wrapper for .NET Chart
Controls, which are only supported on Windows."""
let tags = "F# FSharpChart charting plotting visualization"
// Information for the Gtk build of the project
let projectGtk = "FSharp.Charting.Gtk"
let summaryGtk = summary + " (Gtk, cross-platform)"
let tagsGtk = tags + " Gtk GtkSharp OxyPlot"
let descriptionGtk = """
The FSharp.Charting library (FSharp.Charting.Gtk.dll) is a cross-platform variation of
of FSharp.Charting. It can be used on Windows, OSX and other platforms supporting Gtk."""
// Read additional information from the release notes document
let release =
File.ReadLines "RELEASE_NOTES.md"
|> ReleaseNotesHelper.parseReleaseNotes
let version = release.AssemblyVersion
let releaseNotes = release.Notes |> String.concat "\n"
let compilingOnUnix =
match Environment.OSVersion.Platform with
| PlatformID.MacOSX | PlatformID.Unix -> true
| _ -> false
// --------------------------------------------------------------------------------------
// Generate assembly info files with the right version & up-to-date information
Target "AssemblyInfo" (fun _ ->
[ ("FSharp.Charting/AssemblyInfo.fs", "FSharp.Charting", project, summary)
( "FSharp.Charting.Gtk/AssemblyInfo.Gtk.fs", "FSharp.Charting.Gtk", projectGtk, summaryGtk ) ]
|> Seq.iter (fun (fileName, title, project, summary) ->
CreateFSharpAssemblyInfo fileName
[ Attribute.Title title
Attribute.Product project
Attribute.Description summary
Attribute.Version version
Attribute.FileVersion version] )
)
// --------------------------------------------------------------------------------------
// Update the assembly version numbers in the script file.
Target "UpdateFsxVersions" (fun _ ->
for nm in [ "FSharp.Charting"; "FSharp.Charting.Gtk" ] do
for path in [ @"./" + nm + "/" + nm + ".fsx" ] @ Seq.toList (Directory.EnumerateFiles "docs/content") do
let text1 = File.ReadAllText(path)
// Adjust entries like #I "../../../packages/FSharp.Charting.0.84"
let text2 = Regex.Replace(text1, "packages/" + nm + @".(.*)/lib/net40""", "packages/" + nm + sprintf @".%s/lib/net40""" version)
// Adjust entries like #load "packages/FSharp.Charting.0.84/FSharp.Charting.fsx"
let text3 = Regex.Replace(text2, "packages/" + nm + @".(.*)/" + nm + ".fsx", "packages/" + nm + sprintf @".%s/" version + nm + ".fsx")
if text1 <> text3 then
File.WriteAllText(path, text3)
)
// --------------------------------------------------------------------------------------
// Clean build results
Target "Clean" (fun _ ->
CleanDirs ["bin"]
CleanDirs ["docs/output"]
CleanDirs ["temp"]
)
// --------------------------------------------------------------------------------------
// Build library (builds Visual Studio solution, which builds multiple versions
// of the runtime library & desktop + Silverlight version of design time library)
Target "Build" (fun _ ->
(files [if not compilingOnUnix then
yield "FSharp.Charting/FSharp.Charting.fsproj";
yield "tests/FSharp.Charting.Tests.fsproj" ])
|> MSBuildRelease "" "Rebuild"
|> ignore
)
Target "BuildGtk" (fun _ ->
(files [ "FSharp.Charting.Gtk/FSharp.Charting.Gtk.fsproj" ])
|> MSBuildRelease "" "Rebuild"
|> ignore
)
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner & kill test runner when complete
Target "RunTests" (fun _ ->
ActivateFinalTarget "CloseTestRunner"
if not compilingOnUnix then
(files [ "tests/bin/Release/FSharp.Charting.Tests.dll"])
|> NUnit3 (fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 20.
})
)
FinalTarget "CloseTestRunner" (fun _ ->
ProcessHelper.killProcess "nunit-agent.exe"
)
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target "NuGet" (fun _ ->
Paket.Pack (fun p ->
{ p with
TemplateFile = "nuget/FSharp.Charting.Gtk.template"
Version = release.NugetVersion
OutputPath = "bin"
ReleaseNotes = toLines release.Notes })
if not compilingOnUnix then
Paket.Pack (fun p ->
{ p with
TemplateFile = "nuget/FSharp.Charting.template"
Version = release.NugetVersion
OutputPath = "bin"
ReleaseNotes = toLines release.Notes })
)
// --------------------------------------------------------------------------------------
// Release Scripts
Target "GenerateDocs" (fun _ ->
executeFSIWithArgs "docs/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore
)
Target "ReleaseDocs" (fun _ ->
let tempDocsDir = "temp/gh-pages"
if not (System.IO.Directory.Exists tempDocsDir) then
Repository.cloneSingleBranch "" "https://github.com/fslaborg/FSharp.Charting.git" "gh-pages" tempDocsDir
fullclean tempDocsDir
CopyRecursive "docs/output" tempDocsDir true |> tracefn "%A"
StageAll tempDocsDir
Commit tempDocsDir (sprintf "Update generated documentation for version %s" version)
Branches.push "temp/gh-pages"
)
Target "Release" DoNothing
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build target=<Target>' to verride
Target "All" DoNothing
"Clean"
==> "AssemblyInfo"
==> "UpdateFsxVersions"
==> "Build"
==> "RunTests"
"UpdateFsxVersions"
==> "BuildGtk"
"Build" ==> "NuGet"
"BuildGtk" ==> "NuGet"
"NuGet"
==> "All"
"All" ==> "Release"
"GenerateDocs" ==> "ReleaseDocs" ==> "Release"
Run <| getBuildParamOrDefault "target" "All"