@@ -45,11 +45,13 @@ import Distribution.Simple.BuildPaths (autogenPathsModuleName)
45
45
import Distribution.Simple.CCompiler
46
46
import Distribution.Types.ComponentRequestedSpec
47
47
import Distribution.Types.Dependency
48
+ import Distribution.Types.ExeDependency
48
49
import Distribution.Types.UnqualComponentName
49
50
import Distribution.Simple.Utils hiding (findPackageDesc , notice )
50
51
import Distribution.Version
51
52
import Distribution.Package
52
53
import Distribution.Text
54
+ import Distribution.FooBar
53
55
import Language.Haskell.Extension
54
56
55
57
import Control.Monad (mapM )
@@ -526,13 +528,42 @@ checkFields pkg =
526
528
++ " for example 'tested-with: GHC==6.10.4, GHC==6.12.3' and not "
527
529
++ " 'tested-with: GHC==6.10.4 && ==6.12.3'."
528
530
529
- , check (not (null buildDependsRangeOnInternalLibrary )) $
531
+ , check (not (null depInternalLibraryWithExtraVersion )) $
530
532
PackageBuildWarning $
531
- " The package has a version range for a dependency on an "
533
+ " The package has an extraneous version range for a dependency on an "
532
534
++ " internal library: "
533
- ++ commaSep (map display buildDependsRangeOnInternalLibrary)
534
- ++ " . This version range has no semantic meaning and can be "
535
- ++ " removed."
535
+ ++ commaSep (map display depInternalLibraryWithExtraVersion)
536
+ ++ " . This version range includes the current package but isn't needed "
537
+ ++ " as the current package's library will always be used."
538
+
539
+ , check (not (null depInternalLibraryWithImpossibleVersion)) $
540
+ PackageBuildImpossible $
541
+ " The package has an impossible version range for a dependency on an "
542
+ ++ " internal library: "
543
+ ++ commaSep (map display depInternalLibraryWithImpossibleVersion)
544
+ ++ " . This version range does not include the current package, and must "
545
+ ++ " be removed as the current package's library will always be used."
546
+
547
+ , check (not (null depInternalExecutableWithExtraVersion)) $
548
+ PackageBuildWarning $
549
+ " The package has an extraneous version range for a dependency on an "
550
+ ++ " internal executable: "
551
+ ++ commaSep (map display depInternalExecutableWithExtraVersion)
552
+ ++ " . This version range includes the current package but isn't needed "
553
+ ++ " as the current package's executable will always be used."
554
+
555
+ , check (not (null depInternalExecutableWithImpossibleVersion)) $
556
+ PackageBuildImpossible $
557
+ " The package has an impossible version range for a dependency on an "
558
+ ++ " internal executable: "
559
+ ++ commaSep (map display depInternalExecutableWithImpossibleVersion)
560
+ ++ " . This version range does not include the current package, and must "
561
+ ++ " be removed as the current package's executable will always be used."
562
+
563
+ , check (not (null depMissingInternalExecutable)) $
564
+ PackageBuildImpossible $
565
+ " The package depends on a missing internal executable: "
566
+ ++ commaSep (map display depInternalExecutableWithImpossibleVersion)
536
567
]
537
568
where
538
569
unknownCompilers = [ name | (OtherCompiler name, _) <- testedWith pkg ]
@@ -558,14 +589,55 @@ checkFields pkg =
558
589
internalLibraries =
559
590
map (maybe (packageName pkg) (unqualComponentNameToPackageName) . libName)
560
591
(allLibraries pkg)
561
- buildDependsRangeOnInternalLibrary =
592
+
593
+ internalExecutables = map exeName $ executables pkg
594
+
595
+ internalLibDeps =
562
596
[ dep
563
597
| bi <- allBuildInfo pkg
564
- , dep@ (Dependency name versionRange) <- targetBuildDepends bi
565
- , not (isAnyVersion versionRange)
598
+ , dep@ (Dependency name _) <- targetBuildDepends bi
566
599
, name `elem` internalLibraries
567
600
]
568
601
602
+ internalExeDeps =
603
+ [ dep
604
+ | bi <- allBuildInfo pkg
605
+ , dep <- getAllToolDependencies pkg bi
606
+ , isInternal pkg dep
607
+ ]
608
+
609
+ depInternalLibraryWithExtraVersion =
610
+ [ dep
611
+ | dep@ (Dependency _ versionRange) <- internalLibDeps
612
+ , not $ isAnyVersion versionRange
613
+ , packageVersion pkg `withinRange` versionRange
614
+ ]
615
+
616
+ depInternalLibraryWithImpossibleVersion =
617
+ [ dep
618
+ | dep@ (Dependency _ versionRange) <- internalLibDeps
619
+ , not $ packageVersion pkg `withinRange` versionRange
620
+ ]
621
+
622
+ depInternalExecutableWithExtraVersion =
623
+ [ dep
624
+ | dep@ (ExeDependency _ _ versionRange) <- internalExeDeps
625
+ , not $ isAnyVersion versionRange
626
+ , packageVersion pkg `withinRange` versionRange
627
+ ]
628
+
629
+ depInternalExecutableWithImpossibleVersion =
630
+ [ dep
631
+ | dep@ (ExeDependency _ _ versionRange) <- internalExeDeps
632
+ , not $ packageVersion pkg `withinRange` versionRange
633
+ ]
634
+
635
+ depMissingInternalExecutable =
636
+ [ dep
637
+ | dep@ (ExeDependency _ eName _) <- internalExeDeps
638
+ , not $ eName `elem` internalExecutables
639
+ ]
640
+
569
641
570
642
checkLicense :: PackageDescription -> [PackageCheck ]
571
643
checkLicense pkg =
0 commit comments