Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 53 lines (45 sloc) 1.649 kB
9f9c0b1 @dmpots Initial Revision
authored
1 #!/usr/bin/env runhaskell
2 import Distribution.Simple
031c266 @dmpots Added ability to use local run configurations
authored
3 import Control.Monad
4 import Data.List
5 import System.Directory
6 import System.FilePath
7 import System.IO
fed1050 @dmpots Rename benchmark finding file
authored
8 import FindBench
031c266 @dmpots Added ability to use local run configurations
authored
9
10 main = defaultMainWithHooks simpleUserHooks {postConf = writeLocalConf, postClean = deleteLocalConf}
11
12 writeLocalConf _ _ _ _ = do
a179ae1 @dmpots Generate the benchmarks list automatically
authored
13 findLocalConfigModules configDir
14 findLocalBenchmarks benchmarkDir
031c266 @dmpots Added ability to use local run configurations
authored
15
16 deleteLocalConf _ _ _ _ = do
a179ae1 @dmpots Generate the benchmarks list automatically
authored
17 safeDelete (importsFileName configDir)
18 safeDelete (modulesFileName configDir)
031c266 @dmpots Added ability to use local run configurations
authored
19
20 safeDelete :: FilePath -> IO ()
21 safeDelete f = do
22 e <- doesFileExist f
23 when e (removeFile f)
24
a179ae1 @dmpots Generate the benchmarks list automatically
authored
25 findLocalConfigModules :: FilePath -> IO ()
26 findLocalConfigModules cDir = do
27 fs <- getDirectoryContents cDir
031c266 @dmpots Added ability to use local run configurations
authored
28 putStr "\nLooking for local configuration modules... "
29 let modNames = map dropExtension $ filter (".hs" `isSuffixOf`) fs
30 let imports = map importStmt $ modNames
31 let modules = map importAs $ modNames
32 putStrLn $ "found ("++ (show.length$ modNames)++")"
a179ae1 @dmpots Generate the benchmarks list automatically
authored
33 writeToFile (importsFileName cDir) imports
34 writeToFile (modulesFileName cDir) modules
031c266 @dmpots Added ability to use local run configurations
authored
35 where
36 importStmt m = "import qualified "++m++" as " ++importAs m
37 writeToFile fName contents = do
38 h <- openFile fName WriteMode
39 putStrLn $ "writing " ++ fName
40 putStrLn $ unlines contents
41 hPutStr h (unlines contents)
42 hClose h
43
44 importAs :: String -> String
45 importAs modName = modName++"_Config"
46
a179ae1 @dmpots Generate the benchmarks list automatically
authored
47 configDir, benchmarkDir :: FilePath
031c266 @dmpots Added ability to use local run configurations
authored
48 configDir = "config"
a179ae1 @dmpots Generate the benchmarks list automatically
authored
49 benchmarkDir = "benchmarks"
50 importsFileName, modulesFileName :: FilePath -> FilePath
51 importsFileName baseDir = baseDir </> "LocalConfigImports.txt"
52 modulesFileName baseDir = baseDir </> "LocalConfigModules.txt"
Something went wrong with that request. Please try again.