diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 48d7558fe5..42d46e7e52 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -42,6 +42,7 @@ import Stack.Types.Internal data GhciOpts = GhciOpts {ghciTargets :: ![Text] ,ghciArgs :: ![String] + ,ghciBuildGhcArgs :: ![Text] ,ghciGhcCommand :: !(Maybe FilePath) ,ghciNoLoadModules :: !Bool ,ghciAdditionalPackages :: ![String] @@ -65,7 +66,7 @@ ghci :: (HasConfig r, HasBuildConfig r, HasHttpManager r, MonadMask m, HasLogLevel r, HasTerminal r, HasEnvConfig r, MonadReader r m, MonadIO m, MonadThrow m, MonadLogger m, MonadCatch m, MonadBaseControl IO m) => GhciOpts -> m () ghci GhciOpts{..} = do - (targets,mainIsTargets,pkgs) <- ghciSetup ghciMainIs ghciTargets + (targets,mainIsTargets,pkgs) <- ghciSetup ghciMainIs ghciTargets ghciBuildGhcArgs bconfig <- asks getBuildConfig mainFile <- figureOutMainFile mainIsTargets targets pkgs wc <- getWhichCompiler @@ -154,13 +155,15 @@ ghciSetup :: (HasConfig r, HasHttpManager r, HasBuildConfig r, MonadMask m, HasTerminal r, HasLogLevel r, HasEnvConfig r, MonadReader r m, MonadIO m, MonadThrow m, MonadLogger m, MonadCatch m, MonadBaseControl IO m) => Maybe Text -> [Text] + -> [Text] -> m (Map PackageName SimpleTarget, Maybe (Map PackageName SimpleTarget), [GhciPkgInfo]) -ghciSetup mainIs stringTargets = do +ghciSetup mainIs stringTargets buildGhcOpts = do (_,_,targets) <- parseTargetsFromBuildOpts AllowNoTargets defaultBuildOpts { boptsTargets = stringTargets + , boptsGhcOptions = buildGhcOpts } mainIsTargets <- case mainIs of @@ -208,6 +211,7 @@ ghciSetup mainIs stringTargets = do { beoDisableRun = True } , boptsBuildSubset = BSOnlyDependencies + , boptsGhcOptions = buildGhcOpts } where base = defaultBuildOpts diff --git a/src/Stack/Ide.hs b/src/Stack/Ide.hs index 52b77f6ec5..7e6ea59b8a 100644 --- a/src/Stack/Ide.hs +++ b/src/Stack/Ide.hs @@ -49,9 +49,10 @@ ide :: (HasConfig r, HasBuildConfig r, HasTerminal r, HasLogLevel r, MonadMask m, HasEnvConfig r, MonadReader r m, MonadIO m, MonadThrow m, MonadLogger m, MonadCatch m, MonadBaseControl IO m, HasHttpManager r) => [Text] -- ^ Targets. -> [String] -- ^ GHC options. + -> [Text] -- ^ Build GHC options. -> m () -ide targets useropts = do - (_realTargets,_,pkgs) <- ghciSetup Nothing targets +ide targets useropts buildArgs = do + (_realTargets,_,pkgs) <- ghciSetup Nothing targets buildArgs pwd <- getWorkingDir (pkgopts,srcfiles) <- liftM mconcat $ diff --git a/src/Stack/Options.hs b/src/Stack/Options.hs index 6223f3d702..42cd306f3a 100644 --- a/src/Stack/Options.hs +++ b/src/Stack/Options.hs @@ -424,6 +424,14 @@ ghciOptsParser = GhciOpts <*> fmap concat (many (argsOption (long "ghc-options" <> metavar "OPTION" <> help "Additional options passed to GHCi"))) + <*> ((++) + <$> flag [] ["-Wall", "-Werror"] + ( long "pedantic" + <> help "Turn on -Wall and -Werror (note: option name may change in the future" + ) + <*> many (textOption (long "build-ghc-options" <> + metavar "OPTION" <> + help "Additional options passed to GHC for the build"))) <*> optional (strOption (long "with-ghc" <> metavar "GHC" <> diff --git a/src/main/Main.hs b/src/main/Main.hs index 6f63f76814..df469fd7de 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -300,14 +300,22 @@ main = withInterpreterArgs stackProgName $ \args isInterpreter -> do "start" "Start the ide-backend service" ideCmd - ((,) <$> many (textArgument - (metavar "TARGET" <> - help ("If none specified, use all " <> - "packages defined in current directory"))) - <*> argsOption (long "ghc-options" <> - metavar "OPTION" <> - help "Additional options passed to GHCi" <> - value [])) + ((,,) <$> many (textArgument + (metavar "TARGET" <> + help ("If none specified, use all " <> + "packages defined in current directory"))) + <*> argsOption (long "ghc-options" <> + metavar "OPTION" <> + help "Additional options passed to GHCi" <> + value []) + <*> ((++) + <$> flag [] ["-Wall", "-Werror"] + ( long "pedantic" + <> help "Turn on -Wall and -Werror (note: option name may change in the future" + ) + <*> many (textOption (long "ghc-options" <> + metavar "OPTION" <> + help "Additional options passed to GHC")))) addCommand "packages" "List all available local loadable packages" @@ -824,10 +832,10 @@ ghciCmd ghciOpts go@GlobalOpts{..} = ghci ghciOpts -- | Run ide-backend in the context of a project. -ideCmd :: ([Text], [String]) -> GlobalOpts -> IO () -ideCmd (targets,args) go@GlobalOpts{..} = +ideCmd :: ([Text], [String], [Text]) -> GlobalOpts -> IO () +ideCmd (targets,args,buildArgs) go@GlobalOpts{..} = withBuildConfig go $ -- No locking needed. - ide targets args + ide targets args buildArgs -- | Run ide-backend in the context of a project. packagesCmd :: () -> GlobalOpts -> IO ()