on 4bec310 help sign in
elk/compiler/Build/Utils.hs
35 lines 1.0 kB history raw
1{-# OPTIONS_GHC -W #-}
2module Build.Utils where
4import System.Directory (doesFileExist)
5import System.Environment (getEnv)
6import System.FilePath ((</>), replaceExtension)
7import qualified Build.Flags as Flag
8import qualified Paths_Elm as This
10buildPath :: Flag.Flags -> FilePath -> String -> FilePath
11buildPath flags filePath ext =
12 Flag.build_dir flags </> replaceExtension filePath ext
14cachePath :: Flag.Flags -> FilePath -> String -> FilePath
15cachePath flags filePath ext =
16 Flag.cache_dir flags </> replaceExtension filePath ext
18elmo :: Flag.Flags -> FilePath -> FilePath
19elmo flags filePath =
20 cachePath flags filePath "elmo"
22elmi :: Flag.Flags -> FilePath -> FilePath
23elmi flags filePath =
24 cachePath flags filePath "elmi"
26-- |The absolute path to a data file
27getDataFile :: FilePath -> IO FilePath
28getDataFile name = do
29 path <- This.getDataFileName name
30 exists <- doesFileExist path
31 if exists
32 then return path
33 else do
34 env <- getEnv "ELM_HOME"
35 return (env </> name)