From 21a6d82fba37bf791492c06bc3feff1a00d6ae1e Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Sat, 7 Oct 2023 22:56:32 +0100 Subject: [PATCH] Fix #6278 No need to test for GHC >= 8.0 --- src/Stack/BuildPlan.hs | 2 +- src/Stack/Package.hs | 44 +++++++----------------------------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/Stack/BuildPlan.hs b/src/Stack/BuildPlan.hs index a4a8af956d..ad8f949ad2 100644 --- a/src/Stack/BuildPlan.hs +++ b/src/Stack/BuildPlan.hs @@ -166,7 +166,7 @@ gpdPackageDeps :: -> Map FlagName Bool -> Map PackageName VersionRange gpdPackageDeps gpd ac platform flags = - Map.filterWithKey (const . not . isLocalLibrary) (packageDependencies pkgConfig pkgDesc) + Map.filterWithKey (const . not . isLocalLibrary) (packageDependencies pkgDesc) where isLocalLibrary name' = name' == name || name' `Set.member` subs diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 873b0e2348..4bc50888b5 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -65,7 +65,7 @@ import Stack.ComponentFile ) import Stack.Types.BuildConfig ( HasBuildConfig (..), getProjectWorkDir ) -import Stack.Types.Compiler ( ActualCompiler (..), getGhcVersion ) +import Stack.Types.Compiler ( ActualCompiler (..) ) import Stack.Types.CompilerPaths ( cabalVersionL ) import Stack.Types.Config ( Config (..), HasConfig (..) ) import Stack.Types.EnvConfig ( HasEnvConfig ) @@ -209,7 +209,7 @@ packageFromPackageDescription packageConfig pkgFlags (PackageDescriptionPair pkg (unknownTools, knownTools) = packageDescTools pkg deps = M.filterWithKey (const . not . isMe) (M.unionsWith (<>) - [ asLibrary <$> packageDependencies packageConfig pkg + [ asLibrary <$> packageDependencies pkg -- We include all custom-setup deps - if present - in the package deps -- themselves. Stack always works with the invariant that there will be a -- single installed package relating to a package name, and this applies at @@ -461,44 +461,14 @@ makeObjectFilePathFromC cabalDir namedComponent distDir cFilePath = do pure (componentOutputDir namedComponent distDir relOFilePath) -- | Get all dependencies of the package (buildable targets only). --- --- Note that for Cabal versions 1.22 and earlier, there is a bug where Cabal --- requires dependencies for non-buildable components to be present. We're going --- to use GHC version as a proxy for Cabal library version in this case for --- simplicity, so we'll check for GHC being 7.10 or earlier. This obviously --- makes our function a lot more fun to write... packageDependencies :: - PackageConfig - -> PackageDescription + PackageDescription -> Map PackageName VersionRange -packageDependencies pkgConfig pkg' = +packageDependencies pkg = M.fromListWith intersectVersionRanges $ - map (depPkgName &&& depVerRange) $ - concatMap targetBuildDepends (allBuildInfo' pkg) ++ - maybe [] setupDepends (setupBuildInfo pkg) - where - pkg - | getGhcVersion (packageConfigCompilerVersion pkgConfig) >= mkVersion [8, 0] = pkg' - -- Set all components to buildable. Only need to worry library, exe, test, - -- and bench, since others didn't exist in older Cabal versions - | otherwise = pkg' - { library = - (\c -> c { libBuildInfo = go (libBuildInfo c) }) <$> library pkg' - , executables = - (\c -> c { buildInfo = go (buildInfo c) }) <$> executables pkg' - , testSuites = - if packageConfigEnableTests pkgConfig - then (\c -> c { testBuildInfo = go (testBuildInfo c) }) <$> - testSuites pkg' - else testSuites pkg' - , benchmarks = - if packageConfigEnableBenchmarks pkgConfig - then (\c -> c { benchmarkBuildInfo = go (benchmarkBuildInfo c) }) <$> - benchmarks pkg' - else benchmarks pkg' - } - - go bi = bi { buildable = True } + map (depPkgName &&& depVerRange) $ + concatMap targetBuildDepends (allBuildInfo' pkg) + <> maybe [] setupDepends (setupBuildInfo pkg) -- | Get all dependencies of the package (buildable targets only). --