-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShakefile.hs
41 lines (34 loc) · 1.46 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
import Control.Monad (forM)
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
main :: IO ()
main = shakeArgs shakeOptions{shakeFiles="_build"} $ do
want ["_build/hydra-spec" <.> "pdf"]
phony "clean" $ do
putInfo "Cleaning files in _build"
removeFilesAfter "_build" ["//*"]
"_build/hydra-spec" <.> "pdf" %> \out -> do
assets <- getDirectoryFiles "src" ["//*.sty", "Hydra/Protocol/Figures/*.svg", "//*.bib", "//*.ttf"]
need ["_build/latex" </> c | c <- assets]
srcs <- getDirectoryFiles "src" ["//*.lagda", "//*.tex"]
need ["_build/latex" </> c -<.> "tex" | c <- srcs]
cmd_ (Cwd "_build/latex") "latexmk -xelatex -shell-escape -halt-on-error Hydra/Protocol/Main.tex"
cmd_ "cp _build/latex/Main.pdf _build/hydra-spec.pdf"
-- Copy assets
forM ["sty", "svg", "bib", "ttf"] $ \ext ->
("_build/latex//*." <> ext) %> \out -> do
let src = "src" </> dropDirectory1 (dropDirectory1 out)
copyFile' src out
-- Copy or compile from lagda files
"_build/latex//*.tex" %> \out -> do
let src = "src" </> dropDirectory1 (dropDirectory1 out)
b <- doesFileExist src
if b then do
need [src]
copyFile' src out
else do
let src = "src" </> dropDirectory1 (dropDirectory1 (out -<.> "lagda"))
need [src]
cmd_ $ "agda --transliterate --latex --latex-dir _build/latex " <> src