summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvmchale <>2018-06-23 03:28:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-06-23 03:28:00 (GMT)
commit47a5e2a145376ac33ba4c7300ffddc799e1d97e4 (patch)
treebf4974b9ad741a6ba9cb04604b52b4053e50a4d5
parent89f5fa4a4ec696c61ab746d2f9e121aaef9b5250 (diff)
version 1.9.0.01.9.0.0
-rw-r--r--shake-ats.cabal9
-rw-r--r--src/Development/Shake/ATS.hs42
-rw-r--r--src/Development/Shake/ATS/Environment.hs4
-rw-r--r--src/Development/Shake/ATS/Generate.hs2
-rw-r--r--src/Development/Shake/ATS/Rules.hs8
-rw-r--r--src/Development/Shake/ATS/Type.hs32
6 files changed, 22 insertions, 75 deletions
diff --git a/shake-ats.cabal b/shake-ats.cabal
index 568ddf1..ac6e4c4 100644
--- a/shake-ats.cabal
+++ b/shake-ats.cabal
@@ -1,6 +1,6 @@
cabal-version: 1.18
name: shake-ats
-version: 1.8.0.6
+version: 1.9.0.0
license: BSD3
license-file: LICENSE
copyright: Copyright: (c) 2018 Vanessa McHale
@@ -35,22 +35,21 @@ library
Development.Shake.ATS.Generate
default-language: Haskell2010
other-extensions: RecordWildCards DeriveGeneric DeriveAnyClass
- TemplateHaskell
ghc-options: -Wall
build-depends:
base >=4.9 && <5,
hashable -any,
language-ats -any,
- shake-ext >=2.9.0.0,
+ shake-ext >=3.0.0.0,
hs2ats >=0.2.0.1,
directory -any,
microlens -any,
- microlens-th -any,
text -any,
dependency -any,
shake >=0.14,
binary -any,
- shake-cabal -any
+ shake-cabal -any,
+ shake-c -any
if flag(development)
ghc-options: -Werror
diff --git a/src/Development/Shake/ATS.hs b/src/Development/Shake/ATS.hs
index 2620fe3..d77972b 100644
--- a/src/Development/Shake/ATS.hs
+++ b/src/Development/Shake/ATS.hs
@@ -26,30 +26,6 @@ module Development.Shake.ATS ( -- * Shake Rules
, ATSGen (..)
, HATSGen (..)
, Solver (..)
- -- * Lenses
- , atsTarget
- , cFlags
- , binTarget
- , cc
- , gc
- , hasPretty
- , genTargets
- , hsLibs
- , patsHome
- , patsHomeLocs
- , libs
- , linkStatic
- , linkTargets
- , otherDeps
- , src
- , tgtType
- , toolConfig
- , cpphs
- , hsFile
- , strip
- , solver
- , linkATSLib
- , patsFlags
) where
import Control.Arrow
@@ -69,7 +45,7 @@ import Development.Shake.C
import Development.Shake.FilePath
import Development.Shake.Version
import Language.ATS
-import Lens.Micro
+-- import Lens.Micro
import System.Directory (copyFile, createDirectoryIfMissing, doesFileExist)
import System.Environment (getEnv)
import System.Exit (ExitCode (ExitSuccess))
@@ -108,8 +84,8 @@ gcFlag True = "-DATS_MEMALLOC_GCBDW"
copySources :: ATSToolConfig -> [FilePath] -> Action ()
copySources ATSToolConfig{..} sources =
forM_ sources $ \dep -> do
- liftIO $ createDirectoryIfMissing True (_patsHome ++ "/" ++ takeDirectory dep)
- liftIO $ copyFile dep (_patsHome ++ "/" ++ dep)
+ liftIO $ createDirectoryIfMissing True (_patsHome </> takeDirectory dep)
+ liftIO $ copyFile dep (_patsHome </> dep)
makeCFlags :: [String] -- ^ Inputs
-> [ForeignCabal] -- ^ Haskell libraries
@@ -118,9 +94,9 @@ makeCFlags :: [String] -- ^ Inputs
-> [String]
makeCFlags ss fc ghcV' b = gcFlag' : (hsExtra <> ss) where
gcFlag' = bool ("-optc" <>) id noHs $ gcFlag b
- hsExtra = bool (["--make", "-I.", "-odir", ".atspkg", "-no-hs-main", "-package-db", "~/.cabal/store/ghc-" ++ ghcV' ++ "/package.db/"] ++ packageDbs) mempty noHs
+ hsExtra = bool (["--make", "-I.", "-odir", ".atspkg", "-no-hs-main", "-package-db", "~/.cabal/store/ghc-" ++ ghcV' </> "package.db/"] ++ packageDbs) mempty noHs
noHs = null fc
- packageDbs = (\x -> ["-package-db", x ++ "/dist-newstyle/packagedb/ghc-" ++ ghcV']) =<< libToDirs fc
+ packageDbs = (\x -> ["-package-db", x </> "dist-newstyle" </> "packagedb" </> "ghc-" ++ ghcV']) =<< libToDirs fc
libToDirs :: [ForeignCabal] -> [String]
libToDirs = fmap (takeDirectory . TL.unpack . h)
@@ -144,16 +120,16 @@ cconfig tc libs' gc' extras = do
f = bool id ("atslib":) (_linkATSLib tc)
h' <- pkgHome cc'
let libs'' = f $ bool libs' ("gc" : libs') gc'
- pure $ CConfig [h ++ "/ccomp/runtime/", h, h' ++ "include", ".atspkg/contrib"] libs'' [h' ++ "lib", _patsHome tc ++ "/ccomp/atslib/lib"] extras (_linkStatic tc)
+ pure $ CConfig [h </> "ccomp" </> "runtime", h, h' </> "include", ".atspkg" </> "contrib"] libs'' [h' </> "lib", _patsHome tc </> "ccomp" </> "atslib" </> "lib"] extras (_linkStatic tc)
patsEnv :: ATSToolConfig -> FilePath -> [CmdOption]
patsEnv cfg path = EchoStderr False :
zipWith AddEnv
["PATSHOME", "PATH", "PATSHOMELOCS", "LIBGMP"]
- [_patsHome cfg, _patsHome cfg ++ "/bin:" ++ path, _patsHomeLocs cfg ]
+ [_patsHome cfg, _patsHome cfg </> "bin:" ++ path, _patsHomeLocs cfg ]
atsToC :: FilePath -> FilePath
-atsToC = (-<.> "c") . (".atspkg/c/" <>)
+atsToC = (-<.> "c") . ((".atspkg" </> "c") </>)
ghcV :: CCompiler -> [ForeignCabal] -> Action String
ghcV (GHC _ suff) hsLibs' = maybe def' (fmap (drop 1)) (pure <$> suff) where
@@ -198,7 +174,7 @@ atsBin ATSTarget{..} = do
cconfig' <- cconfig _toolConfig _libs _gc (makeCFlags _cFlags mempty (pure undefined) _gc)
- let atsGen = (hatsFile <$> _linkTargets) <> ((^.atsTarget) <$> _genTargets)
+ let atsGen = (hatsFile <$> _linkTargets) <> (_atsTarget <$> _genTargets)
atsExtras = _otherDeps <> (TL.unpack . objectFile <$> _hsLibs)
zipWithM_ (cgen _toolConfig atsExtras atsGen) _src cTargets
diff --git a/src/Development/Shake/ATS/Environment.hs b/src/Development/Shake/ATS/Environment.hs
index 6679b82..c94538d 100644
--- a/src/Development/Shake/ATS/Environment.hs
+++ b/src/Development/Shake/ATS/Environment.hs
@@ -13,12 +13,12 @@ import System.Environment (getEnv)
-- installed artifacts. This is used to keep libraries built for different
-- platforms separate.
ccToDir :: CCompiler -> String
-ccToDir (GCC (Just s)) = reverse (drop 1 $ reverse s) ++ "/"
+ccToDir (GCC (Just s)) = reverse (drop 1 $ reverse s) ++ [pathSeparator]
ccToDir _ = ""
-- | The directory @~/.atspkg@
pkgHome :: MonadIO m => CCompiler -> m String
-pkgHome cc' = liftIO $ (++ ("/.atspkg/" ++ ccToDir cc')) <$> getEnv "HOME"
+pkgHome cc' = liftIO $ (</> (".atspkg" </> ccToDir cc')) <$> getEnv "HOME"
fixDir :: FilePath -> String -> String
fixDir p =
diff --git a/src/Development/Shake/ATS/Generate.hs b/src/Development/Shake/ATS/Generate.hs
index 92e2fdc..787cab1 100644
--- a/src/Development/Shake/ATS/Generate.hs
+++ b/src/Development/Shake/ATS/Generate.hs
@@ -8,7 +8,7 @@ generateLinks :: String -> Either ATSError String
generateLinks = fmap (printATS . generateLinks') . parseM
generateLinks' :: ATS a -> ATS a
-generateLinks' (ATS ds) = ATS (fmap g ds ++ [macDecl]) -- ATS [Local undefined (ATS (fmap g ds ++ [macDecl])) (ATS mempty)]
+generateLinks' (ATS ds) = ATS (fmap g ds ++ [macDecl])
where g f@Func{} = Extern undefined (set (fun.preF.expression) expr f)
g x = x
expr = Just (StringLit "\"mac#\"")
diff --git a/src/Development/Shake/ATS/Rules.hs b/src/Development/Shake/ATS/Rules.hs
index cd3296c..fe7c2a8 100644
--- a/src/Development/Shake/ATS/Rules.hs
+++ b/src/Development/Shake/ATS/Rules.hs
@@ -44,7 +44,7 @@ getSubdirs p = do
case ds of
[] -> pure []
xs -> do
- ds' <- filterM doesDirectoryExist (((p <> "/") <>) <$> xs)
+ ds' <- filterM doesDirectoryExist ((p </>) <$> xs)
ss <- mapM getSubdirs ds'
pure $ ds' <> join ss
@@ -69,17 +69,17 @@ cabalForeign (GHC _ suff) (ForeignCabal cbp' cf' obf') = do
command_ [Cwd obfDir] "cabal" ["new-build", "all", "-w", "ghc-" ++ ghcV]
-- TODO move this to the @shake-ext@ package?
- let subdir = takeDirectory cbp ++ "/"
+ let subdir = takeDirectory cbp
correctDir = (== "build")
endsBuild = correctDir . last . splitPath
- pkgDir = subdir ++ "dist-newstyle/build/" ++ platform ++ "/ghc-" ++ ghcV ++ "/" ++ libName ++ "-" ++ prettyShow v ++ "/"
+ pkgDir = subdir </> "dist-newstyle" </> "build" </> platform </> "ghc-" ++ ghcV </> libName ++ "-" ++ prettyShow v
dir <- filter endsBuild <$> liftIO (getSubdirs pkgDir)
let obj = head dir ++ "/" ++ takeFileName obf
liftIO $ copyFile obj out
let hdr = dropExtension obj ++ "_stub.h"
- liftIO $ copyFile hdr (takeDirectory out ++ "/" ++ takeFileName hdr)
+ liftIO $ copyFile hdr (takeDirectory out </> takeFileName hdr)
cabalForeign _ _ = mempty
-- | Build a @.lats@ file using @atslex@.
diff --git a/src/Development/Shake/ATS/Type.hs b/src/Development/Shake/ATS/Type.hs
index e3c7391..dcc6639 100644
--- a/src/Development/Shake/ATS/Type.hs
+++ b/src/Development/Shake/ATS/Type.hs
@@ -1,7 +1,6 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
-{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE DeriveAnyClass #-}
+{-# LANGUAGE DeriveGeneric #-}
module Development.Shake.ATS.Type ( ForeignCabal (..)
, Version (..)
@@ -11,30 +10,6 @@ module Development.Shake.ATS.Type ( ForeignCabal (..)
, ATSGen (..)
, HATSGen (..)
, Solver (..)
- -- * Lenses
- , atsTarget
- , hasPretty
- , cFlags
- , otherDeps
- , toolConfig
- , cc
- , linkStatic
- , src
- , gc
- , binTarget
- , genTargets
- , hsLibs
- , libs
- , patsHome
- , patsHomeLocs
- , tgtType
- , linkTargets
- , cpphs
- , hsFile
- , strip
- , solver
- , linkATSLib
- , patsFlags
) where
import Data.Binary (Binary (..))
@@ -43,7 +18,6 @@ import Data.Hashable (Hashable)
import qualified Data.Text.Lazy as TL
import Development.Shake.C
import GHC.Generics (Generic)
-import Lens.Micro.TH
-- We should have four build types:
--
@@ -125,5 +99,3 @@ data ForeignCabal = ForeignCabal { projectFile :: Maybe TL.Text -- ^ @cabal.proj
, cabalFile :: TL.Text -- ^ @.cabal@ file associated with the library
, objectFile :: TL.Text -- ^ Object file to be generated
} deriving (Eq, Show, Generic, Binary, Hashable)
-
-mconcat <$> traverse makeLenses [''ATSGen, ''ATSTarget, ''ATSToolConfig]