Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa McHale committed Jul 25, 2018
1 parent 4074215 commit bc76109
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ats-pkg/ats-pkg.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.0
name: ats-pkg
version: 3.1.0.1
version: 3.1.0.2
license: BSD3
license-file: LICENSE
copyright: Copyright: (c) 2018 Vanessa McHale
Expand Down
32 changes: 17 additions & 15 deletions ats-pkg/src/Language/ATS/Package/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -199,27 +199,34 @@ mkPkg mStr rba lint tim setup rs tgt v = do
, pkgToAction mStr setup rs tgt cfg
]

shouldWrite :: (MonadIO m, Binary a) => a -> FilePath -> m Bool
shouldWrite x fp = do
exists <- liftIO (doesFileExist fp)
contents <- if exists
then liftIO (BSL.readFile fp)
else pure mempty
pure $ BSL.length contents /= 0 && encode x /= contents

mkConfig :: Maybe String -> Rules ()
mkConfig mStr = do

(".atspkg" </> "args") %> \out -> do
shouldWrite' <- shouldWrite mStr args

args %> \out -> do
alwaysRerun
shouldWrite <- do
exists <- liftIO (doesFileExist out)
contents <- if exists
then liftIO (BSL.readFile out)
else pure mempty
pure $ BSL.length contents /= 0 && encode mStr /= contents
if shouldWrite
exists <- liftIO (doesFileExist out)
if not exists || shouldWrite'
then liftIO (BSL.writeFile out (encode mStr))
else mempty

(".atspkg" </> "config") %> \out -> do
need ["atspkg.dhall", ".atspkg" </> "args"]
need ["atspkg.dhall", args]
let go = case mStr of { Just x -> (<> (" " <> x)) ; Nothing -> id }
x <- liftIO $ input auto (T.pack (go "./atspkg.dhall"))
liftIO $ BSL.writeFile out (encode (x :: Pkg))

where args = ".atspkg" </> "args"

setTargets :: [String] -> [FilePath] -> Maybe Text -> Rules ()
setTargets rs bins mt = when (null rs) $
case mt of
Expand Down Expand Up @@ -291,12 +298,7 @@ pkgToAction mStr setup rs tgt ~(Pkg bs ts lbs mt _ v v' ds cds bdeps ccLocal cf

want (unpack . cTarget <$> as)

newFlag <- do
exists <- liftIO (doesFileExist flags)
contents <- if exists
then liftIO (BSL.readFile flags)
else pure mempty
pure $ BSL.length contents /= 0 && encode tgt /= contents
newFlag <- shouldWrite tgt flags

-- this is dumb but w/e
flags %> \out -> do
Expand Down

0 comments on commit bc76109

Please sign in to comment.