aboutsummaryrefslogtreecommitdiff
path: root/compiler/app/Main.hs
diff options
context:
space:
mode:
authorOzoneGrif2020-02-08 04:29:45 +0100
committerGitHub2020-02-08 04:29:45 +0100
commit8facee21e8c60d14257afae13b69f30fb87e2b4b (patch)
tree4abda45c8ee93968b34d12256927ab84822abcd1 /compiler/app/Main.hs
parente41b2bc587d058f996bf2ef41e8459d4f6eb7fff (diff)
parentc22ea3de0fc5a42449b4bae80afa1a94c7afa41e (diff)
downloadldgallery-8facee21e8c60d14257afae13b69f30fb87e2b4b.tar.gz
Merge pull request #89 from pacien/feature-check-distinct-in-out-dirs
Feature check distinct in out dirs
Diffstat (limited to 'compiler/app/Main.hs')
-rw-r--r--compiler/app/Main.hs24
1 files changed, 15 insertions, 9 deletions
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 1864dee..594a5b7 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -20,11 +20,13 @@ module Main where
20 20
21import GHC.Generics (Generic) 21import GHC.Generics (Generic)
22import Paths_ldgallery_compiler (version, getDataFileName) 22import Paths_ldgallery_compiler (version, getDataFileName)
23import Control.Monad (when)
23import Data.Version (showVersion) 24import Data.Version (showVersion)
24import Data.Int (Int64) 25import Data.Int (Int64)
25import Data.Aeson (ToJSON) 26import Data.Aeson (ToJSON)
26import Data.Time.Clock.System (getSystemTime, systemSeconds) 27import Data.Time.Clock.System (getSystemTime, systemSeconds)
27import System.FilePath ((</>)) 28import System.FilePath ((</>))
29import System.Directory (canonicalizePath)
28import System.Console.CmdArgs 30import System.Console.CmdArgs
29 31
30import Compiler 32import Compiler
@@ -88,11 +90,9 @@ main =
88 do 90 do
89 opts <- cmdArgs options 91 opts <- cmdArgs options
90 buildGallery opts 92 buildGallery opts
91 if (withViewer opts) then do 93 when (withViewer opts) $ do
92 copyViewer (outputDir opts) 94 copyViewer (outputDir opts)
93 writeViewerConfig (outputDir opts </> "config.json") 95 writeViewerConfig (outputDir opts </> "config.json")
94 else
95 return ()
96 96
97 where 97 where
98 gallerySubdir :: String 98 gallerySubdir :: String
@@ -100,12 +100,18 @@ main =
100 100
101 buildGallery :: Options -> IO () 101 buildGallery :: Options -> IO ()
102 buildGallery opts = 102 buildGallery opts =
103 compileGallery 103 checkDistinctPaths (inputDir opts) (outputDir opts)
104 (inputDir opts) 104 >> compileGallery
105 (galleryOutputDir opts) 105 (inputDir opts)
106 [outputDir opts] 106 (galleryOutputDir opts)
107 (rebuilAll opts) 107 [outputDir opts]
108 (cleanOutput opts) 108 (rebuilAll opts)
109 (cleanOutput opts)
110 where
111 checkDistinctPaths a b = do
112 canonicalA <- canonicalizePath a
113 canonicalB <- canonicalizePath b
114 when (canonicalA == canonicalB) $ error "Input and output paths refer to the same location."
109 115
110 galleryOutputDir :: Options -> FilePath 116 galleryOutputDir :: Options -> FilePath
111 galleryOutputDir opts = 117 galleryOutputDir opts =