From 8af58455d677eef02d8b9f4f8056a2ee8e8fca0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Goli=C5=84ski?= Date: Mon, 17 Aug 2015 01:11:13 +0200 Subject: [PATCH 1/8] Add arch info to --version #799 --- src/main/Main.hs | 2 ++ stack.cabal | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/Main.hs b/src/main/Main.hs index f58125e8cd..f202a5b7bf 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -32,6 +32,7 @@ import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.IO as T import Data.Traversable +import Distribution.System (buildArch) import Development.GitRev (gitCommitCount) import Network.HTTP.Client import Options.Applicative.Args @@ -149,6 +150,7 @@ main = withInterpreterArgs stackProgName $ \args isInterpreter -> do -- Leave out number of commits for --depth=1 clone -- See https://github.com/commercialhaskell/stack/issues/792 , [" (" ++ $gitCommitCount ++ " commits)" | $gitCommitCount /= ("1"::String)] + , [" ", show buildArch] ] eGlobalRun <- try $ simpleOptions diff --git a/stack.cabal b/stack.cabal index e8606a289a..dd05c9292c 100644 --- a/stack.cabal +++ b/stack.cabal @@ -186,6 +186,7 @@ executable stack build-depends: base >=4.7 && < 5 , bytestring >= 0.10.4.0 + , Cabal , containers , exceptions , filepath From c50bd0dfe0a94e7cf6e34622c56ad4191a4403d2 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 18 Aug 2015 10:23:43 -0700 Subject: [PATCH 2/8] Fix warning --- src/Stack/Build/Execute.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 2ec6176b45..f8269f5821 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -250,7 +250,6 @@ getSetupExe setupHs tmpdir = do liftIO $ D.createDirectoryIfMissing True $ toFilePath setupDir menv <- getMinimalEnvOverride - wc <- getWhichCompiler let args = [ "-clear-package-db" , "-global-package-db" From 451484509b6dd2934371612629b526b8ef35bd3c Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 18 Aug 2015 10:24:39 -0700 Subject: [PATCH 3/8] Travis: use -Werror --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 01be2514ad..3722ef0ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,11 +47,11 @@ install: - cabal --version - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" - travis_retry cabal update - - cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 + - cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls --ghc-options="-O0 -Werror" script: - if [ -f configure.ac ]; then autoreconf -i; fi - - cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options=-O0 # -v2 provides useful information for debugging + - cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options="-O0 -Werror" # -v2 provides useful information for debugging - cabal build # this builds all libraries and executables (including tests/benchmarks) - cabal test - cabal check From 0ba2a55362f6f75386f01c26c1138df6f3292f7d Mon Sep 17 00:00:00 2001 From: Chris Done Date: Tue, 18 Aug 2015 22:12:17 +0200 Subject: [PATCH 4/8] Parse build opts with targets (fixes #818) --- src/Stack/Ghci.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 671049c1c2..4d531aa8e0 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -156,7 +156,7 @@ ghciSetup -> [Text] -> m (Map PackageName SimpleTarget, Maybe (Map PackageName SimpleTarget), [GhciPkgInfo]) ghciSetup mainIs stringTargets = do - (_,_,targets) <- parseTargetsFromBuildOpts AllowNoTargets defaultBuildOpts + (_,_,targets) <- parseTargetsFromBuildOpts AllowNoTargets defaultBuildOpts {boptsTargets=stringTargets} mainIsTargets <- case mainIs of Nothing -> return Nothing From 77316803b43d544e69e4c85eca4bf0aee83b5e38 Mon Sep 17 00:00:00 2001 From: Emanuel Borsboom Date: Tue, 18 Aug 2015 13:39:45 -0700 Subject: [PATCH 5/8] Add '--docker-env' argument --- ChangeLog.md | 4 ++++ src/Stack/Docker.hs | 2 ++ src/Stack/Options.hs | 7 ++++++- src/Stack/Types/Docker.hs | 11 +++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 833e617410..80d189815d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,7 @@ +## Unreleased changes + +* Added the `--docker-env` argument, to set environment variables in Docker container. + ## 0.1.3.1 Major changes: diff --git a/src/Stack/Docker.hs b/src/Stack/Docker.hs index d1379c004c..18b6bf17a1 100644 --- a/src/Stack/Docker.hs +++ b/src/Stack/Docker.hs @@ -247,6 +247,7 @@ runContainerAndExit modConfig ,concatMap (\(k,v) -> ["-e", k ++ "=" ++ v]) envVars ,concatMap sandboxSubdirArg sandboxSubdirs ,concatMap mountArg (dockerMount docker) + ,concatMap (\nv -> ["-e", nv]) (dockerEnv docker) ,case dockerContainerName docker of Just name -> ["--name=" ++ name] Nothing -> [] @@ -677,6 +678,7 @@ dockerOptsFromMonoid mproject stackRoot DockerOptsMonoid{..} = DockerOpts ,dockerContainerName = emptyToNothing dockerMonoidContainerName ,dockerRunArgs = dockerMonoidRunArgs ,dockerMount = dockerMonoidMount + ,dockerEnv = dockerMonoidEnv ,dockerDatabasePath = case dockerMonoidDatabasePath of Nothing -> stackRoot $(mkRelFile "docker.db") diff --git a/src/Stack/Options.hs b/src/Stack/Options.hs index f40021f65b..da88577695 100644 --- a/src/Stack/Options.hs +++ b/src/Stack/Options.hs @@ -319,7 +319,12 @@ dockerOptsParser showOptions = hide <> metavar "(PATH | HOST-PATH:CONTAINER-PATH)" <> help ("Mount volumes from host in container " ++ - "(may specify mutliple times)"))) + "(may specify multiple times)"))) + <*> many (option str (long (dockerOptName dockerEnvArgName) <> + hide <> + metavar "NAME=VALUE" <> + help ("Set environment variable in container " ++ + "(may specify multiple times)"))) <*> maybeStrOption (long (dockerOptName dockerDatabasePathArgName) <> hide <> metavar "PATH" <> diff --git a/src/Stack/Types/Docker.hs b/src/Stack/Types/Docker.hs index a32e80856b..ed1b3302f7 100644 --- a/src/Stack/Types/Docker.hs +++ b/src/Stack/Types/Docker.hs @@ -36,6 +36,8 @@ data DockerOpts = DockerOpts -- ^ Arguments to pass directly to @docker run@. ,dockerMount :: ![Mount] -- ^ Volumes to mount in the container. + ,dockerEnv :: ![String] + -- ^ Environment variables to set in the container. ,dockerDatabasePath :: !(Path Abs File) -- ^ Location of image usage database. } @@ -70,6 +72,8 @@ data DockerOptsMonoid = DockerOptsMonoid -- ^ Arguments to pass directly to @docker run@ ,dockerMonoidMount :: ![Mount] -- ^ Volumes to mount in the container + ,dockerMonoidEnv :: ![String] + -- ^ Environment variables to set in the container ,dockerMonoidDatabasePath :: !(Maybe String) -- ^ Location of image usage database. } @@ -92,6 +96,7 @@ instance FromJSON (DockerOptsMonoid, [JSONWarning]) where dockerMonoidContainerName <- o ..:? dockerContainerNameArgName dockerMonoidRunArgs <- o ..:? dockerRunArgsArgName ..!= [] dockerMonoidMount <- o ..:? dockerMountArgName ..!= [] + dockerMonoidEnv <- o ..:? dockerEnvArgName ..!= [] dockerMonoidDatabasePath <- o ..:? dockerDatabasePathArgName return DockerOptsMonoid{..}) @@ -110,6 +115,7 @@ instance Monoid DockerOptsMonoid where ,dockerMonoidContainerName = Nothing ,dockerMonoidRunArgs = [] ,dockerMonoidMount = [] + ,dockerMonoidEnv = [] ,dockerMonoidDatabasePath = Nothing } mappend l r = DockerOptsMonoid @@ -125,6 +131,7 @@ instance Monoid DockerOptsMonoid where ,dockerMonoidContainerName = dockerMonoidContainerName l <|> dockerMonoidContainerName r ,dockerMonoidRunArgs = dockerMonoidRunArgs r <> dockerMonoidRunArgs l ,dockerMonoidMount = dockerMonoidMount r <> dockerMonoidMount l + ,dockerMonoidEnv = dockerMonoidEnv r <> dockerMonoidEnv l ,dockerMonoidDatabasePath = dockerMonoidDatabasePath l <|> dockerMonoidDatabasePath r } @@ -195,6 +202,10 @@ dockerRunArgsArgName = "run-args" dockerMountArgName :: Text dockerMountArgName = "mount" +-- | Docker environment variable argument name. +dockerEnvArgName :: Text +dockerEnvArgName = "env" + -- | Docker container name argument name. dockerContainerNameArgName :: Text dockerContainerNameArgName = "container-name" From 7d3bc2d47a99b9e852e62981613b00f9e2154275 Mon Sep 17 00:00:00 2001 From: Chris Done Date: Tue, 18 Aug 2015 23:11:38 +0200 Subject: [PATCH 6/8] Don't call build if no targets (#817) Fixes regression caused by adding the build line. --- src/Stack/Ghci.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 4d531aa8e0..0c159b5b30 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -156,7 +156,12 @@ ghciSetup -> [Text] -> m (Map PackageName SimpleTarget, Maybe (Map PackageName SimpleTarget), [GhciPkgInfo]) ghciSetup mainIs stringTargets = do - (_,_,targets) <- parseTargetsFromBuildOpts AllowNoTargets defaultBuildOpts {boptsTargets=stringTargets} + (_,_,targets) <- + parseTargetsFromBuildOpts + AllowNoTargets + defaultBuildOpts + { boptsTargets = stringTargets + } mainIsTargets <- case mainIs of Nothing -> return Nothing @@ -187,7 +192,7 @@ ghciSetup mainIs stringTargets = do forM locals $ \(name,(cabalfp,components)) -> makeGhciPkgInfo sourceMap (map fst locals) name cabalfp components - build (const (return ())) Nothing bopts + unless (null realTargets) (build (const (return ())) Nothing bopts) return (realTargets, mainIsTargets, infos) where makeBuildOpts targets = From 250186216e6f97d2955003418b5342132b46a45e Mon Sep 17 00:00:00 2001 From: Chris Done Date: Tue, 18 Aug 2015 23:34:14 +0200 Subject: [PATCH 7/8] "null" fix for GHC 7.8 --- src/Stack/Ghci.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 0c159b5b30..3705dc6b7c 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -192,7 +192,7 @@ ghciSetup mainIs stringTargets = do forM locals $ \(name,(cabalfp,components)) -> makeGhciPkgInfo sourceMap (map fst locals) name cabalfp components - unless (null realTargets) (build (const (return ())) Nothing bopts) + unless (M.null realTargets) (build (const (return ())) Nothing bopts) return (realTargets, mainIsTargets, infos) where makeBuildOpts targets = From b763b0efaa10cfafff51c0e01bc5157b6f063368 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 19 Aug 2015 14:11:27 +0300 Subject: [PATCH 8/8] Properly set flags for implicit extra-deps #807 --- src/Stack/Build/Source.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Stack/Build/Source.hs b/src/Stack/Build/Source.hs index 6c43711b29..d8b1cf10a1 100644 --- a/src/Stack/Build/Source.hs +++ b/src/Stack/Build/Source.hs @@ -119,7 +119,22 @@ loadSourceMap needTargets bopts = do -- Overwrite any flag settings with those from the config file extraDeps3 = Map.mapWithKey - (\n (v, f) -> PSUpstream v Local $ fromMaybe f $ Map.lookup n $ bcFlags bconfig) + (\n (v, f) -> PSUpstream v Local $ + case ( Map.lookup (Just n) $ boptsFlags bopts + , Map.lookup Nothing $ boptsFlags bopts + , Map.lookup n $ bcFlags bconfig + ) of + -- Didn't have any flag overrides, fall back to the flags + -- defined in the snapshot. + (Nothing, Nothing, Nothing) -> f + -- Either command line flag for this package, general + -- command line flag, or flag in stack.yaml is defined. + -- Take all of those and ignore the snapshot flags. + (x, y, z) -> Map.unions + [ fromMaybe Map.empty x + , fromMaybe Map.empty y + , fromMaybe Map.empty z + ]) extraDeps2 let sourceMap = Map.unions