-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.fsx
More file actions
executable file
·241 lines (201 loc) · 8.99 KB
/
build.fsx
File metadata and controls
executable file
·241 lines (201 loc) · 8.99 KB
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
#!/usr/bin/env -S dotnet fsi
#r "nuget: Fake.Core.Target, 5.23.1"
#r "nuget: Fake.IO.FileSystem, 5.23.1"
#r "nuget: Fake.DotNet.Cli, 5.23.1"
#r "nuget: Fake.Core.ReleaseNotes, 5.23.1"
#r "nuget: Fake.Tools.Git, 5.23.1"
#r "nuget: MSBuild.StructuredLogger, 2.2.441"
open System
open System.IO
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Tools.Git
System.Environment.GetCommandLineArgs()
|> Array.skip 2 // fsi.exe; build.fsx
|> Array.toList
|> Context.FakeExecutionContext.Create false __SOURCE_FILE__
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext
// Git configuration (used for publishing documentation in gh-pages branch)
// The profile where the project is posted
let gitOwner = "FsStorm"
let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitName = "FsShelter"
// The url for the raw files hosted
let gitRaw = Environment.environVarOrDefault "gitRaw" "https://raw.github.com/"+gitOwner+"/"+gitName
// Read additional information from the release notes document
let release = ReleaseNotes.load "RELEASE_NOTES.md"
module ProcessResult =
let assertSuccess (r: ProcessResult) =
if( not r.OK ) then failwithf "Error while executing process: %A" r
Target.create "Clean" (fun _ ->
!! "./**/bin"
++ "./**/obj"
++ "./docs/output"
|> Seq.iter Shell.cleanDir
)
Target.create "Meta" (fun _ ->
[ "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
"<ItemGroup>"
"""<None Include="$(MSBuildThisFileDirectory)/docs/files/img/logo.png" Pack="true" PackagePath="\" />"""
"""<None Include="$(MSBuildThisFileDirectory)/LICENSE.md" Pack="true" PackagePath="\" />"""
"""<None Include="$(MSBuildThisFileDirectory)/README.md" Pack="true" PackagePath="\"/>"""
"""<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>"""
"</ItemGroup>"
"<PropertyGroup>"
"<PackageProjectUrl>https://FsStorm.github.io/FsShelter/</PackageProjectUrl>"
"<PackageLicenseFile>LICENSE.md</PackageLicenseFile>"
"<PackageIcon>logo.png</PackageIcon>"
"<RepositoryUrl>https://github.com/FsStorm/FsShelter.git</RepositoryUrl>"
"<PackageTags>storm;cep;event-driven;fsharp;distributed</PackageTags>"
"<PackageDescription>F# DSL and runtime for Apache Storm topologies</PackageDescription>"
"<Authors>Eugene Tolmachev</Authors>"
sprintf "<PackageReleaseNotes>%s</PackageReleaseNotes>" (List.head release.Notes |> System.Web.HttpUtility.HtmlEncode)
sprintf "<Version>%s</Version>" (string release.SemVer)
"<FsDocsLogoSource>files/img/logo.png</FsDocsLogoSource>"
"<FsDocsFaviconSource>files/img/logo.png</FsDocsFaviconSource>"
"<FsDocsLicenseLink>https://github.com/FsStorm/FsShelter/blob/master/LICENSE.md</FsDocsLicenseLink>"
"<FsDocsReleaseNotesLink>https://github.com/FsStorm/FsShelter/blob/master/RELEASE_NOTES.md</FsDocsReleaseNotesLink>"
"</PropertyGroup>"
"</Project>"]
|> File.write false "Directory.Build.props"
)
Target.create "Restore" (fun _ ->
DotNet.restore id "src"
)
Target.create "Build" (fun _ ->
DotNet.build (fun opt -> { opt with Configuration = DotNet.BuildConfiguration.Release }) "src"
)
Target.create "Tests" (fun _ ->
let args = "--no-restore --filter \"TestCategory!=interactive&TestCategory!=perf\""
DotNet.test (fun a -> a.WithCommon (fun c -> { c with CustomParams = Some args})) "src/FsShelter.Tests"
)
Target.create "Package" (fun _ ->
let args = sprintf "/p:Version=%s --no-restore" (string release.SemVer)
DotNet.pack (fun a -> a.WithCommon (fun c -> { c with CustomParams = Some args })) "src/FsShelter"
DotNet.pack (fun a -> a.WithCommon (fun c -> { c with CustomParams = Some args })) "src/FsShelter.Multilang"
)
Target.create "PublishNuget" (fun _ ->
let exec dir = DotNet.exec (fun a -> a.WithCommon (fun c -> { c with WorkingDirectory=dir }))
[exec "src/FsShelter" "nuget" (sprintf "push bin/Release/FsShelter.%s.nupkg -s nuget.org -k %s" release.NugetVersion (Environment.environVar "nugetkey"))
exec "src/FsShelter.Multilang" "nuget" (sprintf "push bin/Release/FsShelter.Multilang.%s.nupkg -s nuget.org -k %s" release.NugetVersion (Environment.environVar "nugetkey"))]
|> List.iter ProcessResult.assertSuccess
)
// --------------------------------------------------------------------------------------
// Generate the documentation
let fsdocProperties = [
"Configuration=Release"
"TargetFramework=net10.0"
]
Target.create "GenerateDocs" (fun _ ->
Shell.cleanDir ".fsdocs"
DotNet.exec id "fsdocs" ("build --strict --eval --clean"
+ " --projects src/FsShelter/FsShelter.fsproj src/FsShelter.Multilang/FsShelter.Multilang.fsproj"
+ " --properties " + String.Join(" ",fsdocProperties))
|> ProcessResult.assertSuccess
// GitHub Pages needs a root index.html to serve the landing page
File.writeString false ("output" @@ "index.html")
"""<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0;url=content/index.html"></head><body></body></html>"""
)
Target.create "WatchDocs" (fun _ ->
Shell.cleanDir ".fsdocs"
DotNet.exec id "fsdocs" ("watch --eval"
+ " --projects src/FsShelter/FsShelter.fsproj src/FsShelter.Multilang/FsShelter.Multilang.fsproj"
+ " --properties " + String.Join(" ",fsdocProperties)) |> ignore
)
Target.create "ReleaseDocs" (fun _ ->
let tempDocsDir = "temp/gh-pages"
Shell.cleanDir tempDocsDir
Repository.cloneSingleBranch "" ("git@github.com:FsStorm/FsShelter.git") "gh-pages" tempDocsDir
Repository.fullclean tempDocsDir
Shell.copyRecursive "output" tempDocsDir true |> Trace.tracefn "%A"
Staging.stageAll tempDocsDir
Commit.exec tempDocsDir (sprintf "Update generated documentation for version %s" (string release.SemVer))
Branches.push tempDocsDir
)
// --------------------------------------------------------------------------------------
// code-gen tasks
Target.create "ProtoShell" (fun _ ->
let generated = "ext" @@ "ProtoShell" @@ "generated"
let cli =
"packages" @@ "build" @@ "Google.Protobuf.Tools" @@ "tools"
@@ if Environment.isWindows then "windows_x64" @@ "protoc.exe"
else if Environment.isLinux then "linux_x64" @@ "protoc"
else "macosx_x64" @@ "protoc"
Shell.cleanDir generated
Shell.Exec(
cli,
"--csharp_out=" + generated
+ " --proto_path=" + "packages" @@ "build" @@ "Google.Protobuf.Tools" @@ "tools"
+ " --proto_path=" + "paket-files" @@ "FsStorm" @@ "protoshell" @@ "src" @@ "main" @@ "proto"
+ " paket-files" @@ "FsStorm" @@ "protoshell" @@ "src" @@ "main" @@ "proto" @@ "multilang.proto",
".")
|> ignore
)
Target.create "StormThriftNamespace" (fun _ ->
"paket-files" @@ "et1975" @@ "storm" @@ "storm-core" @@ "src" @@ "storm.thrift"
|> Shell.regexReplaceInFileWithEncoding "namespace java org.apache.storm.generated" "namespace netstd StormThrift" Text.Encoding.ASCII
)
Target.create "StormThrift" (fun _ ->
let generated = "ext" @@ "StormThrift" @@ "StormThrift"
Shell.cleanDir generated
Shell.Exec(
// "packet-files" @@ "build" @@ "dlcdn.apache.org" @@ "thrift-0.16.0.exe",
"thrift",
"-out " + generated @@ ".."
+ " --gen netstd"
+ " paket-files" @@ "et1975" @@ "storm" @@ "storm-core" @@ "src" @@ "storm.thrift",
".")
|> ignore
)
Target.create "GenerateSources" ignore
"ProtoShell"
==> "GenerateSources"
"StormThriftNamespace"
==> "StormThrift"
==> "GenerateSources"
// --------------------------------------------------------------------------------------
// graph gen tasks
// GraphViz has to be installed and "dot" be in the path
let exportGraph (app:string) (arg:string) fileName =
Shell.Exec(
"dotnet",
("samples" @@ app @@ "bin" @@ "Release" @@ "net10.0" @@ (sprintf "%s.dll" app)) +
(sprintf " %s | dot -Tsvg -o samples/%s/obj/%s.svg" arg app fileName),
".")
|> ignore
Target.create "WordCountSvg" (fun _ ->
exportGraph "WordCount" "graph" "WordCount"
)
Target.create "WordCountColourSvg" (fun _ ->
exportGraph "WordCount" "colour-graph" "WordCount_colourized"
)
Target.create "WordCountCustomColourSvg" (fun _ ->
exportGraph "WordCount" "custom-colour-graph" "WordCount_custom_colourized"
)
Target.create "GuaranteedSvg" (fun _ ->
exportGraph "Guaranteed" "graph" "Guaranteed"
)
Target.create "ExportGraphs" ignore
Target.create "All" ignore
Target.create "Release" ignore
"ExportGraphs"
<== ["Build"; "WordCountSvg"; "WordCountColourSvg"; "WordCountCustomColourSvg"; "GuaranteedSvg"]
"All"
<== ["Clean"; "Restore"; "Meta"; "Build"; "Tests"; "Package"; "GenerateDocs"]
"Build"
==> "Tests"
"Build"
==> "GenerateDocs"
"Meta"
==> "Build"
==> "Package"
==> "PublishNuget"
"Release"
<== ["All"; "PublishNuget"; "ReleaseDocs"]
Target.runOrDefault "All"