{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}
module Distribution.Simple.BuildPaths
( defaultDistPref
, srcPref
, buildInfoPref
, haddockDirName
, haddockLibraryDirPath
, haddockTestDirPath
, haddockBenchmarkDirPath
, hscolourPref
, haddockPref
, autogenPackageModulesDir
, autogenComponentModulesDir
, preBuildRulesCacheFile
, autogenPathsModuleName
, autogenPackageInfoModuleName
, cppHeaderName
, haddockPath
, haddockPackageLibraryName
, haddockPackageLibraryName'
, haddockLibraryName
, haddockLibraryPath
, mkGenericStaticLibName
, mkLibName
, mkProfLibName
, mkGenericSharedLibName
, mkSharedLibName
, mkProfSharedLibName
, mkStaticLibName
, mkBytecodeLibName
, mkGenericSharedBundledLibName
, exeExtension
, objExtension
, dllExtension
, staticLibExtension
, getSourceFiles
, getLibSourceFiles
, getExeSourceFiles
, getTestSourceFiles
, getBenchmarkSourceFiles
, getFLibSourceFiles
, exeBuildDir
, flibBuildDir
, stubName
, testBuildDir
, benchmarkBuildDir
) where
import Distribution.Compat.Prelude
import Prelude ()
import Data.List (stripPrefix)
import Distribution.Compiler
import Distribution.ModuleName as ModuleName
import Distribution.Package
import Distribution.PackageDescription
import Distribution.Pretty
import Distribution.Simple.Errors
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.PreProcess.Types (builtinHaskellSuffixes)
import Distribution.Simple.Setup.Common
import Distribution.Simple.Setup.Haddock (HaddockTarget (..))
import Distribution.Simple.Utils
import Distribution.System
import Distribution.Utils.Path
import Distribution.Verbosity
srcPref :: FilePath -> FilePath
srcPref :: String -> String
srcPref String
distPref = String
distPref String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
"src"
hscolourPref
:: HaddockTarget
-> SymbolicPath root (Dir Dist)
-> PackageDescription
-> SymbolicPath root (Dir Artifacts)
hscolourPref :: forall root.
HaddockTarget
-> SymbolicPath root ('Dir Dist)
-> PackageDescription
-> SymbolicPath root ('Dir Artifacts)
hscolourPref = HaddockTarget
-> SymbolicPath root ('Dir Dist)
-> PackageDescription
-> SymbolicPath root ('Dir Artifacts)
forall root.
HaddockTarget
-> SymbolicPath root ('Dir Dist)
-> PackageDescription
-> SymbolicPath root ('Dir Artifacts)
haddockPref
buildInfoPref
:: SymbolicPath root (Dir Dist)
-> SymbolicPath root File
buildInfoPref :: forall root.
SymbolicPath root ('Dir Dist) -> SymbolicPath root 'File
buildInfoPref SymbolicPath root ('Dir Dist)
distPref = SymbolicPath root ('Dir Dist)
distPref SymbolicPath root ('Dir Dist)
-> RelativePath Dist 'File -> SymbolicPath root 'File
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Dist 'File
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx String
"build-info.json"
haddockDirName :: HaddockTarget -> PackageDescription -> FilePath
haddockDirName :: HaddockTarget -> PackageDescription -> String
haddockDirName HaddockTarget
ForDevelopment = PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageName -> String)
-> (PackageDescription -> PackageName)
-> PackageDescription
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageDescription -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName
haddockDirName HaddockTarget
ForHackage = (String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-docs") (String -> String)
-> (PackageDescription -> String) -> PackageDescription -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageIdentifier -> String
forall a. Pretty a => a -> String
prettyShow (PackageIdentifier -> String)
-> (PackageDescription -> PackageIdentifier)
-> PackageDescription
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageDescription -> PackageIdentifier
forall pkg. Package pkg => pkg -> PackageIdentifier
packageId
haddockLibraryDirPath
:: HaddockTarget
-> PackageDescription
-> Library
-> FilePath
haddockLibraryDirPath :: HaddockTarget -> PackageDescription -> Library -> String
haddockLibraryDirPath HaddockTarget
haddockTarget PackageDescription
pkg_descr Library
lib =
case Library -> LibraryName
libName Library
lib of
LSubLibName UnqualComponentName
sublib_name ->
HaddockTarget -> PackageDescription -> String
haddockDirName HaddockTarget
haddockTarget PackageDescription
pkg_descr String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow UnqualComponentName
sublib_name
LibraryName
_ -> HaddockTarget -> PackageDescription -> String
haddockDirName HaddockTarget
haddockTarget PackageDescription
pkg_descr
haddockTestDirPath
:: HaddockTarget
-> PackageDescription
-> TestSuite
-> FilePath
haddockTestDirPath :: HaddockTarget -> PackageDescription -> TestSuite -> String
haddockTestDirPath HaddockTarget
haddockTarget PackageDescription
pkg_descr TestSuite
test =
HaddockTarget -> PackageDescription -> String
haddockDirName HaddockTarget
haddockTarget PackageDescription
pkg_descr String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow (TestSuite -> UnqualComponentName
testName TestSuite
test)
haddockBenchmarkDirPath
:: HaddockTarget
-> PackageDescription
-> Benchmark
-> FilePath
haddockBenchmarkDirPath :: HaddockTarget -> PackageDescription -> Benchmark -> String
haddockBenchmarkDirPath HaddockTarget
haddockTarget PackageDescription
pkg_descr Benchmark
bench =
HaddockTarget -> PackageDescription -> String
haddockDirName HaddockTarget
haddockTarget PackageDescription
pkg_descr String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow (Benchmark -> UnqualComponentName
benchmarkName Benchmark
bench)
haddockPref
:: HaddockTarget
-> SymbolicPath root (Dir Dist)
-> PackageDescription
-> SymbolicPath root (Dir Artifacts)
haddockPref :: forall root.
HaddockTarget
-> SymbolicPath root ('Dir Dist)
-> PackageDescription
-> SymbolicPath root ('Dir Artifacts)
haddockPref HaddockTarget
haddockTarget SymbolicPath root ('Dir Dist)
distPref PackageDescription
pkg_descr =
SymbolicPath root ('Dir Dist)
distPref SymbolicPath root ('Dir Dist)
-> RelativePath Dist ('Dir Artifacts)
-> SymbolicPath root ('Dir Artifacts)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Dist ('Dir Artifacts)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx (String
"doc" String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
"html" String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> HaddockTarget -> PackageDescription -> String
haddockDirName HaddockTarget
haddockTarget PackageDescription
pkg_descr)
autogenPackageModulesDir :: LocalBuildInfo -> SymbolicPath Pkg (Dir Source)
autogenPackageModulesDir :: LocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenPackageModulesDir LocalBuildInfo
lbi = LocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
buildDir LocalBuildInfo
lbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build ('Dir Source)
-> SymbolicPath Pkg ('Dir Source)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Build ('Dir Source)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx String
"global-autogen"
autogenComponentModulesDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> SymbolicPath Pkg (Dir Source)
autogenComponentModulesDir :: LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenComponentModulesDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi = LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
componentBuildDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build ('Dir Source)
-> SymbolicPath Pkg ('Dir Source)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Build ('Dir Source)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx String
"autogen"
preBuildRulesCacheFile
:: LocalBuildInfo
-> ComponentLocalBuildInfo
-> SymbolicPath Pkg File
preBuildRulesCacheFile :: LocalBuildInfo -> ComponentLocalBuildInfo -> SymbolicPath Pkg 'File
preBuildRulesCacheFile LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi =
LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
componentBuildDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build 'File -> SymbolicPath Pkg 'File
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Build 'File
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx String
"setup-hooks-rules.cache"
cppHeaderName :: String
= String
"cabal_macros.h"
autogenPathsModuleName :: PackageDescription -> ModuleName
autogenPathsModuleName :: PackageDescription -> ModuleName
autogenPathsModuleName PackageDescription
pkg_descr =
String -> ModuleName
forall a. IsString a => String -> a
ModuleName.fromString (String -> ModuleName) -> String -> ModuleName
forall a b. (a -> b) -> a -> b
$
String
"Paths_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
fixchar (PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageDescription -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageDescription
pkg_descr))
where
fixchar :: Char -> Char
fixchar Char
'-' = Char
'_'
fixchar Char
c = Char
c
autogenPackageInfoModuleName :: PackageDescription -> ModuleName
autogenPackageInfoModuleName :: PackageDescription -> ModuleName
autogenPackageInfoModuleName PackageDescription
pkg_descr =
String -> ModuleName
forall a. IsString a => String -> a
ModuleName.fromString (String -> ModuleName) -> String -> ModuleName
forall a b. (a -> b) -> a -> b
$
String
"PackageInfo_" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
fixchar (PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageDescription -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageDescription
pkg_descr))
where
fixchar :: Char -> Char
fixchar Char
'-' = Char
'_'
fixchar Char
c = Char
c
haddockPath :: PackageDescription -> FilePath
haddockPath :: PackageDescription -> String
haddockPath PackageDescription
pkg_descr = PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageDescription -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageDescription
pkg_descr) String -> String -> String
forall p. FileLike p => p -> String -> p
<.> String
"haddock"
haddockPackageLibraryName :: PackageDescription -> Library -> String
haddockPackageLibraryName :: PackageDescription -> Library -> String
haddockPackageLibraryName PackageDescription
pkg_descr Library
lib =
PackageName -> LibraryName -> String
haddockPackageLibraryName' (PackageDescription -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageDescription
pkg_descr) (Library -> LibraryName
libName Library
lib)
haddockPackageLibraryName' :: PackageName -> LibraryName -> String
haddockPackageLibraryName' :: PackageName -> LibraryName -> String
haddockPackageLibraryName' PackageName
pkg_name LibraryName
lib_name =
case LibraryName
lib_name of
LSubLibName UnqualComponentName
sublib_name ->
PackageName -> String
forall a. Pretty a => a -> String
prettyShow PackageName
pkg_name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
":" String -> String -> String
forall a. [a] -> [a] -> [a]
++ UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow UnqualComponentName
sublib_name
LibraryName
LMainLibName -> PackageName -> String
forall a. Pretty a => a -> String
prettyShow PackageName
pkg_name
haddockLibraryName :: PackageDescription -> Library -> String
haddockLibraryName :: PackageDescription -> Library -> String
haddockLibraryName PackageDescription
pkg_descr Library
lib =
case Library -> LibraryName
libName Library
lib of
LSubLibName UnqualComponentName
sublib_name -> UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow UnqualComponentName
sublib_name
LibraryName
LMainLibName -> PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageDescription -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageDescription
pkg_descr)
haddockLibraryPath :: PackageDescription -> Library -> FilePath
haddockLibraryPath :: PackageDescription -> Library -> String
haddockLibraryPath PackageDescription
pkg_descr Library
lib = PackageDescription -> Library -> String
haddockLibraryName PackageDescription
pkg_descr Library
lib String -> String -> String
forall p. FileLike p => p -> String -> p
<.> String
"haddock"
getLibSourceFiles
:: Verbosity
-> LocalBuildInfo
-> Library
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, SymbolicPath Pkg File)]
getLibSourceFiles :: Verbosity
-> LocalBuildInfo
-> Library
-> ComponentLocalBuildInfo
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
getLibSourceFiles Verbosity
verbosity LocalBuildInfo
lbi Library
lib ComponentLocalBuildInfo
clbi =
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPath Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
forall (allowAbsolute :: AllowAbsolute).
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
getSourceFiles Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir [SymbolicPath Pkg ('Dir Source)]
searchpaths [ModuleName]
modules
where
bi :: BuildInfo
bi = Library -> BuildInfo
libBuildInfo Library
lib
modules :: [ModuleName]
modules = Library -> ComponentLocalBuildInfo -> [ModuleName]
allLibModules Library
lib ComponentLocalBuildInfo
clbi
mbWorkDir :: Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir = LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI LocalBuildInfo
lbi
searchpaths :: [SymbolicPath Pkg ('Dir Source)]
searchpaths =
SymbolicPath Pkg ('Dir Build) -> SymbolicPath Pkg ('Dir Source)
forall (allowAbsolute :: AllowAbsolute) from (to1 :: FileOrDir)
(to2 :: FileOrDir).
SymbolicPathX allowAbsolute from to1
-> SymbolicPathX allowAbsolute from to2
coerceSymbolicPath (LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
componentBuildDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi)
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: BuildInfo -> [SymbolicPath Pkg ('Dir Source)]
hsSourceDirs BuildInfo
bi
[SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. [a] -> [a] -> [a]
++ [ LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenComponentModulesDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi
, LocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenPackageModulesDir LocalBuildInfo
lbi
]
getExeSourceFiles
:: Verbosity
-> LocalBuildInfo
-> Executable
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, SymbolicPath Pkg 'File)]
getExeSourceFiles :: Verbosity
-> LocalBuildInfo
-> Executable
-> ComponentLocalBuildInfo
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
getExeSourceFiles Verbosity
verbosity LocalBuildInfo
lbi Executable
exe ComponentLocalBuildInfo
clbi = do
moduleFiles <- Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPath Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
forall (allowAbsolute :: AllowAbsolute).
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
getSourceFiles Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir [SymbolicPath Pkg ('Dir Source)]
searchpaths [ModuleName]
modules
srcMainPath <- findFileCwd verbosity mbWorkDir (hsSourceDirs bi) (modulePath exe)
return ((ModuleName.main, srcMainPath) : moduleFiles)
where
mbWorkDir :: Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir = LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI LocalBuildInfo
lbi
bi :: BuildInfo
bi = Executable -> BuildInfo
buildInfo Executable
exe
modules :: [ModuleName]
modules = BuildInfo -> [ModuleName]
otherModules BuildInfo
bi
searchpaths :: [SymbolicPath Pkg ('Dir Source)]
searchpaths =
LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenComponentModulesDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: LocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenPackageModulesDir LocalBuildInfo
lbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: SymbolicPath Pkg ('Dir Build) -> SymbolicPath Pkg ('Dir Source)
forall (allowAbsolute :: AllowAbsolute) from (to1 :: FileOrDir)
(to2 :: FileOrDir).
SymbolicPathX allowAbsolute from to1
-> SymbolicPathX allowAbsolute from to2
coerceSymbolicPath (LocalBuildInfo -> Executable -> SymbolicPath Pkg ('Dir Build)
exeBuildDir LocalBuildInfo
lbi Executable
exe)
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: BuildInfo -> [SymbolicPath Pkg ('Dir Source)]
hsSourceDirs BuildInfo
bi
getTestSourceFiles
:: Verbosity
-> LocalBuildInfo
-> TestSuite
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, SymbolicPath Pkg 'File)]
getTestSourceFiles :: Verbosity
-> LocalBuildInfo
-> TestSuite
-> ComponentLocalBuildInfo
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
getTestSourceFiles Verbosity
verbosity LocalBuildInfo
lbi test :: TestSuite
test@TestSuite{testInterface :: TestSuite -> TestSuiteInterface
testInterface = TestSuiteExeV10 Version
_ RelativePath Source 'File
path} ComponentLocalBuildInfo
clbi = do
moduleFiles <- Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPath Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
forall (allowAbsolute :: AllowAbsolute).
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
getSourceFiles Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir [SymbolicPath Pkg ('Dir Source)]
searchpaths [ModuleName]
modules
srcMainPath <- findFileCwd verbosity mbWorkDir (hsSourceDirs bi) path
return ((ModuleName.main, srcMainPath) : moduleFiles)
where
mbWorkDir :: Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir = LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI LocalBuildInfo
lbi
bi :: BuildInfo
bi = TestSuite -> BuildInfo
testBuildInfo TestSuite
test
modules :: [ModuleName]
modules = BuildInfo -> [ModuleName]
otherModules BuildInfo
bi
searchpaths :: [SymbolicPath Pkg ('Dir Source)]
searchpaths =
LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenComponentModulesDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: LocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenPackageModulesDir LocalBuildInfo
lbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: SymbolicPath Pkg ('Dir Build) -> SymbolicPath Pkg ('Dir Source)
forall (allowAbsolute :: AllowAbsolute) from (to1 :: FileOrDir)
(to2 :: FileOrDir).
SymbolicPathX allowAbsolute from to1
-> SymbolicPathX allowAbsolute from to2
coerceSymbolicPath (LocalBuildInfo -> TestSuite -> SymbolicPath Pkg ('Dir Build)
testBuildDir LocalBuildInfo
lbi TestSuite
test)
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: BuildInfo -> [SymbolicPath Pkg ('Dir Source)]
hsSourceDirs BuildInfo
bi
getTestSourceFiles Verbosity
_ LocalBuildInfo
_ TestSuite
_ ComponentLocalBuildInfo
_ = [(ModuleName, SymbolicPath Pkg 'File)]
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return []
getBenchmarkSourceFiles
:: Verbosity
-> LocalBuildInfo
-> Benchmark
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, SymbolicPath Pkg 'File)]
getBenchmarkSourceFiles :: Verbosity
-> LocalBuildInfo
-> Benchmark
-> ComponentLocalBuildInfo
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
getBenchmarkSourceFiles Verbosity
verbosity LocalBuildInfo
lbi bench :: Benchmark
bench@Benchmark{benchmarkInterface :: Benchmark -> BenchmarkInterface
benchmarkInterface = BenchmarkExeV10 Version
_ RelativePath Source 'File
path} ComponentLocalBuildInfo
clbi = do
moduleFiles <- Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPath Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
forall (allowAbsolute :: AllowAbsolute).
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
getSourceFiles Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir [SymbolicPath Pkg ('Dir Source)]
searchpaths [ModuleName]
modules
srcMainPath <- findFileCwd verbosity mbWorkDir (hsSourceDirs bi) path
return ((ModuleName.main, srcMainPath) : moduleFiles)
where
mbWorkDir :: Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir = LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI LocalBuildInfo
lbi
bi :: BuildInfo
bi = Benchmark -> BuildInfo
benchmarkBuildInfo Benchmark
bench
modules :: [ModuleName]
modules = BuildInfo -> [ModuleName]
otherModules BuildInfo
bi
searchpaths :: [SymbolicPath Pkg ('Dir Source)]
searchpaths =
LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenComponentModulesDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: LocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenPackageModulesDir LocalBuildInfo
lbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: SymbolicPath Pkg ('Dir Build) -> SymbolicPath Pkg ('Dir Source)
forall (allowAbsolute :: AllowAbsolute) from (to1 :: FileOrDir)
(to2 :: FileOrDir).
SymbolicPathX allowAbsolute from to1
-> SymbolicPathX allowAbsolute from to2
coerceSymbolicPath (LocalBuildInfo -> Benchmark -> SymbolicPath Pkg ('Dir Build)
benchmarkBuildDir LocalBuildInfo
lbi Benchmark
bench)
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: BuildInfo -> [SymbolicPath Pkg ('Dir Source)]
hsSourceDirs BuildInfo
bi
getBenchmarkSourceFiles Verbosity
_ LocalBuildInfo
_ Benchmark
_ ComponentLocalBuildInfo
_ = [(ModuleName, SymbolicPath Pkg 'File)]
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return []
getFLibSourceFiles
:: Verbosity
-> LocalBuildInfo
-> ForeignLib
-> ComponentLocalBuildInfo
-> IO [(ModuleName.ModuleName, SymbolicPath Pkg File)]
getFLibSourceFiles :: Verbosity
-> LocalBuildInfo
-> ForeignLib
-> ComponentLocalBuildInfo
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
getFLibSourceFiles Verbosity
verbosity LocalBuildInfo
lbi ForeignLib
flib ComponentLocalBuildInfo
clbi =
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPath Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPath Pkg 'File)]
forall (allowAbsolute :: AllowAbsolute).
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
getSourceFiles Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir [SymbolicPath Pkg ('Dir Source)]
searchpaths [ModuleName]
modules
where
bi :: BuildInfo
bi = ForeignLib -> BuildInfo
foreignLibBuildInfo ForeignLib
flib
modules :: [ModuleName]
modules = BuildInfo -> [ModuleName]
otherModules BuildInfo
bi
mbWorkDir :: Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir = LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI LocalBuildInfo
lbi
searchpaths :: [SymbolicPath Pkg ('Dir Source)]
searchpaths =
LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenComponentModulesDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: LocalBuildInfo -> SymbolicPath Pkg ('Dir Source)
autogenPackageModulesDir LocalBuildInfo
lbi
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: SymbolicPath Pkg ('Dir Build) -> SymbolicPath Pkg ('Dir Source)
forall (allowAbsolute :: AllowAbsolute) from (to1 :: FileOrDir)
(to2 :: FileOrDir).
SymbolicPathX allowAbsolute from to1
-> SymbolicPathX allowAbsolute from to2
coerceSymbolicPath (LocalBuildInfo -> ForeignLib -> SymbolicPath Pkg ('Dir Build)
flibBuildDir LocalBuildInfo
lbi ForeignLib
flib)
SymbolicPath Pkg ('Dir Source)
-> [SymbolicPath Pkg ('Dir Source)]
-> [SymbolicPath Pkg ('Dir Source)]
forall a. a -> [a] -> [a]
: BuildInfo -> [SymbolicPath Pkg ('Dir Source)]
hsSourceDirs BuildInfo
bi
getSourceFiles
:: Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPathX allowAbsolute Pkg (Dir Source)]
-> [ModuleName.ModuleName]
-> IO [(ModuleName.ModuleName, SymbolicPathX allowAbsolute Pkg File)]
getSourceFiles :: forall (allowAbsolute :: AllowAbsolute).
Verbosity
-> Maybe (SymbolicPath CWD ('Dir Pkg))
-> [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
-> [ModuleName]
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
getSourceFiles Verbosity
verbosity Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
dirs [ModuleName]
modules = [ModuleName]
-> (ModuleName
-> IO (ModuleName, SymbolicPathX allowAbsolute Pkg 'File))
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
for [ModuleName]
modules ((ModuleName
-> IO (ModuleName, SymbolicPathX allowAbsolute Pkg 'File))
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)])
-> (ModuleName
-> IO (ModuleName, SymbolicPathX allowAbsolute Pkg 'File))
-> IO [(ModuleName, SymbolicPathX allowAbsolute Pkg 'File)]
forall a b. (a -> b) -> a -> b
$ \ModuleName
m ->
(SymbolicPathX allowAbsolute Pkg 'File
-> (ModuleName, SymbolicPathX allowAbsolute Pkg 'File))
-> IO (SymbolicPathX allowAbsolute Pkg 'File)
-> IO (ModuleName, SymbolicPathX allowAbsolute Pkg 'File)
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ModuleName
m,) (IO (SymbolicPathX allowAbsolute Pkg 'File)
-> IO (ModuleName, SymbolicPathX allowAbsolute Pkg 'File))
-> IO (SymbolicPathX allowAbsolute Pkg 'File)
-> IO (ModuleName, SymbolicPathX allowAbsolute Pkg 'File)
forall a b. (a -> b) -> a -> b
$
Maybe (SymbolicPath CWD ('Dir Pkg))
-> [Suffix]
-> [SymbolicPathX allowAbsolute Pkg ('Dir Source)]
-> RelativePath Source 'File
-> IO (Maybe (SymbolicPathX allowAbsolute Pkg 'File))
forall searchDir (allowAbsolute :: AllowAbsolute).
Maybe (SymbolicPath CWD ('Dir Pkg))
-> [Suffix]
-> [SymbolicPathX allowAbsolute Pkg ('Dir searchDir)]
-> RelativePath searchDir 'File
-> IO (Maybe (SymbolicPathX allowAbsolute Pkg 'File))
findFileCwdWithExtension
Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDir
[Suffix]
builtinHaskellSuffixes
[SymbolicPathX allowAbsolute Pkg ('Dir Source)]
dirs
(ModuleName -> RelativePath Source 'File
forall (allowAbsolute :: AllowAbsolute).
ModuleName -> SymbolicPathX allowAbsolute Source 'File
moduleNameSymbolicPath ModuleName
m)
IO (Maybe (SymbolicPathX allowAbsolute Pkg 'File))
-> (Maybe (SymbolicPathX allowAbsolute Pkg 'File)
-> IO (SymbolicPathX allowAbsolute Pkg 'File))
-> IO (SymbolicPathX allowAbsolute Pkg 'File)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IO (SymbolicPathX allowAbsolute Pkg 'File)
-> (SymbolicPathX allowAbsolute Pkg 'File
-> IO (SymbolicPathX allowAbsolute Pkg 'File))
-> Maybe (SymbolicPathX allowAbsolute Pkg 'File)
-> IO (SymbolicPathX allowAbsolute Pkg 'File)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (ModuleName -> IO (SymbolicPathX allowAbsolute Pkg 'File)
forall {a}. ModuleName -> IO a
notFound ModuleName
m) (SymbolicPathX allowAbsolute Pkg 'File
-> IO (SymbolicPathX allowAbsolute Pkg 'File)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (SymbolicPathX allowAbsolute Pkg 'File
-> IO (SymbolicPathX allowAbsolute Pkg 'File))
-> (SymbolicPathX allowAbsolute Pkg 'File
-> SymbolicPathX allowAbsolute Pkg 'File)
-> SymbolicPathX allowAbsolute Pkg 'File
-> IO (SymbolicPathX allowAbsolute Pkg 'File)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SymbolicPathX allowAbsolute Pkg 'File
-> SymbolicPathX allowAbsolute Pkg 'File
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to
-> SymbolicPathX allowAbsolute from to
normaliseSymbolicPath)
where
notFound :: ModuleName -> IO a
notFound ModuleName
module_ =
Verbosity -> CabalException -> IO a
forall a1 a.
(HasCallStack, Exception (VerboseException a1)) =>
Verbosity -> a1 -> IO a
dieWithException Verbosity
verbosity (CabalException -> IO a) -> CabalException -> IO a
forall a b. (a -> b) -> a -> b
$ ModuleName -> CabalException
CantFindSourceModule ModuleName
module_
exeBuildDir :: LocalBuildInfo -> Executable -> SymbolicPath Pkg (Dir Build)
exeBuildDir :: LocalBuildInfo -> Executable -> SymbolicPath Pkg ('Dir Build)
exeBuildDir LocalBuildInfo
lbi Executable
exe = LocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
buildDir LocalBuildInfo
lbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build ('Dir Build) -> SymbolicPath Pkg ('Dir Build)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Build ('Dir Build)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx (String
nm String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-tmp")
where
nm :: String
nm = UnqualComponentName -> String
unUnqualComponentName (UnqualComponentName -> String) -> UnqualComponentName -> String
forall a b. (a -> b) -> a -> b
$ Executable -> UnqualComponentName
exeName Executable
exe
flibBuildDir :: LocalBuildInfo -> ForeignLib -> SymbolicPath Pkg (Dir Build)
flibBuildDir :: LocalBuildInfo -> ForeignLib -> SymbolicPath Pkg ('Dir Build)
flibBuildDir LocalBuildInfo
lbi ForeignLib
flib = LocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
buildDir LocalBuildInfo
lbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build ('Dir Build) -> SymbolicPath Pkg ('Dir Build)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Build ('Dir Build)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx (String
nm String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-tmp")
where
nm :: String
nm = UnqualComponentName -> String
unUnqualComponentName (UnqualComponentName -> String) -> UnqualComponentName -> String
forall a b. (a -> b) -> a -> b
$ ForeignLib -> UnqualComponentName
foreignLibName ForeignLib
flib
stubName :: TestSuite -> FilePath
stubName :: TestSuite -> String
stubName TestSuite
t = UnqualComponentName -> String
unUnqualComponentName (TestSuite -> UnqualComponentName
testName TestSuite
t) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Stub"
testBuildDir :: LocalBuildInfo -> TestSuite -> SymbolicPath Pkg (Dir Build)
testBuildDir :: LocalBuildInfo -> TestSuite -> SymbolicPath Pkg ('Dir Build)
testBuildDir LocalBuildInfo
lbi TestSuite
tst =
LocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
buildDir LocalBuildInfo
lbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build ('Dir Build) -> SymbolicPath Pkg ('Dir Build)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Build ('Dir Build)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx String
testDir
where
testDir :: String
testDir = case TestSuite -> TestSuiteInterface
testInterface TestSuite
tst of
TestSuiteLibV09{} ->
TestSuite -> String
stubName TestSuite
tst String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> TestSuite -> String
stubName TestSuite
tst String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-tmp"
TestSuiteInterface
_ -> String
nm String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-tmp"
nm :: String
nm = UnqualComponentName -> String
unUnqualComponentName (UnqualComponentName -> String) -> UnqualComponentName -> String
forall a b. (a -> b) -> a -> b
$ TestSuite -> UnqualComponentName
testName TestSuite
tst
benchmarkBuildDir :: LocalBuildInfo -> Benchmark -> SymbolicPath Pkg (Dir Build)
benchmarkBuildDir :: LocalBuildInfo -> Benchmark -> SymbolicPath Pkg ('Dir Build)
benchmarkBuildDir LocalBuildInfo
lbi Benchmark
bm =
LocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
buildDir LocalBuildInfo
lbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build ('Dir Build) -> SymbolicPath Pkg ('Dir Build)
forall p q r. PathLike p q r => p -> q -> r
</> String -> RelativePath Build ('Dir Build)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx (String
nm String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-tmp")
where
nm :: String
nm = UnqualComponentName -> String
unUnqualComponentName (UnqualComponentName -> String) -> UnqualComponentName -> String
forall a b. (a -> b) -> a -> b
$ Benchmark -> UnqualComponentName
benchmarkName Benchmark
bm
mkGenericStaticLibName :: String -> String
mkGenericStaticLibName :: String -> String
mkGenericStaticLibName String
lib = String
"lib" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
lib String -> String -> String
forall p. FileLike p => p -> String -> p
<.> String
"a"
mkLibName :: UnitId -> String
mkLibName :: UnitId -> String
mkLibName UnitId
lib = String -> String
mkGenericStaticLibName (UnitId -> String
getHSLibraryName UnitId
lib)
mkProfLibName :: UnitId -> String
mkProfLibName :: UnitId -> String
mkProfLibName UnitId
lib = String -> String
mkGenericStaticLibName (UnitId -> String
getHSLibraryName UnitId
lib String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_p")
mkGenericSharedLibName :: Platform -> CompilerId -> String -> String
mkGenericSharedLibName :: Platform -> CompilerId -> String -> String
mkGenericSharedLibName Platform
platform (CompilerId CompilerFlavor
compilerFlavor Version
compilerVersion) String
lib =
[String] -> String
forall a. Monoid a => [a] -> a
mconcat [String
"lib", String
lib, String
"-", String
comp String -> String -> String
forall p. FileLike p => p -> String -> p
<.> Platform -> String
dllExtension Platform
platform]
where
comp :: String
comp = CompilerFlavor -> String
forall a. Pretty a => a -> String
prettyShow CompilerFlavor
compilerFlavor String -> String -> String
forall a. [a] -> [a] -> [a]
++ Version -> String
forall a. Pretty a => a -> String
prettyShow Version
compilerVersion
mkSharedLibName :: Platform -> CompilerId -> UnitId -> String
mkSharedLibName :: Platform -> CompilerId -> UnitId -> String
mkSharedLibName Platform
platform CompilerId
comp UnitId
lib =
Platform -> CompilerId -> String -> String
mkGenericSharedLibName Platform
platform CompilerId
comp (UnitId -> String
getHSLibraryName UnitId
lib)
mkProfSharedLibName :: Platform -> CompilerId -> UnitId -> String
mkProfSharedLibName :: Platform -> CompilerId -> UnitId -> String
mkProfSharedLibName Platform
platform CompilerId
comp UnitId
lib =
Platform -> CompilerId -> String -> String
mkGenericSharedLibName Platform
platform CompilerId
comp (UnitId -> String
getHSLibraryName UnitId
lib String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"_p")
mkStaticLibName :: Platform -> CompilerId -> UnitId -> String
mkStaticLibName :: Platform -> CompilerId -> UnitId -> String
mkStaticLibName Platform
platform (CompilerId CompilerFlavor
compilerFlavor Version
compilerVersion) UnitId
lib =
String
"lib" String -> String -> String
forall a. [a] -> [a] -> [a]
++ UnitId -> String
getHSLibraryName UnitId
lib String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"-" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
comp String -> String -> String
forall p. FileLike p => p -> String -> p
<.> Platform -> String
staticLibExtension Platform
platform
where
comp :: String
comp = CompilerFlavor -> String
forall a. Pretty a => a -> String
prettyShow CompilerFlavor
compilerFlavor String -> String -> String
forall a. [a] -> [a] -> [a]
++ Version -> String
forall a. Pretty a => a -> String
prettyShow Version
compilerVersion
mkBytecodeLibName :: CompilerId -> UnitId -> String
mkBytecodeLibName :: CompilerId -> UnitId -> String
mkBytecodeLibName CompilerId
_comp UnitId
lib = UnitId -> String
getHSLibraryName UnitId
lib String -> String -> String
forall p. FileLike p => p -> String -> p
<.> String
".bytecodelib"
mkGenericSharedBundledLibName :: Platform -> CompilerId -> String -> String
mkGenericSharedBundledLibName :: Platform -> CompilerId -> String -> String
mkGenericSharedBundledLibName Platform
platform CompilerId
comp String
lib
| String
"HS" String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
`isPrefixOf` String
lib =
Platform -> CompilerId -> String -> String
mkGenericSharedLibName Platform
platform CompilerId
comp String
lib
| Just String
lib' <- String -> String -> Maybe String
forall a. Eq a => [a] -> [a] -> Maybe [a]
stripPrefix String
"C" String
lib =
String
"lib" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
lib' String -> String -> String
forall p. FileLike p => p -> String -> p
<.> Platform -> String
dllExtension Platform
platform
| Bool
otherwise =
String -> String
forall a. HasCallStack => String -> a
error (String
"Don't understand library name " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
lib)
exeExtension :: Platform -> String
exeExtension :: Platform -> String
exeExtension Platform
platform = case Platform
platform of
Platform Arch
_ OS
Windows -> String
"exe"
Platform Arch
Wasm32 OS
_ -> String
"wasm"
Platform
_ -> String
""
objExtension :: String
objExtension :: String
objExtension = String
"o"
dllExtension :: Platform -> String
dllExtension :: Platform -> String
dllExtension (Platform Arch
_arch OS
os) = case OS
os of
OS
Windows -> String
"dll"
OS
OSX -> String
"dylib"
OS
_ -> String
"so"
staticLibExtension :: Platform -> String
staticLibExtension :: Platform -> String
staticLibExtension (Platform Arch
_arch OS
os) = case OS
os of
OS
Windows -> String
"lib"
OS
_ -> String
"a"