shake-ext 0.4.2.0 → 0.5.0.0
raw patch · 2 files changed
+31/−17 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Development.Shake.ATS: Version :: [Integer] -> Version
+ Development.Shake.ATS: instance GHC.Show.Show Development.Shake.ATS.Version
+ Development.Shake.ATS: newtype Version
- Development.Shake.ATS: atsBin :: Bool -> [String] -> String -> String -> Rules ()
+ Development.Shake.ATS: atsBin :: Version -> Bool -> [String] -> String -> String -> Rules ()
- Development.Shake.ATS: cgen :: FilePath -> Rules ()
+ Development.Shake.ATS: cgen :: Version -> FilePath -> Rules ()
- Development.Shake.ATS: cgenPretty :: Rules ()
+ Development.Shake.ATS: cgenPretty :: Version -> Rules ()
Files
- shake-ext.cabal +1/−1
- src/Development/Shake/ATS.hs +30/−16
shake-ext.cabal view
@@ -1,5 +1,5 @@ name: shake-ext-version: 0.4.2.0+version: 0.5.0.0 synopsis: Helper functions for linting with shake description: This package provides several linters out of the box, as well as functionality for building ATS source files with [shake](http://shakebuild.com/). homepage: https://hub.darcs.net/vmchale/shake-ext
src/Development/Shake/ATS.hs view
@@ -1,10 +1,16 @@-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeSynonymInstances #-} -module Development.Shake.ATS ( cgen+module Development.Shake.ATS ( -- * Shake Rules+ cgen , cgenPretty , cleanATS , atsBin+ -- * Actions , patsHome+ -- Types+ , Version (..) ) where import Control.Monad (filterM, forM_)@@ -17,30 +23,38 @@ import System.Directory (copyFile) import System.Exit (ExitCode (ExitSuccess)) +newtype Version = Version [Integer]++instance Show Version where+ show (Version []) = ""+ show (Version [x]) = show x+ show (Version (x:xs)) = show x ++ "." ++ show (Version xs)+ patsHome :: Action String patsHome = fromMaybe "/usr/local/lib/ats2-postiats-0.3.8" <$> mh where mh = fmap (++ "/.atspkg/compiler/") <$> getEnv "HOME" -- TODO install the whole compiler?-atsCommand :: CmdResult r => String -> String -> Action r-atsCommand sourceFile out = do- let home = "/usr/local/lib/ats2-postiats-0.3.8"+atsCommand :: CmdResult r => Version -> String -> String -> Action r+atsCommand version sourceFile out = do+ let home = "/usr/local/lib/ats2-postiats-" ++ show version let atsArgs = [EchoStderr False, AddEnv "PATSHOME" home]- patsc = "patsopt" -- home ++ "/bin/patsopt"+ patsc = "patsopt" command atsArgs patsc ["--output", out, "-dd", sourceFile, "-cc"] gcFlag :: Bool -> String gcFlag False = "-DATS_MEMALLOC_LIBC" gcFlag True = "-DATS_MEMALLOC_GCBDW" -atsBin :: Bool -> [String] -> String -> String -> Rules ()-atsBin gc libs sourceFile out =+-- TODO musl?+atsBin :: Version -> Bool -> [String] -> String -> String -> Rules ()+atsBin v gc libs sourceFile out = out %> \_ -> do need [sourceFile]- let home = "/usr/local/lib/ats2-postiats-0.3.8"+ let home = "/usr/local/lib/ats2-postiats-" ++ show v cmd_ ["mkdir", "-p", dropDirectory1 out] let toLibs = fmap ("-l" <>)- command [EchoStderr False, AddEnv "PATSHOME" home] "patscc" ([sourceFile, "-atsccomp", "gcc -flto -I/usr/local/lib/ats2-postiats-0.3.8/ccomp/runtime/ -I/usr/local/lib/ats2-postiats-0.3.8/", gcFlag gc, "-o", out, "-cleanaft", "-O2", "-mtune=native"] <> toLibs libs)+ command [EchoStderr False, AddEnv "PATSHOME" home] "patscc" ([sourceFile, "-atsccomp", "gcc -flto -I/usr/local/lib/ats2-postiats-0.3.8/ccomp/runtime/ -I/usr/local/lib/ats2-postiats-0.3.8/", gcFlag gc, "-o", out, "-cleanaft", "-O2", "-mtune=native", "-flto"] <> toLibs libs) cleanATS :: Rules () cleanATS =@@ -53,15 +67,15 @@ -- | This provides rules for generating C code from ATS source files in the -- @ats-src@ directory.-cgen :: FilePath -> Rules ()-cgen dir = do+cgen :: Version -> FilePath -> Rules ()+cgen version dir = do atsDeps "//*.c" %> \out -> do let sourceFile = dir ++ "/" ++ (dropDirectory1 out -<.> "dats") need [sourceFile]- atsCommand sourceFile out+ atsCommand version sourceFile out atsDeps :: Rules () atsDeps =@@ -76,8 +90,8 @@ liftIO $ copyFile dep (home ++ "/" ++ dep) -- | This uses @pats-filter@ to prettify the errors.-cgenPretty :: Rules ()-cgenPretty = do+cgenPretty :: Version -> Rules ()+cgenPretty version = do atsDeps @@ -85,7 +99,7 @@ let sourceFile = "ats-src/" ++ (dropDirectory1 out -<.> "dats") need [sourceFile]- (Exit c, Stderr err) :: (Exit, Stderr String) <- atsCommand sourceFile out+ (Exit c, Stderr err) :: (Exit, Stderr String) <- atsCommand version sourceFile out cmd_ [Stdin err] Shell "pats-filter" if c /= ExitSuccess then error "patscc failure"