-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.fsx
85 lines (77 loc) · 2.76 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
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open System.Diagnostics
#load ".fake/build.fsx/intellisense.fsx"
let findMSBuild =
async {
let info = ProcessStartInfo("vswhere.exe", "-property installationPath -latest")
info.RedirectStandardOutput <- true
info.UseShellExecute <- false
use p = Process.Start info
let vs = p.StandardOutput.ReadToEndAsync() |> Async.AwaitTask
p.WaitForExit |> ignore
let! dir = vs
let msBuild = dir+"\\MSBuild\\Current\\Bin\\MSBuild.exe"
return msBuild.Replace("\n", "").Replace("\r", "")
}
Target.create "Clean" (fun _ ->
if (Environment.isLinux) then
!! "**/Cargo.toml"
|> Seq.iter(fun project ->
let dir = Path.getDirectory project
Shell.Exec ("cargo", "clean", dir) |> ignore
)
!! "**/*.csproj"
|> Seq.iter (fun project ->
let dir = Path.getDirectory project
Shell.Exec ("dotnet", "clean", dir) |> ignore
)
if (Environment.isWindows) then
async {
let! msbuild = findMSBuild
let dir = Path.getDirectory msbuild
!! "**/hjudge*/*.vcxproj"
|> Seq.iter(fun project ->
Shell.Exec (msbuild, "/m /v:m /t:Clean "+project, dir) |> ignore
)
} |> Async.RunSynchronously
)
Target.create "Build" (fun _ ->
if (Environment.isLinux) then
!! "**/Cargo.toml"
|> Seq.iter(fun project ->
let dir = Path.getDirectory project
Shell.Exec ("cargo", "build --release", dir) |> ignore
let outputDir = dir+"/target/release";
for x in System.IO.Directory.GetFiles outputDir do
let sb = System.Text.StringBuilder()
let fileName = System.IO.Path.GetFileName x
for i in fileName do
match i with
| '_' -> sb.Append '.' |> ignore
| _ -> sb.Append i |> ignore
let targetFileName = Path.combine outputDir (sb.ToString())
System.IO.File.Move(x, targetFileName)
)
!! "**/*.csproj"
|> Seq.iter (DotNet.publish id)
if (Environment.isWindows) then
async {
let! msbuild = findMSBuild
let dir = Path.getDirectory msbuild
!! "**/hjudge*/*.vcxproj"
|> Seq.iter(fun project ->
Shell.Exec (msbuild, "/m /v:m /p:Configuration=Release /p:Platform=x64 "+project, dir) |> ignore
)
} |> Async.RunSynchronously
)
Target.create "Test" (fun _ ->
!! "**/*.Test.csproj"
|> Seq.iter (DotNet.test id)
)
Target.create "All" ignore
"Clean" ==> "Build" ==> "All"
Target.runOrDefault "All"