@@ -30,7 +30,6 @@ import qualified Data.Set as Set
30
30
import qualified Data.Text as T
31
31
import Data.Text.Encoding (decodeUtf8With )
32
32
import Data.Text.Encoding.Error (lenientDecode )
33
- import qualified Distribution.Package as Cabal
34
33
import qualified Distribution.Text as Cabal
35
34
import qualified Distribution.Version as Cabal
36
35
import Generics.Deriving.Monoid (memptydefault , mappenddefault )
@@ -129,7 +128,7 @@ data Ctx = Ctx
129
128
, baseConfigOpts :: ! BaseConfigOpts
130
129
, loadPackage :: ! (PackageLocationIndex FilePath -> Map FlagName Bool -> [Text ] -> IO Package )
131
130
, combinedMap :: ! CombinedMap
132
- , toolToPackages :: ! (Cabal. Dependency -> Map PackageName VersionRange )
131
+ , toolToPackages :: ! (ExeName -> Map PackageName VersionRange )
133
132
, ctxEnvConfig :: ! EnvConfig
134
133
, callStack :: ! [PackageName ]
135
134
, extraToBuild :: ! (Set PackageName )
@@ -224,18 +223,18 @@ constructPlan ls0 baseConfigOpts0 locals extraToBuild0 localDumpPkgs loadPackage
224
223
, baseConfigOpts = baseConfigOpts0
225
224
, loadPackage = loadPackage0
226
225
, combinedMap = combineMap sourceMap installedMap
227
- , toolToPackages = \ ( Cabal. Dependency name _) ->
226
+ , toolToPackages = \ name ->
228
227
maybe Map. empty (Map. fromSet (const Cabal. anyVersion)) $
229
- Map. lookup ( T. pack . packageNameString . fromCabalPackageName $ name) ( toolMap lp)
228
+ Map. lookup name toolMap
230
229
, ctxEnvConfig = econfig
231
230
, callStack = []
232
231
, extraToBuild = extraToBuild0
233
232
, getVersions = getVersions0
234
233
, wanted = wantedLocalPackages locals <> extraToBuild0
235
234
, localNames = Set. fromList $ map (packageName . lpPackage) locals
236
235
}
237
-
238
- toolMap = getToolMap ls0
236
+ where
237
+ toolMap = getToolMap ls0 lp
239
238
240
239
-- | State to be maintained during the calculation of local packages
241
240
-- to unregister.
@@ -795,51 +794,36 @@ packageDepsWithTools p = do
795
794
ctx <- ask
796
795
-- TODO: it would be cool to defer these warnings until there's an
797
796
-- actual issue building the package.
798
- let toEither ( Cabal. Dependency ( Cabal. unPackageName -> name) _) mp =
797
+ let toEither name mp =
799
798
case Map. toList mp of
800
- [] -> Left (NoToolFound name (packageName p))
801
799
[_] -> Right mp
802
- xs -> Left (AmbiguousToolsFound name (packageName p) (map fst xs))
800
+ xs -> Left (ToolWarning name (packageName p) (map fst xs))
803
801
(warnings0, toolDeps) =
804
802
partitionEithers $
805
- map (\ dep -> toEither dep (toolToPackages ctx dep)) (packageTools p)
803
+ map (\ dep -> toEither dep (toolToPackages ctx dep)) (Map. keys ( packageTools p) )
806
804
-- Check whether the tool is on the PATH before warning about it.
807
- warnings <- fmap catMaybes $ forM warnings0 $ \ warning -> do
808
- let toolName = case warning of
809
- NoToolFound tool _ -> tool
810
- AmbiguousToolsFound tool _ _ -> tool
805
+ warnings <- fmap catMaybes $ forM warnings0 $ \ warning@ (ToolWarning (ExeName toolName) _ _) -> do
811
806
config <- view configL
812
807
menv <- liftIO $ configEnvOverride config minimalEnvSettings { esIncludeLocals = True }
813
- mfound <- findExecutable menv toolName
808
+ mfound <- findExecutable menv $ T. unpack toolName
814
809
case mfound of
815
810
Nothing -> return (Just warning)
816
811
Just _ -> return Nothing
817
812
tell mempty { wWarnings = (map toolWarningText warnings ++ ) }
818
- when (any isNoToolFound warnings) $ do
819
- let msg = T. unlines
820
- [ " Missing build-tools may be caused by dependencies of the build-tool being overridden by extra-deps."
821
- , " This should be fixed soon - see this issue https://github.com/commercialhaskell/stack/issues/595"
822
- ]
823
- tell mempty { wWarnings = (msg: ) }
824
813
return $ Map. unionsWith intersectVersionRanges
825
814
$ packageDeps p
826
815
: toolDeps
827
816
828
- data ToolWarning
829
- = NoToolFound String PackageName
830
- | AmbiguousToolsFound String PackageName [PackageName ]
831
-
832
- isNoToolFound :: ToolWarning -> Bool
833
- isNoToolFound NoToolFound {} = True
834
- isNoToolFound _ = False
817
+ data ToolWarning = ToolWarning ExeName PackageName [PackageName ]
818
+ deriving Show
835
819
836
820
toolWarningText :: ToolWarning -> Text
837
- toolWarningText (NoToolFound toolName pkgName) =
821
+ toolWarningText (ToolWarning ( ExeName toolName) pkgName [] ) =
838
822
" No packages found in snapshot which provide a " <>
839
823
T. pack (show toolName) <>
840
824
" executable, which is a build-tool dependency of " <>
841
825
T. pack (show (packageNameString pkgName))
842
- toolWarningText (AmbiguousToolsFound toolName pkgName options) =
826
+ toolWarningText (ToolWarning ( ExeName toolName) pkgName options) =
843
827
" Multiple packages found in snapshot which provide a " <>
844
828
T. pack (show toolName) <>
845
829
" exeuctable, which is a build-tool dependency of " <>
0 commit comments