forked from rdotnet/rdotnet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.fsx
200 lines (164 loc) · 7.28 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
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll"
open System
open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
// --------------------------------------------------------------------------------------
// Information about the project to be used at NuGet and in AssemblyInfo files
// --------------------------------------------------------------------------------------
let projectName = "Spreads.R"
let projectSummary = "R interoperability library optimized for Spreads"
let projectDescription = """
A .NET interoperability library to access the R statistical package from .NET languages.
The library is based on R.NET and is optimized for fast zero-copy data exchange of arrays and Spreads series."""
let authors = [ "Victor Baybekov, R.NET original authors (Kosei Abe; Jean-Michel Perraud)"]
let companyName = ""
let tags = ".NET R R.NET visualization statistics C# F# Spreads F# data streaming real-time analysis streams time series reactive"
let gitOwner = "Spreads"
let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitName = "Spreads.R"
// --------------------------------------------------------------------------------------
// The rest of the code is standard F# build script
// --------------------------------------------------------------------------------------
// Read release notes & version info from RELEASE_NOTES.md
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let binDir = __SOURCE_DIRECTORY__ @@ "bin"
let release = IO.File.ReadLines "RELEASE_NOTES.md" |> parseReleaseNotes
// Generate assembly info files with the right version & up-to-date information
Target "VersionInfo" (fun _ ->
let fileName = "R.NET/Properties/VersionInfo.cs"
CreateCSharpAssemblyInfoWithConfig fileName
[ Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion ]
(AssemblyInfoFileConfig(false))
CreateFSharpAssemblyInfoWithConfig "RDotNet.FSharp/VersionInfo.fs"
[ Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion ]
(AssemblyInfoFileConfig(false))
)
// --------------------------------------------------------------------------------------
// Update the assembly version numbers in the script file.
open System.IO
//Target "UpdateFsxVersions" (fun _ ->
// let pattern = "packages/RProvider.(.*)/lib"
// let replacement = sprintf "packages/RProvider.%s/lib" release.NugetVersion
// let path = "./src/RProvider/RProvider.fsx"
// let text = File.ReadAllText(path)
// let text = Text.RegularExpressions.Regex.Replace(text, pattern, replacement)
// File.WriteAllText(path, text)
//)
// --------------------------------------------------------------------------------------
// Clean build results & restore NuGet packages
//Target "Clean" (fun _ ->
// CleanDirs ["bin"; "temp" ]
//)
//Target "CleanDocs" (fun _ ->
// CleanDirs ["docs/output"]
//)
// --------------------------------------------------------------------------------------
// Build library & test project
Target "Build" (fun _ ->
// !! ("R.NET.sln")
// |> MSBuildRelease "" "Build"
// |> Log "AppBuild-Output: "
//)
//
//Target "BuildTests" (fun _ ->
!! ("RDotNet.Tests.sln")
|> MSBuildRelease "" "Build"
|> Log "AppBuild-Output: "
)
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner & kill test runner when complete
Target "RunTests" (fun _ ->
let nunitConsolePath = "packages/NUnit.Runners/tools"
ActivateFinalTarget "CloseTestRunner"
!! "RDotNet.Tests/bin/Release/RDotNet.Tests.dll"
|> NUnit (fun p ->
{p with
ToolPath = nunitConsolePath
Domain = NUnitDomainModel.SingleDomainModel
})
)
FinalTarget "CloseTestRunner" (fun _ ->
ProcessHelper.killProcess "nunit-console.exe"
)
// --------------------------------------------------------------------------------------
// Build a NuGet package
let DoNuGet fileName =
// Format the description to fit on a single line (remove \r\n and double-spaces)
let projectDescription = projectDescription.Replace("\r", "").Replace("\n", "").Replace(" ", " ")
NuGet (fun p ->
{ p with
Authors = authors
Project = projectName
Summary = projectSummary
Description = projectDescription
Version = release.NugetVersion
ReleaseNotes = String.concat " " release.Notes
Tags = tags
OutputPath = "bin"
AccessKey = getBuildParamOrDefault "nugetkey" ""
Publish = hasBuildParam "nugetkey" })
fileName
Target "NuGetRDotNet" (fun _ ->
DoNuGet "nuget/Spreads.R.nuspec"
)
// --------------------------------------------------------------------------------------
// Generate the documentation
//Target "GenerateDocs" (fun _ ->
// executeFSIWithArgs "docs/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore
//)
// --------------------------------------------------------------------------------------
// Release Scripts
//Target "ReleaseDocs" (fun _ ->
// Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/gh-pages"
// Branches.checkoutBranch "temp/gh-pages" "gh-pages"
// CopyRecursive "docs/output" "temp/gh-pages" true |> printfn "%A"
// CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
// let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" release.NugetVersion
// CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s"
// Branches.push "temp/gh-pages"
//)
//Target "ReleaseBinaries" (fun _ ->
// Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/release"
// Branches.checkoutBranch "temp/release" "release"
// CopyRecursive "bin" "temp/release" true |> printfn "%A"
// let cmd = sprintf """commit -a -m "Update binaries for version %s""" release.NugetVersion
// CommandHelper.runSimpleGitCommand "temp/release" cmd |> printfn "%s"
// Branches.push "temp/release"
//)
//Target "TagRelease" (fun _ ->
// // Concatenate notes & create a tag in the local repository
// let notes = (String.concat " " release.Notes).Replace("\n", ";").Replace("\r", "")
// let tagName = "v" + release.NugetVersion
// let cmd = sprintf """tag -a %s -m "%s" """ tagName notes
// CommandHelper.runSimpleGitCommand "." cmd |> printfn "%s"
//
// // Find the main remote (BlueMountain GitHub)
// let _, remotes, _ = CommandHelper.runGitCommand "." "remote -v"
// let main = remotes |> Seq.find (fun s -> s.Contains("(push)") && s.Contains("BlueMountainCapital/FSharpRProvider"))
// let remoteName = main.Split('\t').[0]
// Fake.Git.Branches.pushTag "." remoteName tagName
//)
Target "All" DoNothing
Target "NuGet" DoNothing
Target "Release" DoNothing
Target "Test" DoNothing
//"Clean"
// ==> "Build"
// ==> "BuildTests"
// ==> "RunTests"
// ==> "All"
"VersionInfo" ==> "All"
//"Build" ==> "All"
//"All" ==> "RunTests" ==> "Test"
"NuGetRDotNet" ==> "NuGet"
"All" ==> "NuGet" ==> "Release"
RunTargetOrDefault "NuGet"