-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBuild.hs
executable file
·95 lines (79 loc) · 2.86 KB
/
Build.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env stack
-- stack --install-ghc runghc --package shake
import Development.Shake
import Development.Shake.FilePath
import System.Directory
opts = shakeOptions { shakeFiles = ".shake"
, shakeVersion = "1.0"
, shakeVerbosity = Normal
, shakeThreads = 0
}
main :: IO ()
main = getDirectoryFilesIO "demo" ["/*.lhs", "/*.hs"] >>= \allDemos ->
getDirectoryFilesIO "src" ["//*.hs"] >>= \allSrc ->
shakeArgs opts $ do
want ["all"]
"all" ~>
-- need ["haddocks", "gentags", "install", "exe", "js"]
need ["haddocks", "gentags", "install", "js"]
"exe" ~>
need (map (\f -> "demo-exe" </> dropExtension f) allDemos)
"js" ~>
need (map (\f -> "demo-js" </> dropExtension f) allDemos)
"haddocks" ~> do
need (("src" </>) <$> allSrc)
cmd "jle-git-haddocks"
"install" ~> do
need $ ("src" </>) <$> allSrc
cmd "stack install"
"install-ghcjs" ~> do
need $ ("src" </>) <$> allSrc
cmd "stack install --stack-yaml stack-ghcjs.yaml"
"gentags" ~>
need ["tags", "TAGS"]
"demo-exe/*" %> \f -> do
need ["install"]
[src] <- getDirectoryFiles "demo" $ (takeFileName f <.>) <$> ["hs","lhs"]
liftIO $ do
createDirectoryIfMissing True "demo-exe"
createDirectoryIfMissing True ".build"
removeFilesAfter "demo" ["/*.o"]
cmd "stack exec" "--package backprop-learn"
"--"
"ghc"
("demo" </> src)
"-o" f
"-hidir" ".build"
"-threaded"
"-rtsopts"
"-with-rtsopts=-N"
"-Wall"
"-O2"
"demo-js/*" %> \f -> do
need ["install-ghcjs"]
[src] <- getDirectoryFiles "demo" $ (takeFileName f <.>) <$> ["hs","lhs"]
liftIO $ do
createDirectoryIfMissing True "demo-js"
createDirectoryIfMissing True ".build"
removeFilesAfter "demo" ["/*.o"]
cmd "stack exec" "--package backprop-learn"
"--package reflex-dom"
"--stack-yaml stack-ghcjs.yaml"
"--"
"ghcjs"
("demo" </> src)
"-o" f
"-hidir" ".build"
"-threaded"
"-rtsopts"
"-with-rtsopts=-N"
"-Wall"
"-O2"
["tags","TAGS"] &%> \_ -> do
need (("src" </>) <$> allSrc)
cmd "hasktags" "src/"
"clean" ~> do
unit $ cmd "stack clean"
removeFilesAfter ".shake" ["//*"]
removeFilesAfter ".build" ["//*"]
removeFilesAfter "demo-exe" ["//*"]