summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorCsaba Hruska <csaba.hruska@gmail.com>2016-02-04 13:15:48 +0100
committerCsaba Hruska <csaba.hruska@gmail.com>2016-02-04 13:15:48 +0100
commit80aa72b28ae90815c9e142a6fbc7fed14ed56b07 (patch)
treecb5992af5a78ba69a901c3414e33efac3bbc34d0 /tool
parent514da00bf5e0e913acdcdf1706157d0d9c7276e8 (diff)
always include builtins path
Diffstat (limited to 'tool')
-rw-r--r--tool/Compiler.hs12
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
4import qualified Data.ByteString.Lazy as B 4import qualified Data.ByteString.Lazy as B
5import System.FilePath 5import System.FilePath
6 6
7import Paths_lambdacube_compiler (getDataDir)
8import LambdaCube.Compiler 7import LambdaCube.Compiler
9 8
10data Config 9data 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
17sample :: Parser Config 16sample :: Parser Config
18sample = Config 17sample = 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
23main :: IO () 22main :: IO ()
24main = do 23main = 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