diff options
author | Andor Penzes <andor.penzes@gmail.com> | 2016-01-13 16:11:13 +0100 |
---|---|---|
committer | Andor Penzes <andor.penzes@gmail.com> | 2016-01-13 16:11:19 +0100 |
commit | 4775db8d8914792a74ccca177cc77ddd65825fac (patch) | |
tree | 581ac0e2462eb9bbcab0e0c4b85f60260297cf55 /tool | |
parent | 514f2610c00c5a04cb49eee4f64cac8980911617 (diff) |
lc: load Prelude from cabal data dir
Diffstat (limited to 'tool')
-rw-r--r-- | tool/Compiler.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tool/Compiler.hs b/tool/Compiler.hs index 2195f0c6..03429434 100644 --- a/tool/Compiler.hs +++ b/tool/Compiler.hs | |||
@@ -1,22 +1,30 @@ | |||
1 | -- {-# LANGUAGE CPP #-} | ||
1 | {-# LANGUAGE RecordWildCards #-} | 2 | {-# LANGUAGE RecordWildCards #-} |
2 | import Options.Applicative | 3 | import Options.Applicative |
3 | import Data.Aeson | 4 | import Data.Aeson |
4 | import qualified Data.ByteString.Lazy as B | 5 | import qualified Data.ByteString.Lazy as B |
5 | import LambdaCube.Compiler.Driver | 6 | import LambdaCube.Compiler.Driver |
7 | import System.FilePath | ||
8 | import Paths_lambdacube_compiler (getDataDir) | ||
6 | 9 | ||
7 | data Config | 10 | data Config |
8 | = Config | 11 | = Config |
9 | { srcName :: String | 12 | { srcName :: String |
10 | , backend :: Backend | 13 | , backend :: Backend |
14 | , sourceDir :: FilePath | ||
11 | } | 15 | } |
12 | 16 | ||
13 | sample :: Parser Config | 17 | sample :: Parser Config |
14 | sample = Config | 18 | sample = Config |
15 | <$> argument str (metavar "SOURCE_FILE") | 19 | <$> argument str (metavar "SOURCE_FILE") |
16 | <*> flag OpenGL33 WebGL1 (long "webgl" <> help "generate WebGL 1.0 pipeline" ) | 20 | <*> flag OpenGL33 WebGL1 (long "webgl" <> help "generate WebGL 1.0 pipeline" ) |
21 | <*> pure "/lc" | ||
17 | 22 | ||
18 | main :: IO () | 23 | main :: IO () |
19 | main = execParser opts >>= compile | 24 | main = do |
25 | cabalDataDir <- getDataDir | ||
26 | cfg <- execParser opts | ||
27 | compile (cfg {sourceDir = cabalDataDir </> "lc"}) | ||
20 | where | 28 | where |
21 | opts = info (helper <*> sample) | 29 | opts = info (helper <*> sample) |
22 | ( fullDesc | 30 | ( fullDesc |
@@ -25,7 +33,7 @@ main = execParser opts >>= compile | |||
25 | 33 | ||
26 | compile :: Config -> IO () | 34 | compile :: Config -> IO () |
27 | compile Config{..} = do | 35 | compile Config{..} = do |
28 | pplRes <- compileMain ["."] backend srcName | 36 | pplRes <- compileMain [".", sourceDir] backend srcName |
29 | case pplRes of | 37 | case pplRes of |
30 | Left err -> putStrLn err | 38 | Left err -> putStrLn err |
31 | Right ppl -> do | 39 | Right ppl -> do |