@@ -356,7 +356,7 @@ packageFromPackageDescription packageConfig pkgFlags (PackageDescriptionPair pkg
356356 pkgId = package pkg
357357 name = fromCabalPackageName (pkgName pkgId)
358358 deps = M. filterWithKey (const . not . isMe) (M. union
359- (packageDependencies pkg)
359+ (packageDependencies (packageConfigCompilerVersion packageConfig) pkg)
360360 -- We include all custom-setup deps - if present - in the
361361 -- package deps themselves. Stack always works with the
362362 -- invariant that there will be a single installed package
@@ -602,12 +602,36 @@ getBuildComponentDir Nothing = Nothing
602602getBuildComponentDir (Just name) = parseRelDir (name FilePath. </> (name ++ " -tmp" ))
603603
604604-- | Get all dependencies of the package (buildable targets only).
605- packageDependencies :: PackageDescription -> Map PackageName VersionRange
606- packageDependencies pkg =
605+ --
606+ -- Note that for Cabal versions 1.22 and earlier, there is a bug where
607+ -- Cabal requires dependencies for non-buildable components to be
608+ -- present. We're going to use GHC version as a proxy for Cabal
609+ -- library version in this case for simplicity, so we'll check for GHC
610+ -- being 7.10 or earlier. This obviously makes our function a lot more
611+ -- fun to write...
612+ packageDependencies
613+ :: CompilerVersion 'CVActual
614+ -> PackageDescription
615+ -> Map PackageName VersionRange
616+ packageDependencies ghcVersion pkg' =
607617 M. fromListWith intersectVersionRanges $
608618 map (depName &&& depRange) $
609619 concatMap targetBuildDepends (allBuildInfo' pkg) ++
610620 maybe [] setupDepends (setupBuildInfo pkg)
621+ where
622+ pkg
623+ | getGhcVersion ghcVersion >= $ (mkVersion " 8.0" ) = pkg'
624+ -- Set all components to buildable. Only need to worry about
625+ -- library, exe, test, and bench, since others didn't exist in
626+ -- older Cabal versions
627+ | otherwise = pkg'
628+ { library = (\ c -> c { libBuildInfo = go (libBuildInfo c) }) <$> library pkg'
629+ , executables = (\ c -> c { buildInfo = go (buildInfo c) }) <$> executables pkg'
630+ , testSuites = (\ c -> c { testBuildInfo = go (testBuildInfo c) }) <$> testSuites pkg'
631+ , benchmarks = (\ c -> c { benchmarkBuildInfo = go (benchmarkBuildInfo c) }) <$> benchmarks pkg'
632+ }
633+
634+ go bi = bi { buildable = True }
611635
612636-- | Get all dependencies of the package (buildable targets only).
613637--
0 commit comments