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

Pass -package-id to ghci (closes #867) #1082

Merged
merged 2 commits into from
Oct 9, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ Bug fixes:
* Fix quoting of output failed command line arguments
* Mark executable-only packages as installed when copied from cache [#1043](https://github.com/commercialhaskell/stack/pull/1043)
* Canonicalize temporary directory paths [#1047](https://github.com/commercialhaskell/stack/pull/1047)
* Pass -package-id to ghci [#867](https://github.com/commercialhaskell/stack/issues/867)

## 0.1.5.0

2 changes: 0 additions & 2 deletions src/Stack/Build/Installed.hs
Original file line number Diff line number Diff line change
@@ -47,8 +47,6 @@ data LoadHelper = LoadHelper
}
deriving Show

type InstalledMap = Map PackageName (Version, InstallLocation, Installed) -- TODO Version is now redundant and can be gleaned from Installed

-- | Options for 'getInstalled'.
data GetInstalledOpts = GetInstalledOpts
{ getInstalledProfiling :: !Bool
16 changes: 13 additions & 3 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ import Network.HTTP.Client.Conduit
import Path
import Prelude
import Stack.Build
import Stack.Build.Installed
import Stack.Build.Source
import Stack.Build.Target
import Stack.Constants
@@ -177,6 +178,14 @@ ghciSetup mainIs stringTargets = do
let bopts = makeBuildOpts targets
econfig <- asks getEnvConfig
(realTargets,_,_,_,sourceMap) <- loadSourceMap AllowNoTargets bopts
menv <- getMinimalEnvOverride
(installedMap, _, _) <- getInstalled
menv
GetInstalledOpts
{ getInstalledProfiling = False
, getInstalledHaddock = False
}
sourceMap
locals <-
liftM catMaybes $
forM (M.toList (envConfigPackages econfig)) $
@@ -192,7 +201,7 @@ ghciSetup mainIs stringTargets = do
infos <-
forM locals $
\(name,(cabalfp,components)) ->
makeGhciPkgInfo sourceMap (map fst locals) name cabalfp components
makeGhciPkgInfo sourceMap installedMap (map fst locals) name cabalfp components
unless (M.null realTargets) (build (const (return ())) Nothing bopts)
return (realTargets, mainIsTargets, infos)
where
@@ -231,12 +240,13 @@ ghciSetup mainIs stringTargets = do
makeGhciPkgInfo
:: (MonadReader r m, HasEnvConfig r, MonadLogger m, MonadIO m, MonadCatch m)
=> SourceMap
-> InstalledMap
-> [PackageName]
-> PackageName
-> Path Abs File
-> SimpleTarget
-> m GhciPkgInfo
makeGhciPkgInfo sourceMap locals name cabalfp components = do
makeGhciPkgInfo sourceMap installedMap locals name cabalfp components = do
econfig <- asks getEnvConfig
bconfig <- asks getBuildConfig
let config =
@@ -250,7 +260,7 @@ makeGhciPkgInfo sourceMap locals name cabalfp components = do
(warnings,pkg) <- readPackage config cabalfp
mapM_ (printCabalFileWarning cabalfp) warnings
(componentsModules,componentFiles,componentsOpts,generalOpts) <-
getPackageOpts (packageOpts pkg) sourceMap locals cabalfp
getPackageOpts (packageOpts pkg) sourceMap installedMap locals cabalfp
let filterWithinWantedComponents m =
M.elems
(M.filterWithKey
18 changes: 12 additions & 6 deletions src/Stack/Package.hs
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ import Path.Find
import Path.IO
import Prelude
import Safe (headDef, tailSafe)
import Stack.Build.Installed
import Stack.Constants
import Stack.Types
import qualified Stack.Types.PackageIdentifier
@@ -194,10 +195,10 @@ resolvePackage packageConfig gpkg =
[T.pack (exeName b) | b <- executables pkg
, buildable (buildInfo b)]
, packageOpts = GetPackageOpts $
\sourceMap locals cabalfp ->
\sourceMap installedMap locals cabalfp ->
do (componentsModules,componentFiles,_,_) <- getPackageFiles pkgFiles cabalfp
(componentsOpts,generalOpts) <-
generatePkgDescOpts sourceMap locals cabalfp pkg componentFiles
generatePkgDescOpts sourceMap installedMap locals cabalfp pkg componentFiles
return (componentsModules,componentFiles,componentsOpts,generalOpts)
, packageHasExposedModules = maybe
False
@@ -227,12 +228,13 @@ resolvePackage packageConfig gpkg =
generatePkgDescOpts
:: (HasEnvConfig env, HasPlatform env, MonadThrow m, MonadReader env m, MonadIO m)
=> SourceMap
-> InstalledMap
-> [PackageName]
-> Path Abs File
-> PackageDescription
-> Map NamedComponent (Set DotCabalPath)
-> m (Map NamedComponent [String],[String])
generatePkgDescOpts sourceMap locals cabalfp pkg componentPaths = do
generatePkgDescOpts sourceMap installedMap locals cabalfp pkg componentPaths = do
distDir <- distDirFromDir cabalDir
let cabalmacros = autogenDir distDir </> $(mkRelFile "cabal_macros.h")
exists <- fileExists cabalmacros
@@ -244,6 +246,7 @@ generatePkgDescOpts sourceMap locals cabalfp pkg componentPaths = do
( namedComponent
, generateBuildInfoOpts
sourceMap
installedMap
mcabalmacros
cabalDir
distDir
@@ -283,6 +286,7 @@ generatePkgDescOpts sourceMap locals cabalfp pkg componentPaths = do
-- | Generate GHC options for the target.
generateBuildInfoOpts
:: SourceMap
-> InstalledMap
-> Maybe (Path Abs File)
-> Path Abs Dir
-> Path Abs Dir
@@ -291,7 +295,7 @@ generateBuildInfoOpts
-> Set DotCabalPath
-> NamedComponent
-> [String]
generateBuildInfoOpts sourceMap mcabalmacros cabalDir distDir locals b dotCabalPaths componentName =
generateBuildInfoOpts sourceMap installedMap mcabalmacros cabalDir distDir locals b dotCabalPaths componentName =
nubOrd (concat [ghcOpts b, extOpts b, srcOpts, includeOpts, macros, deps, extra b, extraDirs, fworks b, cObjectFiles])
where
cObjectFiles =
@@ -301,8 +305,10 @@ generateBuildInfoOpts sourceMap mcabalmacros cabalDir distDir locals b dotCabalP
cfiles = mapMaybe dotCabalCFilePath (S.toList dotCabalPaths)
deps =
concat
[ ["-package=" <> display name <>
maybe "" -- This empty case applies to e.g. base.
[ case M.lookup (fromCabalPackageName name) installedMap of
Just (_, _, Stack.Types.Library _ident ipid) -> ["-package-id=" <> ghcPkgIdString ipid]
_ -> ["-package=" <> display name <>
maybe "" -- This empty case applies to e.g. base.
((("-" <>) . versionString) . sourceVersion)
(M.lookup (fromCabalPackageName name) sourceMap)]
| Dependency name _ <- targetBuildDepends b
3 changes: 0 additions & 3 deletions src/Stack/Types/Build.hs
Original file line number Diff line number Diff line change
@@ -718,9 +718,6 @@ modTime x =
, toRational
(utctDayTime x))

data Installed = Library PackageIdentifier GhcPkgId | Executable PackageIdentifier
deriving (Show, Eq, Ord)

-- | Configure options to be sent to Setup.hs configure
data ConfigureOpts = ConfigureOpts
{ coDirs :: ![String]
8 changes: 8 additions & 0 deletions src/Stack/Types/Package.hs
Original file line number Diff line number Diff line change
@@ -36,7 +36,9 @@ import Prelude
import Stack.Types.Compiler
import Stack.Types.Config
import Stack.Types.FlagName
import Stack.Types.GhcPkgId
import Stack.Types.PackageName
import Stack.Types.PackageIdentifier
import Stack.Types.Version

-- | All exceptions thrown by the library.
@@ -98,6 +100,7 @@ data Package =
newtype GetPackageOpts = GetPackageOpts
{ getPackageOpts :: forall env m. (MonadIO m,HasEnvConfig env, HasPlatform env, MonadThrow m, MonadReader env m, MonadLogger m, MonadCatch m)
=> SourceMap
-> InstalledMap
-> [PackageName]
-> Path Abs File
-> m (Map NamedComponent (Set ModuleName)
@@ -322,3 +325,8 @@ dotCabalGetPath dcp =
DotCabalMainPath fp -> fp
DotCabalFilePath fp -> fp
DotCabalCFilePath fp -> fp

type InstalledMap = Map PackageName (Version, InstallLocation, Installed) -- TODO Version is now redundant and can be gleaned from Installed

data Installed = Library PackageIdentifier GhcPkgId | Executable PackageIdentifier
deriving (Show, Eq, Ord)