-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBuild.hs
60 lines (50 loc) · 1.93 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
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
ottFile = "Gen/ott-rules.tex"
doc = "Thesis"
ottFlags = "-tex_wrap false -tex_show_meta false"
lhsFlags = "--poly -o"
main :: IO ()
main =
shakeArgs shakeOptions {shakeFiles = "_build"} $ do
want [doc <.> "pdf"]
"*.pdf" %> \_ -> do
let thesisSource = doc -<.> "tex"
texSource <- getDirectoryFiles "" ["/*.tex", "Sources//*.tex"]
codeSource <- getDirectoryFiles "" ["examples/*.sl"]
genFiles <-
(\mngSource ->
["Gen" </> (dropDirectory1 c -<.> "tex") | c <- mngSource]) <$>
getDirectoryFiles "" ["Sources//*.mngtex"]
genLhsFiles <-
(\mngSource ->
["Gen" </> (dropDirectory1 c -<.> "lhstex") | c <- mngSource]) <$>
getDirectoryFiles "" ["Sources//*.lhsmngtex"]
need $ [thesisSource, ottFile] ++ genFiles ++ texSource ++ codeSource ++ genLhsFiles
cmd "latexmk" [thesisSource]
doc ++ ".tex" %> \out -> do
let dep = out -<.> ".lhstex"
need $ [dep]
cmd "lhs2Tex" lhsFlags [out] [dep]
"Gen//*.lhstex" %> \out -> do
ottSource <- getDirectoryFiles "" ["spec/*.ott"]
let dep = "Sources" </> dropDirectory1 out -<.> ".lhsmngtex"
tmp = out -<.> ".tmp"
need $ dep : ottSource
cmd_ "ott" ottSource ottFlags "-tex_filter" [dep] [tmp]
cmd "lhs2Tex" lhsFlags [out] [tmp]
"Gen//*.tex" %> \out -> do
ottSource <- getDirectoryFiles "" ["spec/*.ott"]
let dep = "Sources" </> dropDirectory1 out -<.> ".mngtex"
need $ dep : ottSource
cmd "ott" ottSource ottFlags "-tex_filter" [dep] [out]
ottFile %> \out -> do
ottSource <- getDirectoryFiles "" ["spec/*.ott"]
need ottSource
cmd "ott" ottSource ottFlags "-o" [out]
phony "clean" $ do
putNormal "Cleaning files in _build"
removeFilesAfter "_build" ["//*"]
cmd "latexmk -c"