-
Notifications
You must be signed in to change notification settings - Fork 45
/
build.fsx
176 lines (139 loc) · 5.88 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
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll"
open System
open Fake
open Fake.Git
open Fake.ReleaseNotesHelper
open Fake.AssemblyInfoFile
// --------------------------------------------------------------------------------------
// Information about the project to be used at NuGet and in AssemblyInfo files
// --------------------------------------------------------------------------------------
let project = "LinqOptimizer"
let authors = ["Nessos Information Technologies, Nick Palladinos, Kostas Rontogiannis"]
let summary = "An automatic query optimizer for LINQ to Objects and PLINQ."
let description = """
An automatic query optimizer for LINQ to Objects and PLINQ.
LinqOptimizer compiles declarative LINQ queries into fast loop-based imperative code.
The compiled code has fewer virtual calls, better data locality and speedups of up to 15x.
"""
let tags = "C# F# linq optimization"
let gitHome = "https://github.com/nessos"
let gitName = "LinqOptimizer"
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/nessos"
let nugetSource = "https://api.nuget.org/v3/index.json"
let nugetApiKey = environVarOrDefault "NUGET_KEY" ""
let testProjects =
[
"tests/LinqOptimizer.Tests.CSharp"
"tests/LinqOptimizer.Tests.FSharp"
]
// --------------------------------------------------------------------------------------
// The rest of the code is standard F# build script
// --------------------------------------------------------------------------------------
// Read release notes & version info from RELEASE_NOTES.md
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let release = parseReleaseNotes (IO.File.ReadAllLines "RELEASE_NOTES.md")
let nugetVersion = release.NugetVersion
Target "BuildVersion" (fun _ ->
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" nugetVersion) |> ignore
)
// Generate assembly info files with the right version & up-to-date information
Target "AssemblyInfo" (fun _ ->
let attributes =
[
Attribute.Title project
Attribute.Product project
Attribute.Company "Nessos Information Technologies"
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion
]
CreateCSharpAssemblyInfo "src/LinqOptimizer.Base/Properties/AssemblyInfo.cs" attributes
CreateFSharpAssemblyInfo "src/LinqOptimizer.Core/AssemblyInfo.fs" attributes
CreateCSharpAssemblyInfo "src/LinqOptimizer.CSharp/Properties/AssemblyInfo.cs" attributes
CreateFSharpAssemblyInfo "src/LinqOptimizer.FSharp/AssemblyInfo.fs" attributes
)
// --------------------------------------------------------------------------------------
// Clean build results & restore NuGet packages
Target "RestorePackages" (fun _ ->
!! "./**/packages.config"
|> Seq.iter (RestorePackage (fun p -> { p with ToolPath = "./.nuget/NuGet.exe" }))
)
Target "Clean" (fun _ ->
CleanDirs (!! "**/bin/Release/")
)
//
//// --------------------------------------------------------------------------------------
//// Build library & test project
let configuration = environVarOrDefault "Configuration" "Release"
Target "Build" (fun _ ->
DotNetCli.Build (fun c ->
{ c with
Project = project + ".sln"
Configuration = configuration })
)
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner & kill test runner when complete
Target "RunTests" (fun _ ->
for proj in testProjects do
DotNetCli.Test (fun c ->
{ c with
Project = proj
Configuration = configuration })
)
//
//// --------------------------------------------------------------------------------------
//// Build a NuGet package
Target "NuGet" (fun _ ->
let mkNuGetPackage project =
// Format the description to fit on a single line (remove \r\n and double-spaces)
let description = description.Replace("\r", "").Replace("\n", "").Replace(" ", " ")
let nugetPath = ".nuget/NuGet.exe"
NuGet (fun p ->
{ p with
Authors = authors
Project = project
Summary = summary
Description = description
Version = nugetVersion
ReleaseNotes = String.concat " " release.Notes
Tags = tags
OutputPath = "nuget"
ToolPath = nugetPath
AccessKey = getBuildParamOrDefault "nugetkey" ""
Publish = hasBuildParam "nugetkey" })
("nuget/" + project + ".nuspec")
mkNuGetPackage "LinqOptimizer.CSharp"
mkNuGetPackage "LinqOptimizer.FSharp"
)
Target "PublishNuGet" (fun _ ->
if String.IsNullOrEmpty nugetApiKey then failwith "build did not specify a nuget API key"
let pushPkg nupkg =
// omg dotnet pack doesn't work wih absolute paths
let relativePath = ProduceRelativePath __SOURCE_DIRECTORY__ nupkg
DotNetCli.RunCommand
(fun c -> { c with WorkingDir = __SOURCE_DIRECTORY__ })
(sprintf "nuget push %s -s %s -k %s" relativePath nugetSource nugetApiKey)
!! "NuGet/*.nupkg" |> Seq.toArray |> Array.Parallel.iter pushPkg
)
Target "Release" DoNothing
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
Target "Prepare" DoNothing
Target "PrepareRelease" DoNothing
Target "All" DoNothing
"Clean"
==> "RestorePackages"
==> "AssemblyInfo"
==> "Prepare"
==> "Build"
==> "RunTests"
==> "All"
"All"
==> "PrepareRelease"
==> "NuGet"
==> "PublishNuGet"
==> "Release"
RunTargetOrDefault "NuGet"