Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable stack with yesod keter #1041

Merged
merged 4 commits into from Jul 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions stack.yaml
Expand Up @@ -15,3 +15,4 @@ packages:
- ./yesod-websockets
extra-deps:
- wai-app-static-3.1.0
- nonce-1.0.2
10 changes: 6 additions & 4 deletions yesod-bin/Devel.hs
Expand Up @@ -88,14 +88,14 @@ lockFile :: FilePath
lockFile = "yesod-devel/devel-terminate"

writeLock :: DevelOpts -> IO ()
writeLock opts = do
writeLock _opts = do
createDirectoryIfMissing True "yesod-devel"
writeFile lockFile ""
createDirectoryIfMissing True "dist" -- for compatibility with old devel.hs
writeFile "dist/devel-terminate" ""

removeLock :: DevelOpts -> IO ()
removeLock opts = do
removeLock _opts = do
removeFileIfExists lockFile
removeFileIfExists "dist/devel-terminate" -- for compatibility with old devel.hs

Expand Down Expand Up @@ -138,6 +138,8 @@ defaultDevelOpts = DevelOpts
, proxyTimeout = 10
, useReverseProxy = True
, terminateWith = TerminateOnEnter
, develConfigOpts = []
, develEnv = Nothing
}

cabalProgram :: DevelOpts -> FilePath
Expand Down Expand Up @@ -197,7 +199,7 @@ reverseProxy opts iappPort = do
putStrLn ""
loop (race_ httpProxy httpsProxy) `Ex.catch` \e -> do
print (e :: Ex.SomeException)
exitFailure
_ <- exitFailure
Ex.throwIO e -- heh, just for good measure
where
loop proxies = forever $ do
Expand Down Expand Up @@ -524,7 +526,7 @@ lookupLdAr = do

lookupLdAr' :: IO (Maybe (FilePath, FilePath))
lookupLdAr' = do
#if MIN_VERSION_Cabal(1,22,0)
#if MIN_VERSION_Cabal(1,18,0)
(_, _, pgmc) <- D.configCompilerEx (Just D.GHC) Nothing Nothing D.defaultProgramConfiguration D.silent
#else
(_, pgmc) <- D.configCompiler (Just D.GHC) Nothing Nothing D.defaultProgramConfiguration D.silent
Expand Down
4 changes: 2 additions & 2 deletions yesod-bin/HsFile.hs
Expand Up @@ -3,9 +3,9 @@
module HsFile (mkHsFile) where
import Text.ProjectTemplate (createTemplate)
import Data.Conduit
( ($$), (=$), ConduitM, awaitForever, yield, Source )
( ($$), (=$), awaitForever)
import Data.Conduit.Filesystem (sourceDirectory)
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import Control.Monad.Trans.Resource (runResourceT)
import qualified Data.Conduit.List as CL
import qualified Data.ByteString as BS
import Control.Monad.IO.Class (liftIO)
Expand Down
11 changes: 6 additions & 5 deletions yesod-bin/Keter.hs
Expand Up @@ -11,7 +11,6 @@ import System.Process
import Control.Monad
import System.Directory hiding (findFiles)
import Data.Maybe (mapMaybe)
import System.Directory (removeDirectoryRecursive)
import System.FilePath ((</>))
import qualified Codec.Archive.Tar as Tar
import Control.Exception
Expand Down Expand Up @@ -73,10 +72,12 @@ keter cabal noBuild noCopyTo = do
collapse' (x:xs) = x : collapse' xs
collapse' [] = []

unless noBuild $ do
run cabal ["clean"]
run cabal ["configure"]
run cabal ["build"]
unless noBuild $ if elem "stack.yaml" files
then do run "stack" ["clean"]
createDirectoryIfMissing True "./dist/bin"
run "stack"
(words "--local-bin-path ./dist/bin build --copy-bins")
else mapM_ (\x -> run cabal [x]) ["clean", "configure", "build"]

_ <- try' $ removeDirectoryRecursive "static/tmp"

Expand Down
8 changes: 6 additions & 2 deletions yesod-bin/ghcwrapper.hs
Expand Up @@ -9,7 +9,7 @@ import Control.Monad (when)
import Data.Maybe (fromMaybe)

import Distribution.Compiler (CompilerFlavor (..))
import Distribution.Simple.Configure (configCompiler)
import qualified Distribution.Simple.Configure as D
import Distribution.Simple.Program (arProgram,
defaultProgramConfiguration,
ghcProgram, ldProgram,
Expand Down Expand Up @@ -44,7 +44,11 @@ outFile = "yesod-devel/ghcargs.txt"

runProgram :: Program -> [String] -> IO ExitCode
runProgram pgm args = do
(comp, pgmc) <- configCompiler (Just GHC) Nothing Nothing defaultProgramConfiguration silent
#if MIN_VERSION_Cabal(1,18,0)
(_, comp, pgmc) <- D.configCompilerEx (Just GHC) Nothing Nothing defaultProgramConfiguration silent
#else
(comp, pgmc) <- D.configCompiler (Just GHC) Nothing Nothing defaultProgramConfiguration silent
#endif
pgmc' <- configureAllKnownPrograms silent pgmc
case lookupProgram pgm pgmc' of
Nothing -> do
Expand Down