summaryrefslogtreecommitdiff
path: root/Biz/Bild.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Bild.hs')
-rw-r--r--Biz/Bild.hs69
1 files changed, 9 insertions, 60 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs
index 016b48f..538b991 100644
--- a/Biz/Bild.hs
+++ b/Biz/Bild.hs
@@ -86,10 +86,9 @@
--
-- > -- : out my-ap.js
--
--- When multiple compilers are possible (e.g. ghc vs ghcjs) we use the @out@
--- extension, for example we chose ghcjs when the target @out@ ends in .js. If
--- @out@ does not have an extension, each build type falls back to a default,
--- namely an executable binary.
+-- When multiple compilers are possible we use the @out@ extension to determine
+-- target platform. If @out@ does not have an extension, each build type falls
+-- back to a default, namely an executable binary.
--
-- This method of setting metadata in the module comments works pretty well,
-- and really only needs to be done in the entrypoint module anyway.
@@ -205,8 +204,6 @@ data Compiler
= Copy
| GhcLib
| GhcExe
- | GhcjsExe
- | GhcjsLib
| Guile
| NixBuild
| Rustc
@@ -333,7 +330,7 @@ analyze path = do
pure
Target
{ builder = user <> "@localhost",
- compiler = detectGhcCompiler out <| Text.unpack content,
+ compiler = detectGhcCompiler out,
sysdeps =
contentLines
/> Text.unpack
@@ -430,23 +427,11 @@ ghcPkgFindModule acc m = do
/> Set.union acc
-- | Some rules for detecting the how to compile a ghc module. If there is an
--- out, then we know it's some Exe; if the out ends in .js then it's GhcjsExe,
--- otherwise GhcExe. That part is solved.
---
--- Detecting a Lib is harder, and much code can be compiled by both ghc and
--- ghcjs. For now I'm just guarding against known ghcjs-only modules in the
--- import list.
-detectGhcCompiler :: Maybe Out -> String -> Compiler
-detectGhcCompiler (Just out) _ | jsSuffix out = GhcjsExe
-detectGhcCompiler (Just _) _ = GhcExe
-detectGhcCompiler Nothing content
- | match "import GHCJS" = GhcjsLib
- | otherwise = GhcLib
- where
- match s = s `List.isInfixOf` content
-
-jsSuffix :: String -> Bool
-jsSuffix = List.isSuffixOf ".js"
+-- out, then we know it's some Exe, otherwise it's a Lib.
+detectGhcCompiler :: Maybe Out -> Compiler
+detectGhcCompiler = \case
+ Just _ -> GhcExe
+ Nothing -> GhcLib
isFailure :: Exit.ExitCode -> Bool
isFailure (Exit.ExitFailure _) = True
@@ -516,42 +501,6 @@ build andTest loud target@Target {..} = do
"--make",
path
]
- GhcjsExe -> do
- Log.info ["bild", "dev", "ghcjs-exe", nschunk namespace]
- pure Exit.ExitSuccess
- --proc
- -- loud
- -- namespace
- -- "ghcjs"
- -- [ "-Werror",
- -- "-i" <> root,
- -- "-odir",
- -- root </> intdir,
- -- "-hidir",
- -- root </> intdir,
- -- "--make",
- -- path,
- -- "-main-is",
- -- Namespace.toHaskellModule namespace,
- -- "-o",
- -- root </> vardir </> Maybe.fromJust out
- -- ]
- GhcjsLib -> do
- Log.info ["bild", "dev", "ghcjs-lib", nschunk namespace]
- pure Exit.ExitSuccess
- --proc
- -- loud
- -- namespace
- -- "ghcjs"
- -- [ "-Werror",
- -- "-i" <> root,
- -- "-odir",
- -- root </> intdir,
- -- "-hidir",
- -- root </> intdir,
- -- "--make",
- -- path
- -- ]
Guile -> do
Log.info ["bild", "dev", "guile", nschunk namespace]
_ <-