module Distribution.Simple.BuildPaths (
defaultDistPref, srcPref,
hscolourPref, haddockPref,
autogenModulesDir,
autogenModuleName,
cppHeaderName,
haddockName,
mkLibName,
mkProfLibName,
mkSharedLibName,
exeExtension,
objExtension,
dllExtension,
) where
import System.FilePath ((</>), (<.>))
import Distribution.Package
( PackageIdentifier, packageName )
import Distribution.ModuleName (ModuleName)
import qualified Distribution.ModuleName as ModuleName
import Distribution.Compiler
( CompilerId(..) )
import Distribution.PackageDescription (PackageDescription)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(buildDir))
import Distribution.Simple.Setup (defaultDistPref)
import Distribution.Text
( display )
import Distribution.System (OS(..), buildOS)
srcPref :: FilePath -> FilePath
srcPref distPref = distPref :: FilePathdistPref (</>) :: FilePath -> FilePath -> FilePath</> "src"
hscolourPref :: FilePath -> PackageDescription -> FilePath
hscolourPref = haddockPref :: FilePath -> PackageDescription -> FilePathhaddockPref
haddockPref :: FilePath -> PackageDescription -> FilePath
haddockPref distPref pkg_descr
= distPref :: FilePathdistPref (</>) :: FilePath -> FilePath -> FilePath</> "doc" (</>) :: FilePath -> FilePath -> FilePath</> "html" (</>) :: FilePath -> FilePath -> FilePath</> display :: Text a => a -> Stringdisplay (packageName :: Package pkg => pkg -> PackageNamepackageName pkg_descr :: PackageDescriptionpkg_descr)
autogenModulesDir :: LocalBuildInfo -> String
autogenModulesDir lbi = buildDir :: LocalBuildInfo -> FilePathbuildDir lbi :: LocalBuildInfolbi (</>) :: FilePath -> FilePath -> FilePath</> "autogen"
cppHeaderName :: String
cppHeaderName = "cabal_macros.h"
autogenModuleName :: PackageDescription -> ModuleName
autogenModuleName pkg_descr =
fromString :: String -> ModuleNameModuleName.fromString ($) :: (a -> b) -> a -> b$
"Paths_" (++) :: [a] -> [a] -> [a]++ map :: (a -> b) -> [a] -> [b]map fixchar :: Char -> Charfixchar (display :: Text a => a -> Stringdisplay (packageName :: Package pkg => pkg -> PackageNamepackageName pkg_descr :: PackageDescriptionpkg_descr))
where fixchar '-' = '_'
fixchar c = c :: Charc
haddockName :: PackageDescription -> FilePath
haddockName pkg_descr = display :: Text a => a -> Stringdisplay (packageName :: Package pkg => pkg -> PackageNamepackageName pkg_descr :: PackageDescriptionpkg_descr) (<.>) :: FilePath -> String -> FilePath<.> "haddock"
mkLibName :: PackageIdentifier -> String
mkLibName lib = "libHS" (++) :: [a] -> [a] -> [a]++ display :: Text a => a -> Stringdisplay lib :: PackageIdentifierlib (<.>) :: FilePath -> String -> FilePath<.> "a"
mkProfLibName :: PackageIdentifier -> String
mkProfLibName lib = "libHS" (++) :: [a] -> [a] -> [a]++ display :: Text a => a -> Stringdisplay lib :: PackageIdentifierlib (++) :: [a] -> [a] -> [a]++ "_p" (<.>) :: FilePath -> String -> FilePath<.> "a"
mkSharedLibName :: PackageIdentifier -> CompilerId -> String
mkSharedLibName lib (CompilerId compilerFlavor compilerVersion)
= "libHS" (++) :: [a] -> [a] -> [a]++ display :: Text a => a -> Stringdisplay lib :: PackageIdentifierlib (++) :: [a] -> [a] -> [a]++ "-" (++) :: [a] -> [a] -> [a]++ comp :: [Char]comp (<.>) :: FilePath -> String -> FilePath<.> dllExtension :: StringdllExtension
where comp = display :: Text a => a -> Stringdisplay compilerFlavor :: CompilerFlavorcompilerFlavor (++) :: [a] -> [a] -> [a]++ display :: Text a => a -> Stringdisplay compilerVersion :: VersioncompilerVersion
exeExtension :: String
exeExtension = case buildOS :: OSbuildOS of
Windows -> "exe"
_ -> ""
objExtension :: String
objExtension = "o"
dllExtension :: String
dllExtension = case buildOS :: OSbuildOS of
Windows -> "dll"
OSX -> "dylib"
_ -> "so"