forked from nblockchain/fsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci-build.fsx
executable file
·116 lines (89 loc) · 2.7 KB
/
ci-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
#!/usr/bin/env fsx
open System
open System.IO
open System.Linq
#r "System.Configuration"
open System.Configuration
#load "InfraLib/Misc.fs"
#load "InfraLib/Process.fs"
open FSX.Infrastructure
open Process
let rec FindFsxc() : FileInfo =
let fsxCompiler = "fsxc.exe"
let fsxcBinDir = Path.Combine(__SOURCE_DIRECTORY__, "fsxc", "bin")
let findFsxcExeFiles() =
Directory.GetFiles(fsxcBinDir, fsxCompiler, SearchOption.AllDirectories)
if not(Directory.Exists fsxcBinDir) || not(findFsxcExeFiles().Any()) then
let configureProc =
Process.Execute(
{
Command = "./configure.sh"
Arguments = String.Empty
},
Echo.All
)
if configureProc.ExitCode <> 0 then
Environment.Exit 1
failwith "Unreachable"
let makeProc =
Process.Execute(
{
Command = "make"
Arguments = String.Empty
},
Echo.All
)
if makeProc.ExitCode <> 0 then
Environment.Exit 1
failwith "Unreachable"
FindFsxc()
elif findFsxcExeFiles().Count() > 1 then
Console.Error.WriteLine(
sprintf
"More than one %s file found, please just leave one"
fsxCompiler
)
Environment.Exit 1
failwith "Unreachable"
else
findFsxcExeFiles().Single() |> FileInfo
let fsxLocation = FindFsxc()
Console.WriteLine("Checking if all .fsx scripts build")
let fsxScripts =
Directory.GetFiles(
Directory.GetCurrentDirectory(),
"*.fsx",
SearchOption.AllDirectories
)
let buildFsxScript (script: string) (soFar: bool) : bool =
if (script = null) then
raise <| ArgumentNullException("script")
Console.WriteLine(sprintf "Building %s" script)
let procResult =
Process.Execute(
{
Command = fsxLocation.FullName
Arguments = sprintf "-k %s" script
},
Echo.OutputOnly
)
let success =
match procResult.ExitCode with
| 0 -> true
| _ -> false
Console.WriteLine()
(success && soFar)
let rec buildAll (scripts: list<string>) (soFar: bool) : bool =
match scripts with
| [] -> soFar
| script :: tail ->
let sofarPlusOne = buildFsxScript script soFar
buildAll tail sofarPlusOne
let scripts = List.ofArray fsxScripts
let allCompile = buildAll scripts true
if allCompile then
Console.WriteLine("Success")
Environment.Exit(0)
else
Console.WriteLine("Some script(s) had errors")
Environment.Exit(1)