aboutsummaryrefslogtreecommitdiff
path: root/compiler/app
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/app')
-rw-r--r--compiler/app/Main.hs26
1 files changed, 21 insertions, 5 deletions
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 1a42abf..4dd6660 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -31,6 +31,7 @@ data Options = Options
31 { inputDir :: String 31 { inputDir :: String
32 , outputDir :: String 32 , outputDir :: String
33 , rebuilAll :: Bool 33 , rebuilAll :: Bool
34 , cleanOutput :: Bool
34 , withViewer :: Bool 35 , withViewer :: Bool
35 } deriving (Show, Data, Typeable) 36 } deriving (Show, Data, Typeable)
36 37
@@ -53,6 +54,11 @@ options = Options
53 &= name "rebuild-all" 54 &= name "rebuild-all"
54 &= explicit 55 &= explicit
55 &= help "Invalidate cache and recompile everything" 56 &= help "Invalidate cache and recompile everything"
57 , cleanOutput = False
58 &= name "c"
59 &= name "clean-output"
60 &= explicit
61 &= help "Remove unnecessary files from the output directory"
56 , withViewer = False 62 , withViewer = False
57 &= name "w" 63 &= name "w"
58 &= name "with-viewer" 64 &= name "with-viewer"
@@ -71,10 +77,23 @@ main :: IO ()
71main = 77main =
72 do 78 do
73 opts <- cmdArgs options 79 opts <- cmdArgs options
74 compileGallery (inputDir opts) (galleryOutputDir "gallery" opts) (rebuilAll opts) 80
75 if (withViewer opts) then copyViewer (outputDir opts) else noop 81 buildGallery opts
82
83 if (withViewer opts) then
84 copyViewer (outputDir opts)
85 else
86 return ()
76 87
77 where 88 where
89 buildGallery :: Options -> IO ()
90 buildGallery opts =
91 compileGallery
92 (inputDir opts)
93 (galleryOutputDir "gallery" opts)
94 (rebuilAll opts)
95 (cleanOutput opts)
96
78 galleryOutputDir :: FilePath -> Options -> FilePath 97 galleryOutputDir :: FilePath -> Options -> FilePath
79 galleryOutputDir gallerySubdir opts = 98 galleryOutputDir gallerySubdir opts =
80 if withViewer opts then outputBase </> gallerySubdir else outputBase 99 if withViewer opts then outputBase </> gallerySubdir else outputBase
@@ -86,6 +105,3 @@ main =
86 >> getDataFileName "viewer" 105 >> getDataFileName "viewer"
87 >>= readDirectory 106 >>= readDirectory
88 >>= copyTo target 107 >>= copyTo target
89
90 noop :: IO ()
91 noop = return ()