Add better handling for empty component assignments

This commit is contained in:
Daniel Gröber 2015-03-08 17:32:17 +01:00
parent baf5cad809
commit a6d3f477bc

View File

@ -172,11 +172,19 @@ targetGhcOptions crdl sefnmn = do
let mdlcs = moduleComponents mcs `zipMap` Set.toList sefnmn
candidates = Set.unions $ map snd mdlcs
when (Set.null candidates) $
throwError $ GMECabalCompAssignment mdlcs
let noCandidates = Set.null candidates
noModuleHasAnyAssignment = all (Set.null . snd) mdlcs
let cn = pickComponent candidates
return $ gmcGhcOpts $ fromJust $ Map.lookup cn mcs
if noCandidates && noModuleHasAnyAssignment
then do
gmLog GmWarning "" $ strDoc $ "Could not find a componenet assignment, falling back to sandbox only project options."
sandboxOpts crdl
else do
when noCandidates $
throwError $ GMECabalCompAssignment mdlcs
let cn = pickComponent candidates
return $ gmcGhcOpts $ fromJust $ Map.lookup cn mcs
moduleComponents :: Map GmComponentName (GmComponent (Set ModulePath))
-> Either FilePath ModuleName