shake-ats 1.6.0.1 → 1.6.0.2
raw patch · 4 files changed
+37/−16 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Development.Shake.ATS: [cpphs] :: ATSGen -> Bool
- Development.Shake.ATS: [hsFile] :: ATSGen -> FilePath
+ Development.Shake.ATS: HATSGen :: FilePath -> FilePath -> HATSGen
+ Development.Shake.ATS: [_cpphs] :: ATSGen -> Bool
+ Development.Shake.ATS: [_hsFile] :: ATSGen -> FilePath
+ Development.Shake.ATS: [hatsFile] :: HATSGen -> FilePath
+ Development.Shake.ATS: [satsFile] :: HATSGen -> FilePath
+ Development.Shake.ATS: cabalForeign :: ForeignCabal -> Rules ()
+ Development.Shake.ATS: cpphs :: Lens' ATSGen Bool
+ Development.Shake.ATS: data HATSGen
+ Development.Shake.ATS: hsAts :: ATSGen -> Rules ()
+ Development.Shake.ATS: hsFile :: Lens' ATSGen FilePath
- Development.Shake.ATS: ATSTarget :: [String] -> ATSToolConfig -> Bool -> [String] -> [FilePath] -> [ForeignCabal] -> [ATSGen] -> [(FilePath, FilePath)] -> FilePath -> [FilePath] -> ArtifactType -> ATSTarget
+ Development.Shake.ATS: ATSTarget :: [String] -> ATSToolConfig -> Bool -> [String] -> [FilePath] -> [ForeignCabal] -> [ATSGen] -> [HATSGen] -> FilePath -> [FilePath] -> ArtifactType -> ATSTarget
- Development.Shake.ATS: [_linkTargets] :: ATSTarget -> [(FilePath, FilePath)]
+ Development.Shake.ATS: [_linkTargets] :: ATSTarget -> [HATSGen]
- Development.Shake.ATS: linkTargets :: Lens' ATSTarget [(FilePath, FilePath)]
+ Development.Shake.ATS: linkTargets :: Lens' ATSTarget [HATSGen]
Files
- shake-ats.cabal +1/−1
- src/Development/Shake/ATS.hs +20/−8
- src/Development/Shake/ATS/Rules.hs +4/−4
- src/Development/Shake/ATS/Type.hs +12/−3
shake-ats.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: shake-ats-version: 1.6.0.1+version: 1.6.0.2 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2018 Vanessa McHale
src/Development/Shake/ATS.hs view
@@ -5,11 +5,14 @@ {-# LANGUAGE TypeSynonymInstances #-} module Development.Shake.ATS ( -- * Shake Rules- cleanATS- , atsBin+ atsBin , cgen , genATS , atsLex+ , cabalForeign+ , hsAts+ -- * Shake actions+ , cleanATS -- * Helper functions , getSubdirs , ccToDir@@ -24,6 +27,7 @@ , CCompiler (..) , ArtifactType (..) , ATSGen (..)+ , HATSGen (..) -- * Lenses , atsTarget , cFlags@@ -42,6 +46,8 @@ , src , tgtType , toolConfig+ , cpphs+ , hsFile ) where import Control.Arrow@@ -114,11 +120,11 @@ libToDirs = fmap (takeDirectory . TL.unpack . h) where h (ForeignCabal mpr cf _) = fromMaybe cf mpr --- | Location of @patscc@+-- | Absolute path to @patscc@ patscc :: ATSToolConfig -> String patscc = patsTool "patscc" --- | Location of @patsopt@+-- | Absolute path to @patsopt@ patsopt :: ATSToolConfig -> String patsopt = patsTool "patsopt" @@ -152,17 +158,23 @@ doLib Executable = pure mempty doLib _ = id +hsAts :: ATSGen -> Rules ()+hsAts (ATSGen x y z) = genATS x y z++satsGen :: HATSGen -> Rules ()+satsGen (HATSGen x y) = genLinks x y+ -- | 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. atsBin :: ATSTarget -> Rules () atsBin ATSTarget{..} = do - mapM_ (uncurry genLinks) _linkTargets+ mapM_ satsGen _linkTargets - mapM_ (\(ATSGen x y z) -> genATS x y z) _genTargets+ mapM_ hsAts _genTargets - mapM_ cabalExport _hsLibs+ mapM_ cabalForeign _hsLibs let cTargets = atsToC <$> _src @@ -176,7 +188,7 @@ cconfig' <- cconfig _toolConfig _libs _gc (makeCFlags _cFlags mempty (pure undefined) _gc) - let atsGen = (snd <$> _linkTargets) <> ((^.atsTarget) <$> _genTargets)+ let atsGen = (hatsFile <$> _linkTargets) <> ((^.atsTarget) <$> _genTargets) atsExtras = _otherDeps <> (TL.unpack . objectFile <$> _hsLibs) zipWithM_ (cgen _toolConfig atsExtras atsGen) _src cTargets
src/Development/Shake/ATS/Rules.hs view
@@ -1,6 +1,6 @@ module Development.Shake.ATS.Rules ( atsLex , cleanATS- , cabalExport+ , cabalForeign , getSubdirs , genATS , genLinks@@ -49,8 +49,8 @@ -- | These rules take a @.cabal@ file and the @.o@ file to be produced from -- them, building the @.o@ file.-cabalExport :: ForeignCabal -> Rules ()-cabalExport (ForeignCabal cbp' cf' obf') = do+cabalForeign :: ForeignCabal -> Rules ()+cabalForeign (ForeignCabal cbp' cf' obf') = do let cf = TL.unpack cf' cbp = maybe cf TL.unpack cbp'@@ -78,7 +78,7 @@ let hdr = dropExtension obj ++ "_stub.h" liftIO $ copyFile hdr (takeDirectory out ++ "/" ++ takeFileName hdr) --- | Build a @.lats@ file.+-- | Build a @.lats@ file using @atslex@. atsLex :: FilePath -- ^ Filepath of @.lats@ file -> FilePattern -- ^ File pattern for generated output -> Rules ()
src/Development/Shake/ATS/Type.hs view
@@ -10,6 +10,7 @@ , ArtifactType (..) , ATSToolConfig (..) , ATSGen (..)+ , HATSGen (..) -- * Lenses , atsTarget , hasPretty@@ -28,6 +29,8 @@ , patsHomeLocs , tgtType , linkTargets+ , cpphs+ , hsFile ) where import Data.Binary (Binary (..))@@ -81,11 +84,17 @@ , _linkStatic :: Bool -- ^ Force static linking } deriving (Generic, Binary) -data ATSGen = ATSGen { hsFile :: FilePath -- ^ Haskell file containing types+data HATSGen = HATSGen { satsFile :: FilePath -- ^ @.sats@ file containing type definitions+ , hatsFile :: FilePath -- ^ @.hats@ file to be generated for library distribution+ } deriving (Generic, Binary)++data ATSGen = ATSGen { _hsFile :: FilePath -- ^ Haskell file containing types , _atsTarget :: FilePath -- ^ ATS file to be generated- , cpphs :: Bool -- ^ Whether to use the C preprocessor on the Haskell code+ , _cpphs :: Bool -- ^ Whether to use the C preprocessor on the Haskell code } deriving (Generic, Binary) +-- TODO split off haskell-related types and leave it more general??+ -- | Type for binary and library builds with ATS. data ATSTarget = ATSTarget { _cFlags :: [String] -- ^ Flags to be passed to the C compiler , _toolConfig :: ATSToolConfig -- ^ Configuration options for @patsopt@@@ -94,7 +103,7 @@ , _src :: [FilePath] -- ^ ATS source files. If building an executable, at most one may contain @main0@. , _hsLibs :: [ForeignCabal] -- ^ Cabal-based Haskell libraries. , _genTargets :: [ATSGen] -- ^ Files to be run through @hs2ats@.- , _linkTargets :: [(FilePath, FilePath)] -- ^ Targets for @_link.hats@ generation.+ , _linkTargets :: [HATSGen] -- ^ Targets for @_link.hats@ generation. , _binTarget :: FilePath -- ^ Target , _otherDeps :: [FilePath] -- ^ Other files to track. , _tgtType :: ArtifactType -- ^ Build type