From f228b0f9b9efe6f9c3123146af68e55c3d9ffef2 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 13 Mar 2014 09:23:37 +0200 Subject: [PATCH] Fix problems with build tool test suite cycles --- Stackage/LoadDatabase.hs | 21 +++++++++++++-------- Stackage/Select.hs | 4 ++-- Stackage/Types.hs | 3 ++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Stackage/LoadDatabase.hs b/Stackage/LoadDatabase.hs index 95f30414..d86d2e1e 100644 --- a/Stackage/LoadDatabase.hs +++ b/Stackage/LoadDatabase.hs @@ -155,12 +155,13 @@ loadPackageDB settings coreMap core deps = do | otherwise = loop rest addPackage p v lbs pdb = do - let (deps', hasTests, buildTools', mgpd, execs, mgithub) = parseDeps p lbs + let (deps', hasTests, buildToolsExe', buildToolsOther', mgpd, execs, mgithub) = parseDeps p lbs return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo { piVersion = v , piDeps = deps' , piHasTests = hasTests - , piBuildTools = buildTools' + , piBuildToolsExe = buildToolsExe' + , piBuildToolsAll = buildToolsExe' `Set.union` buildToolsOther' , piGPD = mgpd , piExecs = execs , piGithubUser = mgithub @@ -176,25 +177,29 @@ loadPackageDB settings coreMap core deps = do else mconcat $ map (go gpd . snd) $ condTestSuites gpd , mconcat $ map (go gpd . snd) $ condBenchmarks gpd ], not $ null $ condTestSuites gpd - , Set.fromList $ map depName $ allBuildInfo gpd + , Set.fromList $ map depName $ libExeBuildInfo gpd + , Set.fromList $ map depName $ testBenchBuildInfo gpd , Just gpd , Set.fromList $ map (Executable . fst) $ condExecutables gpd , listToMaybe $ catMaybes $ parseGithubUserHP (homepage $ packageDescription gpd) : map parseGithubUserSR (sourceRepos $ packageDescription gpd) ) - _ -> (mempty, defaultHasTestSuites, Set.empty, Nothing, Set.empty, Nothing) + _ -> (mempty, defaultHasTestSuites, Set.empty, Set.empty, Nothing, Set.empty, Nothing) where - allBuildInfo gpd = concat + allBuildInfo gpd = libExeBuildInfo gpd ++ testBenchBuildInfo gpd + libExeBuildInfo gpd = concat [ maybe mempty (goBI libBuildInfo) $ condLibrary gpd , concat $ map (goBI buildInfo . snd) $ condExecutables gpd - , if skipTests p + ] + testBenchBuildInfo gpd = concat + [ if skipTests p then [] else concat $ map (goBI testBuildInfo . snd) $ condTestSuites gpd , concat $ map (goBI benchmarkBuildInfo . snd) $ condBenchmarks gpd ] - where - goBI f x = buildTools $ f $ condTreeData x + goBI f x = buildTools $ f $ condTreeData x + depName (Dependency (PackageName pn) _) = Executable pn go gpd tree = Map.filterWithKey (\k _ -> not $ ignoredDep k) diff --git a/Stackage/Select.hs b/Stackage/Select.hs index ad091704..a0b12223 100644 --- a/Stackage/Select.hs +++ b/Stackage/Select.hs @@ -77,7 +77,7 @@ iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } = $ mapMaybe (flip Map.lookup buildToolMap) $ Set.toList $ Set.unions - $ map piBuildTools + $ map piBuildToolsAll $ Map.elems $ Map.filterWithKey isSelected m where @@ -108,7 +108,7 @@ iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } = Just pi -> Set.fromList $ mapMaybe (flip Map.lookup buildToolMap) $ Set.toList - $ piBuildTools pi + $ piBuildToolsExe pi topSort :: (Show a, Ord a) => [(a, Set a)] -> Either String [a] topSort orig = diff --git a/Stackage/Types.hs b/Stackage/Types.hs index 73527cda..92e786f7 100644 --- a/Stackage/Types.hs +++ b/Stackage/Types.hs @@ -30,7 +30,8 @@ data PackageInfo = PackageInfo { piVersion :: Version , piDeps :: Map PackageName VersionRange , piHasTests :: Bool - , piBuildTools :: Set Executable + , piBuildToolsExe :: Set Executable -- ^ required just for building executable/lib + , piBuildToolsAll :: Set Executable -- ^ required for all stanzas , piGPD :: Maybe GenericPackageDescription , piExecs :: Set Executable , piGithubUser :: Maybe String