shake-futhark 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+13/−3 lines, 3 filesdep +directory
Dependencies added: directory
Files
- CHANGELOG.md +4/−0
- shake-futhark.cabal +3/−2
- src/Development/Shake/Futhark.hs +6/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # shake-futhark +## 0.1.0.2++ * Nice-ify paths before `need`-ing them+ ## 0.1.0.1 * Fix bug
shake-futhark.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: shake-futhark-version: 0.1.0.1+version: 0.1.0.2 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2020 Vanessa McHale@@ -31,7 +31,8 @@ shake -any, text -any, filepath -any,- containers >=0.6+ containers >=0.6,+ directory -any if impl(ghc >=8.0) ghc-options:
src/Development/Shake/Futhark.hs view
@@ -3,12 +3,14 @@ , needFut ) where +import Control.Monad ((<=<)) import Control.Monad.IO.Class (liftIO) import Data.Containers.ListUtils (nubOrd) import qualified Data.Text.IO as TIO import Development.Shake (Action, need) import Language.Futhark.Parser (parseFuthark) import Language.Futhark.Syntax (DecBase (..), ModBindBase (ModBind), ModExpBase (..), ProgBase (Prog))+import System.Directory (canonicalizePath, makeRelativeToCurrentDirectory) import System.FilePath (takeDirectory, (<.>), (</>)) -- | @'need'@ a file and all its dependencies@@ -17,7 +19,7 @@ need =<< liftIO (mconcat . (fps :) <$> traverse getAllFutDeps fps) getFutDeps :: FilePath -> IO [FilePath]-getFutDeps fp = do+getFutDeps fp = traverse canonicalizeRelative =<< do contents <- TIO.readFile fp let dirFile = takeDirectory fp parsed = either (error.show) id $ parseFuthark fp contents@@ -30,6 +32,9 @@ level <- traverse getAllFutDeps deps let next = nubOrd (concat (deps : level)) pure $ if null level then deps else next++canonicalizeRelative :: FilePath -> IO FilePath+canonicalizeRelative = makeRelativeToCurrentDirectory <=< canonicalizePath extractFromProgBase :: ProgBase f vn -> [FilePath] extractFromProgBase (Prog _ ds) = concatMap extractFromDecBase ds