Don't build stack dependencies by default

Adds a global option `--stack-build-deps` to enable old behavior
This commit is contained in:
Nikolay Yakimov 2016-08-24 18:09:29 +03:00
parent c97049836f
commit 637f73ec80
3 changed files with 10 additions and 3 deletions

View File

@ -208,7 +208,7 @@ withCabal action = do
-- "--flag PACKAGE:[-]FLAG Override flags set in stack.yaml -- "--flag PACKAGE:[-]FLAG Override flags set in stack.yaml
-- (applies to local packages and extra-deps)" -- (applies to local packages and extra-deps)"
stackReconfigure crdl (optPrograms opts) stackReconfigure (optStackBuildDeps opts) crdl (optPrograms opts)
_ -> _ ->
error $ "withCabal: unsupported project type: " ++ show proj error $ "withCabal: unsupported project type: " ++ show proj
@ -234,11 +234,12 @@ withCabal action = do
flagOpt = ["--flags", unwords $ map toFlag flgs] flagOpt = ["--flags", unwords $ map toFlag flgs]
liftIO $ void $ readProc (T.cabalProgram progs) ("configure":progOpts) "" liftIO $ void $ readProc (T.cabalProgram progs) ("configure":progOpts) ""
stackReconfigure crdl progs = do stackReconfigure deps crdl progs = do
withDirectory_ (cradleRootDir crdl) $ do withDirectory_ (cradleRootDir crdl) $ do
supported <- haveStackSupport supported <- haveStackSupport
if supported if supported
then do then do
when deps $
spawn [T.stackProgram progs, "build", "--only-dependencies", "."] spawn [T.stackProgram progs, "build", "--only-dependencies", "."]
spawn [T.stackProgram progs, "build", "--only-configure", "."] spawn [T.stackProgram progs, "build", "--only-configure", "."]
else else

View File

@ -146,6 +146,10 @@ globalArgSpec = Options
<=> value "UTF-8" <=> value "UTF-8"
<=> showDefault <=> showDefault
<=> help "I/O encoding" <=> help "I/O encoding"
<*> switch
$$ long "stack-build-deps"
<=> showDefault
<=> help "Build dependencies if needed when using stack"
where where
fileMappingSpec = fileMappingSpec =
getFileMapping . splitOn '=' <$> strOption getFileMapping . splitOn '=' <$> strOption

View File

@ -106,6 +106,7 @@ data Options = Options {
, optGhcUserOptions :: [GHCOption] , optGhcUserOptions :: [GHCOption]
, optFileMappings :: [(FilePath, Maybe FilePath)] , optFileMappings :: [(FilePath, Maybe FilePath)]
, optEncoding :: String , optEncoding :: String
, optStackBuildDeps :: Bool
} deriving (Show) } deriving (Show)
-- | A default 'Options'. -- | A default 'Options'.
@ -126,6 +127,7 @@ defaultOptions = Options {
, optGhcUserOptions = [] , optGhcUserOptions = []
, optFileMappings = [] , optFileMappings = []
, optEncoding = "UTF-8" , optEncoding = "UTF-8"
, optStackBuildDeps = False
} }
---------------------------------------------------------------- ----------------------------------------------------------------