-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
executable file
·90 lines (73 loc) · 2.42 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
#!/usr/bin/env -S dotnet fsi
#r "nuget: Fake.DotNet.Cli, 5.22.0"
#r "nuget: Fake.IO.FileSystem, 5.22.0"
#r "nuget: Fake.Core.Target, 5.22.0"
#r "nuget: Fake.DotNet.MsBuild, 5.22.0"
#r "nuget: MSBuild.StructuredLogger, 2.1.630"
#r "nuget: System.IO.Compression.ZipFile, 4.3.0"
#r "nuget: System.Reactive, 5.0.0"
open System
open System.IO.Compression
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
// https://github.com/fsharp/FAKE/issues/2517#issuecomment-727282959
Environment.GetCommandLineArgs()
|> Array.skip 2 // skip fsi.exe; build.fsx
|> Array.toList
|> Context.FakeExecutionContext.Create false "build.fsx"
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext
let output = "./nugets"
let projects =
[| "Deno.Fable" |]
let fsharpSourceFiles =
!! "src/**/*.fs"
++ "src/**/*.fsi"
++ "src/**/*.fsx"
++ "build.fsx"
-- "**/obj/**/*.fs"
-- "**/fable_modules/**/*.fs"
Target.initEnvironment ()
Target.create "Clean" (fun _ -> !! "nugets" |> Shell.cleanDirs)
Target.create "Format" (fun _ ->
let result =
fsharpSourceFiles
|> Seq.map (sprintf "\"%s\"")
|> String.concat " "
|> DotNet.exec id "fantomas"
if not result.OK then
printfn $"Errors while formatting all files: %A{result.Messages}")
Target.create "CheckFormat" (fun _ ->
let result =
fsharpSourceFiles
|> Seq.map (sprintf "\"%s\"")
|> String.concat " "
|> sprintf "%s --check"
|> DotNet.exec id "fantomas"
if result.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, check output for more info"
else
Trace.logf $"Errors while formatting: %A{result.Errors}")
Target.create "PackNugets" (fun _ ->
projects
|> Array.iter (fun project ->
DotNet.pack
(fun opts ->
{ opts with
Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some $"./{output}/{project}" })
$"src/{project}"))
Target.create "Zip" (fun _ ->
projects
|> Array.Parallel.iter (fun project -> ZipFile.CreateFromDirectory($"{output}/{project}", $"{output}/{project}.zip")))
Target.create "Default" (fun _ -> Target.runSimple "Zip" [] |> ignore)
"Clean"
==> "CheckFormat"
==> "PackNugets"
==> "Default"
Target.runOrDefault "Default"