diff options
author | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-04 13:15:48 +0100 |
---|---|---|
committer | Csaba Hruska <csaba.hruska@gmail.com> | 2016-02-04 13:15:48 +0100 |
commit | 80aa72b28ae90815c9e142a6fbc7fed14ed56b07 (patch) | |
tree | cb5992af5a78ba69a901c3414e33efac3bbc34d0 /tool | |
parent | 514da00bf5e0e913acdcdf1706157d0d9c7276e8 (diff) |
always include builtins path
Diffstat (limited to 'tool')
-rw-r--r-- | tool/Compiler.hs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tool/Compiler.hs b/tool/Compiler.hs index 0723c0c8..215cf106 100644 --- a/tool/Compiler.hs +++ b/tool/Compiler.hs | |||
@@ -4,27 +4,23 @@ import Data.Aeson | |||
4 | import qualified Data.ByteString.Lazy as B | 4 | import qualified Data.ByteString.Lazy as B |
5 | import System.FilePath | 5 | import System.FilePath |
6 | 6 | ||
7 | import Paths_lambdacube_compiler (getDataDir) | ||
8 | import LambdaCube.Compiler | 7 | import LambdaCube.Compiler |
9 | 8 | ||
10 | data Config | 9 | data Config |
11 | = Config | 10 | = Config |
12 | { srcName :: String | 11 | { srcName :: String |
13 | , backend :: Backend | 12 | , backend :: Backend |
14 | , sourceDir :: FilePath | 13 | , includePaths :: [FilePath] |
15 | } | 14 | } |
16 | 15 | ||
17 | sample :: Parser Config | 16 | sample :: Parser Config |
18 | sample = Config | 17 | sample = Config |
19 | <$> argument str (metavar "SOURCE_FILE") | 18 | <$> argument str (metavar "SOURCE_FILE") |
20 | <*> flag OpenGL33 WebGL1 (long "webgl" <> help "generate WebGL 1.0 pipeline" ) | 19 | <*> flag OpenGL33 WebGL1 (long "webgl" <> help "generate WebGL 1.0 pipeline" ) |
21 | <*> pure "/lc" | 20 | <*> pure ["."] |
22 | 21 | ||
23 | main :: IO () | 22 | main :: IO () |
24 | main = do | 23 | main = compile =<< execParser opts |
25 | cabalDataDir <- getDataDir | ||
26 | cfg <- execParser opts | ||
27 | compile (cfg {sourceDir = cabalDataDir </> "lc"}) | ||
28 | where | 24 | where |
29 | opts = info (helper <*> sample) | 25 | opts = info (helper <*> sample) |
30 | ( fullDesc | 26 | ( fullDesc |
@@ -36,7 +32,7 @@ compile Config{..} = do | |||
36 | let dropExt n | takeExtension n == ".lc" = dropExtension n | 32 | let dropExt n | takeExtension n == ".lc" = dropExtension n |
37 | dropExt n = n | 33 | dropExt n = n |
38 | baseName = dropExt srcName | 34 | baseName = dropExt srcName |
39 | pplRes <- compileMain [".", sourceDir] backend baseName | 35 | pplRes <- compileMain includePaths backend baseName |
40 | case pplRes of | 36 | case pplRes of |
41 | Left err -> putStrLn err | 37 | Left err -> putStrLn err |
42 | Right ppl -> B.writeFile (baseName <> ".json") $ encode ppl | 38 | Right ppl -> B.writeFile (baseName <> ".json") $ encode ppl |