Skip to content

Commit

Permalink
Merge pull request #4023 from ezyang/pr/T3978
Browse files Browse the repository at this point in the history
Do an early check for unbuildable deps, and give good error.
  • Loading branch information
BardurArantsson authored Oct 22, 2016
2 parents 211776b + 18e8227 commit 325d363
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ import Distribution.Text
import qualified Distribution.Compat.Graph as Graph
import Distribution.Compat.Graph(IsNode(..))

import Text.PrettyPrint (text, (<+>))
import Text.PrettyPrint hiding ((<>))
import qualified Data.Map as Map
import Data.Set (Set)
import qualified Data.Set as Set
Expand Down Expand Up @@ -1142,6 +1142,21 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
Map ComponentId FilePath),
ElaboratedConfiguredPackage)
buildComponent (cc_map, lc_map, exe_map) comp = do
-- Before we get too far, check if we depended on something
-- unbuildable. If we did, give a good error. (If we don't
-- check, the 'toConfiguredComponent' will assert fail, see #3978).
case unbuildable_external_lib_deps of
[] -> return ()
deps -> failProgress $
text "The package" <+> disp pkgid <+>
text "depends on unbuildable libraries:" <+>
hsep (punctuate comma (map (disp.solverSrcId) deps))
case unbuildable_external_exe_deps of
[] -> return ()
deps -> failProgress $
text "The package" <+> disp pkgid <+>
text "depends on unbuildable executables:" <+>
hsep (punctuate comma (map (disp.solverSrcId) deps))
infoProgress $ dispConfiguredComponent cc
let -- Use of invariant: DefUnitId indicates that if
-- there is no hash, it must have an empty
Expand Down Expand Up @@ -1270,6 +1285,11 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
external_cc_map = Map.fromList (map mkPkgNameMapping external_lib_dep_pkgs)
external_lc_map = Map.fromList (map mkShapeMapping external_lib_dep_pkgs)

unbuildable_external_lib_deps =
filter (null . elaborateLibSolverId mapDep) external_lib_dep_sids
unbuildable_external_exe_deps =
filter (null . elaborateExeSolverId mapDep) external_exe_dep_sids

mkPkgNameMapping :: ElaboratedPlanPackage
-> (PackageName, (ComponentId, PackageId))
mkPkgNameMapping dpkg =
Expand Down
5 changes: 5 additions & 0 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ Extra-Source-Files:
tests/IntegrationTests/new-build/T3460/sub-package-B/B.hs
tests/IntegrationTests/new-build/T3460/sub-package-B/Setup.hs
tests/IntegrationTests/new-build/T3460/sub-package-B/sub-package-B.cabal
tests/IntegrationTests/new-build/T3978.err
tests/IntegrationTests/new-build/T3978.sh
tests/IntegrationTests/new-build/T3978/cabal.project
tests/IntegrationTests/new-build/T3978/p/p.cabal
tests/IntegrationTests/new-build/T3978/q/q.cabal
tests/IntegrationTests/new-build/executable/Main.hs
tests/IntegrationTests/new-build/executable/Setup.hs
tests/IntegrationTests/new-build/executable/Test.hs
Expand Down
1 change: 1 addition & 0 deletions cabal-install/tests/IntegrationTests/new-build/T3978.err
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RE:^cabal(\.exe)?: The package q-1.0 depends on unbuildable libraries: p-1.0
3 changes: 3 additions & 0 deletions cabal-install/tests/IntegrationTests/new-build/T3978.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
. ./common.sh
cd T3978
! cabal new-build q
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages: p q
allow-older: p:base
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: p
version: 1.0
build-type: Simple
cabal-version: >= 1.10

library
buildable: False
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: q
version: 1.0
build-type: Simple
cabal-version: >= 1.10

library
build-depends: p

0 comments on commit 325d363

Please sign in to comment.