@@ -125,29 +125,38 @@ mainArgParser = MainArgs
125
125
<*> commonArgParser
126
126
127
127
-- Unpack and build a specific released version of Cabal and Cabal-syntax libraries
128
- buildCabalLibsProject :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO FilePath
128
+ buildCabalLibsProject :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO [ FilePath ]
129
129
buildCabalLibsProject projString verb mbGhc dir = do
130
130
let prog_db = userSpecifyPaths [(" ghc" , path) | Just path <- [mbGhc] ] defaultProgramDb
131
131
(cabal, _) <- requireProgram verb (simpleProgram " cabal" ) prog_db
132
132
(ghc, _) <- requireProgram verb ghcProgram prog_db
133
133
134
+ let storeRoot = dir </> " store"
134
135
let pv = fromMaybe (error " no ghc version" ) (programVersion ghc)
135
136
let final_package_db = dir </> " dist-newstyle" </> " packagedb" </> " ghc-" ++ prettyShow pv
136
137
createDirectoryIfMissing True dir
137
138
writeFile (dir </> " cabal.project-test" ) projString
138
139
139
140
runProgramInvocation verb
140
141
((programInvocation cabal
141
- [" --store-dir" , dir </> " store "
142
+ [" --store-dir" , storeRoot
142
143
, " --project-file=" ++ dir </> " cabal.project-test"
143
144
, " build"
144
145
, " -w" , programPath ghc
145
146
, " Cabal" , " Cabal-syntax" , " Cabal-hooks"
146
147
] ) { progInvokeCwd = Just dir })
147
- return final_package_db
148
148
149
+ -- Determine the path to the packagedb in the store for this ghc version
150
+ storesByGhc <- getDirectoryContents storeRoot
151
+ case filter (prettyShow pv `isInfixOf` ) storesByGhc of
152
+ [] -> return [final_package_db]
153
+ storeForGhc: _ -> do
154
+ let storePackageDB = (storeRoot </> storeForGhc </> " package.db" )
155
+ return [storePackageDB, final_package_db]
149
156
150
- buildCabalLibsSpecific :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO FilePath
157
+
158
+
159
+ buildCabalLibsSpecific :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO [FilePath ]
151
160
buildCabalLibsSpecific ver verb mbGhc builddir_rel = do
152
161
let prog_db = userSpecifyPaths [(" ghc" , path) | Just path <- [mbGhc] ] defaultProgramDb
153
162
(cabal, _) <- requireProgram verb (simpleProgram " cabal" ) prog_db
@@ -166,7 +175,7 @@ buildCabalLibsSpecific ver verb mbGhc builddir_rel = do
166
175
buildCabalLibsProject (" packages: Cabal-" ++ ver ++ " Cabal-syntax-" ++ ver ++ " Cabal-hooks-" ++ hooksVer) verb mbGhc dir
167
176
168
177
169
- buildCabalLibsIntree :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO FilePath
178
+ buildCabalLibsIntree :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO [ FilePath ]
170
179
buildCabalLibsIntree root verb mbGhc builddir_rel = do
171
180
dir <- canonicalizePath (builddir_rel </> " intree" )
172
181
buildCabalLibsProject (" packages: " ++ root </> " Cabal" ++ " " ++ root </> " Cabal-syntax" ++ " " ++ root </> " Cabal-hooks" ) verb mbGhc dir
@@ -182,26 +191,26 @@ main = do
182
191
args <- execParser $ info (mainArgParser <**> helper) mempty
183
192
let verbosity = if mainArgVerbose args then verbose else normal
184
193
185
- mpkg_db <-
194
+ pkg_dbs <-
186
195
-- Not path to cabal-install so we're not going to run cabal-install tests so we
187
196
-- can skip setting up a Cabal library to use with cabal-install.
188
197
case argCabalInstallPath (mainCommonArgs args) of
189
198
Nothing -> do
190
199
when (isJust $ mainArgCabalSpec args)
191
200
(putStrLn " Ignoring Cabal library specification as cabal-install tests are not running" )
192
- return Nothing
201
+ return []
193
202
-- Path to cabal-install is passed, so need to install the requested relevant version of Cabal
194
203
-- library.
195
204
Just {} ->
196
205
case mainArgCabalSpec args of
197
206
Nothing -> do
198
207
putStrLn " No Cabal library specified, using boot Cabal library with cabal-install tests"
199
- return Nothing
200
- Just BootCabalLib -> return Nothing
208
+ return []
209
+ Just BootCabalLib -> return []
201
210
Just (InTreeCabalLib root build_dir) ->
202
- Just <$> buildCabalLibsIntree root verbosity (argGhcPath (mainCommonArgs args)) build_dir
211
+ buildCabalLibsIntree root verbosity (argGhcPath (mainCommonArgs args)) build_dir
203
212
Just (SpecificCabalLib ver build_dir) ->
204
- Just <$> buildCabalLibsSpecific ver verbosity (argGhcPath (mainCommonArgs args)) build_dir
213
+ buildCabalLibsSpecific ver verbosity (argGhcPath (mainCommonArgs args)) build_dir
205
214
206
215
-- To run our test scripts, we need to be able to run Haskell code
207
216
-- linked against the Cabal library under test. The most efficient
@@ -228,7 +237,7 @@ main = do
228
237
-> IO result
229
238
runTest runner path
230
239
= runner Nothing [] path $
231
- [" --builddir" , dist_dir, path] ++ [" --extra-package-db=" ++ pkg_db | Just pkg_db <- [mpkg_db] ] ++ renderCommonArgs (mainCommonArgs args)
240
+ [" --builddir" , dist_dir, path] ++ [" --extra-package-db=" ++ pkg_db | pkg_db <- pkg_dbs ] ++ renderCommonArgs (mainCommonArgs args)
232
241
233
242
case mainArgTestPaths args of
234
243
[path] -> do
0 commit comments