Skip to content
Snippets Groups Projects
Commit 622a4fca authored by Alp Mestanogullari's avatar Alp Mestanogullari
Browse files

create splices dir if missing

parent d89a2220
No related branches found
No related tags found
No related merge requests found
......@@ -5,5 +5,5 @@ package ghc-external-slices-plugin
ghc-options: -Wall -Werror
package test-pkg
-- ghc-options: -fplugin=Splices.Plugin -fplugin-opt=Splices.Plugin:save -fplugin-opt=Splices.Plugin:./
-- ghc-options: -fplugin=Splices.Plugin -fplugin-opt=Splices.Plugin:load -fplugin-opt=Splices.Plugin:./
-- ghc-options: -fplugin=Splices.Plugin -fplugin-opt=Splices.Plugin:save -fplugin-opt=Splices.Plugin:./foobar
-- ghc-options: -fplugin=Splices.Plugin -fplugin-opt=Splices.Plugin:load -fplugin-opt=Splices.Plugin:./foobar
......@@ -9,16 +9,15 @@ import TcSplice
import Splices.Data
-- TODO:
-- - optimise this by figuring out a way to only
-- read/write the .hs-splice files once
-- (set up an IORef before updating the hook
import System.Directory
plugin :: Plugin
plugin = defaultPlugin
{ dynflagsPlugin = \opts -> Just (registerHook opts) }
registerHook :: [String] -> (DynFlags -> IO DynFlags)
registerHook opts = \dflags -> do
createDirectoryIfMissing True (modeDir mode)
return $ dflags
{ hooks = (hooks dflags)
{ runMetaHook = Just $ splicesHook mode defaultRunMeta }
......@@ -107,6 +106,10 @@ readSpliceFor loc splicedata req =
data Mode = Load FilePath | Save FilePath
deriving (Eq, Show)
modeDir :: Mode -> FilePath
modeDir (Load d) = d
modeDir (Save d) = d
parseOpts :: [CommandLineOption] -> Mode
parseOpts ["save", dir] = Save dir
parseOpts ["load", dir] = Load dir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment