shake-ats 0.3.0.6 → 1.0.0.0
raw patch · 2 files changed
+49/−8 lines, 2 filesdep ~hs2atsdep ~shake-extPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hs2ats, shake-ext
API changes (from Hackage documentation)
+ Development.Shake.ATS: ForeignCabal :: Text -> Text -> ForeignCabal
+ Development.Shake.ATS: [cabalFile] :: ForeignCabal -> Text
+ Development.Shake.ATS: [objectFile] :: ForeignCabal -> Text
+ Development.Shake.ATS: data ForeignCabal
+ Development.Shake.ATS: getSubdirs :: FilePath -> IO [FilePath]
- Development.Shake.ATS: atsBin :: String -> [String] -> Version -> Version -> Bool -> [String] -> String -> [String] -> [(String, String)] -> String -> Rules ()
+ Development.Shake.ATS: atsBin :: String -> [String] -> Version -> Version -> Bool -> [String] -> String -> [ForeignCabal] -> [(String, String)] -> String -> Rules ()
Files
- shake-ats.cabal +3/−3
- src/Development/Shake/ATS.hs +46/−5
shake-ats.cabal view
@@ -1,5 +1,5 @@ name: shake-ats-version: 0.3.0.6+version: 1.0.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@@ -24,8 +24,8 @@ exposed-modules: Development.Shake.ATS build-depends: base >= 4.7 && < 5 , language-ats- , shake-ext- , hs2ats >= 0.2.0.0+ , shake-ext >= 2.0.0.0+ , hs2ats >= 0.2.0.1 , directory , text , shake
src/Development/Shake/ATS.hs view
@@ -14,8 +14,11 @@ , ghcExport -- * Actions , patsHome+ -- * Helper functions+ , getSubdirs -- Types , Version (..)+ , ForeignCabal (..) ) where import Control.Monad@@ -27,14 +30,26 @@ import Data.Maybe (fromMaybe) import Data.Semigroup (Semigroup (..)) import qualified Data.Text.Lazy as TL-import Development.Shake+import Development.Shake hiding (doesDirectoryExist)+import Development.Shake.Cabal import Development.Shake.FilePath import GHC.Generics (Generic) import Language.ATS import Language.ATS.Generate-import System.Directory (copyFile, createDirectoryIfMissing)+import System.Directory (copyFile, createDirectoryIfMissing, doesDirectoryExist, listDirectory) import System.Exit (ExitCode (ExitSuccess)) +data ForeignCabal = ForeignCabal { cabalFile :: TL.Text+ , objectFile :: TL.Text+ }++getSubdirs :: FilePath -> IO [FilePath]+getSubdirs p = do+ ds <- listDirectory p+ case ds of+ [] -> pure []+ xs -> filterM doesDirectoryExist (((p <> "/") <>) <$> xs)+ newtype Version = Version [Integer] deriving (Eq, Generic, Binary) @@ -47,6 +62,32 @@ createDirectoryIfMissing True (takeDirectory out) genATSTypes src target +-- dumb heuristic:+-- go to dist-newstyle/build+-- find 'build' subdir+-- file is there++cabalExport :: ForeignCabal -> Rules ()+cabalExport (ForeignCabal cf' obf') = do++ let cf = TL.unpack cf'+ obf = TL.unpack obf'++ trDeps <- liftIO $ getCabalDeps cf+ obf %> \out -> do++ need (cf : trDeps)+ cmd_ ["cabal", "new-build"]++ let subdir = takeDirectory cf+ dir <- filter (== "build") <$> liftIO (getSubdirs $ subdir ++ "dist-newstyle/build")+ let obj = head dir ++ "/" ++ obf+ liftIO $ copyFile obj out++ let hdr = dropExtension obj ++ "_stub.h"+ liftIO $ copyFile hdr (takeDirectory out ++ "/" ++ hdr)++-- cabal deps ghcExport :: String -> Rules () ghcExport m = [ m ++ ".o" ] &%> \[out] -> do@@ -97,7 +138,7 @@ -> Bool -- ^ Whether to use the garbage collector -> [String] -- ^ A list of libraries against which to link -> String -- ^ Source file- -> [String] -- ^ Other dependencies to track+ -> [ForeignCabal] -- ^ Cabal-generated Haskell libraries -> [(String, String)] -- ^ Files to be run through @hs2ats@. -> String -- ^ Binary target -> Rules ()@@ -107,14 +148,14 @@ mapM_ (uncurry genATS) atg unless (null hs) $- mapM_ ghcExport ((-<.> "") <$> hs)+ mapM_ cabalExport hs out %> \_ -> do h <- patsHome v' h' <- pkgHome let home = h ++ "lib/ats2-postiats-" ++ show v sources <- transitiveDeps (snd <$> atg) [sourceFile]- need (sources ++ hs)+ need (sources ++ (TL.unpack . objectFile <$> hs)) copySources v v' sources cmd_ ["mkdir", "-p", dropDirectory1 out]