Skip to content

Commit 7aa7e0e

Browse files
WIP/Search upwards for package directory
1 parent b7e365b commit 7aa7e0e

File tree

8 files changed

+206
-153
lines changed

8 files changed

+206
-153
lines changed

cabal-install/Distribution/Client/Exec.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ import Data.Foldable (forM_)
1919
import qualified Distribution.Simple.GHC as GHC
2020
import qualified Distribution.Simple.GHCJS as GHCJS
2121

22-
import Distribution.Client.Sandbox (getSandboxConfigFilePath)
2322
import Distribution.Client.Sandbox.PackageEnvironment (sandboxPackageDBPath)
24-
import Distribution.Client.Sandbox.Types (UseSandbox (..))
23+
import Distribution.Client.Sandbox.Types (UseSandbox (..), SandboxMetadata(..))
2524

2625
import Distribution.Simple.Compiler (Compiler, CompilerFlavor(..), compilerFlavor)
2726
import Distribution.Simple.Program (ghcProgram, ghcjsProgram, lookupProgram)
@@ -65,23 +64,23 @@ exec verbosity useSandbox comp platform programDb extraArgs =
6564

6665
[] -> die "Please specify an executable to run"
6766
where
68-
environmentOverrides =
67+
environmentOverrides =
6968
case useSandbox of
7069
NoSandbox -> return []
71-
(UseSandbox sandboxDir) ->
72-
sandboxEnvironment verbosity sandboxDir comp platform programDb
70+
(UseSandbox sandboxMetadata) ->
71+
sandboxEnvironment verbosity sandboxMetadata comp platform programDb
7372

7473

7574
-- | Return the package's sandbox environment.
7675
--
7776
-- The environment sets GHC_PACKAGE_PATH so that GHC will use the sandbox.
7877
sandboxEnvironment :: Verbosity
79-
-> FilePath
78+
-> SandboxMetadata
8079
-> Compiler
8180
-> Platform
8281
-> ProgramDb
8382
-> IO [(String, Maybe String)]
84-
sandboxEnvironment verbosity sandboxDir comp platform programDb =
83+
sandboxEnvironment verbosity sandboxMetadata comp platform programDb =
8584
case compilerFlavor comp of
8685
GHC -> env GHC.getGlobalPackageDB ghcProgram "GHC_PACKAGE_PATH"
8786
GHCJS -> env GHCJS.getGlobalPackageDB ghcjsProgram "GHCJS_PACKAGE_PATH"
@@ -90,7 +89,7 @@ sandboxEnvironment verbosity sandboxDir comp platform programDb =
9089
env getGlobalPackageDB hcProgram packagePathEnvVar = do
9190
let Just program = lookupProgram hcProgram programDb
9291
gDb <- getGlobalPackageDB verbosity program
93-
sandboxConfigFilePath <- getSandboxConfigFilePath mempty
92+
let sandboxConfigFilePath = smSandboxConfigFile sandboxMetadata
9493
let compilerPackagePath = hcPackagePath gDb
9594
-- Packages database must exist, otherwise things will start
9695
-- failing in mysterious ways.
@@ -104,6 +103,7 @@ sandboxEnvironment verbosity sandboxDir comp platform programDb =
104103
]
105104

106105
hcPackagePath gDb =
106+
let sandboxDir = smSandboxDirectory sandboxMetadata in
107107
let s = sandboxPackageDBPath sandboxDir comp platform
108108
in Just $ prependToSearchPath gDb s
109109

@@ -129,5 +129,6 @@ requireProgram' verbosity useSandbox programDb exe = do
129129
flip modifyProgramSearchPath programDb $ \searchPath ->
130130
case useSandbox of
131131
NoSandbox -> searchPath
132-
UseSandbox sandboxDir ->
132+
UseSandbox sandboxMetadata ->
133+
let sandboxDir = smSandboxDirectory sandboxMetadata in
133134
ProgramSearchPathDir (sandboxDir </> "bin") : searchPath

cabal-install/Distribution/Client/Install.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import Distribution.Client.Sandbox.Timestamp
8989
( withUpdateTimestamps )
9090
import Distribution.Client.Sandbox.Types
9191
( SandboxPackageInfo(..), UseSandbox(..), isUseSandbox
92-
, whenUsingSandbox )
92+
, whenUsingSandbox, SandboxMetadata(..) )
9393
import Distribution.Client.Tar (extractTarGzFile)
9494
import Distribution.Client.Types as Source
9595
import Distribution.Client.BuildReports.Types
@@ -997,7 +997,7 @@ updateSandboxTimestampsFile :: UseSandbox -> Maybe SandboxPackageInfo
997997
-> Compiler -> Platform
998998
-> InstallPlan
999999
-> IO ()
1000-
updateSandboxTimestampsFile (UseSandbox sandboxDir)
1000+
updateSandboxTimestampsFile (UseSandbox sandboxMetadata)
10011001
(Just (SandboxPackageInfo _ _ _ allAddSourceDeps))
10021002
comp platform installPlan =
10031003
withUpdateTimestamps sandboxDir (compilerId comp) platform $ \_ -> do
@@ -1009,6 +1009,8 @@ updateSandboxTimestampsFile (UseSandbox sandboxDir)
10091009
<- map packageSource allSrcPkgs]
10101010
allPathsCanonical <- mapM tryCanonicalizePath allPaths
10111011
return $! filter (`S.member` allAddSourceDeps) allPathsCanonical
1012+
where
1013+
sandboxDir = smSandboxDirectory sandboxMetadata
10121014

10131015
updateSandboxTimestampsFile _ _ _ _ _ = return ()
10141016

0 commit comments

Comments
 (0)