Commit b3e5c678 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

hadrian: Throw error on duplicate-named flavours

Throw an error if the user requests a flavour for which there is more
than one match.

Fixes #17156.
parent 0a5e4f5f
...@@ -58,12 +58,14 @@ flavour :: Action Flavour ...@@ -58,12 +58,14 @@ flavour :: Action Flavour
flavour = do flavour = do
flavourName <- fromMaybe userDefaultFlavour <$> cmdFlavour flavourName <- fromMaybe userDefaultFlavour <$> cmdFlavour
kvs <- userSetting ([] :: [KeyVal]) kvs <- userSetting ([] :: [KeyVal])
let unknownFlavour = error $ "Unknown build flavour: " ++ flavourName let flavours = hadrianFlavours ++ userFlavours
flavours = hadrianFlavours ++ userFlavours
(_settingErrs, tweak) = applySettings kvs (_settingErrs, tweak) = applySettings kvs
return $ maybe unknownFlavour tweak $ return $
find ((== flavourName) . name) flavours case filter (\fl -> name fl == flavourName) flavours of
[] -> error $ "Unknown build flavour: " ++ flavourName
[f] -> tweak f
_ -> error $ "Multiple build flavours named " ++ flavourName
getIntegerPackage :: Expr Package getIntegerPackage :: Expr Package
getIntegerPackage = expr (integerLibrary =<< flavour) getIntegerPackage = expr (integerLibrary =<< flavour)
......
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