shake-ats 1.4.1.2 → 1.5.0.0
raw patch · 5 files changed
+59/−23 lines, 5 filesdep +lensdep −microlensdep ~language-atsdep ~shake-extPVP ok
version bump matches the API change (PVP)
Dependencies added: lens
Dependencies removed: microlens
Dependency ranges changed: language-ats, shake-ext
API changes (from Hackage documentation)
+ Development.Shake.ATS: [linkTargets] :: BinaryTarget -> [(String, String)]
- Development.Shake.ATS: BinaryTarget :: [String] -> ATSToolConfig -> Bool -> [String] -> [String] -> [ForeignCabal] -> [(String, String, Bool)] -> String -> [String] -> [String] -> ArtifactType -> BinaryTarget
+ Development.Shake.ATS: BinaryTarget :: [String] -> ATSToolConfig -> Bool -> [String] -> [String] -> [ForeignCabal] -> [(String, String, Bool)] -> [(String, String)] -> String -> [String] -> [String] -> ArtifactType -> BinaryTarget
Files
- shake-ats.cabal +4/−3
- src/Development/Shake/ATS.hs +12/−3
- src/Development/Shake/ATS/Generate.hs +16/−0
- src/Development/Shake/ATS/Rules.hs +15/−6
- src/Development/Shake/ATS/Type.hs +12/−11
shake-ats.cabal view
@@ -1,5 +1,5 @@ name: shake-ats-version: 1.4.1.2+version: 1.5.0.0 synopsis: Utilities for building ATS projects with shake description: Various helper functions for building [ATS](http://www.ats-lang.org/) with the [shake](http://shakebuild.com/) library homepage: https://github.com/vmchale/shake-ats#readme@@ -25,12 +25,13 @@ other-modules: Development.Shake.ATS.Type , Development.Shake.ATS.Rules , Development.Shake.ATS.Environment+ , Development.Shake.ATS.Generate build-depends: base >= 4.7 && < 5- , language-ats+ , language-ats >= 0.3.0.3 , shake-ext >= 2.1.0.0 , hs2ats >= 0.2.0.1 , directory- , microlens+ , lens , text , dependency , shake
src/Development/Shake/ATS.hs view
@@ -31,6 +31,8 @@ , ArtifactType (..) ) where +import Control.Arrow+import Control.Lens import Control.Monad import Control.Monad.IO.Class import Data.Bool (bool)@@ -47,7 +49,6 @@ import Development.Shake.FilePath import Development.Shake.Version import Language.ATS-import Lens.Micro import System.Directory (copyFile, createDirectoryIfMissing, doesFileExist) import System.Exit (ExitCode (ExitSuccess)) @@ -154,6 +155,9 @@ atsBin :: BinaryTarget -> Rules () atsBin tgt@BinaryTarget{..} = do + unless (null linkTargets) $+ mapM_ (uncurry genLinks) linkTargets+ unless (null genTargets) $ mapM_ (uncurry3 genATS) genTargets @@ -195,7 +199,7 @@ -- tell shake which files to track and copy them to the appropriate -- directory need (otherDeps ++ (TL.unpack . objectFile <$> hsLibs))- sources <- (<> cDeps) <$> transitiveDeps ((^._2) <$> genTargets) [atsSrc]+ sources <- (<> cDeps) <$> transitiveDeps ((snd <$> linkTargets) <> ((^._2) <$> genTargets)) [atsSrc] need sources copySources tc sources @@ -223,11 +227,16 @@ trim :: String -> String trim = init . drop 1 +maybeError :: (MonadIO m) => Either (ATSError String) b -> m ()+maybeError Right{} = pure ()+maybeError (Left y) = printErr y+ transitiveDeps :: (MonadIO m) => [FilePath] -> [FilePath] -> m [FilePath] transitiveDeps _ [] = pure [] transitiveDeps gen ps = fmap join $ forM ps $ \p -> if p `elem` gen then pure mempty else do contents <- liftIO $ readFile p- let ats = fromRight mempty . parse $ contents+ let (ats, err) = (fromRight mempty &&& maybeError) . parse $ contents+ err let dir = takeDirectory p deps <- filterM (\f -> ((f `elem` gen) ||) <$> (liftIO . doesFileExist) f) $ fixDir dir . trim <$> getDependencies ats deps' <- transitiveDeps gen deps
+ src/Development/Shake/ATS/Generate.hs view
@@ -0,0 +1,16 @@+module Development.Shake.ATS.Generate ( generateLinks+ ) where++import Control.Lens+import Data.Semigroup+import Language.ATS++generateLinks :: String -> Either (ATSError String) String+generateLinks = fmap (printATS . generateLinks') . parse++generateLinks' :: ATS -> ATS+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#\"")+ macDecl = Define "#define ATS_MAINATSFLAG 1"
src/Development/Shake/ATS/Rules.hs view
@@ -3,14 +3,16 @@ , cabalExport , getSubdirs , genATS+ , genLinks ) where import Control.Monad-import Data.List (isPrefixOf)-import Data.Semigroup (Semigroup (..))-import qualified Data.Text.Lazy as TL-import Development.Shake hiding (doesDirectoryExist)-import Development.Shake.ATS.Type hiding (BinaryTarget (..))+import Data.List (isPrefixOf)+import Data.Semigroup (Semigroup (..))+import qualified Data.Text.Lazy as TL+import Development.Shake hiding (doesDirectoryExist)+import Development.Shake.ATS.Generate+import Development.Shake.ATS.Type hiding (BinaryTarget (..)) import Development.Shake.Cabal import Development.Shake.FilePath import Language.ATS.Generate@@ -27,6 +29,13 @@ createDirectoryIfMissing True (takeDirectory out) genATSTypes src out cpphs +genLinks :: FilePath -> FilePath -> Rules ()+genLinks dats link =+ link %> \out -> liftIO $ do+ contents <- readFile dats+ let proc = generateLinks contents+ writeFile out (either undefined id proc)+ getSubdirs :: FilePath -> IO [FilePath] getSubdirs p = do ds <- listDirectory p@@ -51,7 +60,7 @@ obf %> \out -> do need (cf : fmap ((obfDir <> "/") <>) trDeps)- command_ [Cwd obfDir] "cabal" ["new-build", "-O2"]+ command_ [Cwd obfDir] "cabal" ["new-build", "all", "-O2"] let subdir = takeDirectory cbp ++ "/" correctDir = (libName `isPrefixOf`)
src/Development/Shake/ATS/Type.hs view
@@ -58,17 +58,18 @@ } deriving (Generic, Binary) -- | Type for binary and library builds with ATS.-data BinaryTarget = BinaryTarget { cFlags :: [String] -- ^ Flags to be passed to the C compiler- , toolConfig :: ATSToolConfig- , gc :: Bool -- ^ Whether to configure build for use with the garbage collector.- , libs :: [String] -- ^ Libraries against which to link- , src :: [String] -- ^ ATS source files. If building an executable, at most one may contain @main0@.- , hsLibs :: [ForeignCabal] -- ^ Cabal-based Haskell libraries- , genTargets :: [(String, String, Bool)] -- ^ Files to be run through @hs2ats@.- , binTarget :: String -- ^ Binary target- , cDeps :: [String] -- ^ C files necessary to compile the target- , otherDeps :: [String] -- ^ Other files necessary to compile target- , tgtType :: ArtifactType -- ^ Build type+data BinaryTarget = BinaryTarget { cFlags :: [String] -- ^ Flags to be passed to the C compiler+ , toolConfig :: ATSToolConfig+ , gc :: Bool -- ^ Whether to configure build for use with the garbage collector.+ , libs :: [String] -- ^ Libraries against which to link+ , src :: [String] -- ^ ATS source files. If building an executable, at most one may contain @main0@.+ , hsLibs :: [ForeignCabal] -- ^ Cabal-based Haskell libraries+ , genTargets :: [(String, String, Bool)] -- ^ Files to be run through @hs2ats@.+ , linkTargets :: [(String, String)] -- ^ Targets for @_link.hats@ generation.+ , binTarget :: String -- ^ Binary target+ , cDeps :: [String] -- ^ C files necessary to compile the target+ , otherDeps :: [String] -- ^ Other files necessary to compile target+ , tgtType :: ArtifactType -- ^ Build type } deriving (Generic, Binary) -- | Data type containing information about Haskell components of a build.