-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shakefile.hs
43 lines (32 loc) · 1.73 KB
/
Shakefile.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
import System.Environment
import Development.Shake
import Development.Shake.FilePath
buildDir = "build"
latexSources = ["thesis.tex", "background.tex", "game.tex", "intro.tex", "solving.tex", "syntcomp.tex", "userguided.tex", "i2c.tex", "conclusions.tex", "asl.tex", "related.tex"]
tslRefSources = ["body.tex"]
bibSources = ["extra.bib"]
main :: IO ()
main = shakeArgs shakeOptions{shakeFiles=".shake/", shakeThreads=4} $ do
want ["thesis.pdf"]
"thesis.pdf" %> \out -> do
files <- getDirectoryFiles "diagrams" ["//*.hs"]
bibs <- getDirectoryFiles "bibtex" ["//*.bib"]
tsls <- getDirectoryFiles "i2c" ["//*.tsl"]
let diagramFiles = map (\x -> buildDir </> "diagrams" </> x -<.> "pdf") files
bibFiles = map ("bibtex" </>) bibs
need $ map ("sources" </>) latexSources ++ map ("tsl_reference" </>) tslRefSources ++ bibSources ++ diagramFiles ++ bibFiles ++ map ("i2c" </>) tsls
env' <- liftIO getEnvironment
let env = Env $ ("TEXINPUTS", "sources:build:") : env'
() <- cmd "pdflatex" env ["-output-directory=" ++ buildDir, "thesis.tex"]
() <- cmd "bibtex" [buildDir </> "thesis.aux"]
() <- cmd "pdflatex" env ["-output-directory=" ++ buildDir, "thesis.tex"]
() <- cmd "pdflatex" env ["-output-directory=" ++ buildDir, "thesis.tex"]
cmd "cp" [buildDir </> "thesis.pdf", "thesis.pdf"]
(buildDir </> "diagrams" </> "*.pdf") %> \out -> do
let nd = dropDirectory1 out -<.> "hs"
need $ [nd]
cmd "runhaskell" [nd, "-o", out, "-w 200"]
phony "clean" $ do
putNormal $ "Cleaning files in .shake and " ++ buildDir
removeFilesAfter ".shake" ["//*"]
removeFilesAfter buildDir ["//*"]