blob: 592a87da6f1910c6f16382ebb2e54d3d903f3eb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
{-# LANGUAGE MultiWayIf #-}
module GHC.Linker.Static.Utils where
import GHC.Prelude
import GHC.Platform
import System.FilePath
-- | Compute the output file name of a program.
--
-- StaticLink boolean is used to indicate if the program is actually a static library
-- (e.g., on iOS).
--
-- Use the provided filename (if any), otherwise use "main.exe" (Windows),
-- "a.out (otherwise without StaticLink set), "liba.a". In every case, add the
-- extension if it is missing.
exeFileName :: ArchOS -> Bool -> Maybe FilePath -> FilePath
exeFileName (ArchOS arch os) staticLink output_fn
| Just s <- output_fn = if
| OSMinGW32 <- os -> s <?.> "exe"
| ArchJavaScript <- arch -> s <?.> "jsexe"
| ArchWasm32 <- arch -> s <?.> "wasm"
| staticLink -> s <?.> "a"
| otherwise -> s
| otherwise = if
| OSMinGW32 <- os -> "main.exe"
| ArchJavaScript <- arch -> "main.jsexe"
| staticLink -> "liba.a"
| otherwise -> "a.out"
where s <?.> ext | null (takeExtension s) = s <.> ext
| otherwise = s
|