module GHC.Linker.Static.Utils where
import GHC.Prelude
import GHC.Platform
import System.FilePath
exeFileName :: Platform -> Bool -> Maybe FilePath -> FilePath
exeFileName :: Platform -> Bool -> Maybe FilePath -> FilePath
exeFileName Platform
platform Bool
staticLink Maybe FilePath
output_fn
| Just FilePath
s <- Maybe FilePath
output_fn =
case Platform -> OS
platformOS Platform
platform of
OS
OSMinGW32 -> FilePath
s FilePath -> FilePath -> FilePath
<?.> FilePath
"exe"
OS
_ -> if Bool
staticLink
then FilePath
s FilePath -> FilePath -> FilePath
<?.> FilePath
"a"
else FilePath
s
| Bool
otherwise =
if Platform -> OS
platformOS Platform
platform OS -> OS -> Bool
forall a. Eq a => a -> a -> Bool
== OS
OSMinGW32
then FilePath
"main.exe"
else if Bool
staticLink
then FilePath
"liba.a"
else FilePath
"a.out"
where FilePath
s <?.> :: FilePath -> FilePath -> FilePath
<?.> FilePath
ext | FilePath -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (FilePath -> FilePath
takeExtension FilePath
s) = FilePath
s FilePath -> FilePath -> FilePath
<.> FilePath
ext
| Bool
otherwise = FilePath
s