Unverified Commit 4e4885ca authored by Oleg Grenrus's avatar Oleg Grenrus Committed by GitHub
Browse files

Merge pull request #7093 from phadej/undefined-custom-setup

Resolve #7091: Require custom-setup for cabal-version: 1.24 and later
parents 09bf7b4e e112555f
......@@ -207,6 +207,7 @@ parseGenericPackageDescription' scannedVer lexWarnings utf8WarnPos fs = do
let gpd2 = postProcessInternalDeps specVer gpd1
checkForUndefinedFlags gpd2
checkForUndefinedCustomSetup gpd2
gpd2 `deepseq` return gpd2
where
safeLast :: [a] -> Maybe a
......@@ -674,9 +675,14 @@ onAllBranches p = go mempty
goBranch acc (CondBranch _ t (Just e)) = go acc t && go acc e
-------------------------------------------------------------------------------
-- Flag check
-- Post parsing checks
-------------------------------------------------------------------------------
-- | Check that we
--
-- * don't use undefined flags (very bad)
-- * define flags which are unused (just bad)
--
checkForUndefinedFlags :: GenericPackageDescription -> ParseResult ()
checkForUndefinedFlags gpd = do
let definedFlags, usedFlags :: Set.Set FlagName
......@@ -691,6 +697,18 @@ checkForUndefinedFlags gpd = do
f :: CondTree ConfVar c a -> Const (Set.Set FlagName) (CondTree ConfVar c a)
f ct = Const (Set.fromList (freeVars ct))
-- | Since @cabal-version: 1.24@ one can specify @custom-setup@.
-- Let us require it.
--
checkForUndefinedCustomSetup :: GenericPackageDescription -> ParseResult ()
checkForUndefinedCustomSetup gpd = do
let pd = packageDescription gpd
let csv = specVersion pd
when (buildType pd == Custom && isNothing (setupBuildInfo pd)) $
when (csv >= CabalSpecV1_24) $ parseFailure zeroPos $
"Since cabal-version: 1.24 specifying custom-setup section is mandatory"
-------------------------------------------------------------------------------
-- Post processing of internal dependencies
-------------------------------------------------------------------------------
......
cabal-version: 2.0
name: mixin
version: 0
build-type: Simple
executable str-example
main-is: Main.hs
......
......@@ -118,7 +118,7 @@ GenericPackageDescription
{author = "",
benchmarks = [],
bugReports = "",
buildTypeRaw = Nothing,
buildTypeRaw = Just Simple,
category = "",
copyright = "",
customFieldsPD = [],
......
cabal-version: 2.0
name: mixin
version: 0
build-type: Simple
executable str-example
main-is: Main.hs
......
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