From f019cf67fe97309ac768449962f4618290167ca0 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 12 Aug 2016 09:54:15 +0530 Subject: [PATCH] Interpreter: Provide a way to hide implicit packages Always pass all the explicitly specified packages in the script to ghc command line. Also allow ghc options to be specified from the interpreter command. This will give user the flixibility to, for example, use '-hide-all-packages' ghc option. Like this: {- stack runghc --package base --package exceptions --package transformers --package containers --package getopt-generics --package filepath --package path --package path-io --package process --package unix-compat -- -hide-all-packages -} fixes #1208 --- src/main/Main.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/Main.hs b/src/main/Main.hs index 176fc4b3a8..02d210b0a7 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -542,7 +542,8 @@ interpreterHandler args f = do progName <- getProgName iargs <- getInterpreterArgs path let parseCmdLine = commandLineHandler progName True - let cmdArgs = stackArgs ++ iargs ++ "--" : path : fileArgs + separator = if "--" `elem` iargs then [] else ["--"] + cmdArgs = stackArgs ++ iargs ++ separator ++ path : fileArgs -- TODO show the command in verbose mode -- hPutStrLn stderr $ unwords $ -- ["Running", "[" ++ progName, unwords cmdArgs ++ "]"] @@ -742,7 +743,9 @@ execCmd ExecOpts {..} go@GlobalOpts{..} = (ExecGhc, args) -> execCompiler "" args -- NOTE: this won't currently work for GHCJS, because it doesn't have -- a runghcjs binary. It probably will someday, though. - (ExecRunGhc, args) -> execCompiler "" ("-e" : "Main.main" : args) + (ExecRunGhc, args) -> + let opts = concatMap (\x -> ["-package", x]) eoPackages + in execCompiler "" (opts ++ ("-e" : "Main.main" : args)) let targets = concatMap words eoPackages unless (null targets) $ Stack.Build.build (const $ return ()) lk defaultBuildOptsCLI