Commit eda30d31 authored by John Ericson's avatar John Ericson Committed by GitHub
Browse files

Merge pull request #4262 from Ericson2314/needed-exes-only

Fix #4217
parents 824d0bae 0ed1909d
......@@ -54,7 +54,7 @@ module Distribution.Client.ProjectPlanning (
import Prelude ()
import Distribution.Client.Compat.Prelude
import Distribution.Client.ProjectPlanning.Types
import Distribution.Client.ProjectPlanning.Types as Ty
import Distribution.Client.PackageHash
import Distribution.Client.RebuildMonad
import Distribution.Client.ProjectConfig
......@@ -95,12 +95,14 @@ import Distribution.ModuleName
import Distribution.Package hiding
(InstalledPackageId, installedPackageId)
import Distribution.Types.Dependency
import Distribution.Types.ExeDependency
import Distribution.Types.PkgconfigDependency
import Distribution.Types.UnqualComponentName
import Distribution.System
import qualified Distribution.PackageDescription as Cabal
import qualified Distribution.PackageDescription as PD
import qualified Distribution.PackageDescription.Configuration as PD
import Distribution.Simple.BuildToolDepends
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
import Distribution.Simple.Compiler hiding (Flag)
import qualified Distribution.Simple.GHC as GHC --TODO: [code cleanup] eliminate
......@@ -1011,7 +1013,7 @@ planPackages comp platform solver SolverSettings{..}
-- former we just apply all these flags to all local targets which
-- is silly. We should check if the flags are appropriate.
[ LabeledPackageConstraint
(PackageConstraint (scopeToplevel pkgname)
(PackageConstraint (scopeToplevel pkgname)
(PackagePropertyFlags flags))
ConstraintSourceConfigFlagOrTarget
| let flags = solverSettingFlagAssignment
......@@ -1270,12 +1272,14 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
compLibDependencies =
-- concatMap (elaborateLibSolverId mapDep) external_lib_dep_sids
ordNub (map (\ci -> ConfiguredId (ci_pkgid ci) (ci_id ci)) (cc_includes cc))
filterExeMapDepApp = filterExeMapDep mapDep pd [Cabal.componentBuildInfo comp]
compExeDependencies =
map confInstId
(concatMap (elaborateExeSolverId mapDep) external_exe_dep_sids) ++
(concatMap (elaborateExeSolverId filterExeMapDepApp) external_exe_dep_sids) ++
cc_internal_build_tools cc
compExeDependencyPaths =
concatMap (elaborateExePath mapDep) external_exe_dep_sids ++
concatMap (elaborateExePath filterExeMapDepApp) external_exe_dep_sids ++
[ path
| cid' <- cc_internal_build_tools cc
, Just path <- [Map.lookup cid' exe_map]]
......@@ -1347,6 +1351,36 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
(Map.fromList [ (req, OpenModuleVar req)
| req <- Set.toList (modShapeRequires shape)])
filterExeMapDep :: (SolverId -> [ElaboratedPlanPackage])
-> PD.PackageDescription -> [PD.BuildInfo]
-> SolverId -> [ElaboratedPlanPackage]
filterExeMapDep mapDep pd bis = filter go . mapDep
where
toolDeps = getAllToolDependencies pd =<< bis
exeKV :: [(PackageName, Set UnqualComponentName)]
exeKV = map go' toolDeps where
go' (ExeDependency p n _) = (p, Set.singleton n)
-- Nothing means wildcard, the complete subset
exeMap :: Map PackageName (Set UnqualComponentName)
exeMap = Map.fromListWith mappend exeKV
go (InstallPlan.Installed _) = error "unexpected state"
go (InstallPlan.PreExisting _) = True
go (InstallPlan.Configured (ElaboratedConfiguredPackage {
elabPkgSourceId = PackageIdentifier { pkgName, .. },
elabPkgOrComp,
..
})) = case elabPkgOrComp of
ElabPackage _ -> True
ElabComponent comp' ->
case Ty.compSolverName comp' of
CD.ComponentExe n
| Just set <- Map.lookup pkgName exeMap
-> Set.member n set
_ -> error "unexpected state"
elaborateLibSolverId' :: (SolverId -> [ElaboratedPlanPackage])
-> SolverId -> [ElaboratedPlanPackage]
elaborateLibSolverId' mapDep = filter is_lib . mapDep
......@@ -1458,16 +1492,18 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
= error $ "elaborateInstallPlan: non-inplace package "
++ " is missing a source hash: " ++ display pkgid
buildInfos = PD.allBuildInfo elabPkgDescription
filterExeMapDepApp = filterExeMapDep mapDep elabPkgDescription buildInfos
pkgLibDependencies = deps
pkgExeDependencies = fmap (concatMap (elaborateExeSolverId mapDep)) exe_deps0
pkgExeDependencyPaths = fmap (concatMap (elaborateExePath mapDep)) exe_deps0
pkgExeDependencies = fmap (concatMap (elaborateExeSolverId filterExeMapDepApp)) exe_deps0
pkgExeDependencyPaths = fmap (concatMap (elaborateExePath filterExeMapDepApp)) exe_deps0
pkgPkgConfigDependencies =
ordNub
$ [ (pn, fromMaybe (error $ "pkgPkgConfigDependencies: impossible! "
++ display pn ++ " from " ++ display pkgid)
(pkgConfigDbPkgVersion pkgConfigDB pn))
| PkgconfigDependency pn _ <- concatMap PD.pkgconfigDepends
(PD.allBuildInfo elabPkgDescription)
| PkgconfigDependency pn _ <- concatMap PD.pkgconfigDepends buildInfos
]
-- Filled in later
......@@ -2985,4 +3021,3 @@ improveInstallPlanWithInstalledPackages installedPkgIdSet =
--TODO: decide what to do if we encounter broken installed packages,
-- since overwriting is never safe.
......@@ -85,12 +85,6 @@ Extra-Source-Files:
tests/IntegrationTests/new-build/T4017/cabal.project
tests/IntegrationTests/new-build/T4017/p/p.cabal
tests/IntegrationTests/new-build/T4017/q/q.cabal
tests/IntegrationTests/new-build/build_tool_depends.sh
tests/IntegrationTests/new-build/build_tool_depends/cabal.project
tests/IntegrationTests/new-build/build_tool_depends/client/Hello.hs
tests/IntegrationTests/new-build/build_tool_depends/client/client.cabal
tests/IntegrationTests/new-build/build_tool_depends/pre-proc/MyCustomPreprocessor.hs
tests/IntegrationTests/new-build/build_tool_depends/pre-proc/pre-proc.cabal
tests/IntegrationTests/new-build/executable/Main.hs
tests/IntegrationTests/new-build/executable/Setup.hs
tests/IntegrationTests/new-build/executable/Test.hs
......
. ./common.sh
cd build_tool_depends
cabal new-build client
packages: client
optional-packages: pre-proc
......@@ -10,3 +10,8 @@ executable zero-to-one
main-is: MyCustomPreprocessor.hs
build-depends: base, directory
default-language: Haskell2010
executable bad-do-not-build-me
main-is: MyMissingPreprocessor.hs
build-depends: base, directory
default-language: Haskell2010
import Test.Cabal.Prelude
-- Test unneed version bound on internal build-tools deps
main = cabalTest $ do
cabal "new-build" ["client"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment