summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvmchale <>2018-09-25 04:34:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-09-25 04:34:00 (GMT)
commita66c6f06efc520f6e1c47303a75fe33e26245c7c (patch)
tree301b6d666d117f027e1d1f3d9fca9bee4d149e54
parentdf492c875f09e4f193b174403976eaa7a60c9fc8 (diff)
version 1.10.0.11.10.0.1
-rw-r--r--CHANGELOG.md4
-rw-r--r--shake-ats.cabal2
-rw-r--r--src/Development/Shake/ATS.hs17
-rw-r--r--src/Development/Shake/ATS/Rules.hs10
4 files changed, 20 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b85c15a..49a5305 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# shake-ats
+## 1.10.0.0
+
+ * Make `cabalForeign` take a `HsCompiler` instead of a `CCompiler`.
+
## 1.9.0.5
* Bugfix for recent version of `shake-cabal`
diff --git a/shake-ats.cabal b/shake-ats.cabal
index ac126c6..0b70f3b 100644
--- a/shake-ats.cabal
+++ b/shake-ats.cabal
@@ -1,6 +1,6 @@
cabal-version: 1.18
name: shake-ats
-version: 1.9.0.5
+version: 1.10.0.1
license: BSD3
license-file: LICENSE
copyright: Copyright: (c) 2018 Vanessa McHale
diff --git a/src/Development/Shake/ATS.hs b/src/Development/Shake/ATS.hs
index 93a8cf8..042c0fd 100644
--- a/src/Development/Shake/ATS.hs
+++ b/src/Development/Shake/ATS.hs
@@ -43,7 +43,9 @@ import Development.Shake hiding (doesFileExist, getEnv
import Development.Shake.ATS.Environment
import Development.Shake.ATS.Rules
import Development.Shake.ATS.Type
-import Development.Shake.C
+import Development.Shake.C hiding (GHC)
+import qualified Development.Shake.C as C
+import Development.Shake.Cabal
import Development.Shake.FilePath
import Development.Shake.Version
import Language.ATS
@@ -140,7 +142,7 @@ patsEnv cfg path = EchoStderr False :
atsToC :: FilePath -> FilePath
atsToC = (-<.> "c") . ((".atspkg" </> "c") </>)
-ghcV :: CCompiler -> [ForeignCabal] -> Action String
+ghcV :: HsCompiler -> [ForeignCabal] -> Action String
ghcV (GHC _ suff) hsLibs' = maybe def' (fmap (drop 1)) (pure <$> suff) where
def' = case hsLibs' of
[] -> pure undefined
@@ -157,11 +159,12 @@ hsAts (ATSGen x y z) = genATS x y z
satsGen :: HATSGen -> Rules ()
satsGen (HATSGen x y) = genLinks x y
--- /.atspkg/contrib/atscntrb-hx-libgmp
+ccToHsc :: CCompiler -> HsCompiler
+ccToHsc (C.GHC pref suff) = GHC pref suff
+ccToHsc _ = GHC Nothing Nothing
-- | Rules for generating binaries or libraries from ATS code. This is very
--- general; use 'defaultATSTarget' for sensible defaults that can be modified
--- with the provided lenses.
+-- general; use 'defaultATSTarget' for sensible defaults.
atsBin :: ATSTarget -> Rules ()
atsBin ATSTarget{..} = do
@@ -169,7 +172,7 @@ atsBin ATSTarget{..} = do
traverse_ hsAts _genTargets
- traverse_ (cabalForeign (_cc _toolConfig)) _hsLibs
+ traverse_ (cabalForeign (ccToHsc $ _cc _toolConfig)) _hsLibs
let cTargets = atsToC <$> _src
@@ -196,7 +199,7 @@ atsBin ATSTarget{..} = do
need (h' cTargets)
- ghcV' <- ghcV (_cc _toolConfig) _hsLibs
+ ghcV' <- ghcV (ccToHsc $ _cc _toolConfig) _hsLibs
cconfig'' <- cconfig _toolConfig _libs _gc (makeCFlags _cFlags _hsLibs ghcV' _gc)
diff --git a/src/Development/Shake/ATS/Rules.hs b/src/Development/Shake/ATS/Rules.hs
index 3600918..4ea108a 100644
--- a/src/Development/Shake/ATS/Rules.hs
+++ b/src/Development/Shake/ATS/Rules.hs
@@ -15,10 +15,10 @@ import qualified Data.Text.Lazy as TL
import Development.Shake hiding (doesDirectoryExist)
import Development.Shake.ATS.Generate
import Development.Shake.ATS.Type hiding (ATSTarget (..))
-import Development.Shake.C
-import Development.Shake.Cabal hiding (GHC)
+import Development.Shake.Cabal
import Development.Shake.FilePath
import Development.Shake.Version
+import Language.ATS
import Language.ATS.Generate
import System.Directory
@@ -38,7 +38,7 @@ genLinks dats link =
link %> \out -> liftIO $ do
contents <- readFile dats
let proc = generateLinks contents
- writeFile out (either undefined id proc) -- FIXME better error
+ either printErr (flip writeFile out) proc
-- | Get subdirectories recursively.
getSubdirs :: FilePath -> IO [FilePath]
@@ -53,7 +53,7 @@ getSubdirs p = do
-- | These rules take a @.cabal@ file and the @.o@ file to be produced from
-- them, building the @.o@ file.
-cabalForeign :: CCompiler -> ForeignCabal -> Rules () -- TODO HsCompiler?
+cabalForeign :: HsCompiler -> ForeignCabal -> Rules ()
cabalForeign (GHC _ suff) (ForeignCabal cbp' cf' obf') = do
let cf = TL.unpack cf'
@@ -83,7 +83,7 @@ cabalForeign (GHC _ suff) (ForeignCabal cbp' cf' obf') = do
let hdr = dropExtension obj ++ "_stub.h"
liftIO $ copyFile hdr (takeDirectory out </> takeFileName hdr)
-cabalForeign _ _ = error "CCompiler must be GHC"
+cabalForeign _ _ = error "HsCompiler must be GHC"
-- | Build a @.lats@ file using @atslex@.
atsLex :: FilePath -- ^ Filepath of @.lats@ file