-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhake.hs
80 lines (59 loc) · 2.22 KB
/
hake.hs
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
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE UnicodeSyntax #-}
import Hake
main ∷ IO ()
main = hake $ do
"clean | clean the project" ∫
cargo ["clean"] ?> removeDirIfExists targetPath
"update | update dependencies" ∫ cargo ["update"]
salieriExecutable ♯
cargo <| "build" : buildFlagsSalieri False
amadeusExecutable ◉ [salieriExecutable] ♯♯
cargo <| "build" : buildFlagsAmadeus False
"fat | build Amadeus and Salieri with fat LTO" ∫
cargo <| "build" : buildFlagsSalieri True
>> cargo <| "build" : buildFlagsAmadeus True
"install | install to system" ◉ [ "fat" ] ∰
cargo <| "install" : buildFlagsAmadeus True
"test | build and test" ◉ [amadeusExecutable] ∰ do
cargo ["test"]
cargo ["clippy"]
rawSystem amadeusExecutable ["--version"]
>>= checkExitCode
"restart | restart services" ◉ [ salieriExecutable
, amadeusExecutable ] ∰ do
systemctl ["restart", appNameSalieri]
systemctl ["restart", appNameAmadeus]
"run | run Amadeus" ◉ [ amadeusExecutable ] ∰ do
cargo . (("run" : buildFlagsAmadeus False) ++) . ("--" :) =<< getHakeArgs
where
appNameSalieri ∷ String
appNameSalieri = "salieri"
appNameAmadeus ∷ String
appNameAmadeus = "amadeus"
targetPath ∷ FilePath
targetPath = "target"
buildPath ∷ FilePath
buildPath = targetPath </> "release"
amadeusFeatures ∷ [String]
amadeusFeatures = [ "trackers" ]
fatArgs ∷ [String]
fatArgs = [ "--profile"
, "fat-release" ]
buildFlagsSalieri ∷ Bool -> [String]
buildFlagsSalieri fat =
let defaultFlags = [ "-p", appNameSalieri
, "--release" ]
in if fat then defaultFlags ++ fatArgs
else defaultFlags
buildFlagsAmadeus ∷ Bool -> [String]
buildFlagsAmadeus fat =
let defaultFlags = [ "-p", appNameAmadeus
, "--release", "--features"
, intercalate "," amadeusFeatures ]
in if fat then defaultFlags ++ fatArgs
else defaultFlags
salieriExecutable ∷ FilePath
salieriExecutable = buildPath </> appNameSalieri
amadeusExecutable ∷ FilePath
amadeusExecutable = buildPath </> appNameAmadeus